gio2 0.90.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/ChangeLog +60 -0
  2. data/README +34 -0
  3. data/Rakefile +76 -0
  4. data/ext/gio2/depend +5 -0
  5. data/ext/gio2/extconf.rb +91 -0
  6. data/ext/gio2/gappinfo.c +318 -0
  7. data/ext/gio2/gapplaunchcontext.c +79 -0
  8. data/ext/gio2/gasyncinitable.c +244 -0
  9. data/ext/gio2/gasyncresult.c +39 -0
  10. data/ext/gio2/gbufferedinputstream.c +184 -0
  11. data/ext/gio2/gbufferedoutputstream.c +82 -0
  12. data/ext/gio2/gcancellable.c +177 -0
  13. data/ext/gio2/gcharsetconverter.c +72 -0
  14. data/ext/gio2/gcontenttype.c +135 -0
  15. data/ext/gio2/gconverter.c +117 -0
  16. data/ext/gio2/gconverterinputstream.c +48 -0
  17. data/ext/gio2/gconverteroutputstream.c +48 -0
  18. data/ext/gio2/gdatainputstream.c +341 -0
  19. data/ext/gio2/gdataoutputstream.c +202 -0
  20. data/ext/gio2/gdesktopappinfo.c +90 -0
  21. data/ext/gio2/gdrive.c +267 -0
  22. data/ext/gio2/gemblem.c +71 -0
  23. data/ext/gio2/gemblemedicon.c +63 -0
  24. data/ext/gio2/gfile.c +2058 -0
  25. data/ext/gio2/gfileattribute.c +263 -0
  26. data/ext/gio2/gfileattributematcher.c +90 -0
  27. data/ext/gio2/gfiledescriptorbased.c +42 -0
  28. data/ext/gio2/gfileenumerator.c +167 -0
  29. data/ext/gio2/gfileicon.c +46 -0
  30. data/ext/gio2/gfileinfo.c +641 -0
  31. data/ext/gio2/gfileinputstream.c +92 -0
  32. data/ext/gio2/gfileiostream.c +98 -0
  33. data/ext/gio2/gfilemonitor.c +63 -0
  34. data/ext/gio2/gfilenamecompleter.c +72 -0
  35. data/ext/gio2/gfileoutputstream.c +100 -0
  36. data/ext/gio2/gfilterinputstream.c +56 -0
  37. data/ext/gio2/gfilteroutputstream.c +56 -0
  38. data/ext/gio2/gicon.c +69 -0
  39. data/ext/gio2/ginetaddress.c +188 -0
  40. data/ext/gio2/ginetsocketaddress.c +54 -0
  41. data/ext/gio2/ginitable.c +195 -0
  42. data/ext/gio2/ginputstream.c +341 -0
  43. data/ext/gio2/gio2.c +120 -0
  44. data/ext/gio2/gio2.def +2 -0
  45. data/ext/gio2/gio2.h +343 -0
  46. data/ext/gio2/gioerror.c +67 -0
  47. data/ext/gio2/giomodule.c +63 -0
  48. data/ext/gio2/gioscheduler.c +195 -0
  49. data/ext/gio2/giostream.c +129 -0
  50. data/ext/gio2/gloadableicon.c +91 -0
  51. data/ext/gio2/gmemoryinputstream.c +65 -0
  52. data/ext/gio2/gmemoryoutputstream.c +65 -0
  53. data/ext/gio2/gmount.c +283 -0
  54. data/ext/gio2/gmountoperation.c +168 -0
  55. data/ext/gio2/gnetworkaddress.c +71 -0
  56. data/ext/gio2/gnetworkservice.c +64 -0
  57. data/ext/gio2/goutputstream.c +343 -0
  58. data/ext/gio2/gresolver.c +230 -0
  59. data/ext/gio2/gseekable.c +89 -0
  60. data/ext/gio2/gsimpleasyncresult.c +153 -0
  61. data/ext/gio2/gsocket.c +451 -0
  62. data/ext/gio2/gsocketaddress.c +45 -0
  63. data/ext/gio2/gsocketclient.c +273 -0
  64. data/ext/gio2/gsocketconnectable.c +97 -0
  65. data/ext/gio2/gsocketconnection.c +82 -0
  66. data/ext/gio2/gsocketcontrolmessage.c +82 -0
  67. data/ext/gio2/gsocketlistener.c +239 -0
  68. data/ext/gio2/gsocketservice.c +64 -0
  69. data/ext/gio2/gsrvtarget.c +77 -0
  70. data/ext/gio2/gtcpconnection.c +48 -0
  71. data/ext/gio2/gthemedicon.c +86 -0
  72. data/ext/gio2/gthreadedsocketservice.c +39 -0
  73. data/ext/gio2/gunixconnection.c +69 -0
  74. data/ext/gio2/gunixfdlist.c +112 -0
  75. data/ext/gio2/gunixfdmessage.c +81 -0
  76. data/ext/gio2/gunixinputstream.c +73 -0
  77. data/ext/gio2/gunixmounts.c +346 -0
  78. data/ext/gio2/gunixoutputstream.c +73 -0
  79. data/ext/gio2/gunixsocketaddress.c +79 -0
  80. data/ext/gio2/gvfs.c +84 -0
  81. data/ext/gio2/gvolume.c +191 -0
  82. data/ext/gio2/gvolumemonitor.c +77 -0
  83. data/ext/gio2/gzlibcompressor.c +47 -0
  84. data/ext/gio2/gzlibdecompressor.c +43 -0
  85. data/ext/gio2/util.c +323 -0
  86. data/extconf.rb +49 -0
  87. data/lib/gio2.rb +141 -0
  88. metadata +184 -0
@@ -0,0 +1,346 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+ /*
3
+ * Ruby/GIO: a Ruby binding of gio-2.0.x.
4
+ * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #include "gio2.h"
22
+
23
+ #ifdef HAVE_GIO_UNIX
24
+ #include <gio/gunixmounts.h>
25
+
26
+ static GUnixMountEntry *
27
+ unixmount_copy(const GUnixMountEntry *mount)
28
+ {
29
+ return (GUnixMountEntry *)mount;
30
+ }
31
+
32
+ static GType
33
+ g_unix_mount_entry_get_type(void)
34
+ {
35
+ static GType our_type = 0;
36
+
37
+ if (our_type == 0)
38
+ our_type = g_boxed_type_register_static("GUnixMountEntry",
39
+ (GBoxedCopyFunc)unixmount_copy,
40
+ (GBoxedFreeFunc)g_unix_mount_free);
41
+
42
+ return our_type;
43
+ }
44
+
45
+ #define G_TYPE_UNIX_MOUNT_ENTRY (g_unix_mount_entry_get_type())
46
+
47
+ #define _SELF(value) \
48
+ ((GUnixMountEntry *)(RVAL2BOXED((value), G_TYPE_UNIX_MOUNT_ENTRY)))
49
+
50
+ #define GUNIXMOUNTENTRY2RVAL(value) BOXED2RVAL((value), G_TYPE_UNIX_MOUNT_ENTRY)
51
+
52
+ static VALUE
53
+ unixmount_compare(VALUE self, VALUE other)
54
+ {
55
+ return INT2FIX(g_unix_mount_compare(_SELF(self), _SELF(other)));
56
+ }
57
+
58
+ static VALUE
59
+ unixmount_get_mount_path(VALUE self)
60
+ {
61
+ return CSTR2RVAL(g_unix_mount_get_mount_path(_SELF(self)));
62
+ }
63
+
64
+ static VALUE
65
+ unixmount_get_device_path(VALUE self)
66
+ {
67
+ return CSTR2RVAL(g_unix_mount_get_device_path(_SELF(self)));
68
+ }
69
+
70
+ static VALUE
71
+ unixmount_get_fs_type(VALUE self)
72
+ {
73
+ return CSTR2RVAL(g_unix_mount_get_fs_type(_SELF(self)));
74
+ }
75
+
76
+ static VALUE
77
+ unixmount_is_readonly(VALUE self)
78
+ {
79
+ return CBOOL2RVAL(g_unix_mount_is_readonly(_SELF(self)));
80
+ }
81
+
82
+ static VALUE
83
+ unixmount_is_system_internal(VALUE self)
84
+ {
85
+ return CBOOL2RVAL(g_unix_mount_is_system_internal(_SELF(self)));
86
+ }
87
+
88
+ static VALUE
89
+ unixmount_guess_icon(VALUE self)
90
+ {
91
+ return GOBJ2RVAL_UNREF(g_unix_mount_guess_icon(_SELF(self)));
92
+ }
93
+
94
+ static VALUE
95
+ unixmount_guess_name(VALUE self)
96
+ {
97
+ return CSTR2RVAL_FREE(g_unix_mount_guess_name(_SELF(self)));
98
+ }
99
+
100
+ static VALUE
101
+ unixmount_guess_can_eject(VALUE self)
102
+ {
103
+ return CBOOL2RVAL(g_unix_mount_guess_can_eject(_SELF(self)));
104
+ }
105
+
106
+ static VALUE
107
+ unixmount_guess_should_display(VALUE self)
108
+ {
109
+ return CBOOL2RVAL(g_unix_mount_guess_should_display(_SELF(self)));
110
+ }
111
+
112
+ static GUnixMountPoint *
113
+ unixmountpoint_copy(const GUnixMountPoint *mount_point)
114
+ {
115
+ return (GUnixMountPoint *)mount_point;
116
+ }
117
+
118
+ static GType
119
+ g_unix_mount_point_get_type(void)
120
+ {
121
+ static GType our_type = 0;
122
+
123
+ if (our_type == 0)
124
+ our_type = g_boxed_type_register_static("GUnixMountPoint",
125
+ (GBoxedCopyFunc)unixmountpoint_copy,
126
+ (GBoxedFreeFunc)g_unix_mount_point_free);
127
+
128
+ return our_type;
129
+ }
130
+
131
+ #define G_TYPE_UNIX_MOUNT_POINT (g_unix_mount_point_get_type())
132
+
133
+ #undef _SELF
134
+ #define _SELF(value) \
135
+ ((GUnixMountPoint *)(RVAL2BOXED((value), G_TYPE_UNIX_MOUNT_POINT)))
136
+
137
+ static VALUE
138
+ unixmountpoint_compare(VALUE self, VALUE other)
139
+ {
140
+ return INT2FIX(g_unix_mount_point_compare(_SELF(self), _SELF(other)));
141
+ }
142
+
143
+ static VALUE
144
+ unixmountpoint_get_mount_path(VALUE self)
145
+ {
146
+ return CSTR2RVAL(g_unix_mount_point_get_mount_path(_SELF(self)));
147
+ }
148
+
149
+ static VALUE
150
+ unixmountpoint_get_device_path(VALUE self)
151
+ {
152
+ return CSTR2RVAL(g_unix_mount_point_get_device_path(_SELF(self)));
153
+ }
154
+
155
+ static VALUE
156
+ unixmountpoint_get_fs_type(VALUE self)
157
+ {
158
+ return CSTR2RVAL(g_unix_mount_point_get_fs_type(_SELF(self)));
159
+ }
160
+
161
+ static VALUE
162
+ unixmountpoint_is_readonly(VALUE self)
163
+ {
164
+ return CBOOL2RVAL(g_unix_mount_point_is_readonly(_SELF(self)));
165
+ }
166
+
167
+ static VALUE
168
+ unixmountpoint_is_user_mountable(VALUE self)
169
+ {
170
+ return CBOOL2RVAL(g_unix_mount_point_is_user_mountable(_SELF(self)));
171
+ }
172
+
173
+ static VALUE
174
+ unixmountpoint_is_loopback(VALUE self)
175
+ {
176
+ return CBOOL2RVAL(g_unix_mount_point_is_loopback(_SELF(self)));
177
+ }
178
+
179
+ static VALUE
180
+ unixmountpoint_guess_icon(VALUE self)
181
+ {
182
+ return GOBJ2RVAL_UNREF(g_unix_mount_point_guess_icon(_SELF(self)));
183
+ }
184
+
185
+ static VALUE
186
+ unixmountpoint_guess_name(VALUE self)
187
+ {
188
+ return CSTR2RVAL_FREE(g_unix_mount_point_guess_name(_SELF(self)));
189
+ }
190
+
191
+ static VALUE
192
+ unixmountpoint_guess_can_eject(VALUE self)
193
+ {
194
+ return CBOOL2RVAL(g_unix_mount_point_guess_can_eject(_SELF(self)));
195
+ }
196
+
197
+ static VALUE
198
+ unixmountpoints_get(G_GNUC_UNUSED VALUE self)
199
+ {
200
+ guint64 time_read;
201
+ GList *mount_points;
202
+
203
+ mount_points = g_unix_mount_points_get(&time_read);
204
+
205
+ return rb_assoc_new(GLIST2ARY_STR_FREE(mount_points),
206
+ GUINT642RVAL(time_read));
207
+ }
208
+
209
+ static VALUE
210
+ unixmounts_get(G_GNUC_UNUSED VALUE self)
211
+ {
212
+ guint64 time_read;
213
+ GList *mounts;
214
+
215
+ mounts = g_unix_mounts_get(&time_read);
216
+
217
+ return rb_assoc_new(GLIST2ARY_STR_FREE(mounts),
218
+ GUINT642RVAL(time_read));
219
+ }
220
+
221
+ static VALUE
222
+ unixmount_at(G_GNUC_UNUSED VALUE self, VALUE mount_path)
223
+ {
224
+ guint64 time_read;
225
+ GUnixMountEntry *mount;
226
+
227
+ mount = g_unix_mount_at(RVAL2CSTR(mount_path), &time_read);
228
+
229
+ return rb_assoc_new(GUNIXMOUNTENTRY2RVAL(mount),
230
+ GUINT642RVAL(time_read));
231
+ }
232
+
233
+ static VALUE
234
+ unixmounts_changed_since(G_GNUC_UNUSED VALUE self, VALUE time_read)
235
+ {
236
+ return CBOOL2RVAL(g_unix_mounts_changed_since(RVAL2GUINT64(time_read)));
237
+ }
238
+
239
+ static VALUE
240
+ unixmountpoints_changed_since(G_GNUC_UNUSED VALUE self, VALUE time_read)
241
+ {
242
+ return CBOOL2RVAL(g_unix_mount_points_changed_since(RVAL2GUINT64(time_read)));
243
+ }
244
+
245
+ #undef _SELF
246
+ #define _SELF(value) G_UNIX_MOUNT_MONITOR(RVAL2GOBJ(value))
247
+
248
+ static VALUE
249
+ unixmountmonitor_initialize(int argc, VALUE *argv, VALUE self)
250
+ {
251
+ VALUE limit_msec;
252
+ GUnixMountMonitor *monitor;
253
+
254
+ rb_scan_args(argc, argv, "01", &limit_msec);
255
+ monitor = g_unix_mount_monitor_new();
256
+ if (!NIL_P(limit_msec))
257
+ g_unix_mount_monitor_set_rate_limit(monitor,
258
+ FIX2INT(limit_msec));
259
+ G_INITIALIZE(self, monitor);
260
+
261
+ return Qnil;
262
+ }
263
+
264
+ static VALUE
265
+ unixmountmonitor_set_rate_limit(VALUE self, VALUE limit_msec)
266
+ {
267
+ g_unix_mount_monitor_set_rate_limit(_SELF(self), FIX2INT(limit_msec));
268
+
269
+ return self;
270
+ }
271
+
272
+ static VALUE
273
+ unix_is_mount_path_system_internal(G_GNUC_UNUSED VALUE self, VALUE mount_path)
274
+ {
275
+ return CBOOL2RVAL(g_unix_is_mount_path_system_internal(RVAL2CSTR(mount_path)));
276
+ }
277
+
278
+ #endif
279
+
280
+ void
281
+ Init_gunixmounts(G_GNUC_UNUSED VALUE glib)
282
+ {
283
+ #ifdef HAVE_GIO_UNIX
284
+ VALUE unixmount, unixmountpoint, unixmountpoints, unixmounts, unixmountmonitor;
285
+
286
+ unixmount = G_DEF_CLASS(G_TYPE_UNIX_MOUNT_ENTRY, "UnixMount", glib);
287
+
288
+ rb_include_module(unixmount, rb_mComparable);
289
+
290
+ /* TODO: This doesn’t follow the naming conventions, but it seems
291
+ * overkill to have GLib::Unix just for mount_path_system_internal?. */
292
+ rb_define_singleton_method(unixmount, "mount_path_system_internal?", unix_is_mount_path_system_internal, 1);
293
+
294
+ rb_define_method(unixmount, "at", unixmount_at, 1);
295
+
296
+ rb_undef_alloc_func(unixmount);
297
+ rbgobj_boxed_not_copy_obj(G_TYPE_UNIX_MOUNT_ENTRY);
298
+
299
+ rb_define_method(unixmount, "compare", unixmount_compare, 1);
300
+ rb_define_alias(unixmount, "<=>", "compare");
301
+ rb_define_method(unixmount, "mount_path", unixmount_get_mount_path, 0);
302
+ rb_define_method(unixmount, "device_path", unixmount_get_device_path, 0);
303
+ rb_define_method(unixmount, "fs_type", unixmount_get_fs_type, 0);
304
+ rb_define_method(unixmount, "readonly?", unixmount_is_readonly, 0);
305
+ rb_define_method(unixmount, "system_internal?", unixmount_is_system_internal, 0);
306
+ rb_define_method(unixmount, "guess_icon", unixmount_guess_icon, 0);
307
+ rb_define_method(unixmount, "guess_name", unixmount_guess_name, 0);
308
+ rb_define_method(unixmount, "guess_can_eject?", unixmount_guess_can_eject, 0);
309
+ rb_define_method(unixmount, "guess_should_display?", unixmount_guess_should_display, 0);
310
+
311
+ unixmountpoint = G_DEF_CLASS(G_TYPE_UNIX_MOUNT_POINT, "UnixMountPoint", glib);
312
+
313
+ rb_include_module(unixmountpoint, rb_mComparable);
314
+
315
+ rb_undef_alloc_func(unixmountpoint);
316
+ rbgobj_boxed_not_copy_obj(G_TYPE_UNIX_MOUNT_POINT);
317
+
318
+ rb_define_method(unixmountpoint, "compare", unixmountpoint_compare, 1);
319
+ rb_define_alias(unixmountpoint, "<=>", "compare");
320
+ rb_define_method(unixmountpoint, "mount_path", unixmountpoint_get_mount_path, 0);
321
+ rb_define_method(unixmountpoint, "device_path", unixmountpoint_get_device_path, 0);
322
+ rb_define_method(unixmountpoint, "fs_type", unixmountpoint_get_fs_type, 0);
323
+ rb_define_method(unixmountpoint, "readonly?", unixmountpoint_is_readonly, 0);
324
+ rb_define_method(unixmountpoint, "user_mountable?", unixmountpoint_is_user_mountable, 0);
325
+ rb_define_method(unixmountpoint, "loopback?", unixmountpoint_is_loopback, 0);
326
+ rb_define_method(unixmountpoint, "guess_icon", unixmountpoint_guess_icon, 0);
327
+ rb_define_method(unixmountpoint, "guess_name", unixmountpoint_guess_name, 0);
328
+ rb_define_method(unixmountpoint, "guess_can_eject?", unixmountpoint_guess_can_eject, 0);
329
+
330
+ unixmountpoints = rb_define_module_under(glib, "UnixMountPoints");
331
+
332
+ rb_define_module_function(unixmountpoints, "get", unixmountpoints_get, 0);
333
+ rb_define_module_function(unixmountpoints, "changed_since?", unixmountpoints_changed_since, 1);
334
+
335
+ unixmounts = rb_define_module_under(glib, "UnixMounts");
336
+
337
+ rb_define_module_function(unixmounts, "get", unixmounts_get, 0);
338
+ rb_define_module_function(unixmounts, "changed_since?", unixmounts_changed_since, 1);
339
+
340
+ unixmountmonitor = G_DEF_CLASS(G_TYPE_UNIX_MOUNT_MONITOR, "UnixMountMonitor", glib);
341
+
342
+ rb_define_method(unixmountmonitor, "initialize", unixmountmonitor_initialize, -1);
343
+ rb_define_method(unixmountmonitor, "set_rate_limit", unixmountmonitor_set_rate_limit, 1);
344
+ G_DEF_SETTER(unixmountmonitor, "rate_limit");
345
+ #endif
346
+ }
@@ -0,0 +1,73 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+ /*
3
+ * Ruby/GIO: a Ruby binding of gio-2.0.x.
4
+ * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #include "gio2.h"
22
+
23
+ #ifdef HAVE_GIO_UNIX
24
+ #include <gio/gunixoutputstream.h>
25
+
26
+ #define _SELF(value) G_UNIX_OUTPUT_STREAM(RVAL2GOBJ(value))
27
+
28
+ static VALUE
29
+ unixoutputstream_initialize(int argc, VALUE *argv, VALUE self)
30
+ {
31
+ VALUE fd, close_fd;
32
+
33
+ rb_scan_args(argc, argv, "11", &fd, &close_fd);
34
+ G_INITIALIZE(self, g_unix_output_stream_new(RVAL2FD(fd),
35
+ RVAL2CBOOL(close_fd)));
36
+
37
+ return Qnil;
38
+ }
39
+
40
+ static VALUE
41
+ unixoutputstream_set_close_fd(VALUE self, VALUE close_fd)
42
+ {
43
+ g_unix_output_stream_set_close_fd(_SELF(self), RVAL2CBOOL(close_fd));
44
+
45
+ return self;
46
+ }
47
+
48
+ static VALUE
49
+ unixoutputstream_get_close_fd(VALUE self)
50
+ {
51
+ return CBOOL2RVAL(g_unix_output_stream_get_close_fd(_SELF(self)));
52
+ }
53
+
54
+ static VALUE
55
+ unixoutputstream_get_fd(VALUE self)
56
+ {
57
+ return FD2RVAL(g_unix_output_stream_get_fd(_SELF(self)));
58
+ }
59
+ #endif
60
+
61
+ void
62
+ Init_gunixoutputstream(G_GNUC_UNUSED VALUE glib)
63
+ {
64
+ #ifdef HAVE_GIO_UNIX
65
+ VALUE unixoutputstream = G_DEF_CLASS(G_TYPE_UNIX_OUTPUT_STREAM, "UnixOutputStream", glib);
66
+
67
+ rb_define_method(unixoutputstream, "initialize", unixoutputstream_initialize, -1);
68
+ rb_define_method(unixoutputstream, "set_close_fd", unixoutputstream_set_close_fd, 1);
69
+ G_DEF_SETTER(unixoutputstream, "close_fd");
70
+ rb_define_method(unixoutputstream, "close_fd?", unixoutputstream_get_close_fd, 0);
71
+ rb_define_method(unixoutputstream, "fd", unixoutputstream_get_fd, 0);
72
+ #endif
73
+ }
@@ -0,0 +1,79 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+ /*
3
+ * Ruby/GIO: a Ruby binding of gio-2.0.x.
4
+ * Copyright (C) 2008-2009 Ruby-GNOME2 Project Team
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #include "gio2.h"
22
+
23
+ #ifdef HAVE_GIO_UNIX
24
+ #include <gio/gunixsocketaddress.h>
25
+
26
+ #define _SELF(value) G_UNIX_SOCKET_ADDRESS(RVAL2GOBJ(value))
27
+
28
+ static VALUE
29
+ unixsocketaddress_initialize(VALUE self, VALUE path)
30
+ {
31
+ G_INITIALIZE(self, g_unix_socket_address_new(RVAL2CSTR(path)));
32
+
33
+ return Qnil;
34
+ }
35
+
36
+ static VALUE
37
+ unixsocketaddress_new_abstract(G_GNUC_UNUSED VALUE self, VALUE path)
38
+ {
39
+ StringValue(path);
40
+ return GOBJ2RVAL_UNREF(g_unix_socket_address_new_abstract(RSTRING_PTR(path),
41
+ RSTRING_LEN(path)));
42
+ }
43
+
44
+ static VALUE
45
+ unixsocketaddress_get_is_abstract(VALUE self)
46
+ {
47
+ return CBOOL2RVAL(g_unix_socket_address_get_is_abstract(_SELF(self)));
48
+ }
49
+
50
+ static VALUE
51
+ unixsocketaddress_get_path(VALUE self)
52
+ {
53
+ return rb_str_new(g_unix_socket_address_get_path(_SELF(self)),
54
+ g_unix_socket_address_get_path_len(_SELF(self)));
55
+ }
56
+
57
+ /* TODO: get_path_len is pointless in Ruby, right? */
58
+
59
+ static VALUE
60
+ unixsocketaddress_abstract_names_supported(G_GNUC_UNUSED VALUE self)
61
+ {
62
+ return CBOOL2RVAL(g_unix_socket_address_abstract_names_supported());
63
+ }
64
+ #endif
65
+
66
+ void
67
+ Init_gunixsocketaddress(G_GNUC_UNUSED VALUE glib)
68
+ {
69
+ #ifdef HAVE_GIO_UNIX
70
+ VALUE unixsocketaddress = G_DEF_CLASS(G_TYPE_UNIX_SOCKET_ADDRESS, "UnixSocketAddress", glib);
71
+
72
+ rb_define_singleton_method(unixsocketaddress, "new_abstract", unixsocketaddress_new_abstract, 1);
73
+ rb_define_singleton_method(unixsocketaddress, "abstract_names_supported?", unixsocketaddress_abstract_names_supported, 0);
74
+
75
+ rb_define_method(unixsocketaddress, "initialize", unixsocketaddress_initialize, 1);
76
+ rb_define_method(unixsocketaddress, "abstract?", unixsocketaddress_get_is_abstract, 0);
77
+ rb_define_method(unixsocketaddress, "path", unixsocketaddress_get_path, 0);
78
+ #endif
79
+ }