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
@@ -36,5 +36,27 @@ module Gtk
36
36
  padding = options[:padding] || 0
37
37
  pack_end_raw(child, expand, fill, padding)
38
38
  end
39
+
40
+ alias_method :set_child_packing_raw, :set_child_packing
41
+ def set_child_packing(child, options={})
42
+ expand = options[:expand]
43
+ fill = options[:fill]
44
+ padding = options[:padding]
45
+ pack_type = options[:pack_type]
46
+
47
+ old_expand, old_fill, old_padding, old_pack_type =
48
+ query_child_packing(child)
49
+
50
+ expand = old_expand if expand.nil?
51
+ fill = old_fill if fill.nil?
52
+ padding = old_padding if padding.nil?
53
+ pack_type = old_pack_type if pack_type.nil?
54
+
55
+ set_child_packing_raw(child,
56
+ expand,
57
+ fill,
58
+ padding,
59
+ pack_type)
60
+ end
39
61
  end
40
62
  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
@@ -16,6 +16,51 @@
16
16
 
17
17
  module Gtk
18
18
  class Builder
19
+ class << self
20
+ def connect_signal(builder,
21
+ object,
22
+ signal_name,
23
+ handler_name,
24
+ connect_object,
25
+ flags,
26
+ &block)
27
+ handler_name = normalize_handler_name(handler_name)
28
+ if connect_object
29
+ handler = connect_object.method(handler_name)
30
+ else
31
+ handler = block.call(handler_name)
32
+ end
33
+
34
+ unless handler
35
+ $stderr.puts("Undefined handler: #{handler_name}") if $DEBUG
36
+ return
37
+ end
38
+
39
+ if flags.is_a?(Integer)
40
+ flags = GLib::ConnectFlags.new(flags)
41
+ end
42
+
43
+ if flags.after?
44
+ signal_connect_method = :signal_connect_after
45
+ else
46
+ signal_connect_method = :signal_connect
47
+ end
48
+
49
+ if handler.arity.zero?
50
+ object.__send__(signal_connect_method, signal_name) do
51
+ handler.call
52
+ end
53
+ else
54
+ object.__send__(signal_connect_method, signal_name, &handler)
55
+ end
56
+ end
57
+
58
+ private
59
+ def normalize_handler_name(name)
60
+ name.gsub(/[-\s]+/, "_")
61
+ end
62
+ end
63
+
19
64
  alias_method :initialize_raw, :initialize
20
65
  def initialize(options={})
21
66
  path = options[:path] || options[:file]
@@ -100,34 +145,10 @@ module Gtk
100
145
  self
101
146
  end
102
147
 
103
- private
104
- def normalize_handler_name(name)
105
- name.gsub(/[-\s]+/, "_")
106
- end
107
-
108
- def __connect_signals__(connector, object, signal_name,
109
- handler_name, connect_object, flags)
110
- handler_name = normalize_handler_name(handler_name)
111
- if connect_object
112
- handler = connect_object.method(handler_name)
113
- else
114
- handler = connector.call(handler_name)
115
- end
116
- unless handler
117
- $stderr.puts("Undefined handler: #{handler_name}") if $DEBUG
118
- return
119
- end
120
-
121
- if flags.after?
122
- signal_connect_method = :signal_connect_after
123
- else
124
- signal_connect_method = :signal_connect
125
- end
126
-
127
- if handler.arity.zero?
128
- object.send(signal_connect_method, signal_name) {handler.call}
129
- else
130
- object.send(signal_connect_method, signal_name, &handler)
148
+ alias_method :connect_signals_raw, :connect_signals
149
+ def connect_signals(&block)
150
+ connect_signals_raw do |*args|
151
+ self.class.connect_signal(*args, &block)
131
152
  end
132
153
  end
133
154
  end
@@ -569,6 +569,13 @@ module Gtk
569
569
 
570
570
  class MenuItem
571
571
  extend GLib::Deprecatable
572
+
573
+ define_deprecated_method_by_hash_args :initialize,
574
+ "label, use_underline=false",
575
+ ":label => label, :use_underline => use_underline" do |_self, label, use_underline|
576
+ [{:label => label, :use_underline => use_underline}]
577
+ end
578
+
572
579
  define_deprecated_method :remove_submenu, :warn => "Use '#{self}#set_submenu'." do |_self|
573
580
  _self.set_submenu(nil)
574
581
  end
@@ -0,0 +1,28 @@
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
+ module Gtk
18
+ class EntryBuffer
19
+ alias_method :initialize_raw, :initialize
20
+ def initialize(text=nil)
21
+ if text.nil?
22
+ initialize_raw(nil, -1)
23
+ else
24
+ initialize_raw(text, text.size)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -24,25 +24,6 @@ module Gtk
24
24
  initialize_raw(columns)
25
25
  end
26
26
 
27
- def set_values(iter, values)
28
- columns = []
29
- _values = []
30
- if values.is_a?(Hash)
31
- values.each do |column_id, value|
32
- type = get_column_type(column_id)
33
- columns << column_id
34
- _values << GLib::Value.new(type, value)
35
- end
36
- else
37
- values.each_with_index do |value, i|
38
- type = get_column_type(i)
39
- columns << i
40
- _values << GLib::Value.new(type, value)
41
- end
42
- end
43
- set(iter, columns, _values)
44
- end
45
-
46
27
  alias_method :append_raw, :append
47
28
  def append
48
29
  iter = append_raw
@@ -58,9 +39,10 @@ module Gtk
58
39
  end
59
40
 
60
41
  alias_method :insert_raw, :insert
61
- def insert(index)
42
+ def insert(index, values=nil)
62
43
  iter = insert_raw(index)
63
44
  setup_iter(iter)
45
+ set_values(iter, values) if values
64
46
  iter
65
47
  end
66
48
 
@@ -107,6 +107,7 @@ module Gtk
107
107
  require "gtk3/container"
108
108
  require "gtk3/css-provider"
109
109
  require "gtk3/dialog"
110
+ require "gtk3/entry-buffer"
110
111
  require "gtk3/file-chooser-dialog"
111
112
  require "gtk3/font-chooser-dialog"
112
113
  require "gtk3/gesture-multi-press"
@@ -337,6 +338,11 @@ module Gtk
337
338
  # Ignore deprecated methods
338
339
  return
339
340
  end
341
+ when "Gtk::TreePath"
342
+ case method_name
343
+ when "next", "prev", "up", "down"
344
+ method_name += "!"
345
+ end
340
346
  when "Gtk::TreeSelection"
341
347
  case method_name
342
348
  when "selected_foreach"
@@ -17,16 +17,17 @@
17
17
  module Gtk
18
18
  class MenuItem
19
19
  alias_method :initialize_raw, :initialize
20
- def initialize(*args)
21
- if args.size == 1
22
- label = args.first
23
- if label.nil?
24
- initialize_raw
20
+ def initialize(options={})
21
+ label = options[:label]
22
+
23
+ if label
24
+ if options[:use_underline]
25
+ initialize_new_with_mnemonic(label)
25
26
  else
26
- initialize_raw(label)
27
+ initialize_new_with_label(label)
27
28
  end
28
29
  else
29
- initialize_raw(*args)
30
+ initialize_raw
30
31
  end
31
32
  end
32
33
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2015 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2014-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
@@ -45,6 +45,10 @@ module Gtk
45
45
  @model.get_path(self)
46
46
  end
47
47
 
48
+ def previous!
49
+ @model.iter_previous(self)
50
+ end
51
+
48
52
  def next!
49
53
  @model.iter_next(self)
50
54
  end
@@ -53,6 +57,26 @@ module Gtk
53
57
  @model.iter_parent(self)
54
58
  end
55
59
 
60
+ def has_child?
61
+ @model.iter_has_child(self)
62
+ end
63
+
64
+ def n_children
65
+ @model.iter_n_children(self)
66
+ end
67
+
68
+ def nth_child(n)
69
+ @model.iter_nth_child(self, n)
70
+ end
71
+
72
+ def children
73
+ @model.iter_children(self)
74
+ end
75
+
76
+ def first_child
77
+ nth_child(0)
78
+ end
79
+
56
80
  def ==(other)
57
81
  other.is_a?(self.class) and
58
82
  @model == other.model and
@@ -59,6 +59,47 @@ module Gtk
59
59
  get_value_raw(iter, column).value
60
60
  end
61
61
 
62
+ alias_method :iter_nth_child_raw, :iter_nth_child
63
+ def iter_nth_child(iter, n)
64
+ got, iter = iter_nth_child_raw(iter, n)
65
+ if got
66
+ setup_iter(iter)
67
+ iter
68
+ else
69
+ nil
70
+ end
71
+ end
72
+
73
+ alias_method :iter_children_raw, :iter_children
74
+ def iter_children(iter)
75
+ got, iter = iter_children_raw(iter)
76
+ if got
77
+ setup_iter(iter)
78
+ iter
79
+ else
80
+ nil
81
+ end
82
+ end
83
+
84
+ def set_values(iter, values)
85
+ columns = []
86
+ _values = []
87
+ if values.is_a?(Hash)
88
+ values.each do |column_id, value|
89
+ type = get_column_type(column_id)
90
+ columns << column_id
91
+ _values << GLib::Value.new(type, value)
92
+ end
93
+ else
94
+ values.each_with_index do |value, i|
95
+ type = get_column_type(i)
96
+ columns << i
97
+ _values << GLib::Value.new(type, value)
98
+ end
99
+ end
100
+ set(iter, columns, _values)
101
+ end
102
+
62
103
  private
63
104
  def setup_iter(iter)
64
105
  iter.model = self
@@ -22,37 +22,38 @@ module Gtk
22
22
  end
23
23
 
24
24
  alias_method :insert_raw, :insert
25
- def insert(parent, position)
25
+ def insert(parent, position, values=nil)
26
26
  iter = insert_raw(parent, position)
27
- iter.model = self
27
+ setup_iter(iter)
28
+ set_values(iter, values) if values
28
29
  iter
29
30
  end
30
31
 
31
32
  alias_method :insert_before_raw, :insert_before
32
33
  def insert_before(parent, sibling)
33
34
  iter = insert_before_raw(parent, sibling)
34
- iter.model = self
35
+ setup_iter(iter)
35
36
  iter
36
37
  end
37
38
 
38
39
  alias_method :insert_after_raw, :insert_after
39
40
  def insert_after(parent, sibling)
40
41
  iter = insert_after_raw(parent, sibling)
41
- iter.model = self
42
+ setup_iter(iter)
42
43
  iter
43
44
  end
44
45
 
45
46
  alias_method :prepend_raw, :prepend
46
47
  def prepend(parent)
47
48
  iter = prepend_raw(parent)
48
- iter.model = self
49
+ setup_iter(iter)
49
50
  iter
50
51
  end
51
52
 
52
53
  alias_method :append_raw, :append
53
54
  def append(parent)
54
55
  iter = append_raw(parent)
55
- iter.model = self
56
+ setup_iter(iter)
56
57
  iter
57
58
  end
58
59
  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
@@ -54,6 +54,13 @@ module Gtk
54
54
  def style_properties
55
55
  style_properties_raw[0]
56
56
  end
57
+
58
+ alias_method :set_connect_func_raw, :set_connect_func
59
+ def set_connect_func(&block)
60
+ set_connect_func_raw do |*args|
61
+ Builder.connect_signal(*args, &block)
62
+ end
63
+ end
57
64
  end
58
65
 
59
66
  alias_method :events_raw, :events
@@ -106,6 +113,16 @@ module Gtk
106
113
  render_icon_pixbuf_raw(stock_id, size)
107
114
  end
108
115
 
116
+ alias_method :translate_coordinates_raw, :translate_coordinates
117
+ def translate_coordinates(widget, x, y)
118
+ translated, x, y = translate_coordinates_raw(widget, x, y)
119
+ if translated
120
+ [x, y]
121
+ else
122
+ nil
123
+ end
124
+ end
125
+
109
126
  private
110
127
  def initialize_post
111
128
  klass = self.class
@@ -1,69 +1,75 @@
1
- # C version (3.18.0) versus Ruby version
1
+ # C version (3.19.1) versus Ruby version
2
2
 
3
3
  C version Ruby version Updated
4
4
  application.c no no
5
- assistant.c no no
6
- builder.c ok no
5
+ assistant.c ok ok
6
+ builder.c ok ok
7
7
  button_box.c ok ok
8
8
  changedisplay.c ok no
9
9
  clipboard.c ok no
10
- colorsel.c ok no
10
+ colorsel.c ok ok
11
11
  combobox.c no no
12
- css_accordion.c ok no
13
- css_basics.c ok no
14
- css_multiplebgs.c no no
15
- css_pixbufs.c no no
16
- css_shadows.c no no
17
- cursors.c no no
18
- dialog.c ok no
12
+ css_accordion.c ok ok
13
+ css_basics.c ok ok
14
+ css_multiplebgs.c ok ok
15
+ css_pixbufs.c ok ok
16
+ css_shadows.c ok ok
17
+ cursors.c ok ok
18
+ dialog.c ok ok
19
19
  drawingarea.c ok no
20
20
  editable_cells.c ok no
21
- entry_buffer.c no no
22
- entry_completion.c ok no
21
+ entry_buffer.c ok ok
22
+ entry_completion.c ok ok
23
23
  event_axes.c no no
24
- expander.c ok no
25
- filtermodel.c no no
26
- font_features.c no no
24
+ expander.c ok ok
25
+ filtermodel.c ok ok
26
+ flowbox.c no no
27
+ font_features.c ok ok
27
28
  gestures.c no no
28
29
  glarea.c no no
29
- headerbar.c no no
30
+ headerbar.c ok ok
30
31
  hypertext.c ok no
31
32
  iconview.c ok no
32
- iconview_edit.c no no
33
+ iconview_edit.c ok ok
33
34
  images.c ok no
34
- infobar.c ok no
35
- links.c ok no
35
+ infobar.c ok ok
36
+ links.c ok ok
36
37
  listbox.c no no
37
- flowbox.c no no
38
38
  list_store.c ok no
39
- markup.c no no
40
- menus.c ok no
39
+ markup.c ok ok
40
+ menus.c ok ok
41
+ modelbutton.c ok ok
41
42
  offscreen_window.c no no
42
43
  offscreen_window2.c no no
43
- overlay.c no no
44
- overlay2.c no no
45
- panes.c ok no
46
- pickers.c no no
44
+ overlay.c ok ok
45
+ overlay2.c ok ok
46
+ panes.c ok ok
47
+ pickers.c ok ok
47
48
  pixbufs.c ok no
48
- popover.c no no
49
- printing.c ok no
50
- revealer.c no no
49
+ popover.c ok ok
50
+ printing.c ok ok
51
+ revealer.c ok ok
51
52
  rotated_text.c ok no
52
- scale.c no no
53
+ scale.c ok ok
53
54
  search_entry.c no no
54
- search_entry2.c no no
55
- sidebar.c no no
56
- sizegroup.c ok no
55
+ search_entry2.c ok ok
56
+ shortcuts.c no no
57
+ sidebar.c ok ok
58
+ sizegroup.c ok ok
57
59
  spinbutton.c no no
58
- spinner.c ok no
59
- stack.c no no
60
- textmask.c no no
61
- textview.c ok no
60
+ spinner.c ok ok
61
+ stack.c ok ok
62
+ textmask.c ok ok
62
63
  textscroll.c no no
63
- theming_style_classes.c ok no
64
+ textview.c ok no
65
+ theming_style_classes.c ok ok
64
66
  toolpalette.c no no
65
67
  transparent.c no no
66
68
  tree_store.c ok no
67
69
 
68
70
  # Ruby version
69
71
  Check all the ruby demos that doesn't correspond to a C version.
72
+
73
+ # Demo that are not to be done
74
+ pagesetup.c
75
+