gtk3 3.0.7 → 3.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/ext/gtk3/extconf.rb +1 -0
  3. data/ext/gtk3/rb-gtk3-tree-view.c +4 -0
  4. data/ext/gtk3/rb-gtk3.c +245 -60
  5. data/lib/gtk3/box.rb +22 -0
  6. data/lib/gtk3/builder.rb +50 -29
  7. data/lib/gtk3/deprecated.rb +7 -0
  8. data/lib/gtk3/entry-buffer.rb +28 -0
  9. data/lib/gtk3/list-store.rb +2 -20
  10. data/lib/gtk3/loader.rb +6 -0
  11. data/lib/gtk3/menu-item.rb +8 -7
  12. data/lib/gtk3/tree-iter.rb +25 -1
  13. data/lib/gtk3/tree-model.rb +41 -0
  14. data/lib/gtk3/tree-store.rb +7 -6
  15. data/lib/gtk3/widget.rb +18 -1
  16. data/sample/gtk-demo/TODO +45 -39
  17. data/sample/gtk-demo/assistant.rb +123 -0
  18. data/sample/gtk-demo/builder.rb +75 -38
  19. data/sample/gtk-demo/button_box.rb +100 -0
  20. data/sample/gtk-demo/colorsel.rb +49 -65
  21. data/sample/gtk-demo/css_accordion.rb +33 -55
  22. data/sample/gtk-demo/css_basics.rb +55 -80
  23. data/sample/gtk-demo/css_multiplebgs.rb +112 -0
  24. data/sample/gtk-demo/css_pixbufs.rb +84 -0
  25. data/sample/gtk-demo/css_shadows.rb +101 -0
  26. data/sample/gtk-demo/cursors.rb +114 -0
  27. data/sample/gtk-demo/dialog.rb +105 -115
  28. data/sample/gtk-demo/entry_buffer.rb +44 -0
  29. data/sample/gtk-demo/entry_completion.rb +40 -52
  30. data/sample/gtk-demo/expander.rb +60 -26
  31. data/sample/gtk-demo/filtermodel.rb +119 -0
  32. data/sample/gtk-demo/font_features.rb +117 -0
  33. data/sample/gtk-demo/headerbar.rb +57 -0
  34. data/sample/gtk-demo/iconview_edit.rb +79 -0
  35. data/sample/gtk-demo/infobar.rb +75 -59
  36. data/sample/gtk-demo/links.rb +53 -40
  37. data/sample/gtk-demo/main.rb +353 -43
  38. data/sample/gtk-demo/main.ui +9 -9
  39. data/sample/gtk-demo/markup.rb +46 -0
  40. data/sample/gtk-demo/menus.rb +111 -162
  41. data/sample/gtk-demo/modelbutton.rb +47 -0
  42. data/sample/gtk-demo/overlay.rb +61 -0
  43. data/sample/gtk-demo/overlay2.rb +75 -0
  44. data/sample/gtk-demo/panes.rb +114 -133
  45. data/sample/gtk-demo/pickers.rb +70 -0
  46. data/sample/gtk-demo/popover.rb +110 -0
  47. data/sample/gtk-demo/printing.rb +68 -83
  48. data/sample/gtk-demo/revealer.rb +53 -0
  49. data/sample/gtk-demo/scale.rb +26 -0
  50. data/sample/gtk-demo/search_entry2.rb +107 -0
  51. data/sample/gtk-demo/sidebar.rb +68 -0
  52. data/sample/gtk-demo/sizegroup.rb +93 -105
  53. data/sample/gtk-demo/spinner.rb +53 -50
  54. data/sample/gtk-demo/stack.rb +28 -0
  55. data/sample/gtk-demo/test_mod.rb +22 -0
  56. data/sample/gtk-demo/textmask.rb +61 -0
  57. data/sample/gtk-demo/theming_style_classes.rb +16 -12
  58. data/sample/misc/app-menu.ui +19 -0
  59. data/sample/misc/button-menu.ui +19 -0
  60. data/sample/misc/icons-theme-viewer.rb +65 -0
  61. data/sample/misc/menu.rb +3 -3
  62. data/sample/misc/menus_from_resources.gresource.xml +8 -0
  63. data/sample/misc/menus_from_resources.rb +91 -0
  64. data/sample/misc/statusicon.rb +1 -1
  65. data/sample/misc/toolbar-menu.ui +23 -0
  66. data/sample/misc/treestore.rb +63 -0
  67. data/sample/tutorial/README.md +368 -6
  68. data/test/test-gtk-box.rb +13 -0
  69. data/test/test-gtk-builder.rb +1 -1
  70. data/test/test-gtk-clipboard.rb +124 -0
  71. data/test/test-gtk-container.rb +3 -3
  72. data/test/test-gtk-entry-buffer.rb +32 -0
  73. data/test/test-gtk-list-store.rb +30 -12
  74. data/test/test-gtk-menu.rb +32 -0
  75. data/test/test-gtk-tree-iter.rb +61 -5
  76. data/test/test-gtk-tree-path.rb +26 -1
  77. data/test/test-gtk-tree-sortable.rb +35 -0
  78. data/test/test-gtk-tree-store.rb +34 -0
  79. data/test/test-gtk-widget.rb +33 -2
  80. metadata +55 -19
  81. data/sample/gtk-demo/button-box.rb +0 -82
@@ -25,4 +25,17 @@ class TestGtkBox < Test::Unit::TestCase
25
25
  end
26
26
  end
27
27
  end
28
+
29
+ test "set_child_packing" do
30
+ box = Gtk::Box.new(:vertical)
31
+ child = Gtk::EventBox.new
32
+ box.add(child)
33
+ box.set_child_packing(child,
34
+ :expand => false,
35
+ :fill => true,
36
+ :padding => 100,
37
+ :pack_type => :end)
38
+ assert_equal([false, true, 100, Gtk::PackType::END],
39
+ box.query_child_packing(child))
40
+ end
28
41
  end
@@ -26,7 +26,7 @@ class TestGtkBuilder < Test::Unit::TestCase
26
26
  end
27
27
 
28
28
  test "resource" do
29
- only_gtk_version(3, 10, 0)
29
+ only_gtk_version(3, 12, 0)
30
30
  register_resource(fixture_path("simple_window.gresource")) do
31
31
  resource_path = "/simple_window/simple_window.ui"
32
32
  builder = Gtk::Builder.new(:resource => resource_path)
@@ -0,0 +1,124 @@
1
+ # Copyright (C) 2015 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestGtkClipboard < Test::Unit::TestCase
18
+ include GtkTestUtils
19
+
20
+ def setup
21
+ @widget = Gtk::Invisible.new
22
+ @clipboard = @widget.get_clipboard(Gdk::Selection::CLIPBOARD)
23
+ end
24
+
25
+ def teardown
26
+ @clipboard.clear
27
+ end
28
+
29
+ test "#request_contents" do
30
+ loop = GLib::MainLoop.new
31
+ received_text = nil
32
+ utf8_string = Gdk::Atom.intern("UTF8_STRING")
33
+ @clipboard.request_contents(utf8_string) do |_clipboard, _selection_data|
34
+ compound_text = Gdk::Atom.intern("COMPOUND_TEXT")
35
+ @clipboard.request_contents(compound_text) do |_clipboard, _selection_data|
36
+ target_string = Gdk::Selection::TARGET_STRING
37
+ @clipboard.request_contents(target_string) do |_clipboard, selection_data|
38
+ received_text = selection_data.text
39
+ loop.quit
40
+ end
41
+ end
42
+ end
43
+ @clipboard.text = "hello"
44
+ loop.run
45
+
46
+ assert_equal("hello", received_text)
47
+ end
48
+
49
+ test "#request_text" do
50
+ loop = GLib::MainLoop.new
51
+ received_text = nil
52
+ @clipboard.request_text do |_clipboard, text|
53
+ received_text = text
54
+ loop.quit
55
+ end
56
+ @clipboard.text = "hello"
57
+ loop.run
58
+
59
+ assert_equal("hello", received_text)
60
+ end
61
+
62
+ test "#request_image" do
63
+ loop = GLib::MainLoop.new
64
+ received_image = nil
65
+ @clipboard.request_image do |_clipboard, image|
66
+ received_image = image
67
+ loop.quit
68
+ end
69
+ image = Gdk::Pixbuf.new(fixture_path("gnome-logo-icon.png"))
70
+ @clipboard.image = image
71
+ loop.run
72
+
73
+ assert_equal([image.width, image.height],
74
+ [received_image.width, received_image.height])
75
+ end
76
+
77
+ test "#request_targets" do
78
+ loop = GLib::MainLoop.new
79
+ received_atoms = nil
80
+ @clipboard.request_targets do |_clipboard, atoms|
81
+ received_atoms = atoms
82
+ loop.quit
83
+ end
84
+ loop.run
85
+
86
+ assert_nil(received_atoms)
87
+ end
88
+
89
+ test "#request_rich_text" do
90
+ loop = GLib::MainLoop.new
91
+ received_format = nil
92
+ received_text = nil
93
+ table = Gtk::TextTagTable.new
94
+ buffer = Gtk::TextBuffer.new(table)
95
+ buffer.register_deserialize_tagset(nil)
96
+ @clipboard.request_rich_text(buffer) do |_clipboard, format, text|
97
+ received_format = format
98
+ received_text = text
99
+ loop.quit
100
+ end
101
+ loop.run
102
+
103
+ assert_equal([
104
+ "application/x-gtk-text-buffer-rich-text",
105
+ nil,
106
+ ],
107
+ [
108
+ received_format.name,
109
+ received_text,
110
+ ])
111
+ end
112
+
113
+ test "#request_uris" do
114
+ loop = GLib::MainLoop.new
115
+ received_uris = nil
116
+ @clipboard.request_uris do |_clipboard, uris|
117
+ received_uris = uris
118
+ loop.quit
119
+ end
120
+ loop.run
121
+
122
+ assert_nil(received_uris)
123
+ end
124
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2015 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2013-2016 Ruby-GNOME2 Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -82,7 +82,7 @@ class TestGtkContainer < Test::Unit::TestCase
82
82
 
83
83
  class TestTemplate < self
84
84
  def test_resource
85
- only_gtk_version(3, 10, 0)
85
+ only_gtk_version(3, 12, 0)
86
86
 
87
87
  Dir.mktmpdir do |dir|
88
88
  Dir.chdir(dir) do
@@ -151,7 +151,7 @@ class TestGtkContainer < Test::Unit::TestCase
151
151
  end
152
152
 
153
153
  def test_data
154
- only_gtk_version(3, 10, 0)
154
+ only_gtk_version(3, 12, 0)
155
155
 
156
156
  class_name = "MyWindowData"
157
157
  label_value = "My Label"
@@ -0,0 +1,32 @@
1
+ # Copyright (C) 2015 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+
18
+ class TestGtkEntryBuffer < Test::Unit::TestCase
19
+ include GtkTestUtils
20
+
21
+ sub_test_case ".new" do
22
+ test "no argument" do
23
+ buffer = Gtk::EntryBuffer.new
24
+ assert_equal("", buffer.text)
25
+ end
26
+
27
+ test "string" do
28
+ buffer = Gtk::EntryBuffer.new("some text")
29
+ assert_equal("some text", buffer.text)
30
+ end
31
+ end
32
+ end
@@ -99,21 +99,39 @@ class TestGtkListStore < Test::Unit::TestCase
99
99
  assert_equal(0, @store.get_iter("1")[0])
100
100
  end
101
101
 
102
- test "#insert" do
103
- iter = @store.append
104
- @store.set_values(iter, [0, '1'])
105
- assert_equal("0", iter.path.to_s)
102
+ sub_test_case "#insert" do
103
+ test "no values" do
104
+ iter = @store.append
105
+ @store.set_values(iter, [0, '1'])
106
+ assert_equal("0", iter.path.to_s)
106
107
 
107
- iter = @store.append
108
- @store.set_values(iter, [2, '3'])
109
- assert_equal("1", iter.path.to_s)
108
+ iter = @store.append
109
+ @store.set_values(iter, [2, '3'])
110
+ assert_equal("1", iter.path.to_s)
110
111
 
111
- iter = @store.insert(1)
112
- @store.set_values(iter, [4, '5'])
112
+ iter = @store.insert(1)
113
+ @store.set_values(iter, [4, '5'])
113
114
 
114
- assert_equal(0, @store.get_iter("0")[0])
115
- assert_equal(4, @store.get_iter("1")[0])
116
- assert_equal(2, @store.get_iter("2")[0])
115
+ assert_equal(0, @store.get_iter("0")[0])
116
+ assert_equal(4, @store.get_iter("1")[0])
117
+ assert_equal(2, @store.get_iter("2")[0])
118
+ end
119
+
120
+ test "values" do
121
+ iter = @store.append
122
+ @store.set_values(iter, [0, '1'])
123
+ assert_equal("0", iter.path.to_s)
124
+
125
+ iter = @store.append
126
+ @store.set_values(iter, [2, '3'])
127
+ assert_equal("1", iter.path.to_s)
128
+
129
+ iter = @store.insert(1, [4, '5'])
130
+
131
+ assert_equal(0, @store.get_iter("0")[0])
132
+ assert_equal(4, @store.get_iter("1")[0])
133
+ assert_equal(2, @store.get_iter("2")[0])
134
+ end
117
135
  end
118
136
 
119
137
  test "#insert_before" do
@@ -0,0 +1,32 @@
1
+ # Copyright (C) 2015 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestGtkMenu < Test::Unit::TestCase
18
+ include GtkTestUtils
19
+
20
+ def setup
21
+ @menu = Gtk::Menu.new
22
+ end
23
+
24
+ def test_popup
25
+ only_gtk_version(3, 6, 0)
26
+ @menu.popup(nil, nil,
27
+ Gdk::BUTTON_PRIMARY,
28
+ Gtk.current_event_time) do |menu, x, y|
29
+ [x, y, true]
30
+ end
31
+ end
32
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2015-2016 Ruby-GNOME2 Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -19,8 +19,8 @@ class TestGtkTreeIter < Test::Unit::TestCase
19
19
  include GtkTestUtils
20
20
 
21
21
  def setup
22
- @model = Gtk::ListStore.new(String)
23
- @iter = @model.append
22
+ @model = Gtk::TreeStore.new(String)
23
+ @iter = @model.append(nil)
24
24
  end
25
25
 
26
26
  def test_path
@@ -52,7 +52,7 @@ class TestGtkTreeIter < Test::Unit::TestCase
52
52
  end
53
53
 
54
54
  test "#next!" do
55
- next_iter = @model.append
55
+ next_iter = @model.append(nil)
56
56
  @iter.values = ["first"]
57
57
  next_iter.values = ["second"]
58
58
  assert_equal("first", @iter[0])
@@ -61,6 +61,62 @@ class TestGtkTreeIter < Test::Unit::TestCase
61
61
  end
62
62
 
63
63
  test "#parent" do
64
- # TODO
64
+ @iter.values = ["Dad"]
65
+ child_iter = @model.append(@iter)
66
+ child_iter.values = ["First son"]
67
+ assert_equal(@iter, child_iter.parent)
68
+ end
69
+
70
+ sub_test_case "#has_child?" do
71
+ test "false" do
72
+ @iter.values = ["Dad"]
73
+ assert do
74
+ not @iter.has_child?
75
+ end
76
+ end
77
+
78
+ test "true" do
79
+ @iter.values = ["Dad"]
80
+ child_iter = @model.append(@iter)
81
+ child_iter.values = ["First son"]
82
+ assert(@iter.has_child?)
83
+ end
84
+ end
85
+
86
+ def test_n_children
87
+ @iter.values = ["Dad"]
88
+ child_iter = @model.append(@iter)
89
+ child_iter.values = ["First son"]
90
+ child_iter = @model.append(@iter)
91
+ child_iter.values = ["First daughter"]
92
+ assert_equal(2, @iter.n_children)
93
+ end
94
+
95
+ def test_nth_children
96
+ @iter.values = ["Dad"]
97
+ first_child_iter = @model.append(@iter)
98
+ first_child_iter.values = ["First son"]
99
+ second_child_iter = @model.append(@iter)
100
+ second_child_iter.values = ["First daughter"]
101
+ assert_equal(first_child_iter, @iter.nth_child(0))
102
+ assert_equal(second_child_iter, @iter.nth_child(1))
103
+ end
104
+
105
+ def test_first_child
106
+ @iter.values = ["Dad"]
107
+ first_child_iter = @model.append(@iter)
108
+ first_child_iter.values = ["First son"]
109
+ second_child_iter = @model.append(@iter)
110
+ second_child_iter.values = ["First daughter"]
111
+ assert_equal(first_child_iter, @iter.first_child)
112
+ end
113
+
114
+ def test_children
115
+ @iter.values = ["Dad"]
116
+ first_child_iter = @model.append(@iter)
117
+ first_child_iter.values = ["First son"]
118
+ second_child_iter = @model.append(@iter)
119
+ second_child_iter.values = ["First daughter"]
120
+ assert_equal(first_child_iter, @iter.children)
65
121
  end
66
122
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2010-2015 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2010-2016 Ruby-GNOME2 Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -35,7 +35,32 @@ class TestGtkTreePath < Test::Unit::TestCase
35
35
  [indices, depth])
36
36
  end
37
37
 
38
+ def test_down!
39
+ path = tree_path("10:4:5")
40
+ path.down!
41
+ assert_equal("10:4:5:0", path.to_s)
42
+ end
43
+
44
+ def test_up!
45
+ path = tree_path("10:4:5")
46
+ path.up!
47
+ assert_equal("10:4", path.to_s)
48
+ end
49
+
50
+ def test_next!
51
+ path = tree_path("10:4:5")
52
+ path.next!
53
+ assert_equal("10:4:6", path.to_s)
54
+ end
55
+
56
+ def test_prev!
57
+ path = tree_path("10:4:5")
58
+ path.prev!
59
+ assert_equal("10:4:4", path.to_s)
60
+ end
61
+
38
62
  private
63
+
39
64
  def tree_path(path)
40
65
  Gtk::TreePath.new(path)
41
66
  end
@@ -0,0 +1,35 @@
1
+ # Copyright (C) 2015 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestGtkTreeSortable < Test::Unit::TestCase
18
+ include GtkTestUtils
19
+
20
+ def setup
21
+ @model = Gtk::ListStore.new(String)
22
+ end
23
+
24
+ test "#set_sort_func" do
25
+ @model.append[0] = "abc"
26
+ @model.append[0] = "xyz"
27
+ @model.append[0] = "efg"
28
+ @model.set_sort_column_id(0, :ascending)
29
+ @model.set_sort_func(0) do |_model, iter1, iter2|
30
+ iter2[0] <=> iter1[0]
31
+ end
32
+ assert_equal(["xyz", "efg", "abc"],
33
+ @model.collect {|_model, _path, iter| iter[0]})
34
+ end
35
+ end