glib2 3.5.1 → 4.0.0
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/ext/glib2/extconf.rb +4 -3
- data/ext/glib2/glib2.def +4 -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 +54 -84
- 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 +36 -18
- 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 +1 -0
- 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
@@ -125,7 +125,7 @@ void
|
|
125
125
|
Init_gobject_typeinstance(void)
|
126
126
|
{
|
127
127
|
/* should be renamed to GLib::Instance? */
|
128
|
-
RG_TARGET_NAMESPACE = rb_define_class_under(
|
128
|
+
RG_TARGET_NAMESPACE = rb_define_class_under(rbg_mGLib(), "Instantiatable", rb_cObject);
|
129
129
|
rb_extend_object(RG_TARGET_NAMESPACE, mMetaInterface);
|
130
130
|
|
131
131
|
rb_define_alloc_func(RG_TARGET_NAMESPACE, (VALUE(*)_((VALUE)))instantiatable_s_allocate);
|
@@ -107,7 +107,7 @@ rg_property(VALUE self, VALUE property_name)
|
|
107
107
|
rb_raise(rb_eTypeError, "%s isn't interface module", rb_class2name(self));
|
108
108
|
/* XXX: g_type_default_interface_ref(G_TYPE_INTERFACE) causes SEGV. */
|
109
109
|
if (gtype == G_TYPE_INTERFACE) {
|
110
|
-
rb_raise(rb_const_get(
|
110
|
+
rb_raise(rb_const_get(rbg_mGLib(), rb_intern("NoPropertyError")),
|
111
111
|
"No such property: %s", name);
|
112
112
|
}
|
113
113
|
|
@@ -115,7 +115,7 @@ rg_property(VALUE self, VALUE property_name)
|
|
115
115
|
prop = g_object_interface_find_property(ginterface, name);
|
116
116
|
if (!prop){
|
117
117
|
g_type_default_interface_unref(ginterface);
|
118
|
-
rb_raise(rb_const_get(
|
118
|
+
rb_raise(rb_const_get(rbg_mGLib(), rb_intern("NoPropertyError")),
|
119
119
|
"No such property: %s", name);
|
120
120
|
}
|
121
121
|
result = GOBJ2RVAL(prop);
|
@@ -173,7 +173,7 @@ rbgobj_init_interface(VALUE interf)
|
|
173
173
|
void
|
174
174
|
Init_gobject_typeinterface(void)
|
175
175
|
{
|
176
|
-
RG_TARGET_NAMESPACE = rb_define_module_under(
|
176
|
+
RG_TARGET_NAMESPACE = rb_define_module_under(rbg_mGLib(), "MetaInterface");
|
177
177
|
rbg_define_method(RG_TARGET_NAMESPACE, "gtype", generic_s_gtype, 0);
|
178
178
|
RG_DEF_METHOD(append_features, 1);
|
179
179
|
RG_DEF_METHOD(included, 1);
|
@@ -181,5 +181,5 @@ Init_gobject_typeinterface(void)
|
|
181
181
|
RG_DEF_METHOD(property, 1);
|
182
182
|
RG_DEF_METHOD(properties, -1);
|
183
183
|
|
184
|
-
rbgobj_mInterface = G_DEF_INTERFACE(G_TYPE_INTERFACE, "Interface",
|
184
|
+
rbgobj_mInterface = G_DEF_INTERFACE(G_TYPE_INTERFACE, "Interface", rbg_mGLib());
|
185
185
|
}
|
@@ -64,7 +64,7 @@ void g_type_module_add_interface (GTypeModule *module,
|
|
64
64
|
void
|
65
65
|
Init_gobject_gtypemodule(void)
|
66
66
|
{
|
67
|
-
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_TYPE_MODULE, "TypeModule",
|
67
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_TYPE_MODULE, "TypeModule", rbg_mGLib());
|
68
68
|
RG_DEF_METHOD(use, 0);
|
69
69
|
RG_DEF_METHOD(unuse, 0);
|
70
70
|
RG_DEF_METHOD(name, 0);
|
@@ -51,7 +51,7 @@ void g_type_plugin_complete_interface_info (GTypePlugin *plugin,
|
|
51
51
|
void
|
52
52
|
Init_gobject_gtypeplugin(void)
|
53
53
|
{
|
54
|
-
VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_TYPE_PLUGIN, "TypePlugin",
|
54
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_TYPE_PLUGIN, "TypePlugin", rbg_mGLib());
|
55
55
|
RG_DEF_METHOD(use, 0);
|
56
56
|
RG_DEF_METHOD(unuse, 0);
|
57
57
|
}
|
data/ext/glib2/rbgobj_value.c
CHANGED
@@ -422,7 +422,7 @@ Init_gobject_gvalue(void)
|
|
422
422
|
qRValueToGValueFunc = g_quark_from_static_string("__ruby_r2g_func__");
|
423
423
|
qGValueToRValueFunc = g_quark_from_static_string("__ruby_g2r_func__");
|
424
424
|
|
425
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_VALUE, "Value",
|
425
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_VALUE, "Value", rbg_mGLib());
|
426
426
|
RG_DEF_METHOD(initialize, -1);
|
427
427
|
RG_DEF_METHOD(type, 0);
|
428
428
|
RG_DEF_METHOD(value, 0);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011-
|
3
|
+
* Copyright (C) 2011-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
|
@@ -22,11 +22,21 @@
|
|
22
22
|
#include "rbgprivate.h"
|
23
23
|
#include "rbgobject.h"
|
24
24
|
|
25
|
+
static const rb_data_type_t rbg_pointer_type = {
|
26
|
+
"GLib::Poitner",
|
27
|
+
{
|
28
|
+
NULL,
|
29
|
+
NULL,
|
30
|
+
},
|
31
|
+
NULL,
|
32
|
+
NULL,
|
33
|
+
RUBY_TYPED_FREE_IMMEDIATELY,
|
34
|
+
};
|
25
35
|
|
26
36
|
VALUE
|
27
37
|
rbgobj_ptr_new(GType type, gpointer ptr)
|
28
38
|
{
|
29
|
-
return
|
39
|
+
return TypedData_Wrap_Struct(GTYPE2CLASS(type), &rbg_pointer_type, ptr);
|
30
40
|
}
|
31
41
|
|
32
42
|
gpointer
|
@@ -34,7 +44,7 @@ rbgobj_ptr2cptr(VALUE ptr)
|
|
34
44
|
{
|
35
45
|
gpointer dest;
|
36
46
|
if (rb_obj_is_kind_of(ptr, GTYPE2CLASS(G_TYPE_POINTER))){
|
37
|
-
|
47
|
+
TypedData_Get_Struct(ptr, void, &rbg_pointer_type, dest);
|
38
48
|
} else if (rb_obj_is_kind_of(ptr, rb_cObject)){
|
39
49
|
dest = (gpointer)ptr;
|
40
50
|
} else{
|
@@ -58,7 +68,7 @@ ptr_gtype(VALUE self)
|
|
58
68
|
static void
|
59
69
|
Init_gtype_pointer(void)
|
60
70
|
{
|
61
|
-
VALUE cPtr = G_DEF_CLASS(G_TYPE_POINTER, "Pointer",
|
71
|
+
VALUE cPtr = G_DEF_CLASS(G_TYPE_POINTER, "Pointer", rbg_mGLib());
|
62
72
|
rbg_define_singleton_method(cPtr, "gtype", ptr_s_gtype, 1);
|
63
73
|
rbg_define_method(cPtr, "gtype", ptr_gtype, 1);
|
64
74
|
}
|
data/ext/glib2/rbgobject.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2003-
|
3
|
+
* Copyright (C) 2003-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,
|
@@ -179,12 +179,7 @@ rbgobj_ruby_object_from_instance_with_unref(gpointer instance)
|
|
179
179
|
void
|
180
180
|
rbgobj_add_relative(VALUE obj, VALUE relative)
|
181
181
|
{
|
182
|
-
|
183
|
-
if (NIL_P(mGLibObject)) {
|
184
|
-
mGLibObject = rb_const_get(mGLib, rb_intern("Object"));
|
185
|
-
}
|
186
|
-
|
187
|
-
if (rb_obj_is_kind_of(obj, mGLibObject)) {
|
182
|
+
if (rb_obj_is_kind_of(obj, rbg_cGLibObject())) {
|
188
183
|
rbgobj_object_add_relative(obj, relative);
|
189
184
|
} else {
|
190
185
|
VALUE rb_gc_marker = Qnil;
|
@@ -212,13 +207,8 @@ rbgobj_invalidate_relatives(VALUE obj)
|
|
212
207
|
void
|
213
208
|
rbgobj_add_relative_removable(VALUE obj, VALUE relative, ID obj_ivar_id, VALUE hash_key)
|
214
209
|
{
|
215
|
-
static VALUE cGLibObject = Qnil;
|
216
|
-
if (NIL_P(cGLibObject)) {
|
217
|
-
cGLibObject = rb_const_get(mGLib, rb_intern("Object"));
|
218
|
-
}
|
219
|
-
|
220
210
|
if (obj_ivar_id == rbgobj_id_children &&
|
221
|
-
rb_obj_is_kind_of(obj,
|
211
|
+
rb_obj_is_kind_of(obj, rbg_cGLibObject())) {
|
222
212
|
rbgobj_object_add_relative(obj, hash_key);
|
223
213
|
} else {
|
224
214
|
VALUE hash = Qnil;
|
@@ -251,17 +241,12 @@ rbgobj_get_relative_removable(VALUE obj, ID obj_ivar_id, VALUE hash_key)
|
|
251
241
|
void
|
252
242
|
rbgobj_remove_relative(VALUE obj, ID obj_ivar_id, VALUE relative)
|
253
243
|
{
|
254
|
-
static VALUE cGLibObject = Qnil;
|
255
|
-
if (NIL_P(cGLibObject)) {
|
256
|
-
cGLibObject = rb_const_get(mGLib, rb_intern("Object"));
|
257
|
-
}
|
258
|
-
|
259
244
|
if (obj_ivar_id == (ID)0) {
|
260
245
|
obj_ivar_id = id_relatives;
|
261
246
|
}
|
262
247
|
|
263
248
|
if ((obj_ivar_id == id_relatives || obj_ivar_id == rbgobj_id_children) &&
|
264
|
-
rb_obj_is_kind_of(obj,
|
249
|
+
rb_obj_is_kind_of(obj, rbg_cGLibObject())) {
|
265
250
|
rbgobj_object_remove_relative(obj, relative);
|
266
251
|
} else {
|
267
252
|
VALUE rb_gc_marker = Qnil;
|
@@ -343,7 +328,7 @@ rbgobj_define_property_accessors(VALUE klass)
|
|
343
328
|
|
344
329
|
if (pspec->flags & G_PARAM_READABLE){
|
345
330
|
g_string_append_printf(
|
346
|
-
source,
|
331
|
+
source,
|
347
332
|
"def %s%s; get_property('%s'); end\n",
|
348
333
|
prop_name,
|
349
334
|
(G_PARAM_SPEC_VALUE_TYPE(pspec) == G_TYPE_BOOLEAN) ? "?" : "",
|
@@ -361,11 +346,12 @@ rbgobj_define_property_accessors(VALUE klass)
|
|
361
346
|
g_free(buf);
|
362
347
|
}
|
363
348
|
|
364
|
-
if (source->len > 0)
|
349
|
+
if (source->len > 0) {
|
365
350
|
rb_funcall(klass, id_module_eval, 3,
|
366
351
|
rb_str_new2(source->str),
|
367
352
|
rb_str_new2(__FILE__),
|
368
353
|
INT2NUM(__LINE__));
|
354
|
+
}
|
369
355
|
g_string_free(source, TRUE);
|
370
356
|
}
|
371
357
|
|
data/ext/glib2/rbgobject.h
CHANGED
@@ -237,6 +237,7 @@ extern GClosure* g_rclosure_new_call(VALUE callback_proc,
|
|
237
237
|
VALUE extra_args,
|
238
238
|
RGClosureCallFunc func);
|
239
239
|
extern void g_rclosure_attach(GClosure *closure, VALUE object);
|
240
|
+
extern void g_rclosure_attach_gobject(GClosure *closure, VALUE object);
|
240
241
|
extern void g_rclosure_set_tag(GClosure *closure, const gchar *tag);
|
241
242
|
|
242
243
|
/* rbgobj_value.c */
|
data/ext/glib2/rbgprivate.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2007-
|
3
|
+
* Copyright (C) 2007-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
|
@@ -22,12 +22,15 @@
|
|
22
22
|
|
23
23
|
/*
|
24
24
|
* CentOS 7: GLib 2.50
|
25
|
-
*
|
26
|
-
*
|
25
|
+
* AlmaLinux 8: GLib 2.56
|
26
|
+
* AlmaLinux 9: GLib 2.68
|
27
27
|
* Ubuntu 18.04: GLib 2.56
|
28
28
|
* Ubuntu 20.04: GLib 2.64
|
29
|
+
* Ubuntu 22.04: GLib 2.72
|
29
30
|
*/
|
30
|
-
#define GLIB_VERSION_MIN_REQUIRED
|
31
|
+
#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_50
|
32
|
+
|
33
|
+
#define G_LOG_DOMAIN "Ruby/GLib2"
|
31
34
|
|
32
35
|
#include "rbgobject.h"
|
33
36
|
|
data/ext/glib2/rbgutil.c
CHANGED
@@ -46,6 +46,25 @@ rbg_define_method(VALUE klass, const char *name, VALUE (*func)(ANYARGS), int arg
|
|
46
46
|
INT2NUM(__LINE__));
|
47
47
|
}
|
48
48
|
|
49
|
+
void
|
50
|
+
rbg_define_private_method(VALUE klass,
|
51
|
+
const char *name,
|
52
|
+
VALUE (*func)(ANYARGS),
|
53
|
+
int argc)
|
54
|
+
{
|
55
|
+
rb_define_private_method(klass, name, func, argc);
|
56
|
+
if ((argc != 1) || strncmp(name, "set_", 4))
|
57
|
+
return;
|
58
|
+
|
59
|
+
name += 4;
|
60
|
+
rb_funcall(klass, rbgutil_id_module_eval, 3,
|
61
|
+
CSTR2RVAL_FREE(g_strdup_printf("def %s=(val); set_%s(val); val; end\n"
|
62
|
+
"private :%s=\n",
|
63
|
+
name, name, name)),
|
64
|
+
rb_str_new2(__FILE__),
|
65
|
+
INT2NUM(__LINE__));
|
66
|
+
}
|
67
|
+
|
49
68
|
void
|
50
69
|
rbg_define_singleton_method(VALUE obj, const char *name, VALUE (*func)(ANYARGS), int argc)
|
51
70
|
{
|
@@ -84,7 +103,7 @@ rbgutil_set_properties(VALUE self, VALUE hash)
|
|
84
103
|
VALUE
|
85
104
|
rbgutil_def_setters(VALUE klass)
|
86
105
|
{
|
87
|
-
return rb_funcall(
|
106
|
+
return rb_funcall(rbg_mGLib(), id_add_one_arg_setter, 1, klass);
|
88
107
|
}
|
89
108
|
|
90
109
|
void
|
data/ext/glib2/rbgutil.h
CHANGED
@@ -55,6 +55,8 @@ G_BEGIN_DECLS
|
|
55
55
|
#define RG_DEF_ATTR(attr, read, write, ex) \
|
56
56
|
rb_attr(RG_TARGET_NAMESPACE, rb_intern(attr), read, write, ex)
|
57
57
|
#define RG_DEF_ALIAS(new, old) rb_define_alias(RG_TARGET_NAMESPACE, new, old)
|
58
|
+
#define RG_DEF_PRIVATE_METHOD(method, argc) \
|
59
|
+
rbg_define_private_method(RG_TARGET_NAMESPACE, #method, rg_ ## method, argc)
|
58
60
|
|
59
61
|
#define RG_REG_GLIBID_SETTER(name) \
|
60
62
|
rbgobj_register_property_setter(CLASS2GTYPE(RG_TARGET_NAMESPACE), name, rbgutil_glibid_r2g_func)
|
@@ -88,6 +90,7 @@ G_BEGIN_DECLS
|
|
88
90
|
(rbgutil_string_set_utf8_encoding(string))
|
89
91
|
|
90
92
|
extern void rbg_define_method(VALUE klass, const char *name, VALUE (*func)(ANYARGS), int argc);
|
93
|
+
extern void rbg_define_private_method(VALUE klass, const char *name, VALUE (*func)(ANYARGS), int argc);
|
91
94
|
extern void rbg_define_singleton_method(VALUE obj, const char *name, VALUE (*func)(ANYARGS), int argc);
|
92
95
|
extern VALUE rbgutil_def_setters(VALUE klass);
|
93
96
|
extern void rbgutil_set_properties(VALUE self, VALUE hash);
|
@@ -56,7 +56,7 @@ rbgutil_protect(VALUE (*func) (VALUE), VALUE data)
|
|
56
56
|
void
|
57
57
|
rbgutil_on_callback_error(VALUE error)
|
58
58
|
{
|
59
|
-
rb_funcall(
|
59
|
+
rb_funcall(rbg_mGLib(), id_exit_application, 2, error, INT2NUM(EXIT_FAILURE));
|
60
60
|
}
|
61
61
|
|
62
62
|
/**********************************************************************/
|
@@ -228,13 +228,13 @@ rbgutil_start_callback_dispatch_thread(void)
|
|
228
228
|
VALUE callback_dispatch_thread;
|
229
229
|
|
230
230
|
g_mutex_lock(&callback_dispatch_thread_mutex);
|
231
|
-
callback_dispatch_thread = rb_ivar_get(
|
231
|
+
callback_dispatch_thread = rb_ivar_get(rbg_mGLib(), id_callback_dispatch_thread);
|
232
232
|
if (NIL_P(callback_dispatch_thread)) {
|
233
233
|
if (pipe(callback_pipe_fds) == -1)
|
234
234
|
rb_sys_fail("pipe()");
|
235
235
|
|
236
236
|
callback_dispatch_thread = rb_thread_create(mainloop, NULL);
|
237
|
-
rb_ivar_set(
|
237
|
+
rb_ivar_set(rbg_mGLib(), id_callback_dispatch_thread,
|
238
238
|
callback_dispatch_thread);
|
239
239
|
}
|
240
240
|
g_mutex_unlock(&callback_dispatch_thread_mutex);
|
@@ -248,10 +248,10 @@ rbgutil_stop_callback_dispatch_thread(void)
|
|
248
248
|
VALUE callback_dispatch_thread;
|
249
249
|
|
250
250
|
g_mutex_lock(&callback_dispatch_thread_mutex);
|
251
|
-
callback_dispatch_thread = rb_ivar_get(
|
251
|
+
callback_dispatch_thread = rb_ivar_get(rbg_mGLib(), id_callback_dispatch_thread);
|
252
252
|
if (!NIL_P(callback_dispatch_thread)) {
|
253
253
|
queue_callback_request(NULL);
|
254
|
-
rb_ivar_set(
|
254
|
+
rb_ivar_set(rbg_mGLib(), id_callback_dispatch_thread, Qnil);
|
255
255
|
}
|
256
256
|
g_mutex_unlock(&callback_dispatch_thread_mutex);
|
257
257
|
#endif
|
@@ -262,12 +262,12 @@ Init_gutil_callback(void)
|
|
262
262
|
{
|
263
263
|
id_exit_application = rb_intern("exit_application");
|
264
264
|
rbgutil_eGLibCallbackNotInitializedError =
|
265
|
-
rb_define_class_under(
|
265
|
+
rb_define_class_under(rbg_mGLib(), "CallbackNotInitializedError",
|
266
266
|
rb_eRuntimeError);
|
267
267
|
|
268
268
|
#ifdef HAVE_NATIVETHREAD
|
269
269
|
id_callback_dispatch_thread = rb_intern("callback_dispatch_thread");
|
270
|
-
rb_ivar_set(
|
270
|
+
rb_ivar_set(rbg_mGLib(), id_callback_dispatch_thread, Qnil);
|
271
271
|
|
272
272
|
callback_request_queue = g_async_queue_new();
|
273
273
|
g_mutex_init(&callback_dispatch_thread_mutex);
|
@@ -0,0 +1,35 @@
|
|
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
|
+
module GLib
|
18
|
+
class DateTime
|
19
|
+
class << self
|
20
|
+
def try_convert(value)
|
21
|
+
case value
|
22
|
+
when ::Time
|
23
|
+
new(year: value.year,
|
24
|
+
month: value.month,
|
25
|
+
day: value.day,
|
26
|
+
hour: value.hour,
|
27
|
+
minute: value.min,
|
28
|
+
second: value.sec + (value.nsec / 1_000_000_000.0))
|
29
|
+
else
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,25 @@
|
|
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
|
+
module GLib
|
18
|
+
class Variant
|
19
|
+
def inspect
|
20
|
+
super.gsub(/>\z/) do
|
21
|
+
" type=#{type} value=#{value.inspect}>"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/glib2.rb
CHANGED
@@ -335,8 +335,13 @@ GLib::Log.set_log_domain(GLib::Thread::LOG_DOMAIN)
|
|
335
335
|
GLib::Log.set_log_domain(GLib::Module::LOG_DOMAIN)
|
336
336
|
|
337
337
|
require "glib2/version"
|
338
|
-
|
338
|
+
|
339
339
|
require "glib2/deprecated"
|
340
|
+
|
341
|
+
require "glib2/date-time"
|
342
|
+
require "glib2/regex"
|
343
|
+
require "glib2/variant"
|
344
|
+
|
340
345
|
=begin
|
341
346
|
Don't we need this?
|
342
347
|
ObjectSpace.define_finalizer(GLib) {
|
data/lib/mkmf-gnome.rb
CHANGED
@@ -191,12 +191,12 @@ end
|
|
191
191
|
|
192
192
|
def add_depend_package_path(target_name, target_source_dir, target_build_dir)
|
193
193
|
if File.exist?(target_source_dir)
|
194
|
-
$INCFLAGS = "-I#{target_source_dir} #{$INCFLAGS}"
|
194
|
+
$INCFLAGS = "-I#{target_source_dir}".quote + " #{$INCFLAGS}"
|
195
195
|
end
|
196
196
|
|
197
197
|
return unless File.exist?(target_build_dir)
|
198
198
|
if target_source_dir != target_build_dir
|
199
|
-
$INCFLAGS = "-I#{target_build_dir} #{$INCFLAGS}"
|
199
|
+
$INCFLAGS = "-I#{target_build_dir}".quote + " #{$INCFLAGS}"
|
200
200
|
end
|
201
201
|
|
202
202
|
library_base_name = File.basename(target_source_dir).gsub(/-/, "_")
|
data/test/test-date-time.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2016-
|
1
|
+
# Copyright (C) 2016-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
|
@@ -24,7 +24,6 @@ class TestDateTime < Test::Unit::TestCase
|
|
24
24
|
end
|
25
25
|
|
26
26
|
sub_test_case "new" do
|
27
|
-
|
28
27
|
test "unix: :local" do
|
29
28
|
time = Time.now
|
30
29
|
format = "%Y-%m-%d-%H-%M"
|
@@ -111,4 +110,17 @@ class TestDateTime < Test::Unit::TestCase
|
|
111
110
|
assert_equal(time.sec, datetime.second)
|
112
111
|
end
|
113
112
|
end
|
113
|
+
|
114
|
+
def test_format_iso8601
|
115
|
+
only_glib_version(2, 66, 0)
|
116
|
+
datetime = GLib::DateTime.new(year: 2022,
|
117
|
+
month: 7,
|
118
|
+
day: 18,
|
119
|
+
hour: 23,
|
120
|
+
minute: 24,
|
121
|
+
second: 4.9,
|
122
|
+
timezone: GLib::TimeZone.utc)
|
123
|
+
assert_equal("2022-07-18T23:24:04.900000Z",
|
124
|
+
datetime.format_iso8601)
|
125
|
+
end
|
114
126
|
end
|
data/test/test-glib2.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# coding: ascii-8bit
|
2
2
|
#
|
3
|
-
# Copyright (C) 2015-
|
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
|
@@ -130,17 +130,19 @@ class TestGLib < Test::Unit::TestCase
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def test_signal_handler_disconnect_and_gc
|
133
|
-
|
133
|
+
object = GLib::Object.new
|
134
134
|
klass = Class.new
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
135
|
+
n_tries = 100
|
136
|
+
n_tries.times {
|
137
|
+
garbage_collected_object = klass.new
|
138
|
+
id = object.signal_connect("notify") { p garbage_collected_object }
|
139
|
+
object.signal_handler_disconnect(id)
|
139
140
|
}
|
140
141
|
GC.start
|
141
|
-
|
142
|
-
|
143
|
-
|
142
|
+
n_alive_objects = ObjectSpace.each_object(klass) {}
|
143
|
+
assert do
|
144
|
+
n_alive_objects < n_tries
|
145
|
+
end
|
144
146
|
end
|
145
147
|
|
146
148
|
def test_gtype
|
@@ -150,4 +152,14 @@ class TestGLib < Test::Unit::TestCase
|
|
150
152
|
obj = GLib::Object.new
|
151
153
|
assert_equal(obj.gtype, GLib::Object.gtype)
|
152
154
|
end
|
155
|
+
|
156
|
+
def test_malloc
|
157
|
+
address = GLib.malloc(29)
|
158
|
+
GLib.free(address)
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_malloc0
|
162
|
+
address = GLib.malloc0(29)
|
163
|
+
GLib.free(address)
|
164
|
+
end
|
153
165
|
end
|
data/test/test-variant.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2018 Ruby-
|
1
|
+
# Copyright (C) 2018-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,6 +17,31 @@
|
|
17
17
|
class TestGLibVariant < Test::Unit::TestCase
|
18
18
|
include GLibTestUtils
|
19
19
|
|
20
|
+
sub_test_case ".parse" do
|
21
|
+
test "no type" do
|
22
|
+
variant = GLib::Variant.parse("'hello'")
|
23
|
+
assert_equal([GLib::VariantType::STRING, "hello"],
|
24
|
+
[variant.type, variant.value])
|
25
|
+
end
|
26
|
+
|
27
|
+
test "type" do
|
28
|
+
variant = GLib::Variant.parse("29", "y")
|
29
|
+
assert_equal([GLib::VariantType::BYTE, 29],
|
30
|
+
[variant.type, variant.value])
|
31
|
+
end
|
32
|
+
|
33
|
+
test "garbage" do
|
34
|
+
message = <<-MESSAGE
|
35
|
+
expected end of input:
|
36
|
+
29 hello
|
37
|
+
^
|
38
|
+
MESSAGE
|
39
|
+
assert_raise(GLib::VariantParseError::InputNotAtEnd.new(message)) do
|
40
|
+
GLib::Variant.parse("29 hello", "y")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
20
45
|
sub_test_case "#initialize" do
|
21
46
|
test "type: string" do
|
22
47
|
variant = GLib::Variant.new("hello", "s")
|
@@ -24,4 +49,22 @@ class TestGLibVariant < Test::Unit::TestCase
|
|
24
49
|
[variant.type, variant.value])
|
25
50
|
end
|
26
51
|
end
|
52
|
+
|
53
|
+
sub_test_case "#to_s" do
|
54
|
+
test "default" do
|
55
|
+
variant = GLib::Variant.new(29, "y")
|
56
|
+
assert_equal("0x1d", variant.to_s)
|
57
|
+
end
|
58
|
+
|
59
|
+
test "type_annotate:" do
|
60
|
+
variant = GLib::Variant.new(29, "y")
|
61
|
+
assert_equal("byte 0x1d", variant.to_s(type_annotate: true))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
test "#inspect" do
|
66
|
+
variant = GLib::Variant.new(29, "y")
|
67
|
+
assert_equal("#<GLib::Variant:0x00 type=y value=29>",
|
68
|
+
variant.inspect.gsub(/0x\h+/, "0x00"))
|
69
|
+
end
|
27
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glib2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
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: 2022-01
|
11
|
+
date: 2022-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pkg-config
|
@@ -65,8 +65,6 @@ files:
|
|
65
65
|
- Rakefile
|
66
66
|
- ext/glib2/depend
|
67
67
|
- ext/glib2/extconf.rb
|
68
|
-
- ext/glib2/glib-enum-types.c
|
69
|
-
- ext/glib2/glib-enum-types.h
|
70
68
|
- ext/glib2/glib2.def
|
71
69
|
- ext/glib2/rbgcompat.h
|
72
70
|
- ext/glib2/rbglib-bytes.c
|
@@ -145,9 +143,11 @@ files:
|
|
145
143
|
- glib2.gemspec
|
146
144
|
- lib/glib-mkenums.rb
|
147
145
|
- lib/glib2.rb
|
146
|
+
- lib/glib2/date-time.rb
|
148
147
|
- lib/glib2/deprecatable.rb
|
149
148
|
- lib/glib2/deprecated.rb
|
150
149
|
- lib/glib2/regex.rb
|
150
|
+
- lib/glib2/variant.rb
|
151
151
|
- lib/glib2/version.rb
|
152
152
|
- lib/gnome2-raketask.rb
|
153
153
|
- lib/gnome2/rake/external-package.rb
|
@@ -207,7 +207,7 @@ licenses:
|
|
207
207
|
- LGPL-2.1+
|
208
208
|
metadata:
|
209
209
|
msys2_mingw_dependencies: glib2
|
210
|
-
post_install_message:
|
210
|
+
post_install_message:
|
211
211
|
rdoc_options: []
|
212
212
|
require_paths:
|
213
213
|
- lib
|
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
223
|
version: '0'
|
224
224
|
requirements: []
|
225
225
|
rubygems_version: 3.4.0.dev
|
226
|
-
signing_key:
|
226
|
+
signing_key:
|
227
227
|
specification_version: 4
|
228
228
|
summary: Ruby/GLib2 is a Ruby binding of GLib-2.x.
|
229
229
|
test_files: []
|