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/rbgobj_signal.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
|
@@ -23,6 +23,7 @@
|
|
23
23
|
|
24
24
|
#define RG_TARGET_NAMESPACE cSignal
|
25
25
|
|
26
|
+
static ID id_connected_closures;
|
26
27
|
static VALUE RG_TARGET_NAMESPACE;
|
27
28
|
VALUE rbgobj_signal_wrap(guint sig_id);
|
28
29
|
|
@@ -39,20 +40,28 @@ static const rb_data_type_t rg_glib_signal_type = {
|
|
39
40
|
RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
|
40
41
|
};
|
41
42
|
|
42
|
-
VALUE
|
43
|
-
|
43
|
+
static VALUE
|
44
|
+
rbgobj_signal_alloc_func(VALUE klass)
|
44
45
|
{
|
45
|
-
VALUE rb_query;
|
46
46
|
GSignalQuery *query;
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
query);
|
52
|
-
g_signal_query(id, query);
|
47
|
+
VALUE rb_query = TypedData_Make_Struct(RG_TARGET_NAMESPACE,
|
48
|
+
GSignalQuery,
|
49
|
+
&rg_glib_signal_type,
|
50
|
+
query);
|
53
51
|
return rb_query;
|
54
52
|
}
|
55
53
|
|
54
|
+
VALUE
|
55
|
+
rbgobj_signal_new(guint id)
|
56
|
+
{
|
57
|
+
ID id_new;
|
58
|
+
CONST_ID(id_new, "new");
|
59
|
+
return rb_funcall(RG_TARGET_NAMESPACE,
|
60
|
+
id_new,
|
61
|
+
1,
|
62
|
+
UINT2NUM(id));
|
63
|
+
}
|
64
|
+
|
56
65
|
static GSignalQuery *
|
57
66
|
rbgobj_signal_get_raw(VALUE rb_signal)
|
58
67
|
{
|
@@ -398,17 +407,28 @@ gobj_sig_connect_impl(gboolean after, int argc, VALUE *argv, VALUE self)
|
|
398
407
|
rbgobj_get_signal_func(signal_id));
|
399
408
|
}
|
400
409
|
}
|
401
|
-
|
410
|
+
g_rclosure_attach_gobject(rclosure, self);
|
402
411
|
g_object = RVAL2GOBJ(self);
|
403
412
|
tag = g_strdup_printf("%s::%s",
|
404
413
|
G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(g_object)),
|
405
414
|
sig_name);
|
406
|
-
g_rclosure_set_tag(
|
415
|
+
g_rclosure_set_tag(rclosure, tag);
|
407
416
|
g_free(tag);
|
408
417
|
handler_id = g_signal_connect_closure_by_id(g_object, signal_id, detail,
|
409
418
|
rclosure, after);
|
419
|
+
VALUE rb_handler_id = ULONG2NUM(handler_id);
|
420
|
+
if (handler_id != 0) {
|
421
|
+
VALUE rb_connected_closures = rb_ivar_get(self, id_connected_closures);
|
422
|
+
if (NIL_P(rb_connected_closures)) {
|
423
|
+
rb_connected_closures = rb_hash_new();
|
424
|
+
rb_ivar_set(self, id_connected_closures, rb_connected_closures);
|
425
|
+
}
|
426
|
+
rb_hash_aset(rb_connected_closures,
|
427
|
+
rb_handler_id,
|
428
|
+
POINTER2NUM(rclosure));
|
429
|
+
}
|
410
430
|
|
411
|
-
return
|
431
|
+
return rb_handler_id;
|
412
432
|
}
|
413
433
|
|
414
434
|
static VALUE
|
@@ -595,6 +615,19 @@ static VALUE
|
|
595
615
|
gobj_sig_handler_disconnect(VALUE self, VALUE id)
|
596
616
|
{
|
597
617
|
g_signal_handler_disconnect(RVAL2GOBJ(self), NUM2ULONG(id));
|
618
|
+
VALUE rb_connected_closures = rb_ivar_get(self, id_connected_closures);
|
619
|
+
if (NIL_P(rb_connected_closures)) {
|
620
|
+
return self;
|
621
|
+
}
|
622
|
+
VALUE rb_rclosure_pointer = rb_hash_aref(rb_connected_closures, id);
|
623
|
+
if (NIL_P(rb_rclosure_pointer)) {
|
624
|
+
return self;
|
625
|
+
}
|
626
|
+
GClosure *rclosure = NUM2POINTER(rb_rclosure_pointer);
|
627
|
+
if (!rclosure) {
|
628
|
+
return self;
|
629
|
+
}
|
630
|
+
g_rclosure_detach_gobject(rclosure, self);
|
598
631
|
return self;
|
599
632
|
}
|
600
633
|
|
@@ -725,7 +758,7 @@ gobj_s_signal_handler_attach(VALUE klass,
|
|
725
758
|
Qnil,
|
726
759
|
rbgobj_get_signal_func(signal_id));
|
727
760
|
g_rclosure_set_tag(rclosure, handler_name);
|
728
|
-
g_rclosure_attach(
|
761
|
+
g_rclosure_attach(rclosure, klass);
|
729
762
|
g_signal_override_class_closure(signal_id, cinfo->gtype, rclosure);
|
730
763
|
|
731
764
|
{
|
@@ -745,6 +778,13 @@ rbgobj_signal_wrap(guint sig_id)
|
|
745
778
|
return rbgobj_signal_new(sig_id);
|
746
779
|
}
|
747
780
|
|
781
|
+
static VALUE
|
782
|
+
rg_initialize(VALUE self, VALUE id)
|
783
|
+
{
|
784
|
+
g_signal_query(NUM2UINT(id), rbgobj_signal_get_raw(self));
|
785
|
+
return RUBY_Qnil;
|
786
|
+
}
|
787
|
+
|
748
788
|
static VALUE
|
749
789
|
rg_id(VALUE self)
|
750
790
|
{
|
@@ -955,10 +995,14 @@ rbgobj_define_action_methods(VALUE klass)
|
|
955
995
|
void
|
956
996
|
Init_gobject_gsignal(void)
|
957
997
|
{
|
998
|
+
id_connected_closures = rb_intern("connected_closures");
|
999
|
+
|
958
1000
|
VALUE cSignalFlags, cSignalMatchType;
|
959
1001
|
|
960
|
-
RG_TARGET_NAMESPACE = rb_define_class_under(
|
1002
|
+
RG_TARGET_NAMESPACE = rb_define_class_under(rbg_mGLib(), "Signal", rb_cObject);
|
1003
|
+
rb_define_alloc_func(RG_TARGET_NAMESPACE, rbgobj_signal_alloc_func);
|
961
1004
|
|
1005
|
+
RG_DEF_METHOD(initialize, 1);
|
962
1006
|
RG_DEF_METHOD(id, 0);
|
963
1007
|
RG_DEF_METHOD(name, 0);
|
964
1008
|
RG_DEF_METHOD(flags, 0);
|
@@ -972,7 +1016,7 @@ Init_gobject_gsignal(void)
|
|
972
1016
|
RG_DEF_METHOD(remove_emission_hook, 1);
|
973
1017
|
|
974
1018
|
/* GSignalFlags */
|
975
|
-
cSignalFlags = G_DEF_CLASS(G_TYPE_SIGNAL_FLAGS, "SignalFlags",
|
1019
|
+
cSignalFlags = G_DEF_CLASS(G_TYPE_SIGNAL_FLAGS, "SignalFlags", rbg_mGLib());
|
976
1020
|
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_SIGNAL_FLAGS, "G_SIGNAL_");
|
977
1021
|
rb_define_const(cSignalFlags, "MASK", INT2NUM(G_SIGNAL_FLAGS_MASK));
|
978
1022
|
rb_define_const(RG_TARGET_NAMESPACE, "FLAGS_MASK", INT2NUM(G_SIGNAL_FLAGS_MASK));
|
@@ -986,19 +1030,19 @@ Init_gobject_gsignal(void)
|
|
986
1030
|
rbg_define_method(RG_TARGET_NAMESPACE, "no_hooks?", query_is_G_SIGNAL_NO_HOOKS, 0);
|
987
1031
|
|
988
1032
|
/* GConnectFlags */
|
989
|
-
G_DEF_CLASS(G_TYPE_CONNECT_FLAGS, "ConnectFlags",
|
1033
|
+
G_DEF_CLASS(G_TYPE_CONNECT_FLAGS, "ConnectFlags", rbg_mGLib());
|
990
1034
|
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_CONNECT_FLAGS, "G_");
|
991
1035
|
|
992
1036
|
/* GSignalMatchType */
|
993
1037
|
cSignalMatchType = G_DEF_CLASS(G_TYPE_SIGNAL_MATCH_TYPE,
|
994
|
-
"SignalMatchType",
|
1038
|
+
"SignalMatchType", rbg_mGLib());
|
995
1039
|
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_SIGNAL_MATCH_TYPE, "G_SIGNAL_");
|
996
1040
|
rb_define_const(cSignalMatchType, "MASK", INT2NUM(G_SIGNAL_MATCH_MASK));
|
997
1041
|
rb_define_const(RG_TARGET_NAMESPACE, "MATCH_MASK", INT2NUM(G_SIGNAL_MATCH_MASK));
|
998
1042
|
|
999
1043
|
rb_define_const(RG_TARGET_NAMESPACE, "TYPE_STATIC_SCOPE", INT2FIX(G_SIGNAL_TYPE_STATIC_SCOPE));
|
1000
1044
|
|
1001
|
-
eNoSignalError = rb_define_class_under(
|
1045
|
+
eNoSignalError = rb_define_class_under(rbg_mGLib(), "NoSignalError", rb_eNameError);
|
1002
1046
|
|
1003
1047
|
rbg_signal_func_table = g_hash_table_new(g_direct_hash, g_direct_equal);
|
1004
1048
|
g_mutex_init(&rbg_signal_func_table_mutex);
|
data/ext/glib2/rbgobj_type.c
CHANGED
@@ -993,12 +993,12 @@ Init_gobject_gtype(void)
|
|
993
993
|
id_lock = rb_intern("lock");
|
994
994
|
id_unlock = rb_intern("unlock");
|
995
995
|
lookup_class_mutex = rb_funcall(rb_cMutex, id_new, 0);
|
996
|
-
rb_iv_set(
|
996
|
+
rb_iv_set(rbg_mGLib(), "lookup_class_mutex", lookup_class_mutex);
|
997
997
|
|
998
998
|
dynamic_gtype_list = g_hash_table_new(g_str_hash, g_str_equal);
|
999
999
|
id_gtype = rb_intern("__gobject_gtype__");
|
1000
1000
|
|
1001
|
-
RG_TARGET_NAMESPACE = rb_define_class_under(
|
1001
|
+
RG_TARGET_NAMESPACE = rb_define_class_under(rbg_mGLib(), "Type", rb_cObject);
|
1002
1002
|
|
1003
1003
|
RG_DEF_SMETHOD(try_convert, 1);
|
1004
1004
|
|
@@ -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
@@ -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
|
*
|
6
6
|
* This library is free software; you can redistribute it and/or
|
@@ -237,6 +237,9 @@ 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);
|
241
|
+
extern void g_rclosure_detach(GClosure *closure, VALUE object);
|
242
|
+
extern void g_rclosure_detach_gobject(GClosure *closure, VALUE object);
|
240
243
|
extern void g_rclosure_set_tag(GClosure *closure, const gchar *tag);
|
241
244
|
|
242
245
|
/* 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
|