glib2 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +3023 -0
- data/README +28 -0
- data/Rakefile +87 -0
- data/extconf.rb +61 -0
- data/sample/bookmarkfile.rb +66 -0
- data/sample/completion.rb +45 -0
- data/sample/idle.rb +41 -0
- data/sample/iochannel.rb +44 -0
- data/sample/keyfile.rb +62 -0
- data/sample/shell.rb +36 -0
- data/sample/spawn.rb +25 -0
- data/sample/timeout.rb +28 -0
- data/sample/timeout2.rb +35 -0
- data/sample/timer.rb +40 -0
- data/sample/type-register.rb +103 -0
- data/sample/type-register2.rb +104 -0
- data/sample/utils.rb +54 -0
- data/src/glib-enum-types.c +1032 -0
- data/src/glib-enum-types.h +140 -0
- data/src/lib/glib-mkenums.rb +199 -0
- data/src/lib/glib2.rb +220 -0
- data/src/lib/mkmf-gnome2.rb +390 -0
- data/src/lib/pkg-config.rb +137 -0
- data/src/rbgcompat.h +30 -0
- data/src/rbglib.c +320 -0
- data/src/rbglib.h +96 -0
- data/src/rbglib_bookmarkfile.c +595 -0
- data/src/rbglib_completion.c +192 -0
- data/src/rbglib_convert.c +195 -0
- data/src/rbglib_error.c +95 -0
- data/src/rbglib_fileutils.c +83 -0
- data/src/rbglib_i18n.c +44 -0
- data/src/rbglib_int64.c +157 -0
- data/src/rbglib_iochannel.c +883 -0
- data/src/rbglib_keyfile.c +846 -0
- data/src/rbglib_maincontext.c +917 -0
- data/src/rbglib_mainloop.c +87 -0
- data/src/rbglib_messages.c +150 -0
- data/src/rbglib_pollfd.c +111 -0
- data/src/rbglib_shell.c +68 -0
- data/src/rbglib_source.c +190 -0
- data/src/rbglib_spawn.c +345 -0
- data/src/rbglib_threads.c +51 -0
- data/src/rbglib_timer.c +127 -0
- data/src/rbglib_unicode.c +611 -0
- data/src/rbglib_utils.c +386 -0
- data/src/rbglib_win32.c +136 -0
- data/src/rbgobj_boxed.c +251 -0
- data/src/rbgobj_closure.c +337 -0
- data/src/rbgobj_convert.c +167 -0
- data/src/rbgobj_enums.c +961 -0
- data/src/rbgobj_fundamental.c +30 -0
- data/src/rbgobj_object.c +892 -0
- data/src/rbgobj_param.c +390 -0
- data/src/rbgobj_paramspecs.c +305 -0
- data/src/rbgobj_signal.c +963 -0
- data/src/rbgobj_strv.c +61 -0
- data/src/rbgobj_type.c +851 -0
- data/src/rbgobj_typeinstance.c +121 -0
- data/src/rbgobj_typeinterface.c +148 -0
- data/src/rbgobj_typemodule.c +66 -0
- data/src/rbgobj_typeplugin.c +49 -0
- data/src/rbgobj_value.c +313 -0
- data/src/rbgobj_valuearray.c +59 -0
- data/src/rbgobj_valuetypes.c +298 -0
- data/src/rbgobject.c +406 -0
- data/src/rbgobject.h +265 -0
- data/src/rbgprivate.h +88 -0
- data/src/rbgutil.c +222 -0
- data/src/rbgutil.h +82 -0
- data/src/rbgutil_callback.c +231 -0
- data/test/glib-test-init.rb +6 -0
- data/test/glib-test-utils.rb +12 -0
- data/test/run-test.rb +25 -0
- data/test/test_enum.rb +99 -0
- data/test/test_file_utils.rb +15 -0
- data/test/test_glib2.rb +120 -0
- data/test/test_iochannel.rb +275 -0
- data/test/test_key_file.rb +38 -0
- data/test/test_mkenums.rb +25 -0
- data/test/test_signal.rb +20 -0
- data/test/test_timeout.rb +28 -0
- data/test/test_unicode.rb +369 -0
- data/test/test_utils.rb +37 -0
- data/test/test_win32.rb +13 -0
- metadata +165 -0
data/src/rbglib_utils.c
ADDED
@@ -0,0 +1,386 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/**********************************************************************
|
3
|
+
|
4
|
+
rbglib_utils.c -
|
5
|
+
|
6
|
+
$Author: ggc $
|
7
|
+
$Date: 2007/07/13 16:07:28 $
|
8
|
+
|
9
|
+
Copyright (C) 2004 Ruby-GNOME2 Project Team
|
10
|
+
Copyright (C) 2004 Pascal Terjan
|
11
|
+
|
12
|
+
**********************************************************************/
|
13
|
+
|
14
|
+
#include "rbgprivate.h"
|
15
|
+
|
16
|
+
#if GLIB_CHECK_VERSION(2,2,0)
|
17
|
+
static VALUE
|
18
|
+
rbglib_m_application_name(self)
|
19
|
+
VALUE self;
|
20
|
+
{
|
21
|
+
return CSTR2RVAL(g_get_application_name());
|
22
|
+
}
|
23
|
+
|
24
|
+
static VALUE
|
25
|
+
rbglib_m_set_application_name(self, application_name)
|
26
|
+
VALUE self, application_name;
|
27
|
+
{
|
28
|
+
g_set_prgname(NIL_P(application_name) ? NULL : RVAL2CSTR(application_name));
|
29
|
+
return self;
|
30
|
+
}
|
31
|
+
#endif
|
32
|
+
|
33
|
+
static VALUE
|
34
|
+
rbglib_m_prgname(self)
|
35
|
+
VALUE self;
|
36
|
+
{
|
37
|
+
return CSTR2RVAL(g_get_prgname());
|
38
|
+
}
|
39
|
+
|
40
|
+
static VALUE
|
41
|
+
rbglib_m_set_prgname(self, prgname)
|
42
|
+
VALUE self, prgname;
|
43
|
+
{
|
44
|
+
g_set_prgname(NIL_P(prgname) ? NULL : RVAL2CSTR(prgname));
|
45
|
+
return self;
|
46
|
+
}
|
47
|
+
|
48
|
+
static VALUE
|
49
|
+
rbglib_m_env(self, variable)
|
50
|
+
VALUE self, variable;
|
51
|
+
{
|
52
|
+
return CSTR2RVAL(g_getenv(RVAL2CSTR(variable)));
|
53
|
+
}
|
54
|
+
|
55
|
+
#if GLIB_CHECK_VERSION(2,4,0)
|
56
|
+
static VALUE
|
57
|
+
rbglib_m_setenv(self, variable, value, overwrite)
|
58
|
+
VALUE self, variable, value, overwrite;
|
59
|
+
{
|
60
|
+
return CBOOL2RVAL(g_setenv(RVAL2CSTR(variable),
|
61
|
+
NIL_P(value) ? NULL : RVAL2CSTR(value),
|
62
|
+
RVAL2CBOOL(overwrite)));
|
63
|
+
}
|
64
|
+
|
65
|
+
static VALUE
|
66
|
+
rbglib_m_unsetenv(self, variable)
|
67
|
+
VALUE self, variable;
|
68
|
+
{
|
69
|
+
g_unsetenv(RVAL2CSTR(variable));
|
70
|
+
return self;
|
71
|
+
}
|
72
|
+
#endif
|
73
|
+
|
74
|
+
#if GLIB_CHECK_VERSION(2,8,0)
|
75
|
+
#if HAVE_G_LISTENV
|
76
|
+
static VALUE
|
77
|
+
rbglib_m_listenv(self)
|
78
|
+
VALUE self;
|
79
|
+
{
|
80
|
+
gchar** c_list;
|
81
|
+
gchar** c_var;
|
82
|
+
VALUE r_list = rb_ary_new();
|
83
|
+
c_list = g_listenv();
|
84
|
+
c_var = c_list;
|
85
|
+
while(*c_var) {
|
86
|
+
rb_ary_push(r_list, rb_str_new2(*(c_var++)));
|
87
|
+
}
|
88
|
+
g_strfreev(c_list);
|
89
|
+
return r_list;
|
90
|
+
}
|
91
|
+
#endif
|
92
|
+
|
93
|
+
static VALUE
|
94
|
+
rbglib_m_host_name(self)
|
95
|
+
VALUE self;
|
96
|
+
{
|
97
|
+
return CSTR2RVAL(g_get_host_name());
|
98
|
+
}
|
99
|
+
#endif
|
100
|
+
|
101
|
+
static VALUE
|
102
|
+
rbglib_m_user_name(self)
|
103
|
+
VALUE self;
|
104
|
+
{
|
105
|
+
return CSTR2RVAL(g_get_user_name());
|
106
|
+
}
|
107
|
+
|
108
|
+
static VALUE
|
109
|
+
rbglib_m_real_name(self)
|
110
|
+
VALUE self;
|
111
|
+
{
|
112
|
+
return CSTR2RVAL(g_get_real_name());
|
113
|
+
}
|
114
|
+
|
115
|
+
#if GLIB_CHECK_VERSION(2, 6, 0)
|
116
|
+
static VALUE
|
117
|
+
rbglib_m_user_cache_dir(VALUE self)
|
118
|
+
{
|
119
|
+
return CSTR2RVAL(g_get_user_cache_dir());
|
120
|
+
}
|
121
|
+
|
122
|
+
static VALUE
|
123
|
+
rbglib_m_user_data_dir(VALUE self)
|
124
|
+
{
|
125
|
+
return CSTR2RVAL(g_get_user_data_dir());
|
126
|
+
}
|
127
|
+
|
128
|
+
static VALUE
|
129
|
+
rbglib_m_user_config_dir(VALUE self)
|
130
|
+
{
|
131
|
+
return CSTR2RVAL(g_get_user_config_dir());
|
132
|
+
}
|
133
|
+
|
134
|
+
static VALUE
|
135
|
+
strv_to_array(const gchar * const *strv)
|
136
|
+
{
|
137
|
+
VALUE array;
|
138
|
+
|
139
|
+
array = rb_ary_new();
|
140
|
+
for (; *strv; strv++) {
|
141
|
+
rb_ary_push(array, CSTR2RVAL(*strv));
|
142
|
+
}
|
143
|
+
|
144
|
+
return array;
|
145
|
+
}
|
146
|
+
|
147
|
+
static VALUE
|
148
|
+
rbglib_m_system_data_dirs(VALUE self)
|
149
|
+
{
|
150
|
+
return strv_to_array(g_get_system_data_dirs());
|
151
|
+
}
|
152
|
+
|
153
|
+
static VALUE
|
154
|
+
rbglib_m_system_config_dirs(VALUE self)
|
155
|
+
{
|
156
|
+
return strv_to_array(g_get_system_config_dirs());
|
157
|
+
}
|
158
|
+
#endif
|
159
|
+
|
160
|
+
#if GLIB_CHECK_VERSION(2, 14, 0)
|
161
|
+
static VALUE
|
162
|
+
rbglib_m_get_user_special_dir(VALUE self, VALUE directory)
|
163
|
+
{
|
164
|
+
return CSTR2RVAL(g_get_user_special_dir(RVAL2GENUM(directory,
|
165
|
+
G_TYPE_USER_DIRECTORY)));
|
166
|
+
}
|
167
|
+
#endif
|
168
|
+
|
169
|
+
static VALUE
|
170
|
+
rbglib_m_home_dir(self)
|
171
|
+
VALUE self;
|
172
|
+
{
|
173
|
+
return CSTR2RVAL(g_get_home_dir());
|
174
|
+
}
|
175
|
+
|
176
|
+
static VALUE
|
177
|
+
rbglib_m_tmp_dir(self)
|
178
|
+
VALUE self;
|
179
|
+
{
|
180
|
+
return CSTR2RVAL(g_get_tmp_dir());
|
181
|
+
}
|
182
|
+
|
183
|
+
static VALUE
|
184
|
+
rbglib_m_current_dir(self)
|
185
|
+
VALUE self;
|
186
|
+
{
|
187
|
+
gchar* dir = g_get_current_dir();
|
188
|
+
VALUE ret = CSTR2RVAL(dir);
|
189
|
+
g_free(dir);
|
190
|
+
return ret;
|
191
|
+
}
|
192
|
+
|
193
|
+
static VALUE
|
194
|
+
rbglib_m_path_is_absolute(self, fname)
|
195
|
+
VALUE self, fname;
|
196
|
+
{
|
197
|
+
return CBOOL2RVAL(g_path_is_absolute(RVAL2CSTR(fname)));
|
198
|
+
}
|
199
|
+
|
200
|
+
static VALUE
|
201
|
+
rbglib_m_path_skip_root(self, fname)
|
202
|
+
VALUE self, fname;
|
203
|
+
{
|
204
|
+
return CSTR2RVAL(g_path_skip_root(RVAL2CSTR(fname)));
|
205
|
+
}
|
206
|
+
|
207
|
+
static VALUE
|
208
|
+
rbglib_m_path_get_basename(self, fname)
|
209
|
+
VALUE self, fname;
|
210
|
+
{
|
211
|
+
return CSTR2RVAL(g_path_get_basename(RVAL2CSTR(fname)));
|
212
|
+
}
|
213
|
+
|
214
|
+
static VALUE
|
215
|
+
rbglib_m_path_get_dirname(self, fname)
|
216
|
+
VALUE self, fname;
|
217
|
+
{
|
218
|
+
return CSTR2RVAL(g_path_get_dirname(RVAL2CSTR(fname)));
|
219
|
+
}
|
220
|
+
|
221
|
+
/*
|
222
|
+
Use File.join()
|
223
|
+
gchar* g_build_filename (const gchar *first_element,
|
224
|
+
...);
|
225
|
+
gchar* g_build_filenamev (gchar **args);
|
226
|
+
gchar* g_build_path (const gchar *separator,
|
227
|
+
const gchar *first_element,
|
228
|
+
...);
|
229
|
+
gchar* g_build_pathv (const gchar *separator,
|
230
|
+
gchar **args);
|
231
|
+
*/
|
232
|
+
|
233
|
+
static VALUE
|
234
|
+
rbglib_m_find_program_in_path(self, program)
|
235
|
+
VALUE self, program;
|
236
|
+
{
|
237
|
+
gchar* path = g_find_program_in_path(RVAL2CSTR(program));
|
238
|
+
VALUE ret = CSTR2RVAL(path);
|
239
|
+
g_free(path);
|
240
|
+
return ret;
|
241
|
+
}
|
242
|
+
|
243
|
+
static VALUE
|
244
|
+
rbglib_m_bit_nth_lsf(self, mask, nth_bit)
|
245
|
+
VALUE self, mask, nth_bit;
|
246
|
+
{
|
247
|
+
return INT2NUM(g_bit_nth_lsf(NUM2ULONG(mask), NUM2INT(nth_bit)));
|
248
|
+
}
|
249
|
+
|
250
|
+
static VALUE
|
251
|
+
rbglib_m_bit_nth_msf(self, mask, nth_bit)
|
252
|
+
VALUE self, mask, nth_bit;
|
253
|
+
{
|
254
|
+
return INT2NUM(g_bit_nth_msf(NUM2ULONG(mask), NUM2INT(nth_bit)));
|
255
|
+
}
|
256
|
+
|
257
|
+
static VALUE
|
258
|
+
rbglib_m_bit_storage(self, number)
|
259
|
+
VALUE self, number;
|
260
|
+
{
|
261
|
+
return UINT2NUM(g_bit_storage(NUM2ULONG(number)));
|
262
|
+
}
|
263
|
+
|
264
|
+
static VALUE
|
265
|
+
rbglib_m_spaced_primes_closest(self, num)
|
266
|
+
VALUE self, num;
|
267
|
+
{
|
268
|
+
return UINT2NUM(g_spaced_primes_closest(NUM2UINT(num)));
|
269
|
+
}
|
270
|
+
|
271
|
+
/*
|
272
|
+
Use at_exit of ruby instead.
|
273
|
+
void g_atexit (GVoidFunc func);
|
274
|
+
*/
|
275
|
+
|
276
|
+
static VALUE
|
277
|
+
rbglib_m_parse_debug_string(self, string, keys)
|
278
|
+
VALUE self, string, keys;
|
279
|
+
{
|
280
|
+
gint i, nkeys;
|
281
|
+
VALUE ary, ret;
|
282
|
+
GDebugKey* gkeys;
|
283
|
+
|
284
|
+
Check_Type(keys, T_HASH);
|
285
|
+
ary = rb_funcall(keys, rb_intern("to_a"), 0);
|
286
|
+
nkeys = RARRAY_LEN(ary);
|
287
|
+
gkeys = g_new(GDebugKey, nkeys);
|
288
|
+
for (i = 0; i < nkeys; i++) {
|
289
|
+
gkeys[i].key = RVAL2CSTR(RARRAY_PTR(RARRAY_PTR(ary)[i])[0]);
|
290
|
+
gkeys[i].value = NUM2UINT(RARRAY_PTR(RARRAY_PTR(ary)[i])[1]);
|
291
|
+
}
|
292
|
+
|
293
|
+
ret = UINT2NUM(g_parse_debug_string(RVAL2CSTR(string), gkeys, nkeys));
|
294
|
+
g_free(gkeys);
|
295
|
+
return ret;
|
296
|
+
}
|
297
|
+
|
298
|
+
/*
|
299
|
+
void (*GVoidFunc) (void);
|
300
|
+
void (*GFreeFunc) (gpointer data);
|
301
|
+
|
302
|
+
Don't need them.
|
303
|
+
void g_qsort_with_data (gconstpointer pbase,
|
304
|
+
gint total_elems,
|
305
|
+
gsize size,
|
306
|
+
GCompareDataFunc compare_func,
|
307
|
+
gpointer user_data);
|
308
|
+
|
309
|
+
void g_nullify_pointer (gpointer *nullify_location);
|
310
|
+
*/
|
311
|
+
|
312
|
+
static VALUE
|
313
|
+
rbglib_m_check_version(self, major, minor, micro)
|
314
|
+
VALUE self, major, minor, micro;
|
315
|
+
{
|
316
|
+
return CBOOL2RVAL(glib_major_version > NUM2UINT(major) ||
|
317
|
+
(glib_major_version == NUM2UINT(major) &&
|
318
|
+
glib_minor_version > NUM2UINT(minor)) ||
|
319
|
+
(glib_major_version == NUM2UINT(major) &&
|
320
|
+
glib_minor_version == NUM2UINT(minor) &&
|
321
|
+
glib_micro_version >= NUM2UINT(micro)));
|
322
|
+
}
|
323
|
+
|
324
|
+
void
|
325
|
+
Init_glib_utils()
|
326
|
+
{
|
327
|
+
/* glib/gutils.h */
|
328
|
+
#if GLIB_CHECK_VERSION(2, 14, 0)
|
329
|
+
G_DEF_CLASS(G_TYPE_USER_DIRECTORY, "UserDirectory", mGLib);
|
330
|
+
G_DEF_CONSTANTS(mGLib, G_TYPE_USER_DIRECTORY, "G_");
|
331
|
+
#endif
|
332
|
+
|
333
|
+
#if GLIB_CHECK_VERSION(2,2,0)
|
334
|
+
rb_define_module_function(mGLib, "application_name", rbglib_m_application_name, 0);
|
335
|
+
rb_define_module_function(mGLib, "set_application_name", rbglib_m_set_application_name, 1);
|
336
|
+
#endif
|
337
|
+
rb_define_module_function(mGLib, "prgname", rbglib_m_prgname, 0);
|
338
|
+
rb_define_module_function(mGLib, "set_prgname", rbglib_m_set_prgname, 1);
|
339
|
+
rb_define_module_function(mGLib, "getenv", rbglib_m_env, 1);
|
340
|
+
#if GLIB_CHECK_VERSION(2,4,0)
|
341
|
+
rb_define_module_function(mGLib, "setenv", rbglib_m_setenv, 2);
|
342
|
+
rb_define_module_function(mGLib, "unsetenv", rbglib_m_unsetenv, 1);
|
343
|
+
#endif
|
344
|
+
#if GLIB_CHECK_VERSION(2,8,0)
|
345
|
+
#if HAVE_G_LISTENV
|
346
|
+
rb_define_module_function(mGLib, "listenv", rbglib_m_listenv, 0);
|
347
|
+
#endif
|
348
|
+
rb_define_module_function(mGLib, "host_name", rbglib_m_host_name, 0);
|
349
|
+
#endif
|
350
|
+
rb_define_module_function(mGLib, "user_name", rbglib_m_user_name, 0);
|
351
|
+
rb_define_module_function(mGLib, "real_name", rbglib_m_real_name, 0);
|
352
|
+
|
353
|
+
#if GLIB_CHECK_VERSION(2, 6, 0)
|
354
|
+
rb_define_module_function(mGLib, "user_cache_dir",
|
355
|
+
rbglib_m_user_cache_dir, 0);
|
356
|
+
rb_define_module_function(mGLib, "user_data_dir",
|
357
|
+
rbglib_m_user_data_dir, 0);
|
358
|
+
rb_define_module_function(mGLib, "user_config_dir",
|
359
|
+
rbglib_m_user_config_dir, 0);
|
360
|
+
rb_define_module_function(mGLib, "system_data_dirs",
|
361
|
+
rbglib_m_system_data_dirs, 0);
|
362
|
+
rb_define_module_function(mGLib, "system_config_dirs",
|
363
|
+
rbglib_m_system_config_dirs, 0);
|
364
|
+
#endif
|
365
|
+
#if GLIB_CHECK_VERSION(2, 14, 0)
|
366
|
+
rb_define_module_function(mGLib, "get_user_special_dir",
|
367
|
+
rbglib_m_get_user_special_dir, 1);
|
368
|
+
#endif
|
369
|
+
rb_define_module_function(mGLib, "home_dir", rbglib_m_home_dir, 0);
|
370
|
+
rb_define_module_function(mGLib, "tmp_dir", rbglib_m_tmp_dir, 0);
|
371
|
+
rb_define_module_function(mGLib, "current_dir", rbglib_m_current_dir, 0);
|
372
|
+
|
373
|
+
rb_define_module_function(mGLib, "path_is_absolute?", rbglib_m_path_is_absolute, 1);
|
374
|
+
rb_define_module_function(mGLib, "path_skip_root", rbglib_m_path_skip_root, 1);
|
375
|
+
rb_define_module_function(mGLib, "path_get_basename", rbglib_m_path_get_basename, 1);
|
376
|
+
rb_define_module_function(mGLib, "path_get_dirname", rbglib_m_path_get_dirname, 1);
|
377
|
+
rb_define_module_function(mGLib, "find_program_in_path", rbglib_m_find_program_in_path, 1);
|
378
|
+
rb_define_module_function(mGLib, "bit_nth_lsf", rbglib_m_bit_nth_lsf, 2);
|
379
|
+
rb_define_module_function(mGLib, "bit_nth_msf", rbglib_m_bit_nth_msf, 2);
|
380
|
+
rb_define_module_function(mGLib, "bit_storage", rbglib_m_bit_storage, 1);
|
381
|
+
rb_define_module_function(mGLib, "spaced_primes_closest", rbglib_m_spaced_primes_closest, 1);
|
382
|
+
rb_define_module_function(mGLib, "parse_debug_string", rbglib_m_parse_debug_string, 2);
|
383
|
+
rb_define_module_function(mGLib, "check_version?", rbglib_m_check_version, 3);
|
384
|
+
|
385
|
+
}
|
386
|
+
|
data/src/rbglib_win32.c
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/**********************************************************************
|
3
|
+
|
4
|
+
rbglib_win32.c -
|
5
|
+
|
6
|
+
$Author: mutoh $
|
7
|
+
$Date: 2006/12/26 15:49:16 $
|
8
|
+
|
9
|
+
Copyright (C) 2006 Kouhei Sutou
|
10
|
+
|
11
|
+
**********************************************************************/
|
12
|
+
|
13
|
+
#include "rbgprivate.h"
|
14
|
+
#include "rbglib.h"
|
15
|
+
#include <glib/gwin32.h>
|
16
|
+
|
17
|
+
#ifdef G_OS_WIN32
|
18
|
+
static VALUE
|
19
|
+
rbglib_m_win32_error_message(self, error)
|
20
|
+
VALUE self, error;
|
21
|
+
{
|
22
|
+
return CSTR2RVAL2(g_win32_error_message(NUM2INT(error)));
|
23
|
+
}
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
rbglib_m_win32_locale(self)
|
27
|
+
VALUE self;
|
28
|
+
{
|
29
|
+
return CSTR2RVAL2(g_win32_getlocale());
|
30
|
+
}
|
31
|
+
|
32
|
+
static VALUE
|
33
|
+
rbglib_m_win32_locale_deprecated(self)
|
34
|
+
VALUE self;
|
35
|
+
{
|
36
|
+
rb_warn("GLib.win32_locale() is deprecated. Use GLib::Win32.locale instead");
|
37
|
+
return rbglib_m_win32_locale(self);
|
38
|
+
}
|
39
|
+
|
40
|
+
static VALUE
|
41
|
+
rbglib_m_win32_get_package_installation_directory(self, package, dll_name)
|
42
|
+
VALUE self, package, dll_name;
|
43
|
+
{
|
44
|
+
return CSTR2RVAL2(g_win32_get_package_installation_directory(RVAL2CSTR(package),
|
45
|
+
RVAL2CSTR(dll_name)));
|
46
|
+
}
|
47
|
+
|
48
|
+
static VALUE
|
49
|
+
rbglib_m_get_package_installation_subdirectory(self, package, dll_name, subdir)
|
50
|
+
VALUE self, package, dll_name, subdir;
|
51
|
+
{
|
52
|
+
return CSTR2RVAL2(g_win32_get_package_installation_subdirectory(RVAL2CSTR(package),
|
53
|
+
RVAL2CSTR(dll_name),
|
54
|
+
RVAL2CSTR(subdir)));
|
55
|
+
}
|
56
|
+
|
57
|
+
#if GLIB_CHECK_VERSION(2,6,0)
|
58
|
+
static VALUE
|
59
|
+
rbglib_m_get_windows_version(self)
|
60
|
+
VALUE self;
|
61
|
+
{
|
62
|
+
return UINT2NUM(g_win32_get_windows_version());
|
63
|
+
}
|
64
|
+
#endif
|
65
|
+
|
66
|
+
#if GLIB_CHECK_VERSION(2,8,0)
|
67
|
+
static VALUE
|
68
|
+
rbglib_m_win32_locale_filename_from_utf8(self, utf8_filename)
|
69
|
+
VALUE self, utf8_filename;
|
70
|
+
{
|
71
|
+
return CSTR2RVAL2(g_win32_locale_filename_from_utf8(RVAL2CSTR(utf8_filename)));
|
72
|
+
}
|
73
|
+
|
74
|
+
static VALUE
|
75
|
+
rbglib_m_win32_locale_filename_from_utf8_deprecated(self)
|
76
|
+
VALUE self;
|
77
|
+
{
|
78
|
+
rb_warn("GLib.win32_locale_filename_from_utf8() is deprecated. Use GLib::Win32.locale_filename_from_utf8 instead");
|
79
|
+
return rbglib_m_win32_locale_filename_from_utf8(self);
|
80
|
+
}
|
81
|
+
|
82
|
+
#endif
|
83
|
+
|
84
|
+
# if GLIB_CHECK_VERSION(2, 16, 0)
|
85
|
+
static VALUE
|
86
|
+
rbglib_m_win32_get_package_installation_directory_of_module(int argc,
|
87
|
+
VALUE *argv,
|
88
|
+
VALUE self)
|
89
|
+
{
|
90
|
+
VALUE rb_module;
|
91
|
+
gchar *directory;
|
92
|
+
gpointer hmodule;
|
93
|
+
|
94
|
+
rb_scan_args(argc, argv, "01", &rb_module);
|
95
|
+
if (NIL_P(rb_module))
|
96
|
+
hmodule = NULL;
|
97
|
+
else
|
98
|
+
hmodule = GINT_TO_POINTER(NUM2INT(rb_module));
|
99
|
+
|
100
|
+
directory = g_win32_get_package_installation_directory_of_module(hmodule);
|
101
|
+
return CSTR2RVAL_FREE(directory);
|
102
|
+
}
|
103
|
+
# endif
|
104
|
+
#endif
|
105
|
+
|
106
|
+
void
|
107
|
+
Init_glib_win32()
|
108
|
+
{
|
109
|
+
#ifdef G_OS_WIN32
|
110
|
+
/* glib/gwin32.h */
|
111
|
+
VALUE mWin32 = rb_define_module_under(mGLib, "Win32");
|
112
|
+
|
113
|
+
rb_define_module_function(mWin32, "error_message", rbglib_m_win32_error_message, 1);
|
114
|
+
rb_define_module_function(mWin32, "locale", rbglib_m_win32_locale, 0);
|
115
|
+
rb_define_module_function(mWin32, "get_package_installation_directory", rbglib_m_win32_get_package_installation_directory, 2);
|
116
|
+
rb_define_module_function(mWin32, "get_package_installation_subdirectory", rbglib_m_get_package_installation_subdirectory, 3);
|
117
|
+
rb_define_module_function(mWin32, "version", rbglib_m_get_windows_version, 0);
|
118
|
+
/* Deprecated */
|
119
|
+
rb_define_module_function(mGLib, "win32_locale", rbglib_m_win32_locale_deprecated, 0);
|
120
|
+
|
121
|
+
# if GLIB_CHECK_VERSION(2,8,0)
|
122
|
+
rb_define_module_function(mWin32, "locale_filename_from_utf8",
|
123
|
+
rbglib_m_win32_locale_filename_from_utf8, 1);
|
124
|
+
/* Deprecated */
|
125
|
+
rb_define_module_function(mGLib, "win32_locale_filename_from_utf8",
|
126
|
+
rbglib_m_win32_locale_filename_from_utf8_deprecated, 1);
|
127
|
+
# endif
|
128
|
+
|
129
|
+
# if GLIB_CHECK_VERSION(2, 16, 0)
|
130
|
+
rb_define_module_function(mWin32,
|
131
|
+
"get_package_installation_directory_of_module",
|
132
|
+
rbglib_m_win32_get_package_installation_directory_of_module,
|
133
|
+
-1);
|
134
|
+
# endif
|
135
|
+
#endif
|
136
|
+
}
|