gtk3 3.4.9 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18510c4c73a54ec566d0872a4379ea844916e6c69f44efcbed43ce8726d34837
4
- data.tar.gz: d56661a9d6bd65ff3a0308585b9a2fdc51e7b9f4081bbd60901f075140bb4bc9
3
+ metadata.gz: 9fbd7f61ea4374757cc5762d2a03cc915755fc7f0c582dccd6b1fd576be2194c
4
+ data.tar.gz: 80cddbe9e92172568e21df21c1eae29e49f6b7556d0a8d44eed9410ee57b77de
5
5
  SHA512:
6
- metadata.gz: 8e69dbe1de57c6afa79be0e095d0caf3dcc787456d34f2cf27c1013fccb285f645876ec345a2671afb494c61bbe6bd5547843a7e2076cad3fada64ea908ed5f5
7
- data.tar.gz: 7a74a321c9508a3bb93d2cfd05f8fe9f578121dfdc8b44b8398dfcf93906af871fb21255939b00286c86c427b35d0d842c8ba57e54d80a4a3af1283913a2e51b
6
+ metadata.gz: 7f2788da31bb6187a156d6be347da8e1e33013723eb6dfcdc4975f5090faca69b3d45c4e5bf2226e3c0970d54ec42ac9470755855d20bb389e5ac761e9d4058c
7
+ data.tar.gz: bf33b0b523f6f1af70945afca73f9be13014f6099027a15b6c1e419ea5206f67fd14b492e6fe374efd48db45188ab9ec842cadb100b72c5282d53c881d45e87c
data/README.md CHANGED
@@ -16,9 +16,9 @@ Ruby/GTK3 is a Ruby binding of GTK+ 3.
16
16
 
17
17
  ## Tutorials, examples:
18
18
 
19
- * gtk3/sample/misc: a lot of simple examples.
20
- * gtk3/sample/gtk-demo: the ruby version of `gtk-demo`.
21
- * gtk3/sample/tutorial: the ruby version of the [offical Gtk3 tutorial "getting started"](https://developer.gnome.org/gtk3/stable/gtk-getting-started.html).
19
+ * [sample/misc](/gtk3/sample/misc): a lot of simple examples.
20
+ * [sample/gtk-demo](/gtk3/sample/gtk-demo): the ruby version of `gtk-demo`.
21
+ * [sample/tutorial](/gtk3/sample/tutorial): the ruby version of the [offical Gtk3 tutorial "getting started"](https://developer.gnome.org/gtk3/stable/gtk-getting-started.html).
22
22
  * a well written tutorial [on how to create a todo application](http://iridakos.com/tutorials/2018/01/25/creating-a-gtk-todo-application-with-ruby)
23
23
 
24
24
  ## License
@@ -0,0 +1,76 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2022 Ruby-GNOME Project Team
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
+ * MA 02110-1301 USA
19
+ */
20
+
21
+ #include "rb-gtk3-private.h"
22
+
23
+ static void
24
+ accel_map_foreach_func(gpointer data,
25
+ const gchar *path,
26
+ guint key,
27
+ GdkModifierType accel_mods,
28
+ gboolean changed)
29
+ {
30
+ VALUE block = (VALUE)data;
31
+ ID id_call;
32
+ CONST_ID(id_call, "call");
33
+ rb_funcall(block,
34
+ id_call,
35
+ 4,
36
+ CSTR2RVAL(path),
37
+ UINT2NUM(key),
38
+ GFLAGS2RVAL(accel_mods, GDK_TYPE_MODIFIER_TYPE),
39
+ CBOOL2RVAL(changed));
40
+ }
41
+
42
+ static VALUE
43
+ rg_s_each(int argc, VALUE *args, VALUE self)
44
+ {
45
+ RETURN_ENUMERATOR(self, argc, args);
46
+
47
+ VALUE options = Qnil;
48
+ VALUE block = Qnil;
49
+ rb_scan_args(argc, args, ":&", &options, &block);
50
+
51
+ ID keywords[1];
52
+ VALUE values[1];
53
+ CONST_ID(keywords[0], "filter");
54
+ rb_get_kwargs(options, keywords, 0, 1, values);
55
+
56
+ VALUE filter = values[0];
57
+ if (filter == RUBY_Qundef || RB_NIL_P(filter)) {
58
+ filter = RUBY_Qtrue;
59
+ }
60
+ if (RB_TEST(filter)) {
61
+ gtk_accel_map_foreach((gpointer)block, accel_map_foreach_func);
62
+ } else {
63
+ gtk_accel_map_foreach_unfiltered((gpointer)block,
64
+ accel_map_foreach_func);
65
+ }
66
+ return self;
67
+ }
68
+
69
+ void
70
+ rbgtk3_accel_map_init(void)
71
+ {
72
+ VALUE mGtk = rb_const_get(rb_cObject, rb_intern("Gtk"));
73
+ VALUE RG_TARGET_NAMESPACE = rb_const_get(mGtk, rb_intern("AccelMap"));
74
+
75
+ RG_DEF_SMETHOD(each, -1);
76
+ }
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2015 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2015-2022 Ruby-GNOME2 Project Team
4
4
  *
5
5
  * This library is free software; you can redistribute it and/or
6
6
  * modify it under the terms of the GNU Lesser General Public
@@ -100,43 +100,17 @@ set_child_prop_func(GtkContainer *container,
100
100
  GOBJ2RVAL(child), GVAL2RVAL(value));
101
101
  }
102
102
 
103
- static void
104
- class_init_func(gpointer g_class, gpointer class_data)
103
+ static VALUE
104
+ rg_s_init(VALUE klass)
105
105
  {
106
- GtkContainerClass *g_container_class = GTK_CONTAINER_CLASS(g_class);
107
-
108
- rbgobj_class_init_func(g_class, class_data);
106
+ rb_call_super(0, NULL);
109
107
 
108
+ GType type = CLASS2GTYPE(klass);
109
+ GtkContainerClass *g_container_class =
110
+ GTK_CONTAINER_CLASS(g_type_class_ref(type));
110
111
  g_container_class->set_child_property = set_child_prop_func;
111
112
  g_container_class->get_child_property = get_child_prop_func;
112
-
113
- rbgtk3_class_init_func(g_class, class_data);
114
- }
115
-
116
- static VALUE
117
- rg_initialize(int argc, VALUE *argv, VALUE self)
118
- {
119
- rb_call_super(argc, argv);
120
- rbgtk3_initialize(self);
121
- return Qnil;
122
- }
123
-
124
- static VALUE
125
- rg_s_type_register(int argc, VALUE *argv, VALUE klass)
126
- {
127
- VALUE type_name;
128
-
129
- rb_scan_args(argc, argv, "01", &type_name);
130
-
131
- rbgobj_register_type(klass, type_name, class_init_func);
132
-
133
- {
134
- VALUE initialize_module;
135
- initialize_module = rb_define_module_under(klass, "ContainerHook");
136
- rbg_define_method(initialize_module,
137
- "initialize", rg_initialize, -1);
138
- rb_include_module(klass, initialize_module);
139
- }
113
+ g_type_class_unref(g_container_class);
140
114
 
141
115
  return Qnil;
142
116
  }
@@ -155,5 +129,5 @@ rbgtk3_container_init(void)
155
129
 
156
130
  rbgobj_register_mark_func(GTK_TYPE_CONTAINER, rb_gtk3_container_mark);
157
131
 
158
- RG_DEF_SMETHOD(type_register, -1);
132
+ RG_DEF_SMETHOD(init, 0);
159
133
  }
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2015-2018 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2015-2022 Ruby-GNOME Project Team
4
4
  *
5
5
  * This library is free software; you can redistribute it and/or
6
6
  * modify it under the terms of the GNU Lesser General Public
@@ -24,17 +24,13 @@
24
24
  /*
25
25
  * CentOS 6: No GTK+ 3
26
26
  * CentOS 7: GTK+ 3.22
27
- * Ubuntu 14.04: GTK+ 3.10
28
- * Ubuntu 16.04: GTK+ 3.18
29
27
  * Ubuntu 18.04: GTK+ 3.22
30
28
  */
31
- #define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_10
29
+ #define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_22
32
30
 
33
31
  #include "rb-gtk3.h"
34
32
 
35
- G_GNUC_INTERNAL void rbgtk3_class_init_func(gpointer g_class, gpointer class_data);
36
- G_GNUC_INTERNAL void rbgtk3_initialize(VALUE self);
37
-
33
+ G_GNUC_INTERNAL void rbgtk3_accel_map_init(void);
38
34
  G_GNUC_INTERNAL void rbgtk3_cell_layout_init(void);
39
35
  G_GNUC_INTERNAL void rbgtk3_container_init(void);
40
36
  G_GNUC_INTERNAL void rbgtk3_spin_button_init(void);
@@ -25,37 +25,15 @@
25
25
  #define RG_TARGET_NAMESPACE cWidget
26
26
  #define _SELF(self) (RVAL2GTKWIDGET(self))
27
27
 
28
- static void
29
- class_init_func(gpointer g_class, gpointer class_data)
30
- {
31
- rbgobj_class_init_func(g_class, class_data);
32
- rbgtk3_class_init_func(g_class, class_data);
33
- }
34
-
35
- static VALUE
36
- rg_initialize(int argc, VALUE *argv, VALUE self)
37
- {
38
- rb_call_super(argc, argv);
39
- rbgtk3_initialize(self);
40
- return Qnil;
41
- }
42
-
43
28
  static VALUE
44
- rg_s_type_register(int argc, VALUE *argv, VALUE klass)
29
+ rg_initialize_post(VALUE self)
45
30
  {
46
- VALUE type_name;
31
+ GObject *object = RVAL2GOBJ(self);
32
+ g_object_ref_sink(object);
47
33
 
48
- rb_scan_args(argc, argv, "01", &type_name);
49
-
50
- rbgobj_register_type(klass, type_name, class_init_func);
51
-
52
- {
53
- VALUE initialize_module;
54
- initialize_module = rb_define_module_under(klass, "WidgetHook");
55
- rbg_define_method(initialize_module,
56
- "initialize", rg_initialize, -1);
57
- rb_include_module(klass, initialize_module);
58
- }
34
+ ID id_initialize_template;
35
+ CONST_ID(id_initialize_template, "initialize_template");
36
+ rb_funcall(self, id_initialize_template, 0);
59
37
 
60
38
  return Qnil;
61
39
  }
@@ -93,7 +71,7 @@ rbgtk3_widget_init(void)
93
71
  mGtk = rb_const_get(rb_cObject, rb_intern("Gtk"));
94
72
  RG_TARGET_NAMESPACE = rb_const_get(mGtk, rb_intern("Widget"));
95
73
 
96
- RG_DEF_SMETHOD(type_register, -1);
74
+ RG_DEF_PRIVATE_METHOD(initialize_post, 0);
97
75
 
98
76
  rbgobj_set_signal_call_func(RG_TARGET_NAMESPACE,
99
77
  "draw",
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2017 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2017-2022 Ruby-GNOME Project Team
4
4
  *
5
5
  * This library is free software; you can redistribute it and/or
6
6
  * modify it under the terms of the GNU Lesser General Public
@@ -46,11 +46,6 @@ static const rb_data_type_t toplevel_window_marker_type = {
46
46
  {
47
47
  toplevel_window_marker_mark,
48
48
  toplevel_window_marker_free,
49
- NULL,
50
- {
51
- NULL,
52
- NULL,
53
- },
54
49
  },
55
50
  NULL,
56
51
  NULL,
@@ -61,16 +56,9 @@ static const rb_data_type_t toplevel_window_marker_type = {
61
56
  void
62
57
  rbgtk3_window_init(void)
63
58
  {
64
- VALUE mGtk;
65
- VALUE toplevel_window_marker_class;
66
- VALUE toplevel_window_marker;
67
59
  ToplevelWindowMarkerData *data;
68
-
69
- mGtk = rb_const_get(rb_cObject, rb_intern("Gtk"));
70
- toplevel_window_marker_class =
71
- rb_define_class_under(mGtk, "ToplevelWindowMarker", rb_cData);
72
- toplevel_window_marker =
73
- TypedData_Make_Struct(toplevel_window_marker_class,
60
+ VALUE toplevel_window_marker =
61
+ TypedData_Make_Struct(rb_cObject,
74
62
  ToplevelWindowMarkerData,
75
63
  &toplevel_window_marker_type,
76
64
  data);
data/ext/gtk3/rb-gtk3.c CHANGED
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2015-2018 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2015-2022 Ruby-GNOME Project Team
4
4
  *
5
5
  * This library is free software; you can redistribute it and/or
6
6
  * modify it under the terms of the GNU Lesser General Public
@@ -573,26 +573,6 @@ rb_gtk3_text_tag_table_mark(gpointer object)
573
573
  gtk_text_tag_table_foreach(table, rb_gtk3_text_tag_table_mark_body, NULL);
574
574
  }
575
575
 
576
- void
577
- rbgtk3_class_init_func(gpointer g_class, G_GNUC_UNUSED gpointer class_data)
578
- {
579
- VALUE rb_class;
580
-
581
- rb_class = GTYPE2CLASS(G_TYPE_FROM_CLASS(g_class));
582
- rb_funcall(rb_class, rb_intern("init"), 0);
583
- }
584
-
585
- void
586
- rbgtk3_initialize(VALUE self)
587
- {
588
- GObject *object;
589
-
590
- object = RVAL2GOBJ(self);
591
- g_object_ref_sink(object);
592
-
593
- rb_funcall(self, rb_intern("initialize_post"), 0);
594
- }
595
-
596
576
  void
597
577
  Init_gtk3(void)
598
578
  {
@@ -615,6 +595,7 @@ Init_gtk3(void)
615
595
  rbgobj_register_mark_func(GTK_TYPE_TEXT_TAG_TABLE,
616
596
  rb_gtk3_text_tag_table_mark);
617
597
 
598
+ rbgtk3_accel_map_init();
618
599
  rbgtk3_cell_layout_init();
619
600
  rbgtk3_container_init();
620
601
  rbgtk3_spin_button_init();
data/gtk3.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- ruby -*-
2
2
  #
3
- # Copyright (C) 2018 Ruby-GNOME Project Team
3
+ # Copyright (C) 2018-2022 Ruby-GNOME Project Team
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -42,9 +42,6 @@ Gem::Specification.new do |s|
42
42
  s.files += Dir.glob("sample/**/*")
43
43
  s.files += Dir.glob("test/**/*")
44
44
 
45
- s.add_runtime_dependency("gio2", "= #{s.version}")
46
45
  s.add_runtime_dependency("atk", "= #{s.version}")
47
- s.add_runtime_dependency("pango", "= #{s.version}")
48
- s.add_runtime_dependency("gdk_pixbuf2", "= #{s.version}")
49
46
  s.add_runtime_dependency("gdk3", "= #{s.version}")
50
47
  end
data/lib/gtk3/label.rb CHANGED
@@ -39,7 +39,7 @@ module Gtk
39
39
  if options == true or options == false or options.nil?
40
40
  mnemonic = options
41
41
  warn "Gtk::Label#set_markup(text, mnemonic) style has been deprecated. " +
42
- "Use Gtk::Label#set_marup(text, {:use_underline => #{mnemonic}}) style instead."
42
+ "Use Gtk::Label#set_markup(text, {:use_underline => #{mnemonic}}) style instead."
43
43
  options = {
44
44
  :use_underline => mnemonic,
45
45
  }
data/lib/gtk3/loader.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2020 Ruby-GNOME Project Team
1
+ # Copyright (C) 2014-2021 Ruby-GNOME 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
@@ -31,6 +31,7 @@ module Gtk
31
31
  call_init_function(repository, namespace)
32
32
  define_stock_module
33
33
  define_version_module
34
+ define_methods_modules
34
35
  setup_pending_constants
35
36
  end
36
37
 
@@ -54,6 +55,36 @@ module Gtk
54
55
  @base_module.const_set("Version", @version_module)
55
56
  end
56
57
 
58
+ def define_methods_modules
59
+ @stock_singleton_methods_module =
60
+ define_methods_module(:StockSingletonMethods)
61
+ @widget_methods_module =
62
+ define_methods_module(:WidgetMethods)
63
+ @gdk_drag_context_methods_module =
64
+ define_methods_module(:GdkDragContextMethods)
65
+ @icon_size_class_methods_module =
66
+ define_methods_module(:IconSizeClassMethods)
67
+ @accel_group_class_methods_module =
68
+ define_methods_module(:AccelGroupClassMethods)
69
+ @gdk_event_methods_module =
70
+ define_methods_module(:GdkEventMethods)
71
+ end
72
+
73
+ def apply_methods_modules
74
+ apply_methods_module(@stock_singleton_methods_module,
75
+ @base_module::Stock.singleton_class)
76
+ apply_methods_module(@widget_methods_module,
77
+ @base_module::Widget)
78
+ apply_methods_module(@gdk_drag_context_methods_module,
79
+ Gdk::DragContext)
80
+ apply_methods_module(@icon_size_class_methods_module,
81
+ @base_module::IconSize.singleton_class)
82
+ apply_methods_module(@accel_group_class_methods_module,
83
+ @base_module::AccelGroup.singleton_class)
84
+ apply_methods_module(@gdk_event_methods_module,
85
+ Gdk::Event)
86
+ end
87
+
57
88
  def level_bar_class
58
89
  @level_bar_class ||= @base_module.const_get(:LevelBar)
59
90
  end
@@ -64,6 +95,7 @@ module Gtk
64
95
 
65
96
  def post_load(repository, namespace)
66
97
  apply_pending_constants
98
+ apply_methods_modules
67
99
  require_extension
68
100
  require_libraries
69
101
  end
@@ -170,32 +202,34 @@ module Gtk
170
202
  when "init", /_get_type\z/
171
203
  # ignore
172
204
  when /\Astock_/
173
- stock_module = @base_module.const_get(:Stock)
174
205
  method_name = rubyish_method_name(info, :prefix => "stock_")
175
- define_singleton_method(stock_module, method_name, info)
206
+ define_module_function(@stock_singleton_methods_module,
207
+ method_name,
208
+ info)
176
209
  when /\Adrag_(?:source_|dest_|get_data\z|(?:un)highlight\z|begin|check_threshold\z)/
177
210
  # For OS X. It may be broken. It's not tested.
178
- widget_class = @base_module.const_get(:Widget)
179
211
  method_name = rubyish_method_name(info)
180
- define_method(info, widget_class, method_name)
212
+ define_method(info, @widget_methods_module, method_name)
181
213
  when /\Adrag_/
182
214
  method_name = rubyish_method_name(info,
183
215
  :prefix => "drag_",
184
216
  :n_in_args_offset => -1)
185
- define_method(info, Gdk::DragContext, method_name)
217
+ define_method(info, @gdk_drag_context_methods_module, method_name)
186
218
  when /\Abinding_/
187
219
  # Ignore because singleton methods are defined.
188
220
  when /\Aicon_size_/
189
- icon_size_class = @base_module.const_get(:IconSize)
190
221
  method_name = rubyish_method_name(info, :prefix => "icon_size_")
191
- define_singleton_method(icon_size_class, method_name, info)
222
+ define_module_function(@icon_size_class_methods_module,
223
+ method_name,
224
+ info)
192
225
  when /\Atest_widget_/
193
226
  name = $POSTMATCH
194
- define_method(info, Gtk::Widget, name)
227
+ define_method(info, @widget_methods_module, name)
195
228
  when /\Aaccel_groups_/
196
- accel_group_class = @base_module.const_get(:AccelGroup)
197
229
  method_name = rubyish_method_name(info, :prefix => "accel_groups_")
198
- define_singleton_method(accel_group_class, method_name, info)
230
+ define_module_function(@accel_group_class_methods_module,
231
+ method_name,
232
+ info)
199
233
  else
200
234
  super
201
235
  end
@@ -206,11 +240,17 @@ module Gtk
206
240
  when "Gtk"
207
241
  case name
208
242
  when "get_event_widget"
209
- define_gdk_event_widget(info)
243
+ define_method(info, @gdk_event_methods_module, "widget")
210
244
  return
211
245
  when "events_pending"
212
246
  name = "events_pending?"
213
247
  end
248
+ when "Gtk::AccelMap"
249
+ case name
250
+ when "each", "foreach_unfiltered"
251
+ # Implemented in C
252
+ return
253
+ end
214
254
  when "Gtk::Widget"
215
255
  case name
216
256
  when "default_style"
@@ -222,10 +262,6 @@ module Gtk
222
262
  super(klass, name, info)
223
263
  end
224
264
 
225
- def define_gdk_event_widget(info)
226
- define_method(info, Gdk::Event, "widget")
227
- end
228
-
229
265
  def define_enum(info)
230
266
  case info.name
231
267
  when /\AArrow/
data/lib/gtk3/widget.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015-2020 Ruby-GNOME Project Team
1
+ # Copyright (C) 2015-2022 Ruby-GNOME 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
@@ -17,9 +17,6 @@
17
17
  module Gtk
18
18
  class Widget
19
19
  class << self
20
- def init
21
- end
22
-
23
20
  def have_template?
24
21
  @have_template ||= false
25
22
  end
@@ -144,8 +141,19 @@ module Gtk
144
141
  @style_context ||= style_context_raw
145
142
  end
146
143
 
144
+ alias_method :insert_action_group_raw, :insert_action_group
145
+ def insert_action_group(name, group)
146
+ insert_action_group_raw(name, group)
147
+ @action_groups ||= {}
148
+ if group.nil?
149
+ @action_groups.delete(name)
150
+ else
151
+ @action_groups[name] = group
152
+ end
153
+ end
154
+
147
155
  private
148
- def initialize_post
156
+ def initialize_template
149
157
  klass = self.class
150
158
  return unless klass.have_template?
151
159
  return unless respond_to?(:init_template)
@@ -344,14 +344,12 @@ class ToolpaletteDemo
344
344
  group = Gtk::ToolItemGroup.new("Radio Item")
345
345
  @palette.add(group)
346
346
 
347
- toggle_group = nil
348
-
347
+ item = nil
349
348
  (1..10).each do |i|
350
349
  label = "##{i}"
351
- item = Gtk::RadioToolButton.new(toggle_group)
350
+ item = Gtk::RadioToolButton.new(item)
352
351
  item.label = label
353
- group .insert(item, -1)
354
- toggle_group = item.group
352
+ group.insert(item, -1)
355
353
  end
356
354
  end
357
355
 
@@ -0,0 +1,103 @@
1
+ # Copyright (C) 2022 Ruby-GNOME 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 TestGtkAccelMap < Test::Unit::TestCase
18
+ class << self
19
+ def startup
20
+ Gtk::AccelMap.add_entry("<category1>/a",
21
+ Gdk::Keyval::KEY_a,
22
+ 0)
23
+ Gtk::AccelMap.add_entry("<category2>/b",
24
+ Gdk::Keyval::KEY_b,
25
+ 0)
26
+ Gtk::AccelMap.add_filter("*category1*")
27
+ end
28
+ end
29
+
30
+ sub_test_case("#each") do
31
+ def test_default
32
+ values = []
33
+ Gtk::AccelMap.each do |*args|
34
+ values << args
35
+ end
36
+ assert_equal([
37
+ [
38
+ "<category2>/b",
39
+ Gdk::Keyval::KEY_b,
40
+ Gdk::ModifierType.new(0),
41
+ false,
42
+ ],
43
+ ],
44
+ values)
45
+ end
46
+
47
+ test("filter: true") do
48
+ values = []
49
+ Gtk::AccelMap.each(filter: true) do |*args|
50
+ values << args
51
+ end
52
+ assert_equal([
53
+ [
54
+ "<category2>/b",
55
+ Gdk::Keyval::KEY_b,
56
+ Gdk::ModifierType.new(0),
57
+ false,
58
+ ],
59
+ ],
60
+ values)
61
+ end
62
+
63
+ test("filter: false") do
64
+ values = []
65
+ Gtk::AccelMap.each(filter: false) do |*args|
66
+ values << args
67
+ end
68
+ assert_equal([
69
+ [
70
+ "<category2>/b",
71
+ Gdk::Keyval::KEY_b,
72
+ Gdk::ModifierType.new(0),
73
+ false,
74
+ ],
75
+ [
76
+ "<category1>/a",
77
+ Gdk::Keyval::KEY_a,
78
+ Gdk::ModifierType.new(0),
79
+ false,
80
+ ],
81
+ ],
82
+ values)
83
+ end
84
+
85
+ def test_enumerator
86
+ assert_equal([
87
+ [
88
+ "<category2>/b",
89
+ Gdk::Keyval::KEY_b,
90
+ Gdk::ModifierType.new(0),
91
+ false,
92
+ ],
93
+ [
94
+ "<category1>/a",
95
+ Gdk::Keyval::KEY_a,
96
+ Gdk::ModifierType.new(0),
97
+ false,
98
+ ],
99
+ ],
100
+ Gtk::AccelMap.each(filter: false).to_a)
101
+ end
102
+ end
103
+ end
@@ -250,15 +250,6 @@ EOX
250
250
  EOX
251
251
  end
252
252
 
253
- def ui_definition_with_signal
254
- <<-EOX
255
- <interface>
256
- <object class="GtkWindow" id="main-window">
257
- </object>
258
- </interface>
259
- EOX
260
- end
261
-
262
253
  def ui_definition_file
263
254
  xml = Tempfile.new("Gtk::Builder")
264
255
  xml.print(ui_definition)
@@ -8,11 +8,13 @@ class TestGtkIconTheme < Test::Unit::TestCase
8
8
  def test_choose_icon
9
9
  assert_nil(@theme.choose_icon("non-existent", 100))
10
10
 
11
- icon = @theme.choose_icon("face-cool", 10)
11
+ icon = @theme.choose_icon("face-cool-symbolic", 10)
12
12
  assert_not_nil(icon)
13
- assert_match(/face-cool/, icon.filename)
13
+ assert_match(/face-cool-symbolic/, icon.filename)
14
14
 
15
- assert_not_nil(@theme.choose_icon("face-cool", 29, [:use_builtin, :no_svg]))
15
+ assert_not_nil(@theme.choose_icon("face-cool-symbolic",
16
+ 29,
17
+ [:use_builtin]))
16
18
  end
17
19
 
18
20
  def test_contexts
@@ -21,7 +23,7 @@ class TestGtkIconTheme < Test::Unit::TestCase
21
23
 
22
24
  class TestIcons < self
23
25
  def test_no_argument
24
- assert_operator(@theme.icons, :include?, "face-cool")
26
+ assert_operator(@theme.icons, :include?, "face-cool-symbolic")
25
27
  end
26
28
 
27
29
  def test_context
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2008-2020 Ruby-GNOME Project Team
1
+ # Copyright (C) 2008-2022 Ruby-GNOME 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
@@ -242,7 +242,13 @@ class TestGtkWidget < Test::Unit::TestCase
242
242
  type_register "BindTemplateChildNothing"
243
243
 
244
244
  singleton_class.send(:define_method, :init) do
245
+ super()
245
246
  set_template(:data => data)
247
+ set_connect_func do |handler_name|
248
+ lambda do
249
+ # Do nothing
250
+ end
251
+ end
246
252
  end
247
253
  end
248
254
  widget = widget_class.new
@@ -255,8 +261,14 @@ class TestGtkWidget < Test::Unit::TestCase
255
261
  type_register "BindTemplateChildBind"
256
262
 
257
263
  singleton_class.send(:define_method, :init) do
264
+ super()
258
265
  set_template(:data => data)
259
266
  bind_template_child(:label)
267
+ set_connect_func do |handler_name|
268
+ lambda do
269
+ # Do nothing
270
+ end
271
+ end
260
272
  end
261
273
  end
262
274
  widget = widget_class.new
@@ -278,6 +290,7 @@ class TestGtkWidget < Test::Unit::TestCase
278
290
  type_register "SetConnectFunc"
279
291
 
280
292
  singleton_class.send(:define_method, :init) do
293
+ super()
281
294
  set_template(:data => data)
282
295
  bind_template_child(:label)
283
296
  set_connect_func do |handler_name|
@@ -292,4 +305,23 @@ class TestGtkWidget < Test::Unit::TestCase
292
305
  assert_equal(["on_move_cursor"], handler_names)
293
306
  end
294
307
  end
308
+
309
+ def test_gc_action_group
310
+ GC.start
311
+ n_alive_action_groups_before =
312
+ ObjectSpace.each_object(Gio::SimpleActionGroup) {}
313
+ n_tries = 100
314
+ n_tries.times do |i|
315
+ action_prefix = "test#{i}"
316
+ action_group = Gio::SimpleActionGroup.new
317
+ @widget.insert_action_group(action_prefix, action_group)
318
+ end
319
+ GC.start
320
+ n_alive_action_groups_after =
321
+ ObjectSpace.each_object(Gio::SimpleActionGroup) {}
322
+ n_alive_action_groups =
323
+ n_alive_action_groups_after -
324
+ n_alive_action_groups_before
325
+ assert_equal(n_tries, n_alive_action_groups)
326
+ end
295
327
  end
metadata CHANGED
@@ -1,85 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gtk3
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.9
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Ruby-GNOME Project Team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-10 00:00:00.000000000 Z
11
+ date: 2022-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: gio2
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 3.4.9
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '='
25
- - !ruby/object:Gem::Version
26
- version: 3.4.9
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: atk
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - '='
32
18
  - !ruby/object:Gem::Version
33
- version: 3.4.9
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '='
39
- - !ruby/object:Gem::Version
40
- version: 3.4.9
41
- - !ruby/object:Gem::Dependency
42
- name: pango
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '='
46
- - !ruby/object:Gem::Version
47
- version: 3.4.9
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '='
53
- - !ruby/object:Gem::Version
54
- version: 3.4.9
55
- - !ruby/object:Gem::Dependency
56
- name: gdk_pixbuf2
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '='
60
- - !ruby/object:Gem::Version
61
- version: 3.4.9
19
+ version: 4.0.0
62
20
  type: :runtime
63
21
  prerelease: false
64
22
  version_requirements: !ruby/object:Gem::Requirement
65
23
  requirements:
66
24
  - - '='
67
25
  - !ruby/object:Gem::Version
68
- version: 3.4.9
26
+ version: 4.0.0
69
27
  - !ruby/object:Gem::Dependency
70
28
  name: gdk3
71
29
  requirement: !ruby/object:Gem::Requirement
72
30
  requirements:
73
31
  - - '='
74
32
  - !ruby/object:Gem::Version
75
- version: 3.4.9
33
+ version: 4.0.0
76
34
  type: :runtime
77
35
  prerelease: false
78
36
  version_requirements: !ruby/object:Gem::Requirement
79
37
  requirements:
80
38
  - - '='
81
39
  - !ruby/object:Gem::Version
82
- version: 3.4.9
40
+ version: 4.0.0
83
41
  description: Ruby/GTK3 is a Ruby binding of GTK+-3.x.
84
42
  email: ruby-gnome2-devel-en@lists.sourceforge.net
85
43
  executables: []
@@ -92,6 +50,7 @@ files:
92
50
  - Rakefile
93
51
  - ext/gtk3/depend
94
52
  - ext/gtk3/extconf.rb
53
+ - ext/gtk3/rb-gtk3-accel-map.c
95
54
  - ext/gtk3/rb-gtk3-cell-layout.c
96
55
  - ext/gtk3/rb-gtk3-container.c
97
56
  - ext/gtk3/rb-gtk3-private.h
@@ -553,6 +512,7 @@ files:
553
512
  - test/test-gtk-about-dialog.rb
554
513
  - test/test-gtk-accel-group.rb
555
514
  - test/test-gtk-accel-key.rb
515
+ - test/test-gtk-accel-map.rb
556
516
  - test/test-gtk-accessible.rb
557
517
  - test/test-gtk-action-bar.rb
558
518
  - test/test-gtk-action-group.rb
@@ -639,7 +599,7 @@ homepage: https://ruby-gnome2.osdn.jp/
639
599
  licenses:
640
600
  - LGPL-2.1+
641
601
  metadata: {}
642
- post_install_message:
602
+ post_install_message:
643
603
  rdoc_options: []
644
604
  require_paths:
645
605
  - lib
@@ -654,8 +614,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
654
614
  - !ruby/object:Gem::Version
655
615
  version: '0'
656
616
  requirements: []
657
- rubygems_version: 3.3.0.dev
658
- signing_key:
617
+ rubygems_version: 3.4.0.dev
618
+ signing_key:
659
619
  specification_version: 4
660
620
  summary: Ruby/GTK3 is a Ruby binding of GTK+-3.x.
661
621
  test_files: []