glib2 2.0.2 → 2.0.3

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.
@@ -419,13 +419,11 @@ source_remove(G_GNUC_UNUSED VALUE self, VALUE tag)
419
419
  return CBOOL2RVAL(g_source_remove(NUM2UINT(tag)));
420
420
  }
421
421
 
422
- #if GLIB_CHECK_VERSION(2,12,0)
423
422
  static VALUE
424
423
  source_current_source(G_GNUC_UNUSED VALUE self)
425
424
  {
426
425
  return BOXED2RVAL(g_main_current_source, G_TYPE_SOURCE);
427
426
  }
428
- #endif
429
427
 
430
428
  static gboolean
431
429
  invoke_source_func(gpointer data)
@@ -533,13 +531,11 @@ rg_release(VALUE self)
533
531
  return self;
534
532
  }
535
533
 
536
- #if GLIB_CHECK_VERSION(2,10,0)
537
534
  static VALUE
538
535
  rg_owner_p(VALUE self)
539
536
  {
540
537
  return CBOOL2RVAL(g_main_context_is_owner(_SELF(self)));
541
538
  }
542
- #endif
543
539
 
544
540
  /*
545
541
  gboolean g_main_context_wait (GMainContext *context,
@@ -805,7 +801,6 @@ idle_remove(G_GNUC_UNUSED VALUE self, VALUE func)
805
801
  return CBOOL2RVAL(g_idle_remove_by_data((gpointer)info));
806
802
  }
807
803
 
808
- #if GLIB_CHECK_VERSION(2,4,0)
809
804
  static VALUE
810
805
  child_watch_source_new(G_GNUC_UNUSED VALUE self, VALUE pid)
811
806
  {
@@ -826,7 +821,6 @@ child_watch_add(VALUE self, VALUE pid)
826
821
  return UINT2NUM(g_child_watch_add((GPid)NUM2INT(pid),
827
822
  (GChildWatchFunc)child_watch_func, (gpointer)func));
828
823
  }
829
- #endif
830
824
 
831
825
  #ifndef HAVE_RB_THREAD_BLOCKING_REGION
832
826
  static void
@@ -846,9 +840,7 @@ Init_glib_main_context(void)
846
840
 
847
841
  VALUE timeout = rb_define_module_under(mGLib, "Timeout");
848
842
  VALUE idle = rb_define_module_under(mGLib, "Idle");
849
- #if GLIB_CHECK_VERSION(2,4,0)
850
843
  VALUE child_watch = rb_define_module_under(mGLib, "ChildWatch");
851
- #endif
852
844
 
853
845
  id_call = rb_intern("call");
854
846
  id__callbacks__ = rb_intern("__callbacks__");
@@ -859,9 +851,7 @@ Init_glib_main_context(void)
859
851
 
860
852
  mGLibSource = rb_const_get(mGLib, rb_intern("Source"));
861
853
  rbg_define_singleton_method(mGLibSource, "remove", source_remove, 1);
862
- #if GLIB_CHECK_VERSION(2,12,0)
863
854
  rbg_define_singleton_method(mGLibSource, "current", source_current_source, 0);
864
- #endif
865
855
  /*
866
856
  id_poll_func = rb_intern("__poll_func__");
867
857
  */
@@ -873,9 +863,7 @@ Init_glib_main_context(void)
873
863
  RG_DEF_METHOD(wakeup, 0);
874
864
  RG_DEF_METHOD(acquire, 0);
875
865
  RG_DEF_METHOD(release, 0);
876
- #if GLIB_CHECK_VERSION(2,10,0)
877
866
  RG_DEF_METHOD_P(owner, 0);
878
- #endif
879
867
  RG_DEF_METHOD(prepare, 0);
880
868
  RG_DEF_METHOD(query, 1);
881
869
  /*
@@ -902,10 +890,8 @@ Init_glib_main_context(void)
902
890
  rbg_define_singleton_method(idle, "add", idle_add, -1);
903
891
  rbg_define_singleton_method(idle, "remove", idle_remove, 1);
904
892
 
905
- #if GLIB_CHECK_VERSION(2,4,0)
906
893
  rbg_define_singleton_method(child_watch, "source_new", child_watch_source_new, 1);
907
894
  rbg_define_singleton_method(child_watch, "add", child_watch_add, 1);
908
- #endif
909
895
 
910
896
  default_poll_func = g_main_context_get_poll_func(NULL);
911
897
  g_main_context_set_poll_func(NULL, rg_poll);
@@ -63,13 +63,11 @@ rg_attach(int argc, VALUE *argv, VALUE self)
63
63
  RVAL2BOXED(context, G_TYPE_MAIN_CONTEXT)));
64
64
  }
65
65
 
66
- #if GLIB_CHECK_VERSION(2,12,0)
67
66
  static VALUE
68
67
  rg_destroyed_p(VALUE self)
69
68
  {
70
69
  return CBOOL2RVAL(g_source_is_destroyed(_SELF(self)));
71
70
  }
72
- #endif
73
71
 
74
72
  static VALUE
75
73
  rg_set_priority(VALUE self, VALUE priority)
@@ -178,9 +176,7 @@ Init_glib_source(void)
178
176
  "CONTINUE", CBOOL2RVAL(G_SOURCE_CONTINUE));
179
177
 
180
178
  RG_DEF_METHOD(attach, -1);
181
- #if GLIB_CHECK_VERSION(2,12,0)
182
179
  RG_DEF_METHOD_P(destroyed, 0);
183
- #endif
184
180
  RG_DEF_METHOD(set_priority, 1);
185
181
  RG_DEF_METHOD(priority, 0);
186
182
  RG_DEF_METHOD(set_can_recurse, 1);
@@ -90,14 +90,12 @@ rg_stop(VALUE self)
90
90
  return self;
91
91
  }
92
92
 
93
- #if GLIB_CHECK_VERSION(2,4,0)
94
93
  static VALUE
95
94
  rg_continue(VALUE self)
96
95
  {
97
96
  g_timer_continue(_SELF(self));
98
97
  return self;
99
98
  }
100
- #endif
101
99
 
102
100
  static VALUE
103
101
  rg_elapsed(VALUE self)
@@ -123,9 +121,7 @@ Init_glib_timer(void)
123
121
  RG_DEF_METHOD(initialize, 0);
124
122
  RG_DEF_METHOD(start, 0);
125
123
  RG_DEF_METHOD(stop, 0);
126
- #if GLIB_CHECK_VERSION(2,4,0)
127
124
  RG_DEF_METHOD(continue, 0);
128
- #endif
129
125
  RG_DEF_METHOD(elapsed, 0);
130
126
  RG_DEF_METHOD(reset, 0);
131
127
  }
@@ -45,9 +45,7 @@ DEF_IS_UNICHAR(xdigit)
45
45
  DEF_IS_UNICHAR(title)
46
46
  DEF_IS_UNICHAR(defined)
47
47
  DEF_IS_UNICHAR(wide)
48
- #if GLIB_CHECK_VERSION(2,12,0)
49
48
  DEF_IS_UNICHAR(wide_cjk)
50
- #endif
51
49
 
52
50
  #undef DEF_IS_UNICHAR
53
51
 
@@ -95,7 +93,6 @@ rg_s_break_type(G_GNUC_UNUSED VALUE self, VALUE unichar)
95
93
  G_TYPE_UNICODE_BREAK_TYPE);
96
94
  }
97
95
 
98
- #if GLIB_CHECK_VERSION(2,4,0)
99
96
  static VALUE
100
97
  rg_s_get_mirror_char(G_GNUC_UNUSED VALUE self, VALUE unichar)
101
98
  {
@@ -107,7 +104,6 @@ rg_s_get_mirror_char(G_GNUC_UNUSED VALUE self, VALUE unichar)
107
104
  return unichar;
108
105
  }
109
106
  }
110
- #endif
111
107
 
112
108
  #if GLIB_CHECK_VERSION(2,14,0)
113
109
  static VALUE
@@ -179,10 +175,8 @@ Init_glib_unichar(void)
179
175
  rbglib_m_unichar_isdefined, 1);
180
176
  rbg_define_singleton_method(RG_TARGET_NAMESPACE, "wide?",
181
177
  rbglib_m_unichar_iswide, 1);
182
- #if GLIB_CHECK_VERSION(2,12,0)
183
178
  rbg_define_singleton_method(RG_TARGET_NAMESPACE, "wide_cjk?",
184
179
  rbglib_m_unichar_iswide_cjk, 1);
185
- #endif
186
180
 
187
181
  RG_DEF_SMETHOD(to_upper, 1);
188
182
  RG_DEF_SMETHOD(to_lower, 1);
@@ -194,9 +188,7 @@ Init_glib_unichar(void)
194
188
  RG_DEF_SMETHOD(type, 1);
195
189
  RG_DEF_SMETHOD(break_type, 1);
196
190
 
197
- #if GLIB_CHECK_VERSION(2,4,0)
198
191
  RG_DEF_SMETHOD(get_mirror_char, 1);
199
- #endif
200
192
 
201
193
  #if GLIB_CHECK_VERSION(2,14,0)
202
194
  RG_DEF_SMETHOD(combining_class, 1);
@@ -154,11 +154,9 @@ rg_s_collate_key(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
154
154
 
155
155
  utf8 = StringValueCStr(rb_utf8);
156
156
  len = RSTRING_LEN(rb_utf8);
157
- #if GLIB_CHECK_VERSION(2,8,0)
158
157
  if (RVAL2CBOOL(for_filename))
159
158
  key = g_utf8_collate_key_for_filename(utf8, len);
160
159
  else
161
- #endif
162
160
  key = g_utf8_collate_key(utf8, len);
163
161
 
164
162
  result = CSTR2RVAL(key);
@@ -24,7 +24,6 @@
24
24
 
25
25
  #define RG_TARGET_NAMESPACE mGLib
26
26
 
27
- #if GLIB_CHECK_VERSION(2,2,0)
28
27
  static VALUE
29
28
  rg_s_application_name(G_GNUC_UNUSED VALUE self)
30
29
  {
@@ -37,7 +36,6 @@ rg_s_set_application_name(VALUE self, VALUE application_name)
37
36
  g_set_prgname(RVAL2CSTR_ACCEPT_NIL(application_name));
38
37
  return self;
39
38
  }
40
- #endif
41
39
 
42
40
  static VALUE
43
41
  rg_s_prgname(G_GNUC_UNUSED VALUE self)
@@ -58,7 +56,6 @@ rg_s_getenv(G_GNUC_UNUSED VALUE self, VALUE variable)
58
56
  return CSTR2RVAL(g_getenv(RVAL2CSTR(variable)));
59
57
  }
60
58
 
61
- #if GLIB_CHECK_VERSION(2,4,0)
62
59
  static VALUE
63
60
  rg_s_setenv(G_GNUC_UNUSED VALUE self, VALUE variable, VALUE value, VALUE overwrite)
64
61
  {
@@ -73,9 +70,7 @@ rg_s_unsetenv(VALUE self, VALUE variable)
73
70
  g_unsetenv(RVAL2CSTR(variable));
74
71
  return self;
75
72
  }
76
- #endif
77
73
 
78
- #if GLIB_CHECK_VERSION(2,8,0)
79
74
  #ifdef HAVE_G_LISTENV
80
75
  static VALUE
81
76
  rg_s_listenv(G_GNUC_UNUSED VALUE self)
@@ -98,7 +93,6 @@ rg_s_host_name(G_GNUC_UNUSED VALUE self)
98
93
  {
99
94
  return CSTR2RVAL(g_get_host_name());
100
95
  }
101
- #endif
102
96
 
103
97
  static VALUE
104
98
  rg_s_user_name(G_GNUC_UNUSED VALUE self)
@@ -112,7 +106,6 @@ rg_s_real_name(G_GNUC_UNUSED VALUE self)
112
106
  return CSTR2RVAL(g_get_real_name());
113
107
  }
114
108
 
115
- #if GLIB_CHECK_VERSION(2, 6, 0)
116
109
  static VALUE
117
110
  rg_s_user_cache_dir(G_GNUC_UNUSED VALUE self)
118
111
  {
@@ -142,7 +135,6 @@ rg_s_system_config_dirs(G_GNUC_UNUSED VALUE self)
142
135
  {
143
136
  return STRV2RVAL((const gchar **)g_get_system_config_dirs());
144
137
  }
145
- #endif
146
138
 
147
139
  #if GLIB_CHECK_VERSION(2, 14, 0)
148
140
  static VALUE
@@ -301,33 +293,25 @@ Init_glib_utils(void)
301
293
  G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_USER_DIRECTORY, "G_");
302
294
  #endif
303
295
 
304
- #if GLIB_CHECK_VERSION(2,2,0)
305
296
  RG_DEF_SMETHOD(application_name, 0);
306
297
  RG_DEF_SMETHOD(set_application_name, 1);
307
- #endif
308
298
  RG_DEF_SMETHOD(prgname, 0);
309
299
  RG_DEF_SMETHOD(set_prgname, 1);
310
300
  RG_DEF_SMETHOD(getenv, 1);
311
- #if GLIB_CHECK_VERSION(2,4,0)
312
301
  RG_DEF_SMETHOD(setenv, 2);
313
302
  RG_DEF_SMETHOD(unsetenv, 1);
314
- #endif
315
- #if GLIB_CHECK_VERSION(2,8,0)
316
303
  #ifdef HAVE_G_LISTENV
317
304
  RG_DEF_SMETHOD(listenv, 0);
318
305
  #endif
319
306
  RG_DEF_SMETHOD(host_name, 0);
320
- #endif
321
307
  RG_DEF_SMETHOD(user_name, 0);
322
308
  RG_DEF_SMETHOD(real_name, 0);
323
309
 
324
- #if GLIB_CHECK_VERSION(2, 6, 0)
325
310
  RG_DEF_SMETHOD(user_cache_dir, 0);
326
311
  RG_DEF_SMETHOD(user_data_dir, 0);
327
312
  RG_DEF_SMETHOD(user_config_dir, 0);
328
313
  RG_DEF_SMETHOD(system_data_dirs, 0);
329
314
  RG_DEF_SMETHOD(system_config_dirs, 0);
330
- #endif
331
315
  #if GLIB_CHECK_VERSION(2, 14, 0)
332
316
  RG_DEF_SMETHOD(get_user_special_dir, 1);
333
317
  #endif
@@ -45,15 +45,12 @@ rbglib_m_win32_locale_deprecated(VALUE self)
45
45
  return rg_s_locale(self);
46
46
  }
47
47
 
48
- #if GLIB_CHECK_VERSION(2,6,0)
49
48
  static VALUE
50
49
  rg_s_version(VALUE self)
51
50
  {
52
51
  return UINT2NUM(g_win32_get_windows_version());
53
52
  }
54
- #endif
55
53
 
56
- #if GLIB_CHECK_VERSION(2,8,0)
57
54
  static VALUE
58
55
  rg_s_locale_filename_from_utf8(VALUE self, VALUE utf8_filename)
59
56
  {
@@ -68,8 +65,6 @@ rbglib_m_win32_locale_filename_from_utf8_deprecated(VALUE self,
68
65
  return rg_s_locale_filename_from_utf8(self, utf8_filename);
69
66
  }
70
67
 
71
- #endif
72
-
73
68
  # if GLIB_CHECK_VERSION(2, 16, 0)
74
69
  static VALUE
75
70
  rg_s_get_package_installation_directory_of_module(int argc,
@@ -105,12 +100,10 @@ Init_glib_win32(void)
105
100
  /* Deprecated */
106
101
  rbg_define_singleton_method(mGLib, "win32_locale", rbglib_m_win32_locale_deprecated, 0);
107
102
 
108
- # if GLIB_CHECK_VERSION(2,8,0)
109
103
  RG_DEF_SMETHOD(locale_filename_from_utf8, 1);
110
104
  /* Deprecated */
111
105
  rbg_define_singleton_method(mGLib, "win32_locale_filename_from_utf8",
112
106
  rbglib_m_win32_locale_filename_from_utf8_deprecated, 1);
113
- # endif
114
107
 
115
108
  # if GLIB_CHECK_VERSION(2, 16, 0)
116
109
  RG_DEF_SMETHOD(get_package_installation_directory_of_module, -1);
@@ -156,22 +156,10 @@ rbgobj_get_gobject(VALUE obj)
156
156
  return holder->gobj;
157
157
  }
158
158
 
159
- static VALUE
160
- dummy_init(int argc, VALUE *argv, VALUE self)
161
- {
162
- GType gtype = CLASS2GTYPE(CLASS_OF(self));
163
- if (G_TYPE_IS_ABSTRACT(gtype))
164
- rb_raise(rb_eTypeError, "initializing abstract class");
165
- else
166
- return rb_call_super(argc, argv);
167
- }
168
-
169
159
  void
170
160
  rbgobj_init_object_class(VALUE klass)
171
161
  {
172
162
  rbgobj_define_property_accessors(klass);
173
- if (G_TYPE_IS_ABSTRACT(CLASS2GTYPE(klass)))
174
- rbg_define_method(klass, "initialize", dummy_init, -1);
175
163
  }
176
164
 
177
165
  /**********************************************************************/
@@ -629,9 +617,17 @@ rg_type_name(VALUE self)
629
617
  static VALUE
630
618
  rg_initialize(int argc, VALUE *argv, VALUE self)
631
619
  {
620
+ GType gtype;
632
621
  VALUE params_hash;
633
622
  GObject* gobj;
634
623
 
624
+ gtype = CLASS2GTYPE(CLASS_OF(self));
625
+ if (G_TYPE_IS_ABSTRACT(gtype)) {
626
+ rb_raise(rb_eTypeError,
627
+ "initializing abstract class: %s",
628
+ RBG_INSPECT(CLASS_OF(self)));
629
+ }
630
+
635
631
  rb_scan_args(argc, argv, "01", &params_hash);
636
632
 
637
633
  if (!NIL_P(params_hash))
@@ -21,8 +21,6 @@
21
21
 
22
22
  #include "rbgprivate.h"
23
23
 
24
- #if GLIB_CHECK_VERSION(2,6,0)
25
-
26
24
  static VALUE
27
25
  strv_to_ruby(const GValue *from)
28
26
  {
@@ -44,5 +42,3 @@ Init_gobject_gstrv(void)
44
42
  rbgobj_register_g2r_func(G_TYPE_STRV, strv_to_ruby);
45
43
  rbgobj_register_r2g_func(G_TYPE_STRV, strv_from_ruby);
46
44
  }
47
-
48
- #endif
@@ -35,8 +35,6 @@ rg_append_features(G_GNUC_UNUSED VALUE self, VALUE klass)
35
35
  return rb_call_super(1, &klass);
36
36
  }
37
37
 
38
- #if GLIB_CHECK_VERSION(2,4,0)
39
-
40
38
  static VALUE
41
39
  rg_install_property(VALUE self, VALUE pspec_obj)
42
40
  {
@@ -122,8 +120,6 @@ rg_properties(int argc, VALUE* argv, VALUE self)
122
120
  return ary;
123
121
  }
124
122
 
125
- #endif
126
-
127
123
  void
128
124
  rbgobj_init_interface(VALUE interf)
129
125
  {
@@ -145,11 +141,9 @@ Init_gobject_typeinterface(void)
145
141
  RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "MetaInterface");
146
142
  rbg_define_method(RG_TARGET_NAMESPACE, "gtype", generic_s_gtype, 0);
147
143
  RG_DEF_METHOD(append_features, 1);
148
- #if GLIB_CHECK_VERSION(2,4,0)
149
144
  RG_DEF_METHOD(install_property, 1);
150
145
  RG_DEF_METHOD(property, 1);
151
146
  RG_DEF_METHOD(properties, -1);
152
- #endif
153
147
 
154
148
  rbgobj_mInterface = G_DEF_INTERFACE(G_TYPE_INTERFACE, "Interface", mGLib);
155
149
  }
@@ -367,6 +367,17 @@ rg_value(VALUE self)
367
367
  return GVAL2RVAL(value);
368
368
  }
369
369
 
370
+ static VALUE
371
+ rg_to_s(VALUE self)
372
+ {
373
+ GValue *value;
374
+ gchar *string_value;
375
+
376
+ value = _SELF(self);
377
+ string_value = g_strdup_value_contents(value);
378
+ return CSTR2RVAL_FREE(string_value);
379
+ }
380
+
370
381
  void
371
382
  Init_gobject_gvalue(void)
372
383
  {
@@ -380,4 +391,5 @@ Init_gobject_gvalue(void)
380
391
  RG_DEF_METHOD(initialize, 2);
381
392
  RG_DEF_METHOD(type, 0);
382
393
  RG_DEF_METHOD(value, 0);
394
+ RG_DEF_METHOD(to_s, 0);
383
395
  }
@@ -149,25 +149,31 @@ rbgobj_ruby_object_from_instance2(gpointer instance, gboolean alloc)
149
149
  }
150
150
  }
151
151
 
152
+ void
153
+ rbgobj_instance_unref(gpointer instance)
154
+ {
155
+ GType type;
156
+
157
+ type = G_TYPE_FROM_INSTANCE(instance);
158
+ if (!rbgobj_convert_unref(type, instance)) {
159
+ type = G_TYPE_FUNDAMENTAL(type);
160
+ switch (type) {
161
+ case G_TYPE_OBJECT:
162
+ g_object_unref(instance);
163
+ break;
164
+ default:
165
+ rbgobj_convert_unref(type, instance);
166
+ break;
167
+ }
168
+ }
169
+ }
170
+
152
171
  VALUE
153
172
  rbgobj_ruby_object_from_instance_with_unref(gpointer instance)
154
173
  {
155
174
  VALUE result = rbgobj_ruby_object_from_instance(instance);
156
175
  if (!NIL_P(result)) {
157
- GType type;
158
-
159
- type = G_TYPE_FROM_INSTANCE(instance);
160
- if (!rbgobj_convert_unref(type, instance)) {
161
- type = G_TYPE_FUNDAMENTAL(type);
162
- switch (type) {
163
- case G_TYPE_OBJECT:
164
- g_object_unref(instance);
165
- break;
166
- default:
167
- rbgobj_convert_unref(type, instance);
168
- break;
169
- }
170
- }
176
+ rbgobj_instance_unref(instance);
171
177
  }
172
178
  return result;
173
179
  }
@@ -265,11 +271,9 @@ rbgobj_define_property_accessors(VALUE klass)
265
271
  gtype = CLASS2GTYPE(klass);
266
272
 
267
273
  if (G_TYPE_IS_INTERFACE(gtype)){
268
- #if GLIB_CHECK_VERSION(2,4,0)
269
274
  gpointer iface = g_type_default_interface_ref(gtype);
270
275
  pspecs = g_object_interface_list_properties(iface, &n_properties);
271
276
  g_type_default_interface_unref(iface);
272
- #endif
273
277
  } else {
274
278
  GObjectClass* oclass = G_OBJECT_CLASS(g_type_class_ref(gtype));
275
279
  pspecs = g_object_class_list_properties(oclass, &n_properties);
@@ -369,9 +373,7 @@ Init_gobject(void)
369
373
  Init_gobject_gvalue();
370
374
  Init_gobject_gvaluetypes();
371
375
  Init_gobject_gboxed();
372
- #if GLIB_CHECK_VERSION(2,6,0)
373
376
  Init_gobject_gstrv();
374
- #endif
375
377
  Init_gobject_value_array();
376
378
  Init_gobject_genumflags();
377
379
  Init_gobject_gparam();