glib2 3.0.8 → 3.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -2
- data/ext/glib2/extconf.rb +0 -1
- data/ext/glib2/rbglib-variant-type.c +5 -1
- data/ext/glib2/rbglib-variant.c +21 -7
- data/ext/glib2/rbglib.c +0 -38
- data/ext/glib2/rbglib.h +2 -2
- data/ext/glib2/rbglib_convert.c +3 -9
- data/ext/glib2/rbglib_matchinfo.c +4 -0
- data/ext/glib2/rbglib_regex.c +12 -1
- data/ext/glib2/rbgobj_object.c +112 -10
- data/ext/glib2/rbgobj_signal.c +12 -1
- data/ext/glib2/rbgobj_type.c +7 -1
- data/ext/glib2/rbgobject.c +0 -6
- data/ext/glib2/rbgprivate.h +0 -4
- data/ext/glib2/rbgutil.c +0 -2
- data/ext/glib2/rbgutil.h +1 -3
- data/lib/glib2.rb +7 -0
- data/lib/gnome2/rake/external-package.rb +118 -2
- data/lib/gnome2/rake/package-task.rb +63 -3
- data/lib/gnome2/rake/windows-binary-build-task.rb +343 -337
- data/lib/gnome2/rake/windows-binary-download-task.rb +151 -148
- data/lib/mkmf-gnome2.rb +11 -30
- data/test/test-binding.rb +157 -66
- data/test/test_glib2.rb +21 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b94f7308e7d76205d90b18b897c9d69accc2a888
|
4
|
+
data.tar.gz: 9aeb896467dcdd6ddd7656ff0dc7f82efe8feacd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2436a45d9721ab2bd307a33bb541980ab2e178f26fe686e9ef97f4ee6f1a7bb4ac8b18a21346fa852ffeac91e104ec7730e788ec6bb0193764917d778eba170c
|
7
|
+
data.tar.gz: dc94179cadf65f94b31597b5e2ffa8eb47d7cd4e8353152c24cdb195cd6ff0702a2cb93b35802c9f0f77fcb77f242a53e9e9984416e5bf0209add69874f036f6
|
data/Rakefile
CHANGED
@@ -85,7 +85,7 @@ package_task = GNOME2::Rake::PackageTask.new do |package|
|
|
85
85
|
:name => "glib",
|
86
86
|
:download_site => :gnome,
|
87
87
|
:label => "GLib",
|
88
|
-
:version => "2.48.
|
88
|
+
:version => "2.48.1",
|
89
89
|
:compression_method => "xz",
|
90
90
|
:windows => {
|
91
91
|
:need_autoreconf => true,
|
@@ -168,7 +168,7 @@ package_task = GNOME2::Rake::PackageTask.new do |package|
|
|
168
168
|
:name => "glib-networking",
|
169
169
|
:download_site => :gnome,
|
170
170
|
:label => "glib-networking",
|
171
|
-
:version => "2.48.
|
171
|
+
:version => "2.48.2",
|
172
172
|
:compression_method => "xz",
|
173
173
|
:windows => {
|
174
174
|
:configure_args => [
|
data/ext/glib2/extconf.rb
CHANGED
@@ -47,7 +47,6 @@ have_func("ruby_set_current_source", ruby_header)
|
|
47
47
|
have_func("rb_thread_call_without_gvl", ruby_header)
|
48
48
|
have_func("ruby_native_thread_p", ruby_header)
|
49
49
|
have_func("rb_thread_call_with_gvl", ruby_header)
|
50
|
-
have_func("rb_str_new_cstr", ruby_header)
|
51
50
|
have_func("rb_gc_register_mark_object", ruby_header)
|
52
51
|
have_func("rb_exc_new_str", ruby_header)
|
53
52
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2015 Ruby-GNOME2 Project Team
|
3
|
+
* Copyright (C) 2015-2016 Ruby-GNOME2 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
|
@@ -286,10 +286,14 @@ Init_glib_variant_type(void)
|
|
286
286
|
DEF_TYPE(DICT_ENTRY);
|
287
287
|
DEF_TYPE(DICTIONARY);
|
288
288
|
DEF_TYPE(STRING_ARRAY);
|
289
|
+
# if GLIB_CHECK_VERSION(2, 30, 0)
|
289
290
|
DEF_TYPE(OBJECT_PATH_ARRAY);
|
291
|
+
# endif
|
290
292
|
DEF_TYPE(BYTESTRING);
|
291
293
|
DEF_TYPE(BYTESTRING_ARRAY);
|
294
|
+
# if GLIB_CHECK_VERSION(2, 30, 0)
|
292
295
|
DEF_TYPE(VARDICT);
|
296
|
+
# endif
|
293
297
|
|
294
298
|
#undef DEF_TYPE
|
295
299
|
}
|
data/ext/glib2/rbglib-variant.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2015 Ruby-GNOME2 Project Team
|
3
|
+
* Copyright (C) 2015-2016 Ruby-GNOME2 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
|
@@ -174,9 +174,7 @@ rg_ruby_to_variant(VALUE rb_value, VALUE rb_variant_type)
|
|
174
174
|
} else if (g_variant_type_equal(variant_type, G_VARIANT_TYPE_VARIANT)) {
|
175
175
|
return g_variant_new_variant(rbg_variant_from_ruby(rb_value));
|
176
176
|
} else if (g_variant_type_equal(variant_type,
|
177
|
-
G_VARIANT_TYPE_STRING_ARRAY)
|
178
|
-
g_variant_type_equal(variant_type,
|
179
|
-
G_VARIANT_TYPE_OBJECT_PATH_ARRAY)) {
|
177
|
+
G_VARIANT_TYPE_STRING_ARRAY)) {
|
180
178
|
const gchar **strings;
|
181
179
|
gssize length;
|
182
180
|
if (NIL_P(rb_value)) {
|
@@ -192,11 +190,27 @@ rg_ruby_to_variant(VALUE rb_value, VALUE rb_variant_type)
|
|
192
190
|
strings[i] = RVAL2CSTR_ACCEPT_NIL(rb_string);
|
193
191
|
}
|
194
192
|
}
|
195
|
-
|
196
|
-
|
193
|
+
return g_variant_new_strv(strings, length);
|
194
|
+
#if GLIB_CHECK_VERSION(2, 30, 0)
|
195
|
+
} else if (g_variant_type_equal(variant_type,
|
196
|
+
G_VARIANT_TYPE_OBJECT_PATH_ARRAY)) {
|
197
|
+
const gchar **paths;
|
198
|
+
gssize length;
|
199
|
+
if (NIL_P(rb_value)) {
|
200
|
+
paths = NULL;
|
201
|
+
length = 0;
|
197
202
|
} else {
|
198
|
-
|
203
|
+
gssize i;
|
204
|
+
|
205
|
+
length = RARRAY_LEN(rb_value);
|
206
|
+
paths = ALLOCA_N(const gchar *, length);
|
207
|
+
for (i = 0; i < length; i++) {
|
208
|
+
VALUE rb_path = RARRAY_PTR(rb_value)[i];
|
209
|
+
paths[i] = RVAL2CSTR_ACCEPT_NIL(rb_path);
|
210
|
+
}
|
199
211
|
}
|
212
|
+
return g_variant_new_objv(paths, length);
|
213
|
+
#endif
|
200
214
|
} else if (g_variant_type_equal(variant_type, G_VARIANT_TYPE_ARRAY)) {
|
201
215
|
int i;
|
202
216
|
GVariantBuilder builder;
|
data/ext/glib2/rbglib.c
CHANGED
@@ -34,10 +34,8 @@ rbg_rval2cstr(VALUE *str)
|
|
34
34
|
{
|
35
35
|
StringValue(*str);
|
36
36
|
|
37
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
38
37
|
if (rb_enc_get(*str) != rb_utf8_encoding())
|
39
38
|
*str = rb_str_export_to_enc(*str, rb_utf8_encoding());
|
40
|
-
#endif
|
41
39
|
|
42
40
|
return StringValueCStr(*str);
|
43
41
|
}
|
@@ -142,11 +140,7 @@ rbg_cstr2rval_len(const gchar *str, gsize len)
|
|
142
140
|
if (str == NULL)
|
143
141
|
return Qnil;
|
144
142
|
|
145
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
146
143
|
return rb_external_str_new_with_enc(str, len, rb_utf8_encoding());
|
147
|
-
#else
|
148
|
-
return rb_str_new(str, len);
|
149
|
-
#endif
|
150
144
|
}
|
151
145
|
|
152
146
|
struct rbg_cstr2rval_len_free_args {
|
@@ -185,7 +179,6 @@ rbg_cstr2rval_with_encoding(const gchar *str, const gchar *encoding)
|
|
185
179
|
return str != NULL ? CSTR2RVAL_LEN_ENC(str, strlen(str), encoding) : Qnil;
|
186
180
|
}
|
187
181
|
|
188
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
189
182
|
VALUE
|
190
183
|
rbg_cstr2rval_len_with_encoding(const gchar *str, gsize len,
|
191
184
|
const gchar *encoding)
|
@@ -198,17 +191,6 @@ rbg_cstr2rval_len_with_encoding(const gchar *str, gsize len,
|
|
198
191
|
rb_enc_find(encoding) :
|
199
192
|
rb_utf8_encoding());
|
200
193
|
}
|
201
|
-
#else
|
202
|
-
VALUE
|
203
|
-
rbg_cstr2rval_len_with_encoding(const gchar *str, gsize len,
|
204
|
-
G_GNUC_UNUSED const gchar *encoding)
|
205
|
-
{
|
206
|
-
if (str == NULL)
|
207
|
-
return Qnil;
|
208
|
-
|
209
|
-
return rb_str_new(str, len);
|
210
|
-
}
|
211
|
-
#endif
|
212
194
|
|
213
195
|
static VALUE
|
214
196
|
rbg_cstr2rval_free_body(VALUE str)
|
@@ -238,11 +220,8 @@ rbg_cstr2rval_with_free(gchar *str)
|
|
238
220
|
return rbg_cstr2rval_free(str);
|
239
221
|
}
|
240
222
|
|
241
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
242
223
|
static rb_encoding *filename_encoding_if_not_utf8;
|
243
|
-
#endif
|
244
224
|
|
245
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
246
225
|
static VALUE
|
247
226
|
rbg_filename_to_ruby_body(VALUE filename)
|
248
227
|
{
|
@@ -267,12 +246,10 @@ rbg_filename_to_ruby_ensure(VALUE filename)
|
|
267
246
|
|
268
247
|
return Qnil;
|
269
248
|
}
|
270
|
-
#endif
|
271
249
|
|
272
250
|
VALUE
|
273
251
|
rbg_filename_to_ruby(const gchar *filename)
|
274
252
|
{
|
275
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
276
253
|
gchar *filename_utf8;
|
277
254
|
gsize written;
|
278
255
|
GError *error = NULL;
|
@@ -289,15 +266,11 @@ rbg_filename_to_ruby(const gchar *filename)
|
|
289
266
|
|
290
267
|
return rb_ensure(rbg_filename_to_ruby_body, (VALUE)filename_utf8,
|
291
268
|
rbg_filename_to_ruby_ensure, (VALUE)filename_utf8);
|
292
|
-
#else
|
293
|
-
return CSTR2RVAL(filename);
|
294
|
-
#endif
|
295
269
|
}
|
296
270
|
|
297
271
|
VALUE
|
298
272
|
rbg_filename_to_ruby_free(gchar *filename)
|
299
273
|
{
|
300
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
301
274
|
gchar *filename_utf8;
|
302
275
|
gsize written;
|
303
276
|
|
@@ -318,15 +291,11 @@ rbg_filename_to_ruby_free(gchar *filename)
|
|
318
291
|
|
319
292
|
return rb_ensure(rbg_filename_to_ruby_body, (VALUE)filename_utf8,
|
320
293
|
rbg_filename_to_ruby_ensure, (VALUE)filename_utf8);
|
321
|
-
#else
|
322
|
-
return CSTR2RVAL_FREE(filename);
|
323
|
-
#endif
|
324
294
|
}
|
325
295
|
|
326
296
|
gchar *
|
327
297
|
rbg_filename_from_ruby(VALUE filename)
|
328
298
|
{
|
329
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
330
299
|
gchar *retval;
|
331
300
|
gsize written;
|
332
301
|
GError *error = NULL;
|
@@ -345,9 +314,6 @@ rbg_filename_from_ruby(VALUE filename)
|
|
345
314
|
RAISE_GERROR(error);
|
346
315
|
|
347
316
|
return retval;
|
348
|
-
#else
|
349
|
-
return g_strdup(RVAL2CSTR(filename));
|
350
|
-
#endif
|
351
317
|
}
|
352
318
|
|
353
319
|
struct rval2strv_args {
|
@@ -1013,9 +979,7 @@ extern void Init_glib2(void);
|
|
1013
979
|
void
|
1014
980
|
Init_glib2(void)
|
1015
981
|
{
|
1016
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
1017
982
|
const gchar **filename_charsets;
|
1018
|
-
#endif
|
1019
983
|
|
1020
984
|
id_inspect = rb_intern("inspect");
|
1021
985
|
|
@@ -1096,7 +1060,6 @@ Init_glib2(void)
|
|
1096
1060
|
rb_define_const(RG_TARGET_NAMESPACE, "SEARCHPATH_SEPARATOR", CSTR2RVAL(G_SEARCHPATH_SEPARATOR_S));
|
1097
1061
|
|
1098
1062
|
/* discover and store glib filename encoding */
|
1099
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
1100
1063
|
if (g_get_filename_charsets(&filename_charsets)
|
1101
1064
|
|| filename_charsets == NULL
|
1102
1065
|
|| filename_charsets[0] == NULL
|
@@ -1108,7 +1071,6 @@ Init_glib2(void)
|
|
1108
1071
|
} else {
|
1109
1072
|
filename_encoding_if_not_utf8 = rb_enc_find(filename_charsets[0]);
|
1110
1073
|
}
|
1111
|
-
#endif
|
1112
1074
|
|
1113
1075
|
/* Don't implement them.
|
1114
1076
|
#define G_DIR_SEPARATOR_S
|
data/ext/glib2/rbglib.h
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-2016 Ruby-GNOME2 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
|
@@ -36,7 +36,7 @@ extern "C" {
|
|
36
36
|
|
37
37
|
#define RBGLIB_MAJOR_VERSION 3
|
38
38
|
#define RBGLIB_MINOR_VERSION 0
|
39
|
-
#define RBGLIB_MICRO_VERSION
|
39
|
+
#define RBGLIB_MICRO_VERSION 9
|
40
40
|
|
41
41
|
#ifndef RB_ZALLOC
|
42
42
|
# ifdef ZALLOC
|
data/ext/glib2/rbglib_convert.c
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
3
|
+
* Copyright (C) 2011-2016 Ruby-GNOME2 Project Team
|
4
4
|
* Copyright (C) 2009 Ruby-GNOME2 Project Team
|
5
5
|
* Copyright (C) 2002,2003 KUBO Takehiro
|
6
6
|
*
|
@@ -49,7 +49,6 @@ static VALUE
|
|
49
49
|
rg_s_locale_to_utf8(G_GNUC_UNUSED VALUE self, VALUE str)
|
50
50
|
{
|
51
51
|
GError *err = NULL;
|
52
|
-
VALUE s = Qnil;
|
53
52
|
gchar* ret;
|
54
53
|
gsize written;
|
55
54
|
|
@@ -59,9 +58,7 @@ rg_s_locale_to_utf8(G_GNUC_UNUSED VALUE self, VALUE str)
|
|
59
58
|
|
60
59
|
if (err != NULL)
|
61
60
|
RAISE_GERROR(err);
|
62
|
-
|
63
|
-
g_free(ret);
|
64
|
-
return s;
|
61
|
+
return CSTR2RVAL_LEN_FREE(ret, written);
|
65
62
|
}
|
66
63
|
|
67
64
|
static VALUE
|
@@ -87,7 +84,6 @@ static VALUE
|
|
87
84
|
rg_s_filename_to_utf8(G_GNUC_UNUSED VALUE self, VALUE str)
|
88
85
|
{
|
89
86
|
GError *err = NULL;
|
90
|
-
VALUE s = Qnil;
|
91
87
|
gchar* ret;
|
92
88
|
gsize written;
|
93
89
|
|
@@ -97,9 +93,7 @@ rg_s_filename_to_utf8(G_GNUC_UNUSED VALUE self, VALUE str)
|
|
97
93
|
|
98
94
|
if (err != NULL)
|
99
95
|
RAISE_GERROR(err);
|
100
|
-
|
101
|
-
g_free(ret);
|
102
|
-
return s;
|
96
|
+
return CSTR2RVAL_LEN_FREE(ret, written);
|
103
97
|
}
|
104
98
|
|
105
99
|
static VALUE
|
@@ -22,6 +22,7 @@
|
|
22
22
|
#define RG_TARGET_NAMESPACE cMatchInfo
|
23
23
|
#define _SELF(s) ((GMatchInfo*)RVAL2BOXED(s, G_TYPE_MATCH_INFO))
|
24
24
|
|
25
|
+
#if GLIB_CHECK_VERSION(2, 30, 0)
|
25
26
|
static VALUE
|
26
27
|
rg_regex(VALUE self)
|
27
28
|
{
|
@@ -157,10 +158,12 @@ rg_expand_references(VALUE self, VALUE rb_string)
|
|
157
158
|
|
158
159
|
return CSTR2RVAL_FREE(expanded_string);
|
159
160
|
}
|
161
|
+
#endif
|
160
162
|
|
161
163
|
void
|
162
164
|
Init_glib_matchinfo(void)
|
163
165
|
{
|
166
|
+
#if GLIB_CHECK_VERSION(2, 30, 0)
|
164
167
|
VALUE RG_TARGET_NAMESPACE;
|
165
168
|
|
166
169
|
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_MATCH_INFO, "MatchInfo", mGLib);
|
@@ -176,4 +179,5 @@ Init_glib_matchinfo(void)
|
|
176
179
|
RG_DEF_METHOD(fetch_all, 0);
|
177
180
|
RG_DEF_METHOD(next, 0);
|
178
181
|
RG_DEF_METHOD(expand_references, 1);
|
182
|
+
#endif
|
179
183
|
}
|
data/ext/glib2/rbglib_regex.c
CHANGED
@@ -136,6 +136,7 @@ rg_split(gint argc, VALUE *argv, VALUE self)
|
|
136
136
|
return STRV2RVAL_FREE(strings);
|
137
137
|
}
|
138
138
|
|
139
|
+
#if GLIB_CHECK_VERSION(2, 30, 0)
|
139
140
|
static VALUE
|
140
141
|
rg_match(gint argc, VALUE *argv, VALUE self)
|
141
142
|
{
|
@@ -190,6 +191,7 @@ rg_match(gint argc, VALUE *argv, VALUE self)
|
|
190
191
|
rb_iv_set(rb_match_info, "@string", rb_frozen_string);
|
191
192
|
return rb_match_info;
|
192
193
|
}
|
194
|
+
#endif
|
193
195
|
|
194
196
|
static VALUE
|
195
197
|
rg_max_backref(VALUE self)
|
@@ -203,6 +205,7 @@ rg_capture_count(VALUE self)
|
|
203
205
|
return INT2NUM(g_regex_get_capture_count(_SELF(self)));
|
204
206
|
}
|
205
207
|
|
208
|
+
#if GLIB_CHECK_VERSION(2, 34, 0)
|
206
209
|
static VALUE
|
207
210
|
rg_has_cr_or_lf_p(VALUE self)
|
208
211
|
{
|
@@ -214,6 +217,7 @@ rg_max_lookbehind(VALUE self)
|
|
214
217
|
{
|
215
218
|
return INT2NUM(g_regex_get_max_lookbehind(_SELF(self)));
|
216
219
|
}
|
220
|
+
#endif
|
217
221
|
|
218
222
|
static VALUE
|
219
223
|
rg_string_number(VALUE self, VALUE string)
|
@@ -221,6 +225,7 @@ rg_string_number(VALUE self, VALUE string)
|
|
221
225
|
return INT2NUM(g_regex_get_string_number(_SELF(self), RVAL2CSTR(string)));
|
222
226
|
}
|
223
227
|
|
228
|
+
#if GLIB_CHECK_VERSION(2, 30, 0)
|
224
229
|
static VALUE
|
225
230
|
rg_match_all(gint argc, VALUE *argv, VALUE self)
|
226
231
|
{
|
@@ -418,7 +423,7 @@ rg_replace(gint argc, VALUE *argv, VALUE self)
|
|
418
423
|
|
419
424
|
return CSTR2RVAL_FREE(modified_string);
|
420
425
|
}
|
421
|
-
|
426
|
+
#endif
|
422
427
|
|
423
428
|
static VALUE
|
424
429
|
rg_s_escape_string(G_GNUC_UNUSED VALUE self, VALUE string)
|
@@ -466,14 +471,20 @@ Init_glib_regex(void)
|
|
466
471
|
RG_DEF_METHOD(compile_flags, 0);
|
467
472
|
RG_DEF_METHOD(match_flags, 0);
|
468
473
|
RG_DEF_METHOD(split, -1);
|
474
|
+
#if GLIB_CHECK_VERSION(2, 30, 0)
|
469
475
|
RG_DEF_METHOD(match, -1);
|
476
|
+
#endif
|
470
477
|
RG_DEF_METHOD(max_backref, 0);
|
471
478
|
RG_DEF_METHOD(capture_count, 0);
|
479
|
+
#if GLIB_CHECK_VERSION(2, 34, 0)
|
472
480
|
RG_DEF_METHOD_P(has_cr_or_lf, 0);
|
473
481
|
RG_DEF_METHOD(max_lookbehind, 0);
|
482
|
+
#endif
|
474
483
|
RG_DEF_METHOD(string_number, 1);
|
484
|
+
#if GLIB_CHECK_VERSION(2, 30, 0)
|
475
485
|
RG_DEF_METHOD(match_all, -1);
|
476
486
|
RG_DEF_METHOD(replace, -1);
|
487
|
+
#endif
|
477
488
|
|
478
489
|
RG_DEF_SMETHOD(escape_string, 1);
|
479
490
|
RG_DEF_SMETHOD(check_replacement, 1);
|
data/ext/glib2/rbgobj_object.c
CHANGED
@@ -302,7 +302,7 @@ rbgobj_gobject_new(GType gtype, VALUE params_hash)
|
|
302
302
|
size_t param_size;
|
303
303
|
struct param_setup_arg arg;
|
304
304
|
|
305
|
-
param_size = NUM2INT(rb_funcall(params_hash, rb_intern("length"), 0));
|
305
|
+
param_size = NUM2INT(rb_funcall(params_hash, rb_intern("length"), 0));
|
306
306
|
|
307
307
|
arg.param_size = param_size;
|
308
308
|
arg.gclass = G_OBJECT_CLASS(g_type_class_ref(gtype));
|
@@ -621,19 +621,97 @@ rg_type_name(VALUE self)
|
|
621
621
|
}
|
622
622
|
|
623
623
|
#if GLIB_CHECK_VERSION(2, 26, 0)
|
624
|
+
typedef struct {
|
625
|
+
VALUE transform_from_callback;
|
626
|
+
VALUE transform_to_callback;
|
627
|
+
VALUE self;
|
628
|
+
} RGBindPropertyCallbackData;
|
629
|
+
|
630
|
+
static gboolean
|
631
|
+
rg_bind_property_transform_to_callback(G_GNUC_UNUSED GBinding *binding,
|
632
|
+
const GValue *from_value,
|
633
|
+
GValue *to_value,
|
634
|
+
gpointer user_data)
|
635
|
+
{
|
636
|
+
RGBindPropertyCallbackData *data = (RGBindPropertyCallbackData *)user_data;
|
637
|
+
VALUE proc;
|
638
|
+
VALUE rb_from_value;
|
639
|
+
VALUE rb_to_value;
|
640
|
+
|
641
|
+
proc = data->transform_to_callback;
|
642
|
+
if (NIL_P(proc))
|
643
|
+
return FALSE;
|
644
|
+
|
645
|
+
rb_from_value = rbgobj_gvalue_to_rvalue(from_value);
|
646
|
+
rb_to_value = rbgobj_gvalue_to_rvalue(to_value);
|
647
|
+
rb_to_value = rb_funcall(proc, rb_intern("call"), 1, rb_from_value);
|
648
|
+
rbgobj_rvalue_to_gvalue(rb_to_value, to_value);
|
649
|
+
return TRUE;
|
650
|
+
}
|
651
|
+
|
652
|
+
static gboolean
|
653
|
+
rg_bind_property_transform_from_callback(G_GNUC_UNUSED GBinding *binding,
|
654
|
+
const GValue *from_value,
|
655
|
+
GValue *to_value,
|
656
|
+
gpointer user_data)
|
657
|
+
{
|
658
|
+
RGBindPropertyCallbackData *data = (RGBindPropertyCallbackData *)user_data;
|
659
|
+
VALUE proc;
|
660
|
+
VALUE rb_from_value;
|
661
|
+
VALUE rb_to_value;
|
662
|
+
|
663
|
+
proc = data->transform_from_callback;
|
664
|
+
if (NIL_P(proc))
|
665
|
+
return FALSE;
|
666
|
+
|
667
|
+
rb_from_value = rbgobj_gvalue_to_rvalue(from_value);
|
668
|
+
rb_to_value = rbgobj_gvalue_to_rvalue(to_value);
|
669
|
+
rb_to_value = rb_funcall(proc, rb_intern("call"), 1, rb_from_value);
|
670
|
+
rbgobj_rvalue_to_gvalue(rb_to_value, to_value);
|
671
|
+
return TRUE;
|
672
|
+
}
|
673
|
+
|
674
|
+
static void
|
675
|
+
rg_destroy_bind_property_full_data(gpointer user_data)
|
676
|
+
{
|
677
|
+
RGBindPropertyCallbackData *data = (RGBindPropertyCallbackData *)user_data;
|
678
|
+
|
679
|
+
if (!NIL_P(data->transform_to_callback))
|
680
|
+
G_CHILD_REMOVE(data->self, data->transform_to_callback);
|
681
|
+
|
682
|
+
if (!NIL_P(data->transform_from_callback))
|
683
|
+
G_CHILD_REMOVE(data->self, data->transform_from_callback);
|
684
|
+
|
685
|
+
xfree(data);
|
686
|
+
}
|
687
|
+
|
624
688
|
static VALUE
|
625
|
-
rg_bind_property(VALUE self
|
626
|
-
VALUE rb_source_property,
|
627
|
-
VALUE rb_target,
|
628
|
-
VALUE rb_target_property,
|
629
|
-
VALUE rb_flags)
|
689
|
+
rg_bind_property(gint argc, VALUE *argv, VALUE self)
|
630
690
|
{
|
691
|
+
VALUE rb_source_property;
|
692
|
+
VALUE rb_target;
|
693
|
+
VALUE rb_target_property;
|
694
|
+
VALUE rb_flags;
|
695
|
+
VALUE rb_options;
|
696
|
+
VALUE rb_transform_to;
|
697
|
+
VALUE rb_transform_from;
|
698
|
+
|
631
699
|
gpointer source;
|
632
700
|
const gchar *source_property;
|
633
701
|
gpointer target;
|
634
702
|
const gchar *target_property;
|
635
703
|
GBindingFlags flags;
|
636
704
|
GBinding *binding;
|
705
|
+
GBindingTransformFunc transform_to = NULL;
|
706
|
+
GBindingTransformFunc transform_from = NULL;
|
707
|
+
|
708
|
+
rb_scan_args(argc, argv, "41", &rb_source_property, &rb_target,
|
709
|
+
&rb_target_property, &rb_flags, &rb_options);
|
710
|
+
|
711
|
+
rbg_scan_options(rb_options,
|
712
|
+
"transform_to", &rb_transform_to,
|
713
|
+
"transform_from", &rb_transform_from,
|
714
|
+
NULL);
|
637
715
|
|
638
716
|
source = RVAL2GOBJ(self);
|
639
717
|
source_property = RVAL2CSTR(rb_source_property);
|
@@ -641,9 +719,33 @@ rg_bind_property(VALUE self,
|
|
641
719
|
target_property = RVAL2CSTR(rb_target_property);
|
642
720
|
flags = RVAL2GBINDINGFLAGS(rb_flags);
|
643
721
|
|
644
|
-
|
645
|
-
|
646
|
-
|
722
|
+
if (!NIL_P(rb_transform_to)) {
|
723
|
+
G_CHILD_ADD(self, rb_transform_to);
|
724
|
+
transform_to = rg_bind_property_transform_to_callback;
|
725
|
+
}
|
726
|
+
|
727
|
+
if (!NIL_P(rb_transform_from)) {
|
728
|
+
G_CHILD_ADD(self, rb_transform_from);
|
729
|
+
transform_from = rg_bind_property_transform_from_callback;
|
730
|
+
}
|
731
|
+
|
732
|
+
if (transform_to || transform_from) {
|
733
|
+
RGBindPropertyCallbackData *data;
|
734
|
+
data = (RGBindPropertyCallbackData *)xmalloc(sizeof(RGBindPropertyCallbackData));
|
735
|
+
data->self = self;
|
736
|
+
data->transform_to_callback = rb_transform_to;
|
737
|
+
data->transform_from_callback = rb_transform_from;
|
738
|
+
binding = g_object_bind_property_full(source, source_property,
|
739
|
+
target, target_property,
|
740
|
+
flags, transform_to,
|
741
|
+
transform_from,
|
742
|
+
(gpointer)data,
|
743
|
+
rg_destroy_bind_property_full_data);
|
744
|
+
} else {
|
745
|
+
binding = g_object_bind_property(source, source_property,
|
746
|
+
target, target_property,
|
747
|
+
flags);
|
748
|
+
}
|
647
749
|
|
648
750
|
return GOBJ2RVAL(binding);
|
649
751
|
}
|
@@ -882,7 +984,7 @@ Init_gobject_gobject(void)
|
|
882
984
|
RG_DEF_METHOD(type_name, 0);
|
883
985
|
|
884
986
|
#if GLIB_CHECK_VERSION(2, 26, 0)
|
885
|
-
RG_DEF_METHOD(bind_property,
|
987
|
+
RG_DEF_METHOD(bind_property, -1);
|
886
988
|
G_DEF_CLASS(G_TYPE_BINDING_FLAGS, "BindingFlags", mGLib);
|
887
989
|
#endif
|
888
990
|
|