glib2 4.2.2 → 4.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b563bb7a7fbbf025f7adff7f364a2aadf65f3699ddfce16188c91899c840b7d
4
- data.tar.gz: ed5e98fee96ef1aa521a66a1cc076ed6fe9c840bee3c2148bdb1ec6513643b9b
3
+ metadata.gz: 3b45ce3056fb7100dc8a3e62431925bfb0bca762d0835c9da0bff9fa3d1d409f
4
+ data.tar.gz: 55e73580612b3aced2dd6753162fb352ff722f8e8b48fdca537cb1e8676d5472
5
5
  SHA512:
6
- metadata.gz: d8b48c4d83df2e02af8cef030b4b3c6b94ce03be7d3626bcc075c38ddee2c711f51a61e5efabfce4be421a1b66e5e99c01c063e341db934a0247e90d41718b8c
7
- data.tar.gz: bd24a6e77f2b3bd515f1e0b28a4571cc0851922fd8afc4b4ca29f00ab9ba851b37de5d75f2f57722187b2fcf5a0384b1e2a78bf6ba423816e64214a1a98abfd1
6
+ metadata.gz: cc7b6ad7a331af646b6b4e7c92d7cf0b606dc57a7ceaa72c6f1c995d8f8e168ef593658692105f45f2adf9a0a639044263a6c776d8dd5b21e3711c185d78ad41
7
+ data.tar.gz: bbf363a2ba3d4831c117803f4484b2f4ca9c3ee2b7aa1af3ef8a9694b1ac24521cf3eec87b90cb2c4edb6dd30ccdaf14af06aa58e845aa297a092b37dda0fb56
data/README.md CHANGED
@@ -24,4 +24,4 @@ the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
24
24
 
25
25
  ## Project Website
26
26
 
27
- https://ruby-gnome2.osdn.jp/
27
+ https://ruby-gnome.github.io/
@@ -0,0 +1,28 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2024 Ruby-GNOME Project Team
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
+ * MA 02110-1301 USA
19
+ */
20
+
21
+ #include "rbgprivate.h"
22
+
23
+ void
24
+ Init_glib_option(void)
25
+ {
26
+ G_DEF_CLASS(G_TYPE_OPTION_ARG, "OptionArg", rbg_mGLib());
27
+ G_DEF_CLASS(G_TYPE_OPTION_FLAGS, "OptionFlags", rbg_mGLib());
28
+ }
@@ -0,0 +1,84 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2024 Ruby-GNOME Project Team
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
+ * MA 02110-1301 USA
19
+ */
20
+
21
+ #include "rbgprivate.h"
22
+
23
+ #define RG_TARGET_NAMESPACE cVariantDict
24
+
25
+ #define _SELF(s) (RVAL2GVARIANTDICT(s))
26
+
27
+ static VALUE RG_TARGET_NAMESPACE;
28
+
29
+ static VALUE
30
+ rg_initialize(int argc, VALUE *argv, VALUE self)
31
+ {
32
+ VALUE rb_variant;
33
+ rb_scan_args(argc, argv, "01", &rb_variant);
34
+ GVariant *variant = NULL;
35
+ if (!RB_NIL_P(rb_variant)) {
36
+ variant = RVAL2GVARIANT(rb_variant);
37
+ }
38
+ GVariantDict *dict = g_variant_dict_new(variant);
39
+ G_INITIALIZE(self, dict);
40
+
41
+ return Qnil;
42
+ }
43
+
44
+ static VALUE
45
+ rg_insert(VALUE self, VALUE rb_key, VALUE rb_value)
46
+ {
47
+ GVariantDict *dict = _SELF(self);
48
+ const gchar *key = RVAL2CSTR(rb_key);
49
+ GVariant *value = RVAL2GVARIANT(rb_value);
50
+ g_variant_dict_insert_value(dict, key, value);
51
+ return Qnil;
52
+ }
53
+
54
+ static VALUE
55
+ rg_lookup(VALUE self, VALUE rb_key, VALUE rb_expected_type)
56
+ {
57
+ GVariantDict *dict = _SELF(self);
58
+ const gchar *key = RVAL2CSTR(rb_key);
59
+ const GVariantType *expected_type = RVAL2GVARIANTTYPE(rb_expected_type);
60
+ GVariant *value = g_variant_dict_lookup_value(dict, key, expected_type);
61
+ return GVARIANT2RVAL(value);
62
+ }
63
+
64
+ static VALUE
65
+ rg_contains_p(VALUE self, VALUE rb_key)
66
+ {
67
+ GVariantDict *dict = _SELF(self);
68
+ const gchar *key = RVAL2CSTR(rb_key);
69
+ gboolean contains = g_variant_dict_contains(dict, key);
70
+ return CBOOL2RVAL(contains);
71
+ }
72
+
73
+ void
74
+ Init_glib_variant_dict(void)
75
+ {
76
+ RG_TARGET_NAMESPACE =
77
+ G_DEF_CLASS(G_TYPE_VARIANT_DICT, "VariantDict", rbg_mGLib());
78
+
79
+ RG_DEF_METHOD(initialize, -1);
80
+
81
+ RG_DEF_METHOD(insert, 2);
82
+ RG_DEF_METHOD(lookup, 2);
83
+ RG_DEF_METHOD_P(contains, 1);
84
+ }
data/ext/glib2/rbglib.c CHANGED
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011-2022 Ruby-GNOME Project Team
3
+ * Copyright (C) 2011-2024 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
@@ -1284,9 +1284,11 @@ union GDoubleIEEE754;
1284
1284
  Init_glib_bookmark_file();
1285
1285
  Init_glib_variant_type();
1286
1286
  Init_glib_variant();
1287
+ Init_glib_variant_dict();
1287
1288
  Init_glib_regex();
1288
1289
  Init_glib_matchinfo();
1289
1290
  Init_glib_date_time();
1290
1291
  Init_glib_time_zone();
1291
1292
  Init_glib_bytes();
1293
+ Init_glib_option();
1292
1294
  }
data/ext/glib2/rbglib.h CHANGED
@@ -33,7 +33,7 @@ G_BEGIN_DECLS
33
33
 
34
34
  #define RBGLIB_MAJOR_VERSION 4
35
35
  #define RBGLIB_MINOR_VERSION 2
36
- #define RBGLIB_MICRO_VERSION 2
36
+ #define RBGLIB_MICRO_VERSION 3
37
37
 
38
38
  #ifndef RB_ZALLOC
39
39
  # ifdef ZALLOC
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011-2015 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2011-2024 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
@@ -43,6 +43,10 @@
43
43
  #define GVALUE2RVAL(o) (BOXED2RVAL(o, G_TYPE_VALUE))
44
44
  #define RVAL2GVARIANTTYPE(o) (rbg_variant_type_from_ruby(o))
45
45
  #define GVARIANTTYPE2RVAL(o) (BOXED2RVAL(o, G_TYPE_VARIANT_TYPE))
46
+ #define RVAL2GVARIANT(o) (rbg_variant_from_ruby(o))
47
+ #define GVARIANT2RVAL(o) (rbg_variant_to_ruby(o))
48
+ #define RVAL2GVARIANTDICT(o) ((GVariantDict *)RVAL2BOXED(o, G_TYPE_VARIANT_DICT))
49
+ #define GVARIANTDICT2RVAL(o) (BOXED2RVAL(o, G_TYPE_VARIANT_DICT))
46
50
 
47
51
  #define RVAL2GIOCONDITION(o) (RVAL2GFLAGS(o, G_TYPE_IO_CONDITION))
48
52
  #define GIOCONDITION2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_IO_CONDITION))
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2004-2021 Ruby-GNOME Project Team
3
+ * Copyright (C) 2004-2024 Ruby-GNOME Project Team
4
4
  * Copyright (C) 2004 Pascal Terjan
5
5
  *
6
6
  * This library is free software; you can redistribute it and/or
@@ -279,6 +279,20 @@ rg_s_check_version_p(G_GNUC_UNUSED VALUE self, VALUE major, VALUE minor, VALUE m
279
279
  glib_micro_version >= NUM2UINT(micro)));
280
280
  }
281
281
 
282
+ #if GLIB_CHECK_VERSION(2, 64, 0)
283
+ static VALUE
284
+ rg_s_get_os_info(G_GNUC_UNUSED VALUE self, VALUE rb_key)
285
+ {
286
+ if (RB_SYMBOL_P(rb_key)) {
287
+ VALUE mOSInfoKey = rb_const_get(rbg_mGLib(), rb_intern("OSInfoKey"));
288
+ VALUE rb_KEY = rb_funcall(rb_sym2str(rb_key), rb_intern("upcase"), 0);
289
+ rb_key = rb_const_get(mOSInfoKey, rb_intern_str(rb_KEY));
290
+ }
291
+ return CSTR2RVAL_FREE(g_get_os_info(RVAL2CSTR(rb_key)));
292
+ }
293
+ #endif
294
+
295
+
282
296
  void
283
297
  Init_glib_utils(void)
284
298
  {
@@ -323,4 +337,26 @@ Init_glib_utils(void)
323
337
  RG_DEF_SMETHOD(parse_debug_string, 2);
324
338
  RG_DEF_SMETHOD_P(check_version, 3);
325
339
 
340
+ #if GLIB_CHECK_VERSION(2, 64, 0)
341
+ RG_DEF_SMETHOD(get_os_info, 1);
342
+
343
+ VALUE mOSInfoKey = rb_define_module_under(RG_TARGET_NAMESPACE, "OSInfoKey");
344
+ # define RG_DEF_OS_INFO_KEY(NAME) \
345
+ rb_define_const(mOSInfoKey, \
346
+ G_STRINGIFY(NAME), \
347
+ CSTR2RVAL(G_OS_INFO_KEY_ ## NAME))
348
+
349
+ RG_DEF_OS_INFO_KEY(NAME);
350
+ RG_DEF_OS_INFO_KEY(PRETTY_NAME);
351
+ RG_DEF_OS_INFO_KEY(VERSION);
352
+ RG_DEF_OS_INFO_KEY(VERSION_CODENAME);
353
+ RG_DEF_OS_INFO_KEY(VERSION_ID);
354
+ RG_DEF_OS_INFO_KEY(ID);
355
+ RG_DEF_OS_INFO_KEY(HOME_URL);
356
+ RG_DEF_OS_INFO_KEY(DOCUMENTATION_URL);
357
+ RG_DEF_OS_INFO_KEY(SUPPORT_URL);
358
+ RG_DEF_OS_INFO_KEY(BUG_REPORT_URL);
359
+ RG_DEF_OS_INFO_KEY(PRIVACY_POLICY_URL);
360
+ # undef RG_DEF_OS_INFO_KEY
361
+ #endif
326
362
  }
@@ -987,7 +987,6 @@ void
987
987
  rbgobj_register_type(VALUE klass, VALUE type_name, GClassInitFunc class_init)
988
988
  {
989
989
  GType parent_type;
990
- GTypeInfo *info;
991
990
 
992
991
  {
993
992
  const RGObjClassInfo *cinfo = rbgobj_lookup_class(klass);
@@ -1025,26 +1024,13 @@ rbgobj_register_type(VALUE klass, VALUE type_name, GClassInitFunc class_init)
1025
1024
  GTypeQuery query;
1026
1025
  g_type_query(parent_type, &query);
1027
1026
 
1028
- /* TODO: Why new? g_type_register_static() doesn’t retain a copy, so
1029
- * this should be allocated on the stack. */
1030
- info = g_new0(GTypeInfo, 1);
1031
- info->class_size = query.class_size;
1032
- info->base_init = NULL;
1033
- info->base_finalize = NULL;
1034
- info->class_init = class_init;
1035
- info->class_finalize = NULL;
1036
- info->class_data = NULL;
1037
- info->instance_size = query.instance_size;
1038
- info->n_preallocs = 0;
1039
- info->instance_init = NULL;
1040
- info->value_table = NULL;
1041
- }
1042
-
1043
- {
1044
- GType type = g_type_register_static(parent_type,
1045
- StringValueCStr(type_name),
1046
- info,
1047
- 0);
1027
+ GType type = g_type_register_static_simple(parent_type,
1028
+ StringValueCStr(type_name),
1029
+ query.class_size,
1030
+ class_init,
1031
+ query.instance_size,
1032
+ NULL,
1033
+ 0);
1048
1034
  if (type == G_TYPE_INVALID) {
1049
1035
  rb_raise(rb_eArgError,
1050
1036
  "failed to register type: <%s>",
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2004-2022 Ruby-GNOME Project Team
3
+ * Copyright (C) 2004-2024 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
@@ -25,6 +25,49 @@
25
25
 
26
26
  #include "rbgprivate.h"
27
27
 
28
+ static GParamFlags
29
+ resolve_flags(VALUE rb_flags)
30
+ {
31
+ GParamFlags flags = 0;
32
+
33
+ switch (rb_type(rb_flags)) {
34
+ case RUBY_T_NIL:
35
+ flags = 0;
36
+ break;
37
+ case RUBY_T_FIXNUM:
38
+ case RUBY_T_BIGNUM:
39
+ flags = NUM2UINT(rb_flags);
40
+ break;
41
+ case RUBY_T_SYMBOL:
42
+ rb_flags = rb_sym2str(rb_flags);
43
+ /* fallthrough */
44
+ case RUBY_T_STRING:
45
+ {
46
+ VALUE rb_FLAGS = rb_funcall(rb_flags, rb_intern("upcase"), 0);
47
+ VALUE mGLibParam = rb_const_get(rbg_mGLib(), rb_intern("Param"));
48
+ flags = NUM2UINT(rb_const_get(mGLibParam, rb_intern_str(rb_FLAGS)));
49
+ }
50
+ break;
51
+ case RUBY_T_ARRAY:
52
+ {
53
+ long i, n;
54
+ n = RARRAY_LEN(rb_flags);
55
+ for (i = 0; i < n; i++) {
56
+ flags |= resolve_flags(RARRAY_PTR(rb_flags)[i]);
57
+ }
58
+ break;
59
+ }
60
+ default:
61
+ rb_raise(rb_eArgError,
62
+ "flag value must be one of "
63
+ "nil, Integer, String, Symbol or Array of them: %s",
64
+ RBG_INSPECT(rb_flags));
65
+ break;
66
+ }
67
+
68
+ return flags;
69
+ }
70
+
28
71
  #define DEF_NUMERIC_PSPEC_METHODS_FUNC(pspec_type, typename, from_ruby, to_ruby, pspec_cast) \
29
72
  static VALUE \
30
73
  typename##_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, \
@@ -32,13 +75,13 @@ typename##_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, \
32
75
  VALUE flags) \
33
76
  { \
34
77
  GParamSpec* pspec; \
35
- pspec = g_param_spec_##typename(StringValuePtr(name), \
36
- StringValuePtr(nick), \
37
- StringValuePtr(blurb), \
78
+ pspec = g_param_spec_##typename(RVAL2CSTR(name), \
79
+ RVAL2CSTR_ACCEPT_NIL(nick), \
80
+ RVAL2CSTR_ACCEPT_NIL(blurb), \
38
81
  from_ruby(minimum), \
39
82
  from_ruby(maximum), \
40
83
  from_ruby(default_value), \
41
- NUM2UINT(flags)); \
84
+ resolve_flags(flags)); \
42
85
  rbgobj_param_spec_initialize(self, pspec); \
43
86
  return Qnil; \
44
87
  } \
@@ -91,11 +134,11 @@ boolean_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
91
134
  VALUE default_value, VALUE flags)
92
135
  {
93
136
  GParamSpec* pspec;
94
- pspec = g_param_spec_boolean(StringValuePtr(name),
95
- StringValuePtr(nick),
96
- StringValuePtr(blurb),
137
+ pspec = g_param_spec_boolean(RVAL2CSTR(name),
138
+ RVAL2CSTR_ACCEPT_NIL(nick),
139
+ RVAL2CSTR_ACCEPT_NIL(blurb),
97
140
  RVAL2CBOOL(default_value),
98
- NUM2UINT(flags));
141
+ resolve_flags(flags));
99
142
  rbgobj_param_spec_initialize(self, pspec);
100
143
  return Qnil;
101
144
  }
@@ -105,11 +148,11 @@ unichar_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
105
148
  VALUE default_value, VALUE flags)
106
149
  {
107
150
  GParamSpec* pspec;
108
- pspec = g_param_spec_unichar(StringValuePtr(name),
109
- StringValuePtr(nick),
110
- StringValuePtr(blurb),
151
+ pspec = g_param_spec_unichar(RVAL2CSTR(name),
152
+ RVAL2CSTR_ACCEPT_NIL(nick),
153
+ RVAL2CSTR_ACCEPT_NIL(blurb),
111
154
  NUM2UINT(default_value),
112
- NUM2UINT(flags));
155
+ resolve_flags(flags));
113
156
  rbgobj_param_spec_initialize(self, pspec);
114
157
  return Qnil;
115
158
  }
@@ -121,12 +164,12 @@ enum_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
121
164
  GParamSpec* pspec;
122
165
  GType gtype = rbgobj_gtype_from_ruby(enum_type);
123
166
 
124
- pspec = g_param_spec_enum(StringValuePtr(name),
125
- StringValuePtr(nick),
126
- StringValuePtr(blurb),
167
+ pspec = g_param_spec_enum(RVAL2CSTR(name),
168
+ RVAL2CSTR_ACCEPT_NIL(nick),
169
+ RVAL2CSTR_ACCEPT_NIL(blurb),
127
170
  gtype,
128
171
  RVAL2GENUM(default_value, gtype),
129
- NUM2UINT(flags));
172
+ resolve_flags(flags));
130
173
  rbgobj_param_spec_initialize(self, pspec);
131
174
  return Qnil;
132
175
  }
@@ -138,12 +181,12 @@ flags_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
138
181
  GParamSpec* pspec;
139
182
  GType gtype = rbgobj_gtype_from_ruby(flags_type);
140
183
 
141
- pspec = g_param_spec_flags(StringValuePtr(name),
142
- StringValuePtr(nick),
143
- StringValuePtr(blurb),
144
- gtype,
145
- RVAL2GFLAGS(default_value, gtype),
146
- NUM2UINT(flags));
184
+ pspec = g_param_spec_flags(RVAL2CSTR(name),
185
+ RVAL2CSTR_ACCEPT_NIL(nick),
186
+ RVAL2CSTR_ACCEPT_NIL(blurb),
187
+ gtype,
188
+ RVAL2GFLAGS(default_value, gtype),
189
+ resolve_flags(flags));
147
190
  rbgobj_param_spec_initialize(self, pspec);
148
191
  return Qnil;
149
192
  }
@@ -153,11 +196,11 @@ string_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
153
196
  VALUE default_value, VALUE flags)
154
197
  {
155
198
  GParamSpec* pspec;
156
- pspec = g_param_spec_string(StringValuePtr(name),
157
- StringValuePtr(nick),
158
- StringValuePtr(blurb),
159
- NIL_P(default_value) ? NULL : StringValuePtr(default_value),
160
- NUM2UINT(flags));
199
+ pspec = g_param_spec_string(RVAL2CSTR(name),
200
+ RVAL2CSTR_ACCEPT_NIL(nick),
201
+ RVAL2CSTR_ACCEPT_NIL(blurb),
202
+ RVAL2CSTR_ACCEPT_NIL(default_value),
203
+ resolve_flags(flags));
161
204
  rbgobj_param_spec_initialize(self, pspec);
162
205
  return Qnil;
163
206
  }
@@ -167,11 +210,11 @@ param_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
167
210
  VALUE param_type, VALUE flags)
168
211
  {
169
212
  GParamSpec* pspec;
170
- pspec = g_param_spec_param(StringValuePtr(name),
171
- StringValuePtr(nick),
172
- StringValuePtr(blurb),
213
+ pspec = g_param_spec_param(RVAL2CSTR(name),
214
+ RVAL2CSTR_ACCEPT_NIL(nick),
215
+ RVAL2CSTR_ACCEPT_NIL(blurb),
173
216
  rbgobj_gtype_from_ruby(param_type),
174
- NUM2UINT(flags));
217
+ resolve_flags(flags));
175
218
  rbgobj_param_spec_initialize(self, pspec);
176
219
  return Qnil;
177
220
  }
@@ -181,11 +224,11 @@ boxed_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
181
224
  VALUE boxed_type, VALUE flags)
182
225
  {
183
226
  GParamSpec* pspec;
184
- pspec = g_param_spec_boxed(StringValuePtr(name),
185
- StringValuePtr(nick),
186
- StringValuePtr(blurb),
227
+ pspec = g_param_spec_boxed(RVAL2CSTR(name),
228
+ RVAL2CSTR_ACCEPT_NIL(nick),
229
+ RVAL2CSTR_ACCEPT_NIL(blurb),
187
230
  rbgobj_gtype_from_ruby(boxed_type),
188
- NUM2UINT(flags));
231
+ resolve_flags(flags));
189
232
  rbgobj_param_spec_initialize(self, pspec);
190
233
  return Qnil;
191
234
  }
@@ -194,10 +237,10 @@ static VALUE
194
237
  pointer_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb, VALUE flags)
195
238
  {
196
239
  GParamSpec* pspec;
197
- pspec = g_param_spec_pointer(StringValuePtr(name),
198
- StringValuePtr(nick),
199
- StringValuePtr(blurb),
200
- NUM2UINT(flags));
240
+ pspec = g_param_spec_pointer(RVAL2CSTR(name),
241
+ RVAL2CSTR_ACCEPT_NIL(nick),
242
+ RVAL2CSTR_ACCEPT_NIL(blurb),
243
+ resolve_flags(flags));
201
244
  rbgobj_param_spec_initialize(self, pspec);
202
245
  return Qnil;
203
246
  }
@@ -207,11 +250,11 @@ value_array_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
207
250
  VALUE element_spec, VALUE flags)
208
251
  {
209
252
  GParamSpec *pspec;
210
- pspec = g_param_spec_value_array(StringValuePtr(name),
211
- StringValuePtr(nick),
212
- StringValuePtr(blurb),
253
+ pspec = g_param_spec_value_array(RVAL2CSTR(name),
254
+ RVAL2CSTR_ACCEPT_NIL(nick),
255
+ RVAL2CSTR_ACCEPT_NIL(blurb),
213
256
  RVAL2GOBJ(element_spec),
214
- NUM2UINT(flags));
257
+ resolve_flags(flags));
215
258
  rbgobj_param_spec_initialize(self, pspec);
216
259
  return Qnil;
217
260
  }
@@ -221,11 +264,11 @@ object_initialize(VALUE self, VALUE name, VALUE nick, VALUE blurb,
221
264
  VALUE object_type, VALUE flags)
222
265
  {
223
266
  GParamSpec* pspec;
224
- pspec = g_param_spec_object(StringValuePtr(name),
225
- StringValuePtr(nick),
226
- StringValuePtr(blurb),
267
+ pspec = g_param_spec_object(RVAL2CSTR(name),
268
+ RVAL2CSTR_ACCEPT_NIL(nick),
269
+ RVAL2CSTR_ACCEPT_NIL(blurb),
227
270
  rbgobj_gtype_from_ruby(object_type),
228
- NUM2UINT(flags));
271
+ resolve_flags(flags));
229
272
  rbgobj_param_spec_initialize(self, pspec);
230
273
  return Qnil;
231
274
  }
@@ -21,11 +21,11 @@
21
21
  #pragma once
22
22
 
23
23
  /*
24
- * CentOS 7: GLib 2.56
25
24
  * AlmaLinux 8: GLib 2.56
26
25
  * AlmaLinux 9: GLib 2.68
27
26
  * Ubuntu 20.04: GLib 2.64
28
27
  * Ubuntu 22.04: GLib 2.72
28
+ * Ubuntu 24.04: GLib 2.80
29
29
  */
30
30
  #ifndef GLIB_VERSION_MIN_REQUIRED
31
31
  # define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_56
@@ -179,11 +179,13 @@ G_GNUC_INTERNAL void Init_glib_keyfile(void);
179
179
  G_GNUC_INTERNAL void Init_glib_bookmark_file(void);
180
180
  G_GNUC_INTERNAL void Init_glib_variant_type(void);
181
181
  G_GNUC_INTERNAL void Init_glib_variant(void);
182
+ G_GNUC_INTERNAL void Init_glib_variant_dict(void);
182
183
  G_GNUC_INTERNAL void Init_glib_regex(void);
183
184
  G_GNUC_INTERNAL void Init_glib_matchinfo(void);
184
185
  G_GNUC_INTERNAL void Init_glib_date_time(void);
185
186
  G_GNUC_INTERNAL void Init_glib_time_zone(void);
186
187
  G_GNUC_INTERNAL void Init_glib_bytes(void);
188
+ G_GNUC_INTERNAL void Init_glib_option(void);
187
189
 
188
190
  G_GNUC_INTERNAL void Init_gobject_convert(void);
189
191
  G_GNUC_INTERNAL void Init_gobject_gtype(void);
data/glib2.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  "many useful utility features."
28
28
  s.author = "The Ruby-GNOME Project Team"
29
29
  s.email = "ruby-gnome2-devel-en@lists.sourceforge.net"
30
- s.homepage = "https://ruby-gnome2.osdn.jp/"
30
+ s.homepage = "https://ruby-gnome.github.io/"
31
31
  s.licenses = ["LGPL-2.1+"]
32
32
  s.version = ruby_glib2_version
33
33
  s.extensions = ["ext/#{s.name}/extconf.rb"]
@@ -126,7 +126,7 @@ module GNOME
126
126
  @description = ""
127
127
  @author = "The Ruby-GNOME2 Project Team"
128
128
  @email = "ruby-gnome2-devel-en@lists.sourceforge.net"
129
- @homepage = "https://ruby-gnome2.osdn.jp/"
129
+ @homepage = "https://ruby-gnome.github.io/"
130
130
  @external_packages = []
131
131
  end
132
132
 
@@ -17,7 +17,7 @@ $KCODE = "U"
17
17
  URI = "https://ruby-gnome2.osdn.jp/"
18
18
  bf = GLib::BookmarkFile.new
19
19
  bf.set_title(URI, "Ruby-GNOME2 sample")
20
- bf.set_description(URI, "Ruby-GNOME2 Sampe for GLib::BookmarkFile")
20
+ bf.set_description(URI, "Ruby-GNOME2 Sample for GLib::BookmarkFile")
21
21
  bf.set_mime_type(URI, "text/html")
22
22
  bf.set_private(URI, false)
23
23
  bf.set_icon(URI, "https://ruby-gnome2.osdn.jp/logo-gy.png", "image/png")
data/test/test-binding.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015-2021 Ruby-GNOME Project Team
1
+ # Copyright (C) 2015-2024 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
@@ -21,21 +21,19 @@ class TestGLibBinding < Test::Unit::TestCase
21
21
  type_register
22
22
 
23
23
  install_property(GLib::Param::Int.new("source", # name
24
- "Source", # nick
25
- "The source data", # blurb
24
+ nil, # nick
25
+ nil, # blurb
26
26
  0, # min
27
27
  100, # max
28
28
  0, # default
29
- GLib::Param::READABLE |
30
- GLib::Param::WRITABLE))
29
+ [:readable, :writable]))
31
30
  install_property(GLib::Param::Int.new("target", # name
32
- "Target", # nick
33
- "The target data", # blurb
31
+ nil, # nick
32
+ nil, # blurb
34
33
  0, # min
35
34
  100, # max
36
35
  0, # default
37
- GLib::Param::READABLE |
38
- GLib::Param::WRITABLE))
36
+ :readwrite))
39
37
 
40
38
  attr_reader :source, :target
41
39
  def initialize
@@ -106,8 +104,7 @@ class TestGLibBinding < Test::Unit::TestCase
106
104
  "Target", # nick
107
105
  "The target data", # blurb
108
106
  "", # default
109
- GLib::Param::READABLE |
110
- GLib::Param::WRITABLE))
107
+ GLib::Param::READWRITE))
111
108
 
112
109
  attr_reader :source, :target
113
110
  def initialize
@@ -0,0 +1,27 @@
1
+ # Copyright (C) 2024 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
+ class TestGLibOption < Test::Unit::TestCase
18
+ include GLibTestUtils
19
+
20
+ def test_arg
21
+ assert_equal(0, GLib::OptionArg::NONE.to_i)
22
+ end
23
+
24
+ def test_flags
25
+ assert_equal(0, GLib::OptionFlags::NONE.to_i)
26
+ end
27
+ end
data/test/test-unicode.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015-2021 Ruby-GNOME Project Team
1
+ # Copyright (C) 2015-2024 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
@@ -400,10 +400,11 @@ class TestGLibUnicode < Test::Unit::TestCase
400
400
  end
401
401
 
402
402
  def binary(string)
403
- if string.respond_to?(:force_encoding)
404
- string.force_encoding("ascii-8bit")
403
+ if string.respond_to?(:b)
404
+ string.b
405
+ else
406
+ string
405
407
  end
406
- string
407
408
  end
408
409
 
409
410
  def little_endian?
data/test/test-utils.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015-2021 Ruby-GNOME Project Team
1
+ # Copyright (C) 2015-2024 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
@@ -42,4 +42,14 @@ class TestGLibUtils < Test::Unit::TestCase
42
42
  GLib.get_user_special_dir(GLib::UserDirectory::DESKTOP)
43
43
  end
44
44
  end
45
+
46
+ def test_get_os_info
47
+ only_glib_version(2, 64, 0)
48
+ assert_kind_of(String, GLib.get_os_info(GLib::OSInfoKey::NAME))
49
+ end
50
+
51
+ def test_get_os_info_symbol
52
+ only_glib_version(2, 64, 0)
53
+ assert_kind_of(String, GLib.get_os_info(:name))
54
+ end
45
55
  end
@@ -0,0 +1,40 @@
1
+ # Copyright (C) 2024 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
+ class TestGLibVariantDict < Test::Unit::TestCase
18
+ include GLibTestUtils
19
+
20
+ def setup
21
+ @dict = GLib::VariantDict.new
22
+ @dict.insert("hello", GLib::Variant.new("world", "s"))
23
+ end
24
+
25
+ def test_lookup
26
+ assert_equal("world", @dict.lookup("hello", "s"))
27
+ end
28
+
29
+ def test_contains_true
30
+ assert do
31
+ @dict.contains?("hello")
32
+ end
33
+ end
34
+
35
+ def test_contains_false
36
+ assert do
37
+ not @dict.contains?("nonexistent")
38
+ end
39
+ end
40
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib2
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.2
4
+ version: 4.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Ruby-GNOME Project Team
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2024-04-02 00:00:00.000000000 Z
10
+ date: 2024-09-19 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: pkg-config
@@ -68,6 +68,8 @@ files:
68
68
  - ext/glib2/rbgcompat.h
69
69
  - ext/glib2/rbglib-bytes.c
70
70
  - ext/glib2/rbglib-gc.c
71
+ - ext/glib2/rbglib-option.c
72
+ - ext/glib2/rbglib-variant-dict.c
71
73
  - ext/glib2/rbglib-variant-type.c
72
74
  - ext/glib2/rbglib-variant.c
73
75
  - ext/glib2/rbglib.c
@@ -187,6 +189,7 @@ files:
187
189
  - test/test-key-file.rb
188
190
  - test/test-match-info.rb
189
191
  - test/test-mkenums.rb
192
+ - test/test-option.rb
190
193
  - test/test-pointer.rb
191
194
  - test/test-poll-fd.rb
192
195
  - test/test-regex.rb
@@ -200,12 +203,13 @@ files:
200
203
  - test/test-unicode.rb
201
204
  - test/test-utils.rb
202
205
  - test/test-value.rb
206
+ - test/test-variant-dict.rb
203
207
  - test/test-variant-type.rb
204
208
  - test/test-variant.rb
205
209
  - test/test-version.rb
206
210
  - test/test-win32.rb
207
211
  - version.rb
208
- homepage: https://ruby-gnome2.osdn.jp/
212
+ homepage: https://ruby-gnome.github.io/
209
213
  licenses:
210
214
  - LGPL-2.1+
211
215
  metadata: