glib2 1.0.0-x86-mingw32 → 1.0.1-x86-mingw32

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.
@@ -23,7 +23,7 @@ extern "C" {
23
23
 
24
24
  #define RBGLIB_MAJOR_VERSION 1
25
25
  #define RBGLIB_MINOR_VERSION 0
26
- #define RBGLIB_MICRO_VERSION 0
26
+ #define RBGLIB_MICRO_VERSION 1
27
27
 
28
28
  #ifndef RSTRING_PTR
29
29
  # define RSTRING_PTR(s) (RSTRING(s)->ptr)
@@ -52,13 +52,22 @@ typedef int GPid;
52
52
  #define CSTR2RVAL_LEN(s, l) (rbg_cstr2rval_len(s, l))
53
53
  #define CSTR2RVAL_ENC(s, e) (rbg_cstr2rval_with_encoding(s, e))
54
54
  #define CSTR2RVAL_LEN_ENC(s, l, e) (rbg_cstr2rval_len_with_encoding(s, l, e))
55
- #define CSTR2RVAL_FREE(s) (rbg_cstr2rval_with_free(s))
55
+ #define CSTR2RVAL_FREE(s) (rbg_cstr2rval_free(s))
56
56
  #define CSTR2RVAL2(s) (CSTR2RVAL_FREE(s))
57
57
 
58
58
  #define RVAL2CSTRFILENAME(v) (rbg_filename_from_ruby(v))
59
+ #define CSTRFILENAME2RVAL(s) (rbg_filename_to_ruby(s))
59
60
  #define CSTRFILENAME2RVAL_FREE(s) (rbg_filename_to_ruby_free(s))
60
61
  #define CSTRFILENAMEARRAY2RVAL_FREE(s) (rbg_filename_gslist_to_array_free(s))
61
62
 
63
+ #define RVAL2STRV(ary) rbg_rval2strv(ary)
64
+ #define RVAL2STRV_ACCEPT_NIL(ary) rbg_rval2strv_accept_nil(ary)
65
+ #define RVAL2STRV_DUP(ary) rbg_rval2strv_dup(ary)
66
+ #define RVAL2STRV_DUP_ACCEPT_NIL(ary) rbg_rval2strv_dup_accept_nil(ary)
67
+
68
+ #define STRV2RVAL(strings) rbg_strv2rval(strings)
69
+ #define STRV2RVAL_FREE(strings) rbg_strv2rval_free(strings)
70
+
62
71
  #define CBOOL2RVAL(b) ((b) ? Qtrue : Qfalse)
63
72
  #define RVAL2CBOOL(b) (RTEST(b))
64
73
  #define GERROR2RVAL(error) (rbgerr_gerror2exception(error))
@@ -83,20 +92,31 @@ RUBY_GLIB2_VAR VALUE mGLib;
83
92
  extern const gchar *rbg_rval_inspect(VALUE object);
84
93
 
85
94
  extern gchar* rbg_string_value_ptr(volatile VALUE* ptr); /* no longer used */
86
- extern gchar *rbg_rval2cstr(VALUE *str);
87
- extern gchar *rbg_rval2cstr_accept_nil(VALUE *str);
95
+ extern const gchar *rbg_rval2cstr(VALUE *str);
96
+ extern const gchar *rbg_rval2cstr_accept_nil(VALUE *str);
88
97
  extern VALUE rbg_cstr2rval(const gchar* str);
89
98
  extern VALUE rbg_cstr2rval_len(const gchar* str, gsize len);
90
99
  extern VALUE rbg_cstr2rval_with_encoding(const gchar* str,
91
100
  const gchar *encoding);
92
101
  extern VALUE rbg_cstr2rval_len_with_encoding(const gchar* str, gsize len,
93
102
  const gchar *encoding);
94
- extern VALUE rbg_cstr2rval_with_free(gchar* str);
103
+ extern VALUE rbg_cstr2rval_free(gchar *str);
104
+ /* just for backward compatibility. */
105
+ extern VALUE rbg_cstr2rval_with_free(gchar *str);
95
106
 
107
+ VALUE rbg_filename_to_ruby(const gchar *filename);
96
108
  extern VALUE rbg_filename_to_ruby_free(gchar *filename);
97
109
  extern gchar *rbg_filename_from_ruby(VALUE filename);
98
110
  extern VALUE rbg_filename_gslist_to_array_free(GSList *list);
99
111
 
112
+ const gchar **rbg_rval2strv(VALUE ary);
113
+ const gchar **rbg_rval2strv_accept_nil(VALUE ary);
114
+ gchar **rbg_rval2strv_dup(VALUE ary);
115
+ gchar **rbg_rval2strv_dup_accept_nil(VALUE ary);
116
+ const gchar **rbg_rval2argv(VALUE ary);
117
+ VALUE rbg_strv2rval(const gchar **strings);
118
+ VALUE rbg_strv2rval_free(gchar **strings);
119
+
100
120
  /* rbgerror.h */
101
121
  extern VALUE rbgerr_gerror2exception(GError *error);
102
122
  extern VALUE rbgerr_define_gerror(GQuark domain, const gchar* name, VALUE module, VALUE parent, VALUE gtype);
@@ -1,553 +1,541 @@
1
- /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
3
-
4
- rbglib_bookmarkfile.c -
5
-
6
- $Author: sakai $
7
- $Date: 2007/07/07 08:25:33 $
8
-
9
- Copyright (C) 2006 Masao Mutoh
10
- ************************************************/
11
-
12
- #include "rbgprivate.h"
13
-
14
- #if GLIB_CHECK_VERSION(2,12,0)
15
- /************************************************/
16
- static GBookmarkFile*
17
- bookmarkfile_copy(const GBookmarkFile* file)
18
- {
19
- /*
20
- GBookmarkFile* new_file;
21
- g_return_val_if_fail (file != NULL, NULL);
22
- new_file = g_key_file_new();
23
- *new_file = (GBookmarkFile*)*file;
24
- return new_file;
25
- */
26
- return (GBookmarkFile*)file;
27
- }
28
-
29
-
30
- GType
31
- g_bookmark_file_get_type(void)
32
- {
33
- static GType our_type = 0;
34
- if (our_type == 0)
35
- our_type = g_boxed_type_register_static("GBookmarkFile",
36
- (GBoxedCopyFunc)bookmarkfile_copy,
37
- (GBoxedFreeFunc)g_bookmark_file_free);
38
- return our_type;
39
- }
40
- /************************************************/
41
-
42
- #define G_TYPE_BOOKMARK_FILE (g_bookmark_file_get_type())
43
- #define _SELF(self) ((GBookmarkFile*)(RVAL2BOXED(self, G_TYPE_BOOKMARK_FILE)))
44
-
45
- static VALUE
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbglib_bookmarkfile.c -
5
+
6
+ $Author: sakai $
7
+ $Date: 2007/07/07 08:25:33 $
8
+
9
+ Copyright (C) 2006 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "rbgprivate.h"
13
+
14
+ #if GLIB_CHECK_VERSION(2,12,0)
15
+ /************************************************/
16
+ static GBookmarkFile*
17
+ bookmarkfile_copy(const GBookmarkFile* file)
18
+ {
19
+ /*
20
+ GBookmarkFile* new_file;
21
+ g_return_val_if_fail (file != NULL, NULL);
22
+ new_file = g_key_file_new();
23
+ *new_file = (GBookmarkFile*)*file;
24
+ return new_file;
25
+ */
26
+ return (GBookmarkFile*)file;
27
+ }
28
+
29
+
30
+ GType
31
+ g_bookmark_file_get_type(void)
32
+ {
33
+ static GType our_type = 0;
34
+ if (our_type == 0)
35
+ our_type = g_boxed_type_register_static("GBookmarkFile",
36
+ (GBoxedCopyFunc)bookmarkfile_copy,
37
+ (GBoxedFreeFunc)g_bookmark_file_free);
38
+ return our_type;
39
+ }
40
+ /************************************************/
41
+
42
+ #define G_TYPE_BOOKMARK_FILE (g_bookmark_file_get_type())
43
+ #define _SELF(self) ((GBookmarkFile*)(RVAL2BOXED(self, G_TYPE_BOOKMARK_FILE)))
44
+
45
+ static VALUE
46
46
  bf_initialize(VALUE self)
47
- {
48
- G_INITIALIZE(self, g_bookmark_file_new());
49
- return Qnil;
50
- }
51
-
52
- static VALUE
53
- bf_load_from_file(VALUE self, VALUE filename)
54
- {
55
- GError* error = NULL;
56
- gboolean ret = g_bookmark_file_load_from_file(_SELF(self),
57
- RVAL2CSTRFILENAME(filename),
58
- &error);
59
- if (!ret) RAISE_GERROR(error);
60
- return self;
61
- }
62
-
63
- static VALUE
64
- bf_load_from_data(VALUE self, VALUE data)
65
- {
66
- GError *error = NULL;
67
-
68
- StringValue(data);
69
- if (!g_bookmark_file_load_from_data(_SELF(self),
70
- RSTRING_PTR(data),
71
- RSTRING_LEN(data),
72
- &error))
73
- RAISE_GERROR(error);
74
-
75
- return Qnil;
76
- }
77
-
78
- static VALUE
47
+ {
48
+ G_INITIALIZE(self, g_bookmark_file_new());
49
+ return Qnil;
50
+ }
51
+
52
+ static VALUE
53
+ bf_load_from_file(VALUE self, VALUE rbfilename)
54
+ {
55
+ gchar *filename = RVAL2CSTRFILENAME(rbfilename);
56
+ GError* error = NULL;
57
+ gboolean ret = g_bookmark_file_load_from_file(_SELF(self), filename, &error);
58
+ g_free(filename);
59
+ if (!ret)
60
+ RAISE_GERROR(error);
61
+
62
+ return self;
63
+ }
64
+
65
+ static VALUE
66
+ bf_load_from_data(VALUE self, VALUE data)
67
+ {
68
+ GError *error = NULL;
69
+
70
+ StringValue(data);
71
+ if (!g_bookmark_file_load_from_data(_SELF(self),
72
+ RSTRING_PTR(data),
73
+ RSTRING_LEN(data),
74
+ &error))
75
+ RAISE_GERROR(error);
76
+
77
+ return Qnil;
78
+ }
79
+
80
+ static VALUE
79
81
  bf_load_from_data_dirs(VALUE self, VALUE file)
80
- {
81
- GError* error = NULL;
82
- gboolean ret;
83
- gchar* full_path;
84
-
85
- ret = g_bookmark_file_load_from_data_dirs(_SELF(self),
86
- (const gchar*)RVAL2CSTR(file),
87
- &full_path, &error);
88
-
89
- if (! ret) RAISE_GERROR(error);
90
-
91
- return full_path ? CSTR2RVAL(full_path) : Qnil;
92
- }
93
-
94
- static VALUE
82
+ {
83
+ GError* error = NULL;
84
+ gboolean ret;
85
+ gchar* full_path;
86
+
87
+ ret = g_bookmark_file_load_from_data_dirs(_SELF(self),
88
+ RVAL2CSTR(file),
89
+ &full_path, &error);
90
+
91
+ if (! ret) RAISE_GERROR(error);
92
+
93
+ return full_path ? CSTR2RVAL(full_path) : Qnil;
94
+ }
95
+
96
+ static VALUE
95
97
  bf_to_data(VALUE self)
96
- {
97
- GError* error = NULL;
98
- gchar* data = g_bookmark_file_to_data(_SELF(self), NULL, &error);
99
-
100
- if (error) RAISE_GERROR(error);
101
-
102
- return CSTR2RVAL_FREE(data);
103
- }
104
-
105
- static VALUE
106
- bf_to_file(VALUE self, VALUE filename)
107
- {
108
- GError* error = NULL;
109
- gboolean ret = g_bookmark_file_to_file(_SELF(self),
110
- RVAL2CSTRFILENAME(filename),
111
- &error);
112
- if (!ret) RAISE_GERROR(error);
113
- return self;
114
- }
115
-
116
- static VALUE
98
+ {
99
+ GError* error = NULL;
100
+ gchar* data = g_bookmark_file_to_data(_SELF(self), NULL, &error);
101
+
102
+ if (error) RAISE_GERROR(error);
103
+
104
+ return CSTR2RVAL_FREE(data);
105
+ }
106
+
107
+ static VALUE
108
+ bf_to_file(VALUE self, VALUE rbfilename)
109
+ {
110
+ gchar *filename = RVAL2CSTRFILENAME(rbfilename);
111
+ GError* error = NULL;
112
+ gboolean ret = g_bookmark_file_to_file(_SELF(self), filename, &error);
113
+ g_free(filename);
114
+ if (!ret)
115
+ RAISE_GERROR(error);
116
+
117
+ return self;
118
+ }
119
+
120
+ static VALUE
117
121
  bf_has_item(VALUE self, VALUE uri)
118
- {
119
- return CBOOL2RVAL(g_bookmark_file_has_item(_SELF(self),
120
- (const gchar *)RVAL2CSTR(uri)));
121
- }
122
-
123
- static VALUE
122
+ {
123
+ return CBOOL2RVAL(g_bookmark_file_has_item(_SELF(self),
124
+ RVAL2CSTR(uri)));
125
+ }
126
+
127
+ static VALUE
124
128
  bf_has_group(VALUE self, VALUE uri, VALUE group)
125
- {
126
- GError* error = NULL;
127
- return CBOOL2RVAL(g_bookmark_file_has_group(_SELF(self),
128
- (const gchar *)RVAL2CSTR(uri),
129
- (const gchar *)RVAL2CSTR(group),
130
- &error));
131
- }
132
-
133
- static VALUE
129
+ {
130
+ GError* error = NULL;
131
+ return CBOOL2RVAL(g_bookmark_file_has_group(_SELF(self),
132
+ RVAL2CSTR(uri),
133
+ RVAL2CSTR(group),
134
+ &error));
135
+ }
136
+
137
+ static VALUE
134
138
  bf_has_application(VALUE self, VALUE uri, VALUE name)
135
- {
136
- GError* error = NULL;
137
- return CBOOL2RVAL(g_bookmark_file_has_application(_SELF(self),
138
- (const gchar *)RVAL2CSTR(uri),
139
- (const gchar *)RVAL2CSTR(name),
140
- &error));
141
- }
142
-
143
- static VALUE
139
+ {
140
+ GError* error = NULL;
141
+ return CBOOL2RVAL(g_bookmark_file_has_application(_SELF(self),
142
+ RVAL2CSTR(uri),
143
+ RVAL2CSTR(name),
144
+ &error));
145
+ }
146
+
147
+ static VALUE
144
148
  bf_get_size(VALUE self)
145
- {
146
- return INT2NUM(g_bookmark_file_get_size(_SELF(self)));
147
- }
148
-
149
- static VALUE
149
+ {
150
+ return INT2NUM(g_bookmark_file_get_size(_SELF(self)));
151
+ }
152
+
153
+ static VALUE
150
154
  bf_get_uris(VALUE self)
151
- {
152
- int i;
153
- gsize len;
154
- VALUE ary = rb_ary_new();
155
- gchar** ret = g_bookmark_file_get_uris(_SELF(self), &len);
156
-
157
- for (i = 0; i < len; i++){
158
- rb_ary_push(ary, CSTR2RVAL(ret[i]));
159
- }
160
-
161
- g_strfreev(ret);
162
-
163
- return ary;
164
- }
165
-
166
- static VALUE
155
+ {
156
+ return STRV2RVAL_FREE(g_bookmark_file_get_uris(_SELF(self), NULL));
157
+ }
158
+
159
+ static VALUE
167
160
  bf_get_title(VALUE self, VALUE uri)
168
- {
169
- GError *error = NULL;
170
- gchar* ret = g_bookmark_file_get_title(_SELF(self),
171
- (const gchar *)RVAL2CSTR(uri),
172
- &error);
173
- if (error) RAISE_GERROR(error);
174
- return CSTR2RVAL_FREE(ret);
175
- }
176
-
177
- static VALUE
161
+ {
162
+ GError *error = NULL;
163
+ gchar* ret = g_bookmark_file_get_title(_SELF(self),
164
+ RVAL2CSTR(uri),
165
+ &error);
166
+ if (error) RAISE_GERROR(error);
167
+ return CSTR2RVAL_FREE(ret);
168
+ }
169
+
170
+ static VALUE
178
171
  bf_get_description(VALUE self, VALUE uri)
179
- {
180
- GError *error = NULL;
181
- gchar* ret = g_bookmark_file_get_description(_SELF(self),
182
- (const gchar *)RVAL2CSTR(uri),
183
- &error);
184
- if (error) RAISE_GERROR(error);
185
- return CSTR2RVAL_FREE(ret);
186
- }
187
-
188
- static VALUE
172
+ {
173
+ GError *error = NULL;
174
+ gchar* ret = g_bookmark_file_get_description(_SELF(self),
175
+ RVAL2CSTR(uri),
176
+ &error);
177
+ if (error) RAISE_GERROR(error);
178
+ return CSTR2RVAL_FREE(ret);
179
+ }
180
+
181
+ static VALUE
189
182
  bf_get_mime_type(VALUE self, VALUE uri)
190
- {
191
- GError *error = NULL;
192
- gchar* ret = g_bookmark_file_get_mime_type(_SELF(self),
193
- (const gchar *)RVAL2CSTR(uri),
194
- &error);
195
- if (error) RAISE_GERROR(error);
196
- return CSTR2RVAL_FREE(ret);
197
- }
198
-
199
- static VALUE
183
+ {
184
+ GError *error = NULL;
185
+ gchar* ret = g_bookmark_file_get_mime_type(_SELF(self),
186
+ RVAL2CSTR(uri),
187
+ &error);
188
+ if (error) RAISE_GERROR(error);
189
+ return CSTR2RVAL_FREE(ret);
190
+ }
191
+
192
+ static VALUE
200
193
  bf_get_is_private(VALUE self, VALUE uri)
201
- {
202
- GError *error = NULL;
203
- gboolean ret = g_bookmark_file_get_is_private(_SELF(self),
204
- (const gchar *)RVAL2CSTR(uri),
205
- &error);
206
- if (error) RAISE_GERROR(error);
207
- return CBOOL2RVAL(ret);
208
- }
209
-
210
- static VALUE
194
+ {
195
+ GError *error = NULL;
196
+ gboolean ret = g_bookmark_file_get_is_private(_SELF(self),
197
+ RVAL2CSTR(uri),
198
+ &error);
199
+ if (error) RAISE_GERROR(error);
200
+ return CBOOL2RVAL(ret);
201
+ }
202
+
203
+ static VALUE
211
204
  bf_get_icon(VALUE self, VALUE uri)
212
- {
213
- gchar* href;
214
- gchar* mime_type;
215
- GError *error = NULL;
216
- gboolean ret = g_bookmark_file_get_icon(_SELF(self),
217
- (const gchar *)RVAL2CSTR(uri),
218
- &href, &mime_type,
219
- &error);
220
- if (!ret){
221
- if (error) RAISE_GERROR(error);
222
- return Qnil;
223
- }
224
- return rb_assoc_new(CSTR2RVAL_FREE(href), CSTR2RVAL_FREE(mime_type));
225
- }
226
-
227
- static VALUE
205
+ {
206
+ gchar* href;
207
+ gchar* mime_type;
208
+ GError *error = NULL;
209
+ gboolean ret = g_bookmark_file_get_icon(_SELF(self),
210
+ RVAL2CSTR(uri),
211
+ &href, &mime_type,
212
+ &error);
213
+ if (!ret){
214
+ if (error) RAISE_GERROR(error);
215
+ return Qnil;
216
+ }
217
+ return rb_assoc_new(CSTR2RVAL_FREE(href), CSTR2RVAL_FREE(mime_type));
218
+ }
219
+
220
+ static VALUE
228
221
  bf_get_added(VALUE self, VALUE uri)
229
- {
230
- GError *error = NULL;
231
- time_t ret = g_bookmark_file_get_added(_SELF(self),
232
- (const gchar *)RVAL2CSTR(uri),
233
- &error);
234
- if (!ret) RAISE_GERROR(error);
235
-
236
- return rb_time_new(ret, 0);
237
- }
238
-
239
- static VALUE
222
+ {
223
+ GError *error = NULL;
224
+ time_t ret = g_bookmark_file_get_added(_SELF(self),
225
+ RVAL2CSTR(uri),
226
+ &error);
227
+ if (!ret) RAISE_GERROR(error);
228
+
229
+ return rb_time_new(ret, 0);
230
+ }
231
+
232
+ static VALUE
240
233
  bf_get_modified(VALUE self, VALUE uri)
241
- {
242
- GError *error = NULL;
243
- time_t ret = g_bookmark_file_get_modified(_SELF(self),
244
- (const gchar *)RVAL2CSTR(uri),
245
- &error);
246
- if (!ret) RAISE_GERROR(error);
247
-
248
- return rb_time_new(ret, 0);
249
- }
250
-
251
- static VALUE
234
+ {
235
+ GError *error = NULL;
236
+ time_t ret = g_bookmark_file_get_modified(_SELF(self),
237
+ RVAL2CSTR(uri),
238
+ &error);
239
+ if (!ret) RAISE_GERROR(error);
240
+
241
+ return rb_time_new(ret, 0);
242
+ }
243
+
244
+ static VALUE
252
245
  bf_get_visited(VALUE self, VALUE uri)
253
- {
254
- GError *error = NULL;
255
- time_t ret = g_bookmark_file_get_visited(_SELF(self),
256
- (const gchar *)RVAL2CSTR(uri),
257
- &error);
258
- if (!ret) RAISE_GERROR(error);
259
-
260
- return rb_time_new(ret, 0);
261
- }
262
-
263
- static VALUE
246
+ {
247
+ GError *error = NULL;
248
+ time_t ret = g_bookmark_file_get_visited(_SELF(self),
249
+ RVAL2CSTR(uri),
250
+ &error);
251
+ if (!ret) RAISE_GERROR(error);
252
+
253
+ return rb_time_new(ret, 0);
254
+ }
255
+
256
+ static VALUE
264
257
  bf_get_groups(VALUE self, VALUE uri)
265
- {
266
- gsize length;
267
- VALUE ary;
268
- gint i;
269
- GError* error = NULL;
270
- gchar** ret = g_bookmark_file_get_groups(_SELF(self),
271
- (const gchar *)RVAL2CSTR(uri),
272
- &length, &error);
273
- if (error) RAISE_GERROR(error);
274
-
275
-
276
- ary = rb_ary_new();
277
- for(i = 0; i < length; i++){
278
- rb_ary_push(ary, CSTR2RVAL(ret[i]));
279
- }
280
-
281
- g_strfreev(ret);
282
- return ary;
283
- }
284
-
285
- static VALUE
258
+ {
259
+ gsize length;
260
+ VALUE ary;
261
+ gsize i;
262
+ GError* error = NULL;
263
+ gchar** ret = g_bookmark_file_get_groups(_SELF(self),
264
+ RVAL2CSTR(uri),
265
+ &length, &error);
266
+ if (error) RAISE_GERROR(error);
267
+
268
+
269
+ ary = rb_ary_new();
270
+ for(i = 0; i < length; i++){
271
+ rb_ary_push(ary, CSTR2RVAL(ret[i]));
272
+ }
273
+
274
+ g_strfreev(ret);
275
+ return ary;
276
+ }
277
+
278
+ static VALUE
286
279
  bf_get_applications(VALUE self, VALUE uri)
287
- {
288
- gsize length;
289
- VALUE ary;
290
- gint i;
291
- GError* error = NULL;
292
- gchar** ret = g_bookmark_file_get_applications(_SELF(self),
293
- (const gchar *)RVAL2CSTR(uri),
294
- &length, &error);
295
- if (error) RAISE_GERROR(error);
296
-
297
-
298
- ary = rb_ary_new();
299
- for(i = 0; i < length; i++){
300
- rb_ary_push(ary, CSTR2RVAL(ret[i]));
301
- }
302
-
303
- g_strfreev(ret);
304
- return ary;
305
- }
306
-
307
- static VALUE
280
+ {
281
+ gsize length;
282
+ VALUE ary;
283
+ gsize i;
284
+ GError* error = NULL;
285
+ gchar** ret = g_bookmark_file_get_applications(_SELF(self),
286
+ RVAL2CSTR(uri),
287
+ &length, &error);
288
+ if (error) RAISE_GERROR(error);
289
+
290
+
291
+ ary = rb_ary_new();
292
+ for(i = 0; i < length; i++){
293
+ rb_ary_push(ary, CSTR2RVAL(ret[i]));
294
+ }
295
+
296
+ g_strfreev(ret);
297
+ return ary;
298
+ }
299
+
300
+ static VALUE
308
301
  bf_get_app_info(VALUE self, VALUE uri, VALUE name)
309
- {
310
- gchar* exec;
311
- guint count;
312
- time_t stamp;
313
- GError* error = NULL;
314
-
315
- gboolean ret = g_bookmark_file_get_app_info(_SELF(self),
316
- (const gchar *)RVAL2CSTR(uri),
317
- (const gchar *)RVAL2CSTR(name),
318
- &exec, &count, &stamp, &error);
319
- if (!ret) RAISE_GERROR(error);
320
-
321
- return rb_ary_new3(3, CSTR2RVAL(exec), UINT2NUM(count), rb_time_new(stamp, 0));
322
- }
323
-
324
- static VALUE
302
+ {
303
+ gchar* exec;
304
+ guint count;
305
+ time_t stamp;
306
+ GError* error = NULL;
307
+
308
+ gboolean ret = g_bookmark_file_get_app_info(_SELF(self),
309
+ RVAL2CSTR(uri),
310
+ RVAL2CSTR(name),
311
+ &exec, &count, &stamp, &error);
312
+ if (!ret) RAISE_GERROR(error);
313
+
314
+ return rb_ary_new3(3, CSTR2RVAL(exec), UINT2NUM(count), rb_time_new(stamp, 0));
315
+ }
316
+
317
+ static VALUE
325
318
  bf_set_title(VALUE self, VALUE uri, VALUE title)
326
- {
327
- g_bookmark_file_set_title(_SELF(self),
328
- (const gchar *)RVAL2CSTR(uri),
329
- (const gchar *)RVAL2CSTR(title));
330
- return self;
331
- }
332
-
333
- static VALUE
319
+ {
320
+ g_bookmark_file_set_title(_SELF(self),
321
+ RVAL2CSTR(uri),
322
+ RVAL2CSTR(title));
323
+ return self;
324
+ }
325
+
326
+ static VALUE
334
327
  bf_set_description(VALUE self, VALUE uri, VALUE description)
335
- {
336
- g_bookmark_file_set_description(_SELF(self),
337
- (const gchar *)RVAL2CSTR(uri),
338
- (const gchar *)RVAL2CSTR(description));
339
- return self;
340
- }
341
-
342
- static VALUE
328
+ {
329
+ g_bookmark_file_set_description(_SELF(self),
330
+ RVAL2CSTR(uri),
331
+ RVAL2CSTR(description));
332
+ return self;
333
+ }
334
+
335
+ static VALUE
343
336
  bf_set_mime_type(VALUE self, VALUE uri, VALUE mime_type)
344
- {
345
- g_bookmark_file_set_mime_type(_SELF(self),
346
- (const gchar *)RVAL2CSTR(uri),
347
- (const gchar *)RVAL2CSTR(mime_type));
348
- return self;
349
- }
350
-
351
- static VALUE
337
+ {
338
+ g_bookmark_file_set_mime_type(_SELF(self),
339
+ RVAL2CSTR(uri),
340
+ RVAL2CSTR(mime_type));
341
+ return self;
342
+ }
343
+
344
+ static VALUE
352
345
  bf_set_is_private(VALUE self, VALUE uri, VALUE is_private)
353
- {
354
- g_bookmark_file_set_is_private(_SELF(self),
355
- (const gchar *)RVAL2CSTR(uri),
356
- RVAL2CBOOL(is_private));
357
- return self;
358
- }
359
-
360
- static VALUE
346
+ {
347
+ g_bookmark_file_set_is_private(_SELF(self),
348
+ RVAL2CSTR(uri),
349
+ RVAL2CBOOL(is_private));
350
+ return self;
351
+ }
352
+
353
+ static VALUE
361
354
  bf_set_icon(VALUE self, VALUE uri, VALUE href, VALUE mime_type)
362
- {
363
- g_bookmark_file_set_icon(_SELF(self),
364
- (const gchar *)RVAL2CSTR(uri),
365
- (const gchar *)RVAL2CSTR(href),
366
- (const gchar *)RVAL2CSTR(mime_type));
367
- return self;
368
- }
369
-
370
- static VALUE
355
+ {
356
+ g_bookmark_file_set_icon(_SELF(self),
357
+ RVAL2CSTR(uri),
358
+ RVAL2CSTR(href),
359
+ RVAL2CSTR(mime_type));
360
+ return self;
361
+ }
362
+
363
+ static VALUE
371
364
  bf_set_added(VALUE self, VALUE uri, VALUE time)
372
- {
373
- g_bookmark_file_set_added(_SELF(self),
374
- (const gchar *)RVAL2CSTR(uri),
375
- (time_t)NUM2LONG(rb_Integer(time)));
376
- return self;
377
- }
378
-
379
- static VALUE
380
- bf_set_groups(VALUE self, VALUE uri, VALUE groups)
381
- {
382
- gint len = RARRAY_LEN(groups);
383
- gchar** glist = ALLOCA_N(gchar*, len);
384
- gint i;
385
-
386
- for (i = 0; i < len; i++){
387
- glist[i] = RVAL2CSTR(RARRAY_PTR(groups)[i]);
388
- }
389
-
390
- g_bookmark_file_set_groups(_SELF(self),
391
- (const gchar *)RVAL2CSTR(uri),
392
- (const gchar **)glist, len);
393
- return self;
394
- }
395
-
396
- static VALUE
365
+ {
366
+ g_bookmark_file_set_added(_SELF(self),
367
+ RVAL2CSTR(uri),
368
+ (time_t)NUM2LONG(rb_Integer(time)));
369
+ return self;
370
+ }
371
+
372
+ static VALUE
373
+ bf_set_groups(VALUE self, VALUE uri, VALUE rbgroups)
374
+ {
375
+ VALUE ary = rb_ary_to_ary(rbgroups);
376
+ const gchar **groups = RVAL2STRV(ary);
377
+
378
+ g_bookmark_file_set_groups(_SELF(self), RVAL2CSTR(uri), groups, RARRAY_LEN(ary));
379
+
380
+ g_free(groups);
381
+
382
+ return self;
383
+ }
384
+
385
+ static VALUE
397
386
  bf_set_modified(VALUE self, VALUE uri, VALUE time)
398
- {
399
- g_bookmark_file_set_modified(_SELF(self),
400
- (const gchar *)RVAL2CSTR(uri),
401
- (time_t)NUM2LONG(rb_Integer(time)));
402
- return self;
403
- }
404
-
405
- static VALUE
387
+ {
388
+ g_bookmark_file_set_modified(_SELF(self),
389
+ RVAL2CSTR(uri),
390
+ (time_t)NUM2LONG(rb_Integer(time)));
391
+ return self;
392
+ }
393
+
394
+ static VALUE
406
395
  bf_set_visited(VALUE self, VALUE uri, VALUE time)
407
- {
408
- g_bookmark_file_set_visited(_SELF(self),
409
- (const gchar *)RVAL2CSTR(uri),
410
- (time_t)NUM2LONG(rb_Integer(time)));
411
- return self;
412
- }
413
-
414
- static VALUE
396
+ {
397
+ g_bookmark_file_set_visited(_SELF(self),
398
+ RVAL2CSTR(uri),
399
+ (time_t)NUM2LONG(rb_Integer(time)));
400
+ return self;
401
+ }
402
+
403
+ static VALUE
415
404
  bf_set_app_info(VALUE self, VALUE uri, VALUE name, VALUE exec, VALUE count, VALUE stamp)
416
- {
417
- GError* error = NULL;
418
- gboolean ret = g_bookmark_file_set_app_info(_SELF(self),
419
- (const gchar *)RVAL2CSTR(uri),
420
- (const gchar *)RVAL2CSTR(name),
421
- (const gchar *)RVAL2CSTR(exec),
422
- NUM2INT(count),
423
- (time_t)NUM2LONG(rb_Integer(stamp)),
424
- &error);
425
-
426
- if (! ret) RAISE_GERROR(error);
427
-
428
- return self;
429
- }
430
-
431
- static VALUE
405
+ {
406
+ GError* error = NULL;
407
+ gboolean ret = g_bookmark_file_set_app_info(_SELF(self),
408
+ RVAL2CSTR(uri),
409
+ RVAL2CSTR(name),
410
+ RVAL2CSTR(exec),
411
+ NUM2INT(count),
412
+ (time_t)NUM2LONG(rb_Integer(stamp)),
413
+ &error);
414
+
415
+ if (! ret) RAISE_GERROR(error);
416
+
417
+ return self;
418
+ }
419
+
420
+ static VALUE
432
421
  bf_add_group(VALUE self, VALUE uri, VALUE group)
433
- {
434
- g_bookmark_file_add_group(_SELF(self),
435
- (const gchar *)RVAL2CSTR(uri),
436
- (const gchar *)RVAL2CSTR(group));
437
- return self;
438
- }
439
-
440
- static VALUE
422
+ {
423
+ g_bookmark_file_add_group(_SELF(self),
424
+ RVAL2CSTR(uri),
425
+ RVAL2CSTR(group));
426
+ return self;
427
+ }
428
+
429
+ static VALUE
441
430
  bf_add_application(VALUE self, VALUE uri, VALUE name, VALUE exec)
442
- {
443
- g_bookmark_file_add_application(_SELF(self),
444
- (const gchar *)RVAL2CSTR(uri),
445
- (const gchar *)RVAL2CSTR(name),
446
- (const gchar *)RVAL2CSTR(exec));
447
- return self;
448
- }
449
-
450
- static VALUE
431
+ {
432
+ g_bookmark_file_add_application(_SELF(self),
433
+ RVAL2CSTR(uri),
434
+ RVAL2CSTR(name),
435
+ RVAL2CSTR(exec));
436
+ return self;
437
+ }
438
+
439
+ static VALUE
451
440
  bf_remove_group(VALUE self, VALUE uri, VALUE group)
452
- {
453
- GError* error = NULL;
454
- gboolean ret = g_bookmark_file_remove_group(_SELF(self),
455
- (const gchar *)RVAL2CSTR(uri),
456
- (const gchar *)RVAL2CSTR(group),
457
- &error);
458
- if (! ret) RAISE_GERROR(error);
459
-
460
- return self;
461
- }
462
-
463
- static VALUE
441
+ {
442
+ GError* error = NULL;
443
+ gboolean ret = g_bookmark_file_remove_group(_SELF(self),
444
+ RVAL2CSTR(uri),
445
+ RVAL2CSTR(group),
446
+ &error);
447
+ if (! ret) RAISE_GERROR(error);
448
+
449
+ return self;
450
+ }
451
+
452
+ static VALUE
464
453
  bf_remove_application(VALUE self, VALUE uri, VALUE name)
465
- {
466
- GError *error = NULL;
467
- gboolean ret = g_bookmark_file_remove_application(_SELF(self),
468
- (const gchar *)RVAL2CSTR(uri),
469
- (const gchar *)RVAL2CSTR(name),
470
- &error);
471
- if (! ret) RAISE_GERROR(error);
472
-
473
- return self;
474
- }
475
-
476
-
477
- static VALUE
454
+ {
455
+ GError *error = NULL;
456
+ gboolean ret = g_bookmark_file_remove_application(_SELF(self),
457
+ RVAL2CSTR(uri),
458
+ RVAL2CSTR(name),
459
+ &error);
460
+ if (! ret) RAISE_GERROR(error);
461
+
462
+ return self;
463
+ }
464
+
465
+
466
+ static VALUE
478
467
  bf_remove_item(VALUE self, VALUE uri)
479
- {
480
- GError *error = NULL;
481
- gboolean ret = g_bookmark_file_remove_item(_SELF(self),
482
- (const gchar *)RVAL2CSTR(uri),
483
- &error);
484
- if (! ret) RAISE_GERROR(error);
485
-
486
- return self;
487
- }
488
-
489
- static VALUE
468
+ {
469
+ GError *error = NULL;
470
+ gboolean ret = g_bookmark_file_remove_item(_SELF(self),
471
+ RVAL2CSTR(uri),
472
+ &error);
473
+ if (! ret) RAISE_GERROR(error);
474
+
475
+ return self;
476
+ }
477
+
478
+ static VALUE
490
479
  bf_move_item(VALUE self, VALUE old_uri, VALUE new_uri)
491
- {
492
- GError *error = NULL;
493
- gboolean ret = g_bookmark_file_move_item(_SELF(self),
494
- (const gchar *)RVAL2CSTR(old_uri),
495
- (const gchar *)RVAL2CSTR(new_uri),
496
- &error);
497
- if (! ret) RAISE_GERROR(error);
498
-
499
- return self;
500
- }
501
-
502
- #endif
503
-
504
- void
505
- Init_glib_bookmark_file()
506
- {
507
- #if GLIB_CHECK_VERSION(2,12,0)
508
- VALUE bf = G_DEF_CLASS(G_TYPE_BOOKMARK_FILE, "BookmarkFile", mGLib);
509
-
510
- G_DEF_ERROR(G_BOOKMARK_FILE_ERROR, "BookmarkFileError", mGLib,
511
- rb_eRuntimeError, G_TYPE_BOOKMARK_FILE_ERROR);
512
-
513
- rb_define_method(bf, "initialize", bf_initialize, 0);
514
- rb_define_method(bf, "load_from_file", bf_load_from_file, 1);
515
- rb_define_method(bf, "load_from_data", bf_load_from_data, 1);
516
- rb_define_method(bf, "load_from_data_dirs", bf_load_from_data_dirs, 1);
517
- rb_define_method(bf, "to_data", bf_to_data, 0);
518
- rb_define_method(bf, "to_file", bf_to_file, 1);
519
- rb_define_method(bf, "has_item?", bf_has_item, 1);
520
- rb_define_method(bf, "has_group?", bf_has_group, 2);
521
- rb_define_method(bf, "has_application?", bf_has_application, 2);
522
- rb_define_method(bf, "size", bf_get_size, 0);
523
- rb_define_method(bf, "uris", bf_get_uris, 0);
524
- rb_define_method(bf, "get_title", bf_get_title, 1);
525
- rb_define_method(bf, "get_description", bf_get_description, 1);
526
- rb_define_method(bf, "get_mime_type", bf_get_mime_type, 1);
527
- rb_define_method(bf, "private?", bf_get_is_private, 1);
528
- rb_define_method(bf, "get_icon", bf_get_icon, 1);
529
- rb_define_method(bf, "get_added", bf_get_added, 1);
530
- rb_define_method(bf, "get_modified", bf_get_modified, 1);
531
- rb_define_method(bf, "get_visited", bf_get_visited, 1);
532
- rb_define_method(bf, "get_groups", bf_get_groups, 1);
533
- rb_define_method(bf, "get_applications", bf_get_applications, 1);
534
- rb_define_method(bf, "get_app_info", bf_get_app_info, 2);
535
- rb_define_method(bf, "set_title", bf_set_title, 2);
536
- rb_define_method(bf, "set_description", bf_set_description, 2);
537
- rb_define_method(bf, "set_mime_type", bf_set_mime_type, 2);
538
- rb_define_method(bf, "set_private", bf_set_is_private, 2);
539
- rb_define_method(bf, "set_icon", bf_set_icon, 3);
540
- rb_define_method(bf, "set_added", bf_set_added, 2);
541
- rb_define_method(bf, "set_groups", bf_set_groups, 2);
542
- rb_define_method(bf, "set_modified", bf_set_modified, 2);
543
- rb_define_method(bf, "set_visited", bf_set_visited, 2);
544
- rb_define_method(bf, "set_app_info", bf_set_app_info, 5);
545
- rb_define_method(bf, "add_group", bf_add_group, 2);
546
- rb_define_method(bf, "add_application", bf_add_application, 3);
547
- rb_define_method(bf, "remove_group", bf_remove_group, 2);
548
- rb_define_method(bf, "remove_application", bf_remove_application, 2);
549
- rb_define_method(bf, "remove_item", bf_remove_item, 1);
550
- rb_define_method(bf, "move_item", bf_move_item, 2);
551
- #endif
552
- }
553
-
480
+ {
481
+ GError *error = NULL;
482
+ gboolean ret = g_bookmark_file_move_item(_SELF(self),
483
+ RVAL2CSTR(old_uri),
484
+ RVAL2CSTR(new_uri),
485
+ &error);
486
+ if (! ret) RAISE_GERROR(error);
487
+
488
+ return self;
489
+ }
490
+
491
+ #endif
492
+
493
+ void
494
+ Init_glib_bookmark_file()
495
+ {
496
+ #if GLIB_CHECK_VERSION(2,12,0)
497
+ VALUE bf = G_DEF_CLASS(G_TYPE_BOOKMARK_FILE, "BookmarkFile", mGLib);
498
+
499
+ G_DEF_ERROR(G_BOOKMARK_FILE_ERROR, "BookmarkFileError", mGLib,
500
+ rb_eRuntimeError, G_TYPE_BOOKMARK_FILE_ERROR);
501
+
502
+ rb_define_method(bf, "initialize", bf_initialize, 0);
503
+ rb_define_method(bf, "load_from_file", bf_load_from_file, 1);
504
+ rb_define_method(bf, "load_from_data", bf_load_from_data, 1);
505
+ rb_define_method(bf, "load_from_data_dirs", bf_load_from_data_dirs, 1);
506
+ rb_define_method(bf, "to_data", bf_to_data, 0);
507
+ rb_define_method(bf, "to_file", bf_to_file, 1);
508
+ rb_define_method(bf, "has_item?", bf_has_item, 1);
509
+ rb_define_method(bf, "has_group?", bf_has_group, 2);
510
+ rb_define_method(bf, "has_application?", bf_has_application, 2);
511
+ rb_define_method(bf, "size", bf_get_size, 0);
512
+ rb_define_method(bf, "uris", bf_get_uris, 0);
513
+ rb_define_method(bf, "get_title", bf_get_title, 1);
514
+ rb_define_method(bf, "get_description", bf_get_description, 1);
515
+ rb_define_method(bf, "get_mime_type", bf_get_mime_type, 1);
516
+ rb_define_method(bf, "private?", bf_get_is_private, 1);
517
+ rb_define_method(bf, "get_icon", bf_get_icon, 1);
518
+ rb_define_method(bf, "get_added", bf_get_added, 1);
519
+ rb_define_method(bf, "get_modified", bf_get_modified, 1);
520
+ rb_define_method(bf, "get_visited", bf_get_visited, 1);
521
+ rb_define_method(bf, "get_groups", bf_get_groups, 1);
522
+ rb_define_method(bf, "get_applications", bf_get_applications, 1);
523
+ rb_define_method(bf, "get_app_info", bf_get_app_info, 2);
524
+ rb_define_method(bf, "set_title", bf_set_title, 2);
525
+ rb_define_method(bf, "set_description", bf_set_description, 2);
526
+ rb_define_method(bf, "set_mime_type", bf_set_mime_type, 2);
527
+ rb_define_method(bf, "set_private", bf_set_is_private, 2);
528
+ rb_define_method(bf, "set_icon", bf_set_icon, 3);
529
+ rb_define_method(bf, "set_added", bf_set_added, 2);
530
+ rb_define_method(bf, "set_groups", bf_set_groups, 2);
531
+ rb_define_method(bf, "set_modified", bf_set_modified, 2);
532
+ rb_define_method(bf, "set_visited", bf_set_visited, 2);
533
+ rb_define_method(bf, "set_app_info", bf_set_app_info, 5);
534
+ rb_define_method(bf, "add_group", bf_add_group, 2);
535
+ rb_define_method(bf, "add_application", bf_add_application, 3);
536
+ rb_define_method(bf, "remove_group", bf_remove_group, 2);
537
+ rb_define_method(bf, "remove_application", bf_remove_application, 2);
538
+ rb_define_method(bf, "remove_item", bf_remove_item, 1);
539
+ rb_define_method(bf, "move_item", bf_move_item, 2);
540
+ #endif
541
+ }