glib2 4.3.7 → 4.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011-2025 Ruby-GNOME Project Team
3
+ * Copyright (C) 2011-2026 Ruby-GNOME Project Team
4
4
  * Copyright (C) 2005 Masao Mutoh
5
5
  *
6
6
  * This library is free software; you can redistribute it and/or
@@ -21,10 +21,6 @@
21
21
 
22
22
  #include "rbgprivate.h"
23
23
 
24
- #ifdef HAVE_RUBY_THREAD_H
25
- # include <ruby/thread.h>
26
- #endif
27
-
28
24
  GPrivate rg_polling_key = G_PRIVATE_INIT(NULL);
29
25
 
30
26
  /*
@@ -59,7 +55,6 @@ rg_poll_in_blocking_raw(PollInfo *info)
59
55
  info->result = default_poll_func(info->ufds, info->nfsd, info->timeout);
60
56
  }
61
57
 
62
- #ifdef HAVE_RB_THREAD_CALL_WITHOUT_GVL
63
58
  static void *
64
59
  rg_poll_in_blocking(void *data)
65
60
  {
@@ -67,15 +62,6 @@ rg_poll_in_blocking(void *data)
67
62
  rg_poll_in_blocking_raw(info);
68
63
  return NULL;
69
64
  }
70
- #else
71
- static VALUE
72
- rg_poll_in_blocking(void *data)
73
- {
74
- PollInfo *info = data;
75
- rg_poll_in_blocking_raw(info);
76
- return Qnil;
77
- }
78
- #endif
79
65
 
80
66
  static gint
81
67
  rg_poll(GPollFD *ufds, guint nfsd, gint timeout)
@@ -89,13 +75,8 @@ rg_poll(GPollFD *ufds, guint nfsd, gint timeout)
89
75
 
90
76
  g_private_set(&rg_polling_key, GINT_TO_POINTER(TRUE));
91
77
  if (g_thread_self() == main_thread) {
92
- #ifdef HAVE_RB_THREAD_CALL_WITHOUT_GVL
93
78
  rb_thread_call_without_gvl(rg_poll_in_blocking, &info,
94
79
  RUBY_UBF_IO, NULL);
95
- #else
96
- rb_thread_blocking_region(rg_poll_in_blocking, &info,
97
- RUBY_UBF_IO, NULL);
98
- #endif
99
80
  } else {
100
81
  rg_poll_in_blocking_raw(&info);
101
82
  }
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2003-2022 Ruby-GNOME Project Team
3
+ * Copyright (C) 2003-2026 Ruby-GNOME Project Team
4
4
  * Copyright (C) 2002,2003 Masahiro Sakai
5
5
  * Copyright (C) 1998-2000 Yukihiro Matsumoto,
6
6
  * Daisuke Kanda,
@@ -25,6 +25,10 @@
25
25
  #include "rbgprivate.h"
26
26
  #include <ctype.h>
27
27
 
28
+ #ifdef HAVE_GIREPOSITORY
29
+ # include "rbgi-private.h"
30
+ #endif
31
+
28
32
  static ID id_relatives;
29
33
  static ID id_delete;
30
34
  static ID id_module_eval;
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2003-2025 Ruby-GNOME Project Team
3
+ * Copyright (C) 2003-2026 Ruby-GNOME Project Team
4
4
  * Copyright (C) 2002,2003 Masahiro Sakai
5
5
  *
6
6
  * This library is free software; you can redistribute it and/or
@@ -23,6 +23,7 @@
23
23
 
24
24
  #include <glib-object.h>
25
25
  #include <ruby.h>
26
+ #include <ruby/thread.h>
26
27
  #include "rbglib.h"
27
28
  #include "rbgutil.h"
28
29
 
data/ext/glib2/rbgutil.h CHANGED
@@ -117,6 +117,7 @@ extern void rbgutil_set_properties(VALUE self, VALUE hash);
117
117
  extern VALUE rbgutil_protect(VALUE (*proc) (VALUE), VALUE data);
118
118
  extern void rbgutil_on_callback_error(VALUE error);
119
119
  extern VALUE rbgutil_invoke_callback(VALUE (*func)(VALUE), VALUE arg);
120
+ extern void rbgutil_invoke_callback_async(VALUE (*func)(VALUE), VALUE arg);
120
121
  extern void rbgutil_start_callback_dispatch_thread(void);
121
122
  extern void rbgutil_stop_callback_dispatch_thread(void);
122
123
 
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2007-2022 Ruby-GNOME Project Team
3
+ * Copyright (C) 2007-2026 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
@@ -33,10 +33,6 @@
33
33
  #include <fcntl.h>
34
34
  #include <errno.h>
35
35
 
36
- #ifndef HAVE_RUBY_NATIVE_THREAD_P
37
- # define ruby_native_thread_p() is_ruby_native_thread()
38
- #endif
39
-
40
36
  static VALUE rbgutil_eGLibCallbackNotInitializedError;
41
37
  static ID id_exit_application;
42
38
 
@@ -61,12 +57,14 @@ rbgutil_on_callback_error(VALUE error)
61
57
 
62
58
  /**********************************************************************/
63
59
 
64
- #ifdef HAVE_NATIVETHREAD
65
-
66
60
  typedef struct _CallbackRequest {
67
61
  VALUE (*function)(VALUE);
68
62
  VALUE argument;
69
63
  VALUE result;
64
+ /* An async request is heap-allocated by the requester, doesn't
65
+ * report its result and is freed by the dispatch thread. done_mutex
66
+ * and done_cond are unused for it. */
67
+ gboolean async;
70
68
  GMutex done_mutex;
71
69
  GCond done_cond;
72
70
  } CallbackRequest;
@@ -79,6 +77,25 @@ static gint callback_pipe_fds[2] = {-1, -1};
79
77
  #define CALLBACK_PIPE_READY_MESSAGE "R"
80
78
  #define CALLBACK_PIPE_READY_MESSAGE_SIZE 1
81
79
 
80
+ static CallbackRequest *
81
+ callback_request_new_async(VALUE (*func)(VALUE), VALUE arg)
82
+ {
83
+ CallbackRequest *request;
84
+
85
+ request = g_new0(CallbackRequest, 1);
86
+ request->function = func;
87
+ request->argument = arg;
88
+ request->result = Qnil;
89
+ request->async = TRUE;
90
+ return request;
91
+ }
92
+
93
+ static void
94
+ callback_request_free(CallbackRequest *request)
95
+ {
96
+ g_free(request);
97
+ }
98
+
82
99
  static VALUE
83
100
  exec_callback(VALUE data)
84
101
  {
@@ -119,7 +136,14 @@ mainloop(G_GNUC_UNUSED void *user_data)
119
136
  if (!request)
120
137
  break;
121
138
 
122
- rb_thread_create(process_request, request);
139
+ if (request->async) {
140
+ /* Async callbacks must be fast because they block the
141
+ * dispatch thread. */
142
+ rbgutil_protect(exec_callback, (VALUE)request);
143
+ callback_request_free(request);
144
+ } else {
145
+ rb_thread_create(process_request, request);
146
+ }
123
147
  }
124
148
 
125
149
  close(callback_pipe_fds[0]);
@@ -155,8 +179,8 @@ invoke_callback_in_ruby_thread(VALUE (*func)(VALUE), VALUE arg)
155
179
  g_mutex_lock(&callback_dispatch_thread_mutex);
156
180
  if (callback_pipe_fds[0] == -1) {
157
181
  g_error("Please call rbgutil_start_callback_dispatch_thread() "
158
- "to dispatch a callback from non-ruby thread before "
159
- "callbacks are requested from non-ruby thread.");
182
+ "to dispatch a callback from non-Ruby thread before "
183
+ "callbacks are requested from non-Ruby thread.");
160
184
  g_mutex_unlock(&callback_dispatch_thread_mutex);
161
185
  return Qnil;
162
186
  }
@@ -164,6 +188,7 @@ invoke_callback_in_ruby_thread(VALUE (*func)(VALUE), VALUE arg)
164
188
  request.function = func;
165
189
  request.argument = arg;
166
190
  request.result = Qnil;
191
+ request.async = FALSE;
167
192
  g_mutex_init(&(request.done_mutex));
168
193
  g_cond_init(&(request.done_cond));
169
194
 
@@ -181,8 +206,21 @@ invoke_callback_in_ruby_thread(VALUE (*func)(VALUE), VALUE arg)
181
206
  return request.result;
182
207
  }
183
208
 
184
- #ifdef HAVE_RB_THREAD_CALL_WITH_GVL
185
- extern void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
209
+ static void
210
+ invoke_callback_async_in_ruby_thread(VALUE (*func)(VALUE), VALUE arg)
211
+ {
212
+ g_mutex_lock(&callback_dispatch_thread_mutex);
213
+ if (callback_pipe_fds[0] == -1) {
214
+ g_mutex_unlock(&callback_dispatch_thread_mutex);
215
+ g_error("Please call rbgutil_start_callback_dispatch_thread() "
216
+ "to dispatch a callback from non-Ruby thread before "
217
+ "callbacks are requested from non-Ruby thread.");
218
+ return;
219
+ }
220
+
221
+ queue_callback_request(callback_request_new_async(func, arg));
222
+ g_mutex_unlock(&callback_dispatch_thread_mutex);
223
+ }
186
224
 
187
225
  static void *
188
226
  invoke_callback_with_gvl(void *arg)
@@ -190,33 +228,50 @@ invoke_callback_with_gvl(void *arg)
190
228
  CallbackRequest *req = (CallbackRequest*)arg;
191
229
  return (void *)rbgutil_protect(req->function, req->argument);
192
230
  }
193
- #endif
194
-
195
- #endif
196
231
 
197
232
  /**********************************************************************/
198
233
 
199
234
  VALUE
200
235
  rbgutil_invoke_callback(VALUE (*func)(VALUE), VALUE arg)
201
236
  {
202
- #ifdef HAVE_NATIVETHREAD
203
237
  if (ruby_native_thread_p()) {
204
- if (!GPOINTER_TO_INT(g_private_get(&rg_polling_key))) {
205
- return rbgutil_protect(func, arg);
206
- }
207
- # ifdef HAVE_RB_THREAD_CALL_WITH_GVL
208
- {
238
+ if (GPOINTER_TO_INT(g_private_get(&rg_polling_key))) {
209
239
  CallbackRequest req;
210
240
  req.function = func;
211
241
  req.argument = arg;
212
242
  return (VALUE)rb_thread_call_with_gvl(invoke_callback_with_gvl, &req);
243
+ } else {
244
+ return rbgutil_protect(func, arg);
213
245
  }
214
- # endif
215
246
  } else {
216
247
  return invoke_callback_in_ruby_thread(func, arg);
217
248
  }
218
- #endif
219
- return rbgutil_protect(func, arg);
249
+ }
250
+
251
+ /*
252
+ * Fire-and-forget variant of rbgutil_invoke_callback().
253
+ *
254
+ * When this is called from a non-Ruby thread, this doesn't wait for
255
+ * the callback result; the callback is run later in the callback
256
+ * dispatch thread. Use this for callbacks that are invoked frequently
257
+ * from non-Ruby threads and don't need to report a result, such as
258
+ * GDestroyNotify. See also rbgutil_invoke_callback().
259
+ */
260
+ void
261
+ rbgutil_invoke_callback_async(VALUE (*func)(VALUE), VALUE arg)
262
+ {
263
+ if (ruby_native_thread_p()) {
264
+ if (GPOINTER_TO_INT(g_private_get(&rg_polling_key))) {
265
+ CallbackRequest request;
266
+ request.function = func;
267
+ request.argument = arg;
268
+ rb_thread_call_with_gvl(invoke_callback_with_gvl, &request);
269
+ } else {
270
+ rbgutil_protect(func, arg);
271
+ }
272
+ } else {
273
+ invoke_callback_async_in_ruby_thread(func, arg);
274
+ }
220
275
  }
221
276
 
222
277
  /**********************************************************************/
@@ -224,7 +279,6 @@ rbgutil_invoke_callback(VALUE (*func)(VALUE), VALUE arg)
224
279
  void
225
280
  rbgutil_start_callback_dispatch_thread(void)
226
281
  {
227
- #ifdef HAVE_NATIVETHREAD
228
282
  VALUE callback_dispatch_thread;
229
283
 
230
284
  g_mutex_lock(&callback_dispatch_thread_mutex);
@@ -238,13 +292,11 @@ rbgutil_start_callback_dispatch_thread(void)
238
292
  callback_dispatch_thread);
239
293
  }
240
294
  g_mutex_unlock(&callback_dispatch_thread_mutex);
241
- #endif
242
295
  }
243
296
 
244
297
  void
245
298
  rbgutil_stop_callback_dispatch_thread(void)
246
299
  {
247
- #ifdef HAVE_NATIVETHREAD
248
300
  VALUE callback_dispatch_thread;
249
301
 
250
302
  g_mutex_lock(&callback_dispatch_thread_mutex);
@@ -254,7 +306,6 @@ rbgutil_stop_callback_dispatch_thread(void)
254
306
  rb_ivar_set(rbg_mGLib(), id_callback_dispatch_thread, Qnil);
255
307
  }
256
308
  g_mutex_unlock(&callback_dispatch_thread_mutex);
257
- #endif
258
309
  }
259
310
 
260
311
  void
@@ -265,11 +316,9 @@ Init_gutil_callback(void)
265
316
  rb_define_class_under(rbg_mGLib(), "CallbackNotInitializedError",
266
317
  rb_eRuntimeError);
267
318
 
268
- #ifdef HAVE_NATIVETHREAD
269
319
  id_callback_dispatch_thread = rb_intern("callback_dispatch_thread");
270
320
  rb_ivar_set(rbg_mGLib(), id_callback_dispatch_thread, Qnil);
271
321
 
272
322
  callback_request_queue = g_async_queue_new();
273
323
  g_mutex_init(&callback_dispatch_thread_mutex);
274
- #endif
275
324
  }
data/lib/glib-mkenums.rb CHANGED
@@ -3,9 +3,9 @@
3
3
  #
4
4
  # C language enum description generation library like as glib-mkenums tool.
5
5
  #
6
- # Copyright(C) 2006-2015 Ruby-GNOME2 Project.
6
+ # Copyright (C) 2006-2026 Ruby-GNOME Project Team
7
7
  #
8
- # This program is licenced under the same license of Ruby-GNOME2.
8
+ # This program is licensed under the same license of Ruby-GNOME.
9
9
  #
10
10
 
11
11
  module GLib
@@ -92,7 +92,13 @@ GType #{@enum_name}_get_type (void);
92
92
 
93
93
  private
94
94
  def to_snail_case(name)
95
- prefix_processed_name = name.sub(/^[A-Z]/) do |prefix|
95
+ id_prefix = @options[:id_prefix]
96
+ if id_prefix
97
+ id_prefix_pattern = /\A#{Regexp.escape(id_prefix)}/
98
+ else
99
+ id_prefix_pattern = /\A[A-Z]/
100
+ end
101
+ prefix_processed_name = name.sub(id_prefix_pattern) do |prefix|
96
102
  prefix.downcase
97
103
  end
98
104
  snail_cased_name = prefix_processed_name.gsub(/[A-Z]+/) do |upper_case|
@@ -118,7 +124,7 @@ GType #{@enum_name}_get_type (void);
118
124
  # GLIB_DEPRECATED_TYPE_IN_2_38_FOR(GTestSubprocessFlags)
119
125
  (?:\s+[\w()\s]+)?
120
126
  ;/mx) do |force_flags, constants, name|
121
- enum_options = {}
127
+ enum_options = {id_prefix: options[:id_prefix]}
122
128
  enum_options[:force_flags] = !force_flags.nil?
123
129
  force_flags_patterns = [(options[:force_flags] || [])].flatten
124
130
  if force_flags_patterns.any? {|pattern| pattern === name}
@@ -0,0 +1,140 @@
1
+ # Copyright (C) 2013-2026 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
+ require_relative "collection-reader"
18
+
19
+ module GLib
20
+ class CallableInfo
21
+ extend CollectionReader
22
+
23
+ collection_reader("args")
24
+
25
+ def in_args
26
+ @in_args ||= compute_in_args
27
+ end
28
+
29
+ def required_in_args
30
+ @required_in_args ||= in_args.reject do |arg|
31
+ arg.may_be_null?
32
+ end
33
+ end
34
+
35
+ def n_in_args
36
+ in_args.size
37
+ end
38
+
39
+ def n_required_in_args
40
+ required_in_args.size
41
+ end
42
+
43
+ def require_callback?
44
+ (@require_callback ||= compute_require_callback) == :required
45
+ end
46
+
47
+ def out_args
48
+ @out_args ||= args.find_all do |arg|
49
+ case arg.direction
50
+ when Direction::OUT, Direction::INOUT
51
+ true
52
+ else
53
+ false
54
+ end
55
+ end
56
+ end
57
+
58
+ def n_out_args
59
+ out_args.size
60
+ end
61
+
62
+ def have_return_value?
63
+ return true if return_type.tag != TypeTag::VOID
64
+ return true if return_type.pointer?
65
+ not n_out_args.zero?
66
+ end
67
+
68
+ def description
69
+ signature
70
+ end
71
+
72
+ def signature
73
+ argument_signatures = args.collect(&:signature).join(", ")
74
+ "#{name}(#{argument_signatures}): #{return_type.description}"
75
+ end
76
+
77
+ def inspect
78
+ super.gsub(/>\z/) do
79
+ " signature=<#{signature}>" +
80
+ " name=#{name.inspect}" +
81
+ " arguments=#{args.inspect}" +
82
+ " return_type=#{return_type.inspect}" +
83
+ " may_return_null=#{may_return_null?.inspect}>"
84
+ end
85
+ end
86
+
87
+ private
88
+ def compute_in_args
89
+ array_length_indexes = []
90
+ callback_indexes = []
91
+ closure_indexes = []
92
+ destroy_indexes = []
93
+ args.each_with_index do |arg, i|
94
+ if arg.type.tag == TypeTag::ARRAY
95
+ array_length = arg.type.array_length
96
+ array_length_indexes << array_length if array_length != -1
97
+ end
98
+
99
+ unless arg.scope == ScopeType::INVALID
100
+ callback_indexes << i
101
+ closure_index = arg.closure
102
+ closure_indexes << closure_index if closure_index != -1
103
+ destroy_index = arg.destroy
104
+ destroy_indexes << destroy_index if destroy_index != -1
105
+ end
106
+ end
107
+
108
+ args.find_all.with_index do |arg, i|
109
+ case arg.direction
110
+ when Direction::IN, Direction::INOUT
111
+ if array_length_indexes.include?(i)
112
+ false
113
+ elsif callback_indexes.include?(i)
114
+ false
115
+ elsif closure_indexes.include?(i)
116
+ false
117
+ elsif destroy_indexes.include?(i)
118
+ false
119
+ else
120
+ true
121
+ end
122
+ else
123
+ arg.output_buffer?
124
+ end
125
+ end
126
+ end
127
+
128
+ def compute_require_callback
129
+ args.each do |arg|
130
+ if arg.direction == Direction::IN and
131
+ arg.scope != ScopeType::INVALID and
132
+ !arg.may_be_null?
133
+ return :required
134
+ end
135
+ end
136
+
137
+ :not_required
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,41 @@
1
+ # Copyright (C) 2012-2026 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
+ module GLib
18
+ module CollectionReader
19
+ def collection_reader(name)
20
+ n_getter = "n_#{name}"
21
+ if name.end_with?("ies")
22
+ singular = name.sub(/ies\z/, "y")
23
+ else
24
+ singular = name.sub(/s\z/, "")
25
+ end
26
+ getter = "get_#{singular}"
27
+ cache_name = "@#{name}"
28
+ define_method(name) do
29
+ if instance_variable_defined?(cache_name)
30
+ instance_variable_get(cache_name)
31
+ else
32
+ collection = send(n_getter).times.collect do |i|
33
+ send(getter, i)
34
+ end
35
+ instance_variable_set(cache_name, collection)
36
+ collection
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,32 @@
1
+ # Copyright (C) 2013-2026 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
+ require_relative "collection-reader"
18
+
19
+ module GLib
20
+ class InterfaceInfo
21
+ extend CollectionReader
22
+
23
+ alias_method :__methods__, :methods
24
+
25
+ collection_reader("prerequisites")
26
+ collection_reader("properties")
27
+ collection_reader("methods")
28
+ collection_reader("signals")
29
+ collection_reader("vfuncs")
30
+ collection_reader("constants")
31
+ end
32
+ end
@@ -0,0 +1,47 @@
1
+ # Copyright (C) 2012-2026 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
+ module GLib
18
+ class Repository
19
+ class << self
20
+ if Repository.respond_to?(:default)
21
+ alias_method :default_raw, :default
22
+ def default
23
+ @@default ||= default_raw
24
+ end
25
+ else
26
+ def default
27
+ @@default ||= new
28
+ end
29
+ end
30
+ end
31
+
32
+ include Enumerable
33
+
34
+ def each(*namespaces)
35
+ return to_enum(__method__, *namespaces) unless block_given?
36
+
37
+ if namespaces.empty?
38
+ namespaces = loaded_namespaces
39
+ end
40
+ namespaces.each do |namespace|
41
+ get_n_infos(namespace).times do |i|
42
+ yield(get_info(namespace, i))
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,33 @@
1
+ # Copyright (C) 2019-2026 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
+ module GLib
18
+ class TypeInfo
19
+ def try_convert(value)
20
+ tag.try_convert(self, value)
21
+ end
22
+
23
+ def description
24
+ tag.description(self)
25
+ end
26
+
27
+ def inspect
28
+ super.gsub(/>\z/) do
29
+ " tag=#{tag.inspect}>"
30
+ end
31
+ end
32
+ end
33
+ end
data/lib/glib2.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2005-2025 Ruby-GNOME Project Team
1
+ # Copyright (C) 2005-2026 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
@@ -345,6 +345,13 @@ require "glib2/value"
345
345
  require "glib2/variant"
346
346
  require "glib2/variant-type"
347
347
 
348
+ if GLib.const_defined?(:Repository)
349
+ require_relative "glib2/callable-info"
350
+ require_relative "glib2/interface-info"
351
+ require_relative "glib2/repository"
352
+ require_relative "glib2/type-info"
353
+ end
354
+
348
355
  =begin
349
356
  Don't we need this?
350
357
  ObjectSpace.define_finalizer(GLib) {