glib2 3.4.3 → 3.4.7
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.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/ext/glib2/extconf.rb +1 -5
- data/ext/glib2/glib-enum-types.c +1233 -0
- data/ext/glib2/glib-enum-types.h +154 -0
- data/ext/glib2/glib2.def +1 -0
- data/ext/glib2/rbglib-bytes.c +1 -5
- data/ext/glib2/rbglib-gc.c +98 -52
- data/ext/glib2/rbglib-variant-type.c +1 -5
- data/ext/glib2/rbglib-variant.c +3 -5
- data/ext/glib2/rbglib.c +4 -0
- data/ext/glib2/rbglib.h +12 -2
- data/ext/glib2/rbglib_bookmarkfile.c +1 -1
- data/ext/glib2/rbglib_datetime.c +1 -5
- data/ext/glib2/rbglib_error.c +21 -2
- data/ext/glib2/rbglib_fileutils.c +1 -17
- data/ext/glib2/rbglib_iochannel.c +4 -4
- data/ext/glib2/rbglib_keyfile.c +1 -35
- data/ext/glib2/rbglib_maincontext.c +6 -32
- data/ext/glib2/rbglib_mainloop.c +2 -17
- data/ext/glib2/rbglib_matchinfo.c +1 -5
- data/ext/glib2/rbglib_messages.c +4 -5
- data/ext/glib2/rbglib_pollfd.c +1 -25
- data/ext/glib2/rbglib_regex.c +1 -13
- data/ext/glib2/rbglib_source.c +1 -39
- data/ext/glib2/rbglib_spawn.c +5 -10
- data/ext/glib2/rbglib_spawnerror.c +2 -2
- data/ext/glib2/rbglib_threads.c +2 -15
- data/ext/glib2/rbglib_timezone.c +1 -5
- data/ext/glib2/rbglib_unichar.c +46 -5
- data/ext/glib2/rbglib_unicode.c +1 -18
- data/ext/glib2/rbglib_utils.c +1 -14
- data/ext/glib2/rbglib_win32.c +3 -7
- data/ext/glib2/rbgobj_binding.c +1 -7
- data/ext/glib2/rbgobj_closure.c +22 -9
- data/ext/glib2/rbgobj_object.c +116 -105
- data/ext/glib2/rbgobj_param.c +2 -8
- data/ext/glib2/rbgobj_paramspecs.c +6 -24
- data/ext/glib2/rbgobj_signal.c +104 -92
- data/ext/glib2/rbgobj_strv.c +2 -2
- data/ext/glib2/rbgobj_type.c +57 -67
- data/ext/glib2/rbgobj_typeinterface.c +38 -2
- data/ext/glib2/rbgobj_value.c +3 -7
- data/ext/glib2/rbgobj_valuetypes.c +14 -62
- data/ext/glib2/rbgobject.c +4 -6
- data/ext/glib2/rbgobject.h +2 -27
- data/ext/glib2/rbgprivate.h +6 -6
- data/ext/glib2/rbgutil_callback.c +23 -26
- data/lib/glib2.rb +32 -3
- data/lib/glib2/deprecated.rb +22 -1
- data/lib/mkmf-gnome.rb +4 -4
- data/test/glib-test-utils.rb +18 -3
- data/test/run-test.rb +49 -15
- data/test/test-binding.rb +1 -11
- data/test/test-bytes.rb +1 -5
- data/test/test-date-time.rb +1 -3
- data/test/{glib-test-init.rb → test-error.rb} +25 -3
- data/test/test-file-utils.rb +1 -32
- data/test/test-iochannel.rb +3 -5
- data/test/test-key-file.rb +5 -6
- data/test/test-match-info.rb +1 -5
- data/test/test-regex.rb +1 -5
- data/test/test-source.rb +1 -14
- data/test/test-spawn.rb +2 -1
- data/test/test-time-zone.rb +1 -5
- data/test/test-timeout.rb +2 -3
- data/test/test-unicode.rb +16 -12
- data/test/test-utils.rb +2 -8
- data/test/test-variant-type.rb +1 -3
- data/test/test-win32.rb +6 -6
- metadata +6 -5
- data/ext/glib2/rbgobj_valuearray.c +0 -100
data/ext/glib2/rbglib_unicode.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011-
|
3
|
+
* Copyright (C) 2011-2021 Ruby-GNOME Project Team
|
4
4
|
* Copyright (C) 2006 Kouhei Sutou
|
5
5
|
*
|
6
6
|
* This library is free software; you can redistribute it and/or
|
@@ -49,20 +49,6 @@ rg_s_canonical_ordering(G_GNUC_UNUSED VALUE self, VALUE rb_ucs4)
|
|
49
49
|
return normalized_ucs4;
|
50
50
|
}
|
51
51
|
|
52
|
-
static VALUE
|
53
|
-
rg_s_canonical_decomposition(G_GNUC_UNUSED VALUE self, VALUE unichar)
|
54
|
-
{
|
55
|
-
VALUE normalized_ucs4;
|
56
|
-
gunichar *ucs4;
|
57
|
-
gsize len;
|
58
|
-
|
59
|
-
ucs4 = g_unicode_canonical_decomposition(NUM2UINT(unichar), &len);
|
60
|
-
normalized_ucs4 = CSTR2RVAL_LEN_UCS4((const char *)ucs4,
|
61
|
-
len * sizeof(gunichar));
|
62
|
-
g_free(ucs4);
|
63
|
-
return normalized_ucs4;
|
64
|
-
}
|
65
|
-
|
66
52
|
void
|
67
53
|
Init_glib_unicode(void)
|
68
54
|
{
|
@@ -75,16 +61,13 @@ Init_glib_unicode(void)
|
|
75
61
|
G_DEF_CLASS(G_TYPE_UNICODE_BREAK_TYPE, "BreakType", RG_TARGET_NAMESPACE);
|
76
62
|
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_UNICODE_BREAK_TYPE, "G_UNICODE_");
|
77
63
|
|
78
|
-
#if GLIB_CHECK_VERSION(2,14,0)
|
79
64
|
/* GUnicodeScript */
|
80
65
|
G_DEF_CLASS(G_TYPE_UNICODE_SCRIPT, "Script", RG_TARGET_NAMESPACE);
|
81
66
|
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_UNICODE_SCRIPT, "G_UNICODE_");
|
82
|
-
#endif
|
83
67
|
|
84
68
|
G_DEF_CLASS(G_TYPE_NORMALIZE_MODE, "NormalizeMode", mGLib);
|
85
69
|
|
86
70
|
rbg_define_singleton_method(mGLib, "charset", rbglib_m_charset, 0);
|
87
71
|
|
88
72
|
RG_DEF_SMETHOD(canonical_ordering, 1);
|
89
|
-
RG_DEF_SMETHOD(canonical_decomposition, 1);
|
90
73
|
}
|
data/ext/glib2/rbglib_utils.c
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C)
|
4
|
-
* Copyright (C) 2004 Ruby-GNOME2 Project Team
|
3
|
+
* Copyright (C) 2004-2021 Ruby-GNOME Project Team
|
5
4
|
* Copyright (C) 2004 Pascal Terjan
|
6
5
|
*
|
7
6
|
* This library is free software; you can redistribute it and/or
|
@@ -71,7 +70,6 @@ rg_s_unsetenv(VALUE self, VALUE variable)
|
|
71
70
|
return self;
|
72
71
|
}
|
73
72
|
|
74
|
-
#ifdef HAVE_G_LISTENV
|
75
73
|
static VALUE
|
76
74
|
rg_s_listenv(G_GNUC_UNUSED VALUE self)
|
77
75
|
{
|
@@ -86,7 +84,6 @@ rg_s_listenv(G_GNUC_UNUSED VALUE self)
|
|
86
84
|
g_strfreev(c_list);
|
87
85
|
return r_list;
|
88
86
|
}
|
89
|
-
#endif
|
90
87
|
|
91
88
|
static VALUE
|
92
89
|
rg_s_host_name(G_GNUC_UNUSED VALUE self)
|
@@ -136,14 +133,12 @@ rg_s_system_config_dirs(G_GNUC_UNUSED VALUE self)
|
|
136
133
|
return STRV2RVAL((const gchar **)g_get_system_config_dirs());
|
137
134
|
}
|
138
135
|
|
139
|
-
#if GLIB_CHECK_VERSION(2, 14, 0)
|
140
136
|
static VALUE
|
141
137
|
rg_s_get_user_special_dir(G_GNUC_UNUSED VALUE self, VALUE directory)
|
142
138
|
{
|
143
139
|
return CSTR2RVAL(g_get_user_special_dir(RVAL2GENUM(directory,
|
144
140
|
G_TYPE_USER_DIRECTORY)));
|
145
141
|
}
|
146
|
-
#endif
|
147
142
|
|
148
143
|
static VALUE
|
149
144
|
rg_s_home_dir(G_GNUC_UNUSED VALUE self)
|
@@ -288,15 +283,11 @@ void
|
|
288
283
|
Init_glib_utils(void)
|
289
284
|
{
|
290
285
|
/* glib/gutils.h */
|
291
|
-
#if GLIB_CHECK_VERSION(2, 14, 0)
|
292
286
|
G_DEF_CLASS(G_TYPE_USER_DIRECTORY, "UserDirectory", RG_TARGET_NAMESPACE);
|
293
287
|
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_USER_DIRECTORY, "G_");
|
294
|
-
#endif
|
295
288
|
|
296
|
-
#if GLIB_CHECK_VERSION(2, 30, 0)
|
297
289
|
G_DEF_CLASS(G_TYPE_FORMAT_SIZE_FLAGS,
|
298
290
|
"FormatSizeFlags", RG_TARGET_NAMESPACE);
|
299
|
-
#endif
|
300
291
|
|
301
292
|
RG_DEF_SMETHOD(application_name, 0);
|
302
293
|
RG_DEF_SMETHOD(set_application_name, 1);
|
@@ -305,9 +296,7 @@ Init_glib_utils(void)
|
|
305
296
|
RG_DEF_SMETHOD(getenv, 1);
|
306
297
|
RG_DEF_SMETHOD(setenv, 2);
|
307
298
|
RG_DEF_SMETHOD(unsetenv, 1);
|
308
|
-
#ifdef HAVE_G_LISTENV
|
309
299
|
RG_DEF_SMETHOD(listenv, 0);
|
310
|
-
#endif
|
311
300
|
RG_DEF_SMETHOD(host_name, 0);
|
312
301
|
RG_DEF_SMETHOD(user_name, 0);
|
313
302
|
RG_DEF_SMETHOD(real_name, 0);
|
@@ -317,9 +306,7 @@ Init_glib_utils(void)
|
|
317
306
|
RG_DEF_SMETHOD(user_config_dir, 0);
|
318
307
|
RG_DEF_SMETHOD(system_data_dirs, 0);
|
319
308
|
RG_DEF_SMETHOD(system_config_dirs, 0);
|
320
|
-
#if GLIB_CHECK_VERSION(2, 14, 0)
|
321
309
|
RG_DEF_SMETHOD(get_user_special_dir, 1);
|
322
|
-
#endif
|
323
310
|
RG_DEF_SMETHOD(home_dir, 0);
|
324
311
|
RG_DEF_SMETHOD(tmp_dir, 0);
|
325
312
|
RG_DEF_SMETHOD(current_dir, 0);
|
data/ext/glib2/rbglib_win32.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011 Ruby-
|
3
|
+
* Copyright (C) 2011-2021 Ruby-GNOME Project Team
|
4
4
|
* Copyright (C) 2006 Kouhei Sutou
|
5
5
|
*
|
6
6
|
* This library is free software; you can redistribute it and/or
|
@@ -65,11 +65,10 @@ rbglib_m_win32_locale_filename_from_utf8_deprecated(VALUE self,
|
|
65
65
|
return rg_s_locale_filename_from_utf8(self, utf8_filename);
|
66
66
|
}
|
67
67
|
|
68
|
-
# if GLIB_CHECK_VERSION(2, 16, 0)
|
69
68
|
static VALUE
|
70
69
|
rg_s_get_package_installation_directory_of_module(int argc,
|
71
|
-
|
72
|
-
|
70
|
+
VALUE *argv,
|
71
|
+
VALUE self)
|
73
72
|
{
|
74
73
|
VALUE rb_module;
|
75
74
|
gchar *directory;
|
@@ -84,7 +83,6 @@ rg_s_get_package_installation_directory_of_module(int argc,
|
|
84
83
|
directory = g_win32_get_package_installation_directory_of_module(hmodule);
|
85
84
|
return CSTR2RVAL_FREE(directory);
|
86
85
|
}
|
87
|
-
# endif
|
88
86
|
#endif
|
89
87
|
|
90
88
|
void
|
@@ -105,8 +103,6 @@ Init_glib_win32(void)
|
|
105
103
|
rbg_define_singleton_method(mGLib, "win32_locale_filename_from_utf8",
|
106
104
|
rbglib_m_win32_locale_filename_from_utf8_deprecated, 1);
|
107
105
|
|
108
|
-
# if GLIB_CHECK_VERSION(2, 16, 0)
|
109
106
|
RG_DEF_SMETHOD(get_package_installation_directory_of_module, -1);
|
110
|
-
# endif
|
111
107
|
#endif
|
112
108
|
}
|
data/ext/glib2/rbgobj_binding.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2015 Ruby-
|
3
|
+
* Copyright (C) 2015-2021 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,7 +24,6 @@
|
|
24
24
|
|
25
25
|
#define _SELF(object) G_BINDING(RVAL2GOBJ(self))
|
26
26
|
|
27
|
-
#if GLIB_CHECK_VERSION(2, 38, 0)
|
28
27
|
static VALUE
|
29
28
|
rg_unbind(VALUE self)
|
30
29
|
{
|
@@ -39,18 +38,13 @@ rg_unbind(VALUE self)
|
|
39
38
|
|
40
39
|
return self;
|
41
40
|
}
|
42
|
-
#endif
|
43
41
|
|
44
42
|
void
|
45
43
|
Init_gobject_gbinding(void)
|
46
44
|
{
|
47
|
-
#if GLIB_CHECK_VERSION(2, 26, 0)
|
48
45
|
VALUE RG_TARGET_NAMESPACE;
|
49
46
|
|
50
47
|
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BINDING, "Binding", mGLib);
|
51
|
-
#endif
|
52
48
|
|
53
|
-
#if GLIB_CHECK_VERSION(2, 38, 0)
|
54
49
|
RG_DEF_METHOD(unbind, 0);
|
55
|
-
#endif
|
56
50
|
}
|
data/ext/glib2/rbgobj_closure.c
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C)
|
4
|
-
* Copyright (C) 2002-2006 Ruby-GNOME2 Project
|
3
|
+
* Copyright (C) 2002-2021 Ruby-GNOME Project Team
|
5
4
|
* Copyright (C) 2002,2003 Masahiro Sakai
|
6
5
|
*
|
7
6
|
* This library is free software; you can redistribute it and/or
|
@@ -173,7 +172,7 @@ rclosure_unref(GRClosure *rclosure)
|
|
173
172
|
g_list_free(rclosure->objects);
|
174
173
|
rclosure->objects = NULL;
|
175
174
|
if (!NIL_P(rclosure->rb_holder)) {
|
176
|
-
|
175
|
+
RTYPEDDATA_DATA(rclosure->rb_holder) = NULL;
|
177
176
|
rclosure->rb_holder = Qnil;
|
178
177
|
}
|
179
178
|
}
|
@@ -201,8 +200,10 @@ rclosure_invalidate(G_GNUC_UNUSED gpointer data, GClosure *closure)
|
|
201
200
|
}
|
202
201
|
|
203
202
|
static void
|
204
|
-
gr_closure_holder_mark(
|
203
|
+
gr_closure_holder_mark(void *data)
|
205
204
|
{
|
205
|
+
GRClosure *rclosure = data;
|
206
|
+
|
206
207
|
if (!rclosure)
|
207
208
|
return;
|
208
209
|
|
@@ -211,8 +212,10 @@ gr_closure_holder_mark(GRClosure *rclosure)
|
|
211
212
|
}
|
212
213
|
|
213
214
|
static void
|
214
|
-
gr_closure_holder_free(
|
215
|
+
gr_closure_holder_free(void *data)
|
215
216
|
{
|
217
|
+
GRClosure *rclosure = data;
|
218
|
+
|
216
219
|
if (!rclosure)
|
217
220
|
return;
|
218
221
|
|
@@ -225,6 +228,17 @@ gr_closure_holder_free(GRClosure *rclosure)
|
|
225
228
|
}
|
226
229
|
}
|
227
230
|
|
231
|
+
static const rb_data_type_t rbg_closure_holder_type = {
|
232
|
+
"GLib::ClosureHolder",
|
233
|
+
{
|
234
|
+
gr_closure_holder_mark,
|
235
|
+
gr_closure_holder_free,
|
236
|
+
},
|
237
|
+
NULL,
|
238
|
+
NULL,
|
239
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
240
|
+
};
|
241
|
+
|
228
242
|
static GClosure *
|
229
243
|
g_rclosure_new_raw(VALUE callback_proc,
|
230
244
|
VALUE extra_args,
|
@@ -241,10 +255,9 @@ g_rclosure_new_raw(VALUE callback_proc,
|
|
241
255
|
closure->objects = NULL;
|
242
256
|
closure->callback = callback_proc;
|
243
257
|
closure->extra_args = extra_args;
|
244
|
-
closure->rb_holder =
|
245
|
-
|
246
|
-
|
247
|
-
closure);
|
258
|
+
closure->rb_holder = TypedData_Wrap_Struct(rb_cObject,
|
259
|
+
&rbg_closure_holder_type,
|
260
|
+
closure);
|
248
261
|
closure->tag[0] = '\0';
|
249
262
|
|
250
263
|
g_closure_set_marshal((GClosure*)closure, &rclosure_marshal);
|
data/ext/glib2/rbgobj_object.c
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C)
|
4
|
-
* Copyright (C) 2002-2004 Ruby-GNOME Project Team
|
3
|
+
* Copyright (C) 2002-2021 Ruby-GNOME Project Team
|
5
4
|
* Copyright (C) 2002-2003 Masahiro Sakai
|
6
|
-
* Copyright (C) 1998-2000
|
7
|
-
*
|
8
|
-
*
|
5
|
+
* Copyright (C) 1998-2000 Yukihiro Matsumoto,
|
6
|
+
* Daisuke Kanda,
|
7
|
+
* Hiroshi Igarashi
|
9
8
|
*
|
10
9
|
* This library is free software; you can redistribute it and/or
|
11
10
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -365,7 +364,9 @@ static VALUE
|
|
365
364
|
gobj_new_body(VALUE rb_arg)
|
366
365
|
{
|
367
366
|
struct param_setup_arg *arg = (struct param_setup_arg *)rb_arg;
|
368
|
-
|
367
|
+
ID id_each;
|
368
|
+
CONST_ID(id_each, "each");
|
369
|
+
rb_block_call(arg->params_hash, id_each, 0, NULL, _params_setup, (VALUE)arg);
|
369
370
|
return (VALUE)g_object_newv(G_TYPE_FROM_CLASS(arg->gclass),
|
370
371
|
arg->param_size, arg->params);
|
371
372
|
}
|
@@ -496,140 +497,146 @@ gobj_s_properties(int argc, VALUE* argv, VALUE self)
|
|
496
497
|
return ary;
|
497
498
|
}
|
498
499
|
|
499
|
-
static
|
500
|
-
static
|
500
|
+
static GHashTable *rbg_type_to_prop_setter_tables;
|
501
|
+
static GMutex rbg_type_to_prop_setter_tables_mutex;
|
502
|
+
static GHashTable *rbg_type_to_prop_getter_tables;
|
503
|
+
static GMutex rbg_type_to_prop_getter_tables_mutex;
|
501
504
|
|
502
|
-
void
|
503
|
-
|
505
|
+
static void
|
506
|
+
rbg_register_property_accessor(GHashTable *tables,
|
507
|
+
GMutex *mutex,
|
508
|
+
GType gtype,
|
509
|
+
const char *name,
|
510
|
+
gpointer accessor)
|
504
511
|
{
|
505
|
-
|
506
|
-
GParamSpec* pspec;
|
512
|
+
g_mutex_lock(mutex);
|
507
513
|
|
508
|
-
|
509
|
-
if (
|
510
|
-
table =
|
511
|
-
|
514
|
+
GHashTable *table = g_hash_table_lookup(tables, GUINT_TO_POINTER(gtype));
|
515
|
+
if (!table) {
|
516
|
+
table = g_hash_table_new(g_str_hash, g_str_equal);
|
517
|
+
g_hash_table_insert(tables, GUINT_TO_POINTER(gtype), table);
|
512
518
|
}
|
513
519
|
|
514
|
-
|
515
|
-
pspec = g_object_class_find_property(
|
516
|
-
|
517
|
-
|
518
|
-
|
520
|
+
GObjectClass *gclass = g_type_class_ref(gtype);
|
521
|
+
GParamSpec *pspec = g_object_class_find_property(gclass, name);
|
522
|
+
g_hash_table_insert(table,
|
523
|
+
(gchar *)g_param_spec_get_name(pspec),
|
524
|
+
accessor);
|
525
|
+
g_type_class_unref(gclass);
|
519
526
|
|
520
|
-
|
527
|
+
g_mutex_unlock(mutex);
|
521
528
|
}
|
522
529
|
|
523
|
-
|
524
|
-
|
530
|
+
static gpointer
|
531
|
+
rbg_get_property_accessor(GHashTable *tables,
|
532
|
+
GMutex *mutex,
|
533
|
+
GType gtype,
|
534
|
+
const char *name)
|
525
535
|
{
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
if (
|
531
|
-
|
532
|
-
|
536
|
+
g_mutex_lock(mutex);
|
537
|
+
|
538
|
+
gpointer accessor = NULL;
|
539
|
+
GHashTable *table = g_hash_table_lookup(tables, GUINT_TO_POINTER(gtype));
|
540
|
+
if (table) {
|
541
|
+
GObjectClass *gclass = g_type_class_ref(gtype);
|
542
|
+
GParamSpec *pspec = g_object_class_find_property(gclass, name);
|
543
|
+
accessor = g_hash_table_lookup(table, g_param_spec_get_name(pspec));
|
544
|
+
g_type_class_unref(gclass);
|
533
545
|
}
|
534
546
|
|
535
|
-
|
536
|
-
pspec = g_object_class_find_property(oclass, name);
|
547
|
+
g_mutex_unlock(mutex);
|
537
548
|
|
538
|
-
|
539
|
-
|
549
|
+
return accessor;
|
550
|
+
}
|
540
551
|
|
541
|
-
|
552
|
+
void
|
553
|
+
rbgobj_register_property_setter(GType gtype,
|
554
|
+
const char *name,
|
555
|
+
RValueToGValueFunc func)
|
556
|
+
{
|
557
|
+
rbg_register_property_accessor(rbg_type_to_prop_setter_tables,
|
558
|
+
&rbg_type_to_prop_setter_tables_mutex,
|
559
|
+
gtype,
|
560
|
+
name,
|
561
|
+
func);
|
562
|
+
}
|
563
|
+
|
564
|
+
void
|
565
|
+
rbgobj_register_property_getter(GType gtype, const char *name, GValueToRValueFunc func)
|
566
|
+
{
|
567
|
+
rbg_register_property_accessor(rbg_type_to_prop_getter_tables,
|
568
|
+
&rbg_type_to_prop_getter_tables_mutex,
|
569
|
+
gtype,
|
570
|
+
name,
|
571
|
+
func);
|
542
572
|
}
|
543
573
|
|
544
574
|
static VALUE
|
545
575
|
rg_set_property(VALUE self, VALUE prop_name, VALUE val)
|
546
576
|
{
|
547
|
-
GParamSpec* pspec;
|
548
577
|
const char* name;
|
549
|
-
|
550
578
|
if (SYMBOL_P(prop_name))
|
551
579
|
name = rb_id2name(SYM2ID(prop_name));
|
552
580
|
else
|
553
581
|
name = StringValuePtr(prop_name);
|
554
582
|
|
555
|
-
pspec =
|
556
|
-
|
557
|
-
|
583
|
+
GParamSpec* pspec =
|
584
|
+
g_object_class_find_property(G_OBJECT_GET_CLASS(RVAL2GOBJ(self)),
|
585
|
+
name);
|
558
586
|
if (!pspec)
|
559
587
|
rb_raise(eNoPropertyError, "No such property: %s", name);
|
560
|
-
else {
|
561
|
-
// FIXME: use rb_ensure to call g_value_unset()
|
562
|
-
RValueToGValueFunc setter = NULL;
|
563
|
-
GValue gval = G_VALUE_INIT;
|
564
588
|
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
}
|
581
|
-
|
582
|
-
g_object_set_property(RVAL2GOBJ(self), name, &gval);
|
583
|
-
g_value_unset(&gval);
|
589
|
+
RValueToGValueFunc setter =
|
590
|
+
rbg_get_property_accessor(rbg_type_to_prop_setter_tables,
|
591
|
+
&rbg_type_to_prop_setter_tables_mutex,
|
592
|
+
pspec->owner_type,
|
593
|
+
name);
|
594
|
+
// FIXME: use rb_ensure to call g_value_unset()
|
595
|
+
GValue gval = G_VALUE_INIT;
|
596
|
+
g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec));
|
597
|
+
if (setter) {
|
598
|
+
setter(val, &gval);
|
599
|
+
} else {
|
600
|
+
rbgobj_rvalue_to_gvalue(val, &gval);
|
601
|
+
}
|
602
|
+
g_object_set_property(RVAL2GOBJ(self), name, &gval);
|
603
|
+
g_value_unset(&gval);
|
584
604
|
|
585
|
-
|
605
|
+
G_CHILD_SET(self, rb_intern(name), val);
|
586
606
|
|
587
|
-
|
588
|
-
}
|
607
|
+
return self;
|
589
608
|
}
|
590
609
|
|
591
610
|
static VALUE
|
592
611
|
rg_get_property(VALUE self, VALUE prop_name)
|
593
612
|
{
|
594
|
-
GParamSpec* pspec;
|
595
613
|
const char* name;
|
596
|
-
|
597
614
|
if (SYMBOL_P(prop_name))
|
598
615
|
name = rb_id2name(SYM2ID(prop_name));
|
599
616
|
else
|
600
617
|
name = StringValuePtr(prop_name);
|
601
618
|
|
602
|
-
pspec =
|
603
|
-
|
604
|
-
|
619
|
+
GParamSpec *pspec =
|
620
|
+
g_object_class_find_property(G_OBJECT_GET_CLASS(RVAL2GOBJ(self)),
|
621
|
+
name);
|
605
622
|
if (!pspec)
|
606
623
|
rb_raise(eNoPropertyError, "No such property: %s", name);
|
607
|
-
else {
|
608
|
-
// FIXME: use rb_ensure to call g_value_unset()
|
609
|
-
GValueToRValueFunc getter = NULL;
|
610
|
-
GValue gval = G_VALUE_INIT;
|
611
|
-
VALUE ret;
|
612
|
-
|
613
|
-
{
|
614
|
-
VALUE table = rb_hash_aref(type_to_prop_getter_table,
|
615
|
-
INT2FIX(pspec->owner_type));
|
616
|
-
if (!NIL_P(table)){
|
617
|
-
VALUE obj = rb_hash_aref(table, CSTR2RVAL(g_param_spec_get_name(pspec)));
|
618
|
-
if (!NIL_P(obj))
|
619
|
-
Data_Get_Struct(obj, void, getter);
|
620
|
-
}
|
621
|
-
}
|
622
|
-
|
623
|
-
g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec));
|
624
|
-
g_object_get_property(RVAL2GOBJ(self), name, &gval);
|
625
624
|
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
625
|
+
GValueToRValueFunc getter =
|
626
|
+
rbg_get_property_accessor(rbg_type_to_prop_getter_tables,
|
627
|
+
&rbg_type_to_prop_getter_tables_mutex,
|
628
|
+
pspec->owner_type,
|
629
|
+
name);
|
630
|
+
// FIXME: use rb_ensure to call g_value_unset()
|
631
|
+
GValue gval = G_VALUE_INIT;
|
632
|
+
g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec));
|
633
|
+
g_object_get_property(RVAL2GOBJ(self), name, &gval);
|
634
|
+
VALUE ret = getter ? getter(&gval) : GVAL2RVAL(&gval);
|
635
|
+
g_value_unset(&gval);
|
636
|
+
|
637
|
+
G_CHILD_SET(self, rb_intern(name), ret);
|
638
|
+
|
639
|
+
return ret;
|
633
640
|
}
|
634
641
|
|
635
642
|
static VALUE rg_thaw_notify(VALUE self);
|
@@ -714,7 +721,6 @@ rg_type_name(VALUE self)
|
|
714
721
|
return CSTR2RVAL(G_OBJECT_TYPE_NAME(RVAL2GOBJ(self)));
|
715
722
|
}
|
716
723
|
|
717
|
-
#if GLIB_CHECK_VERSION(2, 26, 0)
|
718
724
|
typedef struct {
|
719
725
|
VALUE transform_from_callback;
|
720
726
|
VALUE transform_to_callback;
|
@@ -843,7 +849,6 @@ rg_bind_property(gint argc, VALUE *argv, VALUE self)
|
|
843
849
|
|
844
850
|
return rb_binding;
|
845
851
|
}
|
846
|
-
#endif
|
847
852
|
|
848
853
|
static VALUE
|
849
854
|
rg_initialize(int argc, VALUE *argv, VALUE self)
|
@@ -1090,18 +1095,24 @@ Init_gobject_gobject(void)
|
|
1090
1095
|
RG_DEF_METHOD(inspect, 0);
|
1091
1096
|
RG_DEF_METHOD(type_name, 0);
|
1092
1097
|
|
1093
|
-
#if GLIB_CHECK_VERSION(2, 26, 0)
|
1094
1098
|
RG_DEF_METHOD(bind_property, -1);
|
1095
1099
|
G_DEF_CLASS(G_TYPE_BINDING_FLAGS, "BindingFlags", mGLib);
|
1096
|
-
#endif
|
1097
1100
|
|
1098
1101
|
eNoPropertyError = rb_define_class_under(mGLib, "NoPropertyError",
|
1099
1102
|
rb_eNameError);
|
1100
1103
|
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1104
|
+
rbg_type_to_prop_setter_tables =
|
1105
|
+
g_hash_table_new_full(g_direct_hash,
|
1106
|
+
g_direct_equal,
|
1107
|
+
NULL,
|
1108
|
+
(GDestroyNotify)g_hash_table_unref);
|
1109
|
+
g_mutex_init(&rbg_type_to_prop_setter_tables_mutex);
|
1110
|
+
rbg_type_to_prop_getter_tables =
|
1111
|
+
g_hash_table_new_full(g_direct_hash,
|
1112
|
+
g_direct_equal,
|
1113
|
+
NULL,
|
1114
|
+
(GDestroyNotify)g_hash_table_unref);
|
1115
|
+
g_mutex_init(&rbg_type_to_prop_getter_tables_mutex);
|
1105
1116
|
|
1106
1117
|
/* subclass */
|
1107
1118
|
RG_DEF_SMETHOD(type_register, -1);
|