glib2 3.5.1 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/glib2/extconf.rb +4 -3
- data/ext/glib2/glib2.def +6 -0
- data/ext/glib2/rbglib-bytes.c +1 -1
- data/ext/glib2/rbglib-gc.c +1 -1
- data/ext/glib2/rbglib-variant-type.c +1 -1
- data/ext/glib2/rbglib-variant.c +75 -2
- data/ext/glib2/rbglib.c +25 -59
- data/ext/glib2/rbglib.h +16 -3
- data/ext/glib2/rbglib_bookmarkfile.c +3 -2
- data/ext/glib2/rbglib_convert.c +2 -2
- data/ext/glib2/rbglib_datetime.c +14 -3
- data/ext/glib2/rbglib_error.c +2 -2
- data/ext/glib2/rbglib_fileutils.c +2 -2
- data/ext/glib2/rbglib_gettext.c +1 -1
- data/ext/glib2/rbglib_i18n.c +2 -2
- data/ext/glib2/rbglib_io_constants.c +1 -1
- data/ext/glib2/rbglib_iochannel.c +2 -2
- data/ext/glib2/rbglib_iochannel_win32_socket.c +2 -2
- data/ext/glib2/rbglib_iochannelerror.c +1 -1
- data/ext/glib2/rbglib_keyfile.c +2 -2
- data/ext/glib2/rbglib_maincontext.c +6 -6
- data/ext/glib2/rbglib_mainloop.c +1 -1
- data/ext/glib2/rbglib_matchinfo.c +1 -1
- data/ext/glib2/rbglib_messages.c +1 -1
- data/ext/glib2/rbglib_pollfd.c +1 -1
- data/ext/glib2/rbglib_regex.c +3 -3
- data/ext/glib2/rbglib_shell.c +1 -1
- data/ext/glib2/rbglib_shellerror.c +1 -1
- data/ext/glib2/rbglib_source.c +1 -1
- data/ext/glib2/rbglib_spawn.c +1 -1
- data/ext/glib2/rbglib_spawnerror.c +1 -1
- data/ext/glib2/rbglib_threads.c +1 -1
- data/ext/glib2/rbglib_timer.c +1 -1
- data/ext/glib2/rbglib_timezone.c +1 -1
- data/ext/glib2/rbglib_ucs4.c +1 -1
- data/ext/glib2/rbglib_unichar.c +1 -1
- data/ext/glib2/rbglib_unicode.c +3 -3
- data/ext/glib2/rbglib_utf16.c +1 -1
- data/ext/glib2/rbglib_utf8.c +1 -1
- data/ext/glib2/rbglib_utils.c +1 -1
- data/ext/glib2/rbglib_win32.c +3 -3
- data/ext/glib2/rbgobj_binding.c +1 -1
- data/ext/glib2/rbgobj_boxed.c +1 -1
- data/ext/glib2/rbgobj_closure.c +76 -85
- data/ext/glib2/rbgobj_enums.c +1 -1
- data/ext/glib2/rbgobj_flags.c +1 -1
- data/ext/glib2/rbgobj_object.c +32 -5
- data/ext/glib2/rbgobj_param.c +1 -1
- data/ext/glib2/rbgobj_signal.c +63 -19
- data/ext/glib2/rbgobj_type.c +2 -2
- data/ext/glib2/rbgobj_typeinstance.c +1 -1
- data/ext/glib2/rbgobj_typeinterface.c +4 -4
- data/ext/glib2/rbgobj_typemodule.c +1 -1
- data/ext/glib2/rbgobj_typeplugin.c +1 -1
- data/ext/glib2/rbgobj_value.c +1 -1
- data/ext/glib2/rbgobj_valuetypes.c +14 -4
- data/ext/glib2/rbgobject.c +7 -21
- data/ext/glib2/rbgobject.h +4 -1
- data/ext/glib2/rbgprivate.h +7 -4
- data/ext/glib2/rbgutil.c +20 -1
- data/ext/glib2/rbgutil.h +3 -0
- data/ext/glib2/rbgutil_callback.c +7 -7
- data/lib/glib2/date-time.rb +35 -0
- data/lib/glib2/variant.rb +25 -0
- data/lib/glib2.rb +6 -1
- data/lib/mkmf-gnome.rb +2 -2
- data/test/test-date-time.rb +14 -2
- data/test/test-glib2.rb +21 -9
- data/test/test-variant.rb +44 -1
- metadata +7 -7
- data/ext/glib2/glib-enum-types.c +0 -1233
- data/ext/glib2/glib-enum-types.h +0 -154
data/ext/glib2/rbglib_spawn.c
CHANGED
@@ -217,7 +217,7 @@ rg_s_close_pid(G_GNUC_UNUSED VALUE self, VALUE pid)
|
|
217
217
|
void
|
218
218
|
Init_glib_spawn(void)
|
219
219
|
{
|
220
|
-
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(
|
220
|
+
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "Spawn");
|
221
221
|
|
222
222
|
id_call = rb_intern("call");
|
223
223
|
id_new = rb_intern("new");
|
@@ -28,7 +28,7 @@
|
|
28
28
|
void
|
29
29
|
Init_glib_spawnerror(void)
|
30
30
|
{
|
31
|
-
VALUE RG_TARGET_NAMESPACE = G_DEF_ERROR2(G_SPAWN_ERROR, "SpawnError",
|
31
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_ERROR2(G_SPAWN_ERROR, "SpawnError", rbg_mGLib(), rb_eIOError);
|
32
32
|
|
33
33
|
rb_define_const(RG_TARGET_NAMESPACE, "FORK", INT2NUM(G_SPAWN_ERROR_FORK));
|
34
34
|
rb_define_const(RG_TARGET_NAMESPACE, "READ", INT2NUM(G_SPAWN_ERROR_READ));
|
data/ext/glib2/rbglib_threads.c
CHANGED
@@ -41,7 +41,7 @@ rg_s_supported_p(G_GNUC_UNUSED VALUE self)
|
|
41
41
|
void
|
42
42
|
Init_glib_threads(void)
|
43
43
|
{
|
44
|
-
RG_TARGET_NAMESPACE = rb_define_class_under(
|
44
|
+
RG_TARGET_NAMESPACE = rb_define_class_under(rbg_mGLib(), "Thread", rb_cObject);
|
45
45
|
|
46
46
|
RG_DEF_SMETHOD(init, 0);
|
47
47
|
RG_DEF_SMETHOD_P(supported, 0);
|
data/ext/glib2/rbglib_timer.c
CHANGED
@@ -116,7 +116,7 @@ rg_reset(VALUE self)
|
|
116
116
|
void
|
117
117
|
Init_glib_timer(void)
|
118
118
|
{
|
119
|
-
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_TIMER, "Timer",
|
119
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_TIMER, "Timer", rbg_mGLib());
|
120
120
|
|
121
121
|
RG_DEF_METHOD(initialize, 0);
|
122
122
|
RG_DEF_METHOD(start, 0);
|
data/ext/glib2/rbglib_timezone.c
CHANGED
@@ -73,7 +73,7 @@ void
|
|
73
73
|
Init_glib_time_zone(void)
|
74
74
|
{
|
75
75
|
VALUE RG_TARGET_NAMESPACE;
|
76
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_TIME_ZONE, "TimeZone",
|
76
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_TIME_ZONE, "TimeZone", rbg_mGLib());
|
77
77
|
RG_DEF_METHOD(initialize, -1);
|
78
78
|
RG_DEF_SMETHOD(local, 0);
|
79
79
|
RG_DEF_SMETHOD(utc, 0);
|
data/ext/glib2/rbglib_ucs4.c
CHANGED
@@ -72,7 +72,7 @@ rg_s_to_utf8(G_GNUC_UNUSED VALUE self, VALUE rb_ucs4)
|
|
72
72
|
void
|
73
73
|
Init_glib_ucs4(void)
|
74
74
|
{
|
75
|
-
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(
|
75
|
+
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "UCS4");
|
76
76
|
|
77
77
|
RG_DEF_SMETHOD(to_utf16, 1);
|
78
78
|
RG_DEF_SMETHOD(to_utf8, 1);
|
data/ext/glib2/rbglib_unichar.c
CHANGED
@@ -185,7 +185,7 @@ rg_s_decompose(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
|
|
185
185
|
void
|
186
186
|
Init_glib_unichar(void)
|
187
187
|
{
|
188
|
-
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(
|
188
|
+
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "UniChar");
|
189
189
|
|
190
190
|
rbg_define_singleton_method(RG_TARGET_NAMESPACE, "alnum?",
|
191
191
|
rbglib_m_unichar_isalnum, 1);
|
data/ext/glib2/rbglib_unicode.c
CHANGED
@@ -52,7 +52,7 @@ rg_s_canonical_ordering(G_GNUC_UNUSED VALUE self, VALUE rb_ucs4)
|
|
52
52
|
void
|
53
53
|
Init_glib_unicode(void)
|
54
54
|
{
|
55
|
-
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(
|
55
|
+
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "Unicode");
|
56
56
|
|
57
57
|
/* GUnicodeType */
|
58
58
|
G_DEF_CLASS(G_TYPE_UNICODE_TYPE, "Type", RG_TARGET_NAMESPACE);
|
@@ -65,9 +65,9 @@ Init_glib_unicode(void)
|
|
65
65
|
G_DEF_CLASS(G_TYPE_UNICODE_SCRIPT, "Script", RG_TARGET_NAMESPACE);
|
66
66
|
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_UNICODE_SCRIPT, "G_UNICODE_");
|
67
67
|
|
68
|
-
G_DEF_CLASS(G_TYPE_NORMALIZE_MODE, "NormalizeMode",
|
68
|
+
G_DEF_CLASS(G_TYPE_NORMALIZE_MODE, "NormalizeMode", rbg_mGLib());
|
69
69
|
|
70
|
-
rbg_define_singleton_method(
|
70
|
+
rbg_define_singleton_method(rbg_mGLib(), "charset", rbglib_m_charset, 0);
|
71
71
|
|
72
72
|
RG_DEF_SMETHOD(canonical_ordering, 1);
|
73
73
|
}
|
data/ext/glib2/rbglib_utf16.c
CHANGED
@@ -71,7 +71,7 @@ rg_s_to_utf8(G_GNUC_UNUSED VALUE self, VALUE rb_utf16)
|
|
71
71
|
void
|
72
72
|
Init_glib_utf16(void)
|
73
73
|
{
|
74
|
-
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(
|
74
|
+
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "UTF16");
|
75
75
|
|
76
76
|
RG_DEF_SMETHOD(to_ucs4, 1);
|
77
77
|
RG_DEF_SMETHOD(to_utf8, 1);
|
data/ext/glib2/rbglib_utf8.c
CHANGED
@@ -218,7 +218,7 @@ rg_s_to_ucs4(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
|
|
218
218
|
void
|
219
219
|
Init_glib_utf8(void)
|
220
220
|
{
|
221
|
-
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(
|
221
|
+
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "UTF8");
|
222
222
|
|
223
223
|
/*
|
224
224
|
Not implemented.
|
data/ext/glib2/rbglib_utils.c
CHANGED
data/ext/glib2/rbglib_win32.c
CHANGED
@@ -90,17 +90,17 @@ Init_glib_win32(void)
|
|
90
90
|
{
|
91
91
|
#ifdef G_OS_WIN32
|
92
92
|
/* glib/gwin32.h */
|
93
|
-
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(
|
93
|
+
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "Win32");
|
94
94
|
|
95
95
|
RG_DEF_SMETHOD(error_message, 1);
|
96
96
|
RG_DEF_SMETHOD(locale, 0);
|
97
97
|
RG_DEF_SMETHOD(version, 0);
|
98
98
|
/* Deprecated */
|
99
|
-
rbg_define_singleton_method(
|
99
|
+
rbg_define_singleton_method(rbg_mGLib(), "win32_locale", rbglib_m_win32_locale_deprecated, 0);
|
100
100
|
|
101
101
|
RG_DEF_SMETHOD(locale_filename_from_utf8, 1);
|
102
102
|
/* Deprecated */
|
103
|
-
rbg_define_singleton_method(
|
103
|
+
rbg_define_singleton_method(rbg_mGLib(), "win32_locale_filename_from_utf8",
|
104
104
|
rbglib_m_win32_locale_filename_from_utf8_deprecated, 1);
|
105
105
|
|
106
106
|
RG_DEF_SMETHOD(get_package_installation_directory_of_module, -1);
|
data/ext/glib2/rbgobj_binding.c
CHANGED
data/ext/glib2/rbgobj_boxed.c
CHANGED
@@ -302,7 +302,7 @@ boxed_from_ruby(VALUE from, GValue *to)
|
|
302
302
|
void
|
303
303
|
Init_gobject_gboxed(void)
|
304
304
|
{
|
305
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BOXED, "Boxed",
|
305
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BOXED, "Boxed", rbg_mGLib());
|
306
306
|
|
307
307
|
rbgobj_register_g2r_func(G_TYPE_BOXED, boxed_to_ruby);
|
308
308
|
rbgobj_register_r2g_func(G_TYPE_BOXED, boxed_from_ruby);
|
data/ext/glib2/rbgobj_closure.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2002-
|
3
|
+
* Copyright (C) 2002-2022 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
|
@@ -34,7 +34,6 @@ struct _GRClosure
|
|
34
34
|
VALUE callback;
|
35
35
|
VALUE extra_args;
|
36
36
|
VALUE rb_holder;
|
37
|
-
gint count;
|
38
37
|
GList *objects;
|
39
38
|
GValToRValSignalFunc g2r_func;
|
40
39
|
RGClosureCallFunc call_func;
|
@@ -64,7 +63,7 @@ struct marshal_arg
|
|
64
63
|
static int
|
65
64
|
rclosure_alive_p(GRClosure *rclosure)
|
66
65
|
{
|
67
|
-
return
|
66
|
+
return !NIL_P(rclosure->rb_holder);
|
68
67
|
}
|
69
68
|
|
70
69
|
static VALUE
|
@@ -121,8 +120,8 @@ rclosure_marshal_do(VALUE arg_)
|
|
121
120
|
|
122
121
|
ret = rb_apply(callback, id_call, args);
|
123
122
|
} else {
|
124
|
-
|
125
|
-
|
123
|
+
g_warning("GRClosure invoking callback: already destroyed: %s",
|
124
|
+
rclosure->tag[0] ? rclosure->tag : "(anonymous)");
|
126
125
|
}
|
127
126
|
|
128
127
|
if (return_value && G_VALUE_TYPE(return_value))
|
@@ -159,43 +158,25 @@ rclosure_marshal(GClosure* closure,
|
|
159
158
|
static void rclosure_weak_notify(gpointer data, GObject* where_the_object_was);
|
160
159
|
|
161
160
|
static void
|
162
|
-
|
161
|
+
rclosure_finalize(G_GNUC_UNUSED gpointer data, GClosure *closure)
|
163
162
|
{
|
164
|
-
rclosure
|
163
|
+
GRClosure *rclosure = (GRClosure *)closure;
|
165
164
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
rclosure->objects = NULL;
|
174
|
-
if (!NIL_P(rclosure->rb_holder)) {
|
175
|
-
RTYPEDDATA_DATA(rclosure->rb_holder) = NULL;
|
176
|
-
rclosure->rb_holder = Qnil;
|
165
|
+
GList *next;
|
166
|
+
for (next = rclosure->objects; next; next = next->next) {
|
167
|
+
GObject *object = G_OBJECT(next->data);
|
168
|
+
g_object_weak_unref(object, rclosure_weak_notify, rclosure);
|
169
|
+
VALUE obj = rbgobj_ruby_object_from_instance2(object, FALSE);
|
170
|
+
if (!NIL_P(rclosure->rb_holder) && !NIL_P(obj)) {
|
171
|
+
rbgobj_object_remove_relative(obj, rclosure->rb_holder);
|
177
172
|
}
|
178
173
|
}
|
179
|
-
|
174
|
+
g_list_free(rclosure->objects);
|
175
|
+
rclosure->objects = NULL;
|
180
176
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
GRClosure *rclosure = (GRClosure*)closure;
|
185
|
-
|
186
|
-
if (rclosure->count > 0) {
|
187
|
-
GList *next;
|
188
|
-
|
189
|
-
rclosure->count = 1;
|
190
|
-
for (next = rclosure->objects; next; next = next->next) {
|
191
|
-
GObject *object = G_OBJECT(next->data);
|
192
|
-
VALUE obj = rbgobj_ruby_object_from_instance2(object, FALSE);
|
193
|
-
if (!NIL_P(rclosure->rb_holder) && !NIL_P(obj)) {
|
194
|
-
rbgobj_object_remove_relative(obj, rclosure->rb_holder);
|
195
|
-
}
|
196
|
-
}
|
197
|
-
|
198
|
-
rclosure_unref(rclosure);
|
177
|
+
if (!NIL_P(rclosure->rb_holder)) {
|
178
|
+
RTYPEDDATA_DATA(rclosure->rb_holder) = NULL;
|
179
|
+
rclosure->rb_holder = Qnil;
|
199
180
|
}
|
200
181
|
}
|
201
182
|
|
@@ -219,13 +200,7 @@ gr_closure_holder_free(void *data)
|
|
219
200
|
if (!rclosure)
|
220
201
|
return;
|
221
202
|
|
222
|
-
|
223
|
-
rclosure->count = 1;
|
224
|
-
|
225
|
-
/* No need to remove us from the relatives hash of our objects, as
|
226
|
-
* those aren't alive anymore anyway */
|
227
|
-
rclosure_unref(rclosure);
|
228
|
-
}
|
203
|
+
g_closure_unref((GClosure *)rclosure);
|
229
204
|
}
|
230
205
|
|
231
206
|
static const rb_data_type_t rbg_closure_holder_type = {
|
@@ -245,26 +220,26 @@ g_rclosure_new_raw(VALUE callback_proc,
|
|
245
220
|
GValToRValSignalFunc g2r_func,
|
246
221
|
RGClosureCallFunc call_func)
|
247
222
|
{
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
return
|
223
|
+
GClosure *closure = g_closure_new_simple(sizeof(GRClosure), NULL);
|
224
|
+
|
225
|
+
GRClosure *rclosure = (GRClosure *)closure;
|
226
|
+
|
227
|
+
rclosure->g2r_func = g2r_func;
|
228
|
+
rclosure->call_func = call_func;
|
229
|
+
rclosure->objects = NULL;
|
230
|
+
rclosure->callback = callback_proc;
|
231
|
+
rclosure->extra_args = extra_args;
|
232
|
+
rclosure->rb_holder = TypedData_Wrap_Struct(rb_cObject,
|
233
|
+
&rbg_closure_holder_type,
|
234
|
+
rclosure);
|
235
|
+
rclosure->tag[0] = '\0';
|
236
|
+
|
237
|
+
g_closure_ref(closure);
|
238
|
+
g_closure_sink(closure);
|
239
|
+
g_closure_set_marshal(closure, &rclosure_marshal);
|
240
|
+
g_closure_add_finalize_notifier(closure, NULL, rclosure_finalize);
|
241
|
+
|
242
|
+
return closure;
|
268
243
|
}
|
269
244
|
|
270
245
|
GClosure *
|
@@ -287,34 +262,51 @@ g_rclosure_new_call(VALUE callback_proc,
|
|
287
262
|
}
|
288
263
|
|
289
264
|
static void
|
290
|
-
rclosure_weak_notify(gpointer data, GObject*
|
265
|
+
rclosure_weak_notify(gpointer data, GObject *where_the_object_was)
|
291
266
|
{
|
292
267
|
GRClosure *rclosure = data;
|
293
|
-
|
294
|
-
|
295
|
-
g_list_remove(rclosure->objects, where_the_object_was);
|
296
|
-
rclosure_unref(rclosure);
|
297
|
-
}
|
268
|
+
rclosure->objects = g_list_remove(rclosure->objects, where_the_object_was);
|
269
|
+
g_closure_unref((GClosure *)rclosure);
|
298
270
|
}
|
299
271
|
|
300
272
|
void
|
301
273
|
g_rclosure_attach(GClosure *closure, VALUE object)
|
302
274
|
{
|
303
|
-
static VALUE cGLibObject = Qnil;
|
304
275
|
GRClosure *rclosure = (GRClosure *)closure;
|
276
|
+
rbgobj_add_relative_removable(object,
|
277
|
+
Qnil,
|
278
|
+
id_closures,
|
279
|
+
rclosure->rb_holder);
|
280
|
+
}
|
281
|
+
|
282
|
+
void
|
283
|
+
g_rclosure_attach_gobject(GClosure *closure, VALUE object)
|
284
|
+
{
|
285
|
+
GRClosure *rclosure = (GRClosure *)closure;
|
286
|
+
g_rclosure_attach(closure, object);
|
305
287
|
|
306
|
-
|
288
|
+
GObject *gobject = RVAL2GOBJ(object);
|
289
|
+
g_closure_ref(closure);
|
290
|
+
g_object_weak_ref(gobject, rclosure_weak_notify, rclosure);
|
291
|
+
rclosure->objects = g_list_prepend(rclosure->objects, gobject);
|
292
|
+
}
|
307
293
|
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
294
|
+
void
|
295
|
+
g_rclosure_detach(GClosure *closure, VALUE object)
|
296
|
+
{
|
297
|
+
GRClosure *rclosure = (GRClosure *)closure;
|
298
|
+
rbgobj_remove_relative(object, id_closures, rclosure->rb_holder);
|
299
|
+
}
|
300
|
+
|
301
|
+
void
|
302
|
+
g_rclosure_detach_gobject(GClosure *closure, VALUE object)
|
303
|
+
{
|
304
|
+
GRClosure *rclosure = (GRClosure *)closure;
|
305
|
+
g_rclosure_detach(closure, object);
|
306
|
+
|
307
|
+
GObject *gobject = RVAL2GOBJ(object);
|
308
|
+
g_object_weak_unref(gobject, rclosure_weak_notify, rclosure);
|
309
|
+
rclosure_weak_notify(rclosure, gobject);
|
318
310
|
}
|
319
311
|
|
320
312
|
void
|
@@ -350,9 +342,8 @@ init_rclosure(void)
|
|
350
342
|
static VALUE
|
351
343
|
rg_initialize(VALUE self)
|
352
344
|
{
|
353
|
-
GClosure*
|
345
|
+
GClosure *closure = g_rclosure_new(rb_block_proc(), Qnil, NULL);
|
354
346
|
G_INITIALIZE(self, closure);
|
355
|
-
g_closure_sink(closure);
|
356
347
|
return self;
|
357
348
|
}
|
358
349
|
|
@@ -387,7 +378,7 @@ Init_gobject_gclosure(void)
|
|
387
378
|
|
388
379
|
init_rclosure();
|
389
380
|
|
390
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_CLOSURE, "Closure",
|
381
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_CLOSURE, "Closure", rbg_mGLib());
|
391
382
|
|
392
383
|
RG_DEF_METHOD(initialize, 0);
|
393
384
|
RG_DEF_METHOD_P(in_marshal, 0);
|
data/ext/glib2/rbgobj_enums.c
CHANGED
@@ -413,7 +413,7 @@ Init_gobject_genums(void)
|
|
413
413
|
id_to_s = rb_intern("to_s");
|
414
414
|
id_values = rb_intern("values");
|
415
415
|
|
416
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_ENUM, "Enum",
|
416
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_ENUM, "Enum", rbg_mGLib());
|
417
417
|
|
418
418
|
rbg_define_singleton_method(RG_TARGET_NAMESPACE, "gtype", generic_s_gtype, 0);
|
419
419
|
rbg_define_method(RG_TARGET_NAMESPACE, "gtype", generic_gtype, 0);
|
data/ext/glib2/rbgobj_flags.c
CHANGED
@@ -542,7 +542,7 @@ Init_gobject_gflags(void)
|
|
542
542
|
id_or = rb_intern("|");
|
543
543
|
id_to_i = rb_intern("to_i");
|
544
544
|
|
545
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FLAGS, "Flags",
|
545
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_FLAGS, "Flags", rbg_mGLib());
|
546
546
|
|
547
547
|
rbg_define_singleton_method(RG_TARGET_NAMESPACE, "gtype", generic_s_gtype, 0);
|
548
548
|
rbg_define_method(RG_TARGET_NAMESPACE, "gtype", generic_gtype, 0);
|
data/ext/glib2/rbgobj_object.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2002-
|
3
|
+
* Copyright (C) 2002-2022 Ruby-GNOME Project Team
|
4
4
|
* Copyright (C) 2002-2003 Masahiro Sakai
|
5
5
|
* Copyright (C) 1998-2000 Yukihiro Matsumoto,
|
6
6
|
* Daisuke Kanda,
|
@@ -30,6 +30,12 @@ VALUE RG_TARGET_NAMESPACE;
|
|
30
30
|
static VALUE eNoPropertyError;
|
31
31
|
static GQuark RUBY_GOBJECT_OBJ_KEY;
|
32
32
|
|
33
|
+
VALUE
|
34
|
+
rbg_cGLibObject(void)
|
35
|
+
{
|
36
|
+
return RG_TARGET_NAMESPACE;
|
37
|
+
}
|
38
|
+
|
33
39
|
gboolean
|
34
40
|
rbg_is_object(VALUE object)
|
35
41
|
{
|
@@ -311,6 +317,12 @@ rg_s_new_bang(int argc, VALUE *argv, VALUE self)
|
|
311
317
|
return result;
|
312
318
|
}
|
313
319
|
|
320
|
+
static VALUE
|
321
|
+
rg_s_init(int argc, VALUE *argv, VALUE self)
|
322
|
+
{
|
323
|
+
return RUBY_Qnil;
|
324
|
+
}
|
325
|
+
|
314
326
|
struct param_setup_arg {
|
315
327
|
GObjectClass* gclass;
|
316
328
|
GParameter* params;
|
@@ -872,6 +884,15 @@ rg_initialize(int argc, VALUE *argv, VALUE self)
|
|
872
884
|
gobj = rbgobj_gobject_new(RVAL2GTYPE(self), params_hash);
|
873
885
|
|
874
886
|
G_INITIALIZE(self, gobj);
|
887
|
+
|
888
|
+
rb_funcall(self, rb_intern("initialize_post"), 0);
|
889
|
+
|
890
|
+
return Qnil;
|
891
|
+
}
|
892
|
+
|
893
|
+
static VALUE
|
894
|
+
rg_initialize_post(VALUE self)
|
895
|
+
{
|
875
896
|
return Qnil;
|
876
897
|
}
|
877
898
|
|
@@ -956,6 +977,9 @@ rbgobj_class_init_func(gpointer g_class, G_GNUC_UNUSED gpointer class_data)
|
|
956
977
|
|
957
978
|
g_object_class->set_property = set_prop_func;
|
958
979
|
g_object_class->get_property = get_prop_func;
|
980
|
+
|
981
|
+
VALUE rb_class = GTYPE2CLASS(G_TYPE_FROM_CLASS(g_class));
|
982
|
+
rb_funcall(rb_class, rb_intern("init"), 0);
|
959
983
|
}
|
960
984
|
|
961
985
|
void
|
@@ -1062,11 +1086,11 @@ rg_s_type_register(int argc, VALUE *argv, VALUE self)
|
|
1062
1086
|
void
|
1063
1087
|
Init_gobject_gobject(void)
|
1064
1088
|
{
|
1065
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS_WITH_GC_FUNC(G_TYPE_OBJECT, "Object",
|
1089
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS_WITH_GC_FUNC(G_TYPE_OBJECT, "Object", rbg_mGLib(),
|
1066
1090
|
gobj_mark, NULL);
|
1067
1091
|
|
1068
1092
|
#ifdef G_TYPE_INITIALLY_UNOWNED
|
1069
|
-
G_DEF_CLASS(G_TYPE_INITIALLY_UNOWNED, "InitiallyUnowned",
|
1093
|
+
G_DEF_CLASS(G_TYPE_INITIALLY_UNOWNED, "InitiallyUnowned", rbg_mGLib());
|
1070
1094
|
#endif
|
1071
1095
|
|
1072
1096
|
RUBY_GOBJECT_OBJ_KEY = g_quark_from_static_string("__ruby_gobject_object__");
|
@@ -1074,6 +1098,8 @@ Init_gobject_gobject(void)
|
|
1074
1098
|
rb_define_alloc_func(RG_TARGET_NAMESPACE, rbgobj_object_alloc_func);
|
1075
1099
|
RG_DEF_SMETHOD_BANG(new, -1);
|
1076
1100
|
|
1101
|
+
RG_DEF_SMETHOD(init, 0);
|
1102
|
+
|
1077
1103
|
rbg_define_singleton_method(RG_TARGET_NAMESPACE, "property", &gobj_s_property, 1);
|
1078
1104
|
rbg_define_singleton_method(RG_TARGET_NAMESPACE, "properties", &gobj_s_properties, -1);
|
1079
1105
|
RG_DEF_SMETHOD(install_property, -1);
|
@@ -1089,6 +1115,7 @@ Init_gobject_gobject(void)
|
|
1089
1115
|
RG_DEF_METHOD_P(destroyed, 0);
|
1090
1116
|
|
1091
1117
|
RG_DEF_METHOD(initialize, -1);
|
1118
|
+
RG_DEF_PRIVATE_METHOD(initialize_post, 0);
|
1092
1119
|
rbg_define_method(RG_TARGET_NAMESPACE, "ref_count", gobj_ref_count, 0); /* for debugging */
|
1093
1120
|
RG_DEF_METHOD_P(floating, 0); /* for debugging */
|
1094
1121
|
RG_DEF_METHOD(unref, 0);
|
@@ -1096,9 +1123,9 @@ Init_gobject_gobject(void)
|
|
1096
1123
|
RG_DEF_METHOD(type_name, 0);
|
1097
1124
|
|
1098
1125
|
RG_DEF_METHOD(bind_property, -1);
|
1099
|
-
G_DEF_CLASS(G_TYPE_BINDING_FLAGS, "BindingFlags",
|
1126
|
+
G_DEF_CLASS(G_TYPE_BINDING_FLAGS, "BindingFlags", rbg_mGLib());
|
1100
1127
|
|
1101
|
-
eNoPropertyError = rb_define_class_under(
|
1128
|
+
eNoPropertyError = rb_define_class_under(rbg_mGLib(), "NoPropertyError",
|
1102
1129
|
rb_eNameError);
|
1103
1130
|
|
1104
1131
|
rbg_type_to_prop_setter_tables =
|
data/ext/glib2/rbgobj_param.c
CHANGED
@@ -353,7 +353,7 @@ void
|
|
353
353
|
Init_gobject_gparam(void)
|
354
354
|
{
|
355
355
|
qparamspec = g_quark_from_static_string("__ruby_gobject_param_spec__");
|
356
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_PARAM, "Param",
|
356
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_PARAM, "Param", rbg_mGLib());
|
357
357
|
|
358
358
|
/* GParamFlags */
|
359
359
|
rb_define_const(RG_TARGET_NAMESPACE, "READABLE",
|