gio2 0.90.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +60 -0
- data/README +34 -0
- data/Rakefile +76 -0
- data/ext/gio2/depend +5 -0
- data/ext/gio2/extconf.rb +91 -0
- data/ext/gio2/gappinfo.c +318 -0
- data/ext/gio2/gapplaunchcontext.c +79 -0
- data/ext/gio2/gasyncinitable.c +244 -0
- data/ext/gio2/gasyncresult.c +39 -0
- data/ext/gio2/gbufferedinputstream.c +184 -0
- data/ext/gio2/gbufferedoutputstream.c +82 -0
- data/ext/gio2/gcancellable.c +177 -0
- data/ext/gio2/gcharsetconverter.c +72 -0
- data/ext/gio2/gcontenttype.c +135 -0
- data/ext/gio2/gconverter.c +117 -0
- data/ext/gio2/gconverterinputstream.c +48 -0
- data/ext/gio2/gconverteroutputstream.c +48 -0
- data/ext/gio2/gdatainputstream.c +341 -0
- data/ext/gio2/gdataoutputstream.c +202 -0
- data/ext/gio2/gdesktopappinfo.c +90 -0
- data/ext/gio2/gdrive.c +267 -0
- data/ext/gio2/gemblem.c +71 -0
- data/ext/gio2/gemblemedicon.c +63 -0
- data/ext/gio2/gfile.c +2058 -0
- data/ext/gio2/gfileattribute.c +263 -0
- data/ext/gio2/gfileattributematcher.c +90 -0
- data/ext/gio2/gfiledescriptorbased.c +42 -0
- data/ext/gio2/gfileenumerator.c +167 -0
- data/ext/gio2/gfileicon.c +46 -0
- data/ext/gio2/gfileinfo.c +641 -0
- data/ext/gio2/gfileinputstream.c +92 -0
- data/ext/gio2/gfileiostream.c +98 -0
- data/ext/gio2/gfilemonitor.c +63 -0
- data/ext/gio2/gfilenamecompleter.c +72 -0
- data/ext/gio2/gfileoutputstream.c +100 -0
- data/ext/gio2/gfilterinputstream.c +56 -0
- data/ext/gio2/gfilteroutputstream.c +56 -0
- data/ext/gio2/gicon.c +69 -0
- data/ext/gio2/ginetaddress.c +188 -0
- data/ext/gio2/ginetsocketaddress.c +54 -0
- data/ext/gio2/ginitable.c +195 -0
- data/ext/gio2/ginputstream.c +341 -0
- data/ext/gio2/gio2.c +120 -0
- data/ext/gio2/gio2.def +2 -0
- data/ext/gio2/gio2.h +343 -0
- data/ext/gio2/gioerror.c +67 -0
- data/ext/gio2/giomodule.c +63 -0
- data/ext/gio2/gioscheduler.c +195 -0
- data/ext/gio2/giostream.c +129 -0
- data/ext/gio2/gloadableicon.c +91 -0
- data/ext/gio2/gmemoryinputstream.c +65 -0
- data/ext/gio2/gmemoryoutputstream.c +65 -0
- data/ext/gio2/gmount.c +283 -0
- data/ext/gio2/gmountoperation.c +168 -0
- data/ext/gio2/gnetworkaddress.c +71 -0
- data/ext/gio2/gnetworkservice.c +64 -0
- data/ext/gio2/goutputstream.c +343 -0
- data/ext/gio2/gresolver.c +230 -0
- data/ext/gio2/gseekable.c +89 -0
- data/ext/gio2/gsimpleasyncresult.c +153 -0
- data/ext/gio2/gsocket.c +451 -0
- data/ext/gio2/gsocketaddress.c +45 -0
- data/ext/gio2/gsocketclient.c +273 -0
- data/ext/gio2/gsocketconnectable.c +97 -0
- data/ext/gio2/gsocketconnection.c +82 -0
- data/ext/gio2/gsocketcontrolmessage.c +82 -0
- data/ext/gio2/gsocketlistener.c +239 -0
- data/ext/gio2/gsocketservice.c +64 -0
- data/ext/gio2/gsrvtarget.c +77 -0
- data/ext/gio2/gtcpconnection.c +48 -0
- data/ext/gio2/gthemedicon.c +86 -0
- data/ext/gio2/gthreadedsocketservice.c +39 -0
- data/ext/gio2/gunixconnection.c +69 -0
- data/ext/gio2/gunixfdlist.c +112 -0
- data/ext/gio2/gunixfdmessage.c +81 -0
- data/ext/gio2/gunixinputstream.c +73 -0
- data/ext/gio2/gunixmounts.c +346 -0
- data/ext/gio2/gunixoutputstream.c +73 -0
- data/ext/gio2/gunixsocketaddress.c +79 -0
- data/ext/gio2/gvfs.c +84 -0
- data/ext/gio2/gvolume.c +191 -0
- data/ext/gio2/gvolumemonitor.c +77 -0
- data/ext/gio2/gzlibcompressor.c +47 -0
- data/ext/gio2/gzlibdecompressor.c +43 -0
- data/ext/gio2/util.c +323 -0
- data/extconf.rb +49 -0
- data/lib/gio2.rb +141 -0
- metadata +184 -0
data/ext/gio2/gvfs.c
ADDED
@@ -0,0 +1,84 @@
|
|
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
|
+
#define _SELF(value) G_VFS(RVAL2GOBJ(value))
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
vfs_get_file_for_path(VALUE self, VALUE path)
|
27
|
+
{
|
28
|
+
return GOBJ2RVAL_UNREF(g_vfs_get_file_for_path(_SELF(self), RVAL2CSTR(path)));
|
29
|
+
}
|
30
|
+
|
31
|
+
static VALUE
|
32
|
+
vfs_get_file_for_uri(VALUE self, VALUE uri)
|
33
|
+
{
|
34
|
+
return GOBJ2RVAL_UNREF(g_vfs_get_file_for_uri(_SELF(self), RVAL2CSTR(uri)));
|
35
|
+
}
|
36
|
+
|
37
|
+
static VALUE
|
38
|
+
vfs_parse_name(VALUE self, VALUE parse_name)
|
39
|
+
{
|
40
|
+
return GOBJ2RVAL_UNREF(g_vfs_parse_name(_SELF(self), RVAL2CSTR(parse_name)));
|
41
|
+
}
|
42
|
+
|
43
|
+
static VALUE
|
44
|
+
vfs_get_default(G_GNUC_UNUSED VALUE self)
|
45
|
+
{
|
46
|
+
return GOBJ2RVAL(g_vfs_get_default());
|
47
|
+
}
|
48
|
+
|
49
|
+
static VALUE
|
50
|
+
vfs_get_local(G_GNUC_UNUSED VALUE self)
|
51
|
+
{
|
52
|
+
return GOBJ2RVAL(g_vfs_get_local());
|
53
|
+
}
|
54
|
+
|
55
|
+
static VALUE
|
56
|
+
vfs_is_active(VALUE self)
|
57
|
+
{
|
58
|
+
return CBOOL2RVAL(g_vfs_is_active(_SELF(self)));
|
59
|
+
}
|
60
|
+
|
61
|
+
static VALUE
|
62
|
+
vfs_get_supported_uri_schemes(VALUE self)
|
63
|
+
{
|
64
|
+
return STRVECTOR2ARY(g_vfs_get_supported_uri_schemes(_SELF(self)));
|
65
|
+
}
|
66
|
+
|
67
|
+
void
|
68
|
+
Init_gvfs(VALUE glib)
|
69
|
+
{
|
70
|
+
VALUE vfs = G_DEF_CLASS(G_TYPE_VFS, "Vfs", glib);
|
71
|
+
|
72
|
+
rb_define_const(vfs, "EXTENSION_POINT_NAME", CSTR2RVAL(G_VFS_EXTENSION_POINT_NAME));
|
73
|
+
|
74
|
+
rb_define_singleton_method(vfs, "default", vfs_get_default, 0);
|
75
|
+
rb_define_singleton_method(vfs, "local", vfs_get_local, 0);
|
76
|
+
|
77
|
+
rb_undef_alloc_func(vfs);
|
78
|
+
|
79
|
+
rb_define_method(vfs, "file_for_path", vfs_get_file_for_path, 1);
|
80
|
+
rb_define_method(vfs, "file_for_uri", vfs_get_file_for_uri, 1);
|
81
|
+
rb_define_method(vfs, "parse_name", vfs_parse_name, 1);
|
82
|
+
rb_define_method(vfs, "active?", vfs_is_active, 0);
|
83
|
+
rb_define_method(vfs, "supported_uri_schemes", vfs_get_supported_uri_schemes, 0);
|
84
|
+
}
|
data/ext/gio2/gvolume.c
ADDED
@@ -0,0 +1,191 @@
|
|
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
|
+
#define _SELF(value) G_VOLUME(RVAL2GOBJ(value))
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
volume_get_name(VALUE self)
|
27
|
+
{
|
28
|
+
return CSTR2RVAL_FREE(g_volume_get_name(_SELF(self)));
|
29
|
+
}
|
30
|
+
|
31
|
+
static VALUE
|
32
|
+
volume_get_uuid(VALUE self)
|
33
|
+
{
|
34
|
+
return CSTR2RVAL_FREE(g_volume_get_uuid(_SELF(self)));
|
35
|
+
}
|
36
|
+
|
37
|
+
static VALUE
|
38
|
+
volume_get_icon(VALUE self)
|
39
|
+
{
|
40
|
+
return GOBJ2RVAL_UNREF(g_volume_get_icon(_SELF(self)));
|
41
|
+
}
|
42
|
+
|
43
|
+
static VALUE
|
44
|
+
volume_get_drive(VALUE self)
|
45
|
+
{
|
46
|
+
return GOBJ2RVAL_UNREF(g_volume_get_drive(_SELF(self)));
|
47
|
+
}
|
48
|
+
|
49
|
+
static VALUE
|
50
|
+
volume_get_mount(VALUE self)
|
51
|
+
{
|
52
|
+
return GOBJ2RVAL_UNREF(g_volume_get_mount(_SELF(self)));
|
53
|
+
}
|
54
|
+
|
55
|
+
static VALUE
|
56
|
+
volume_can_mount(VALUE self)
|
57
|
+
{
|
58
|
+
return CBOOL2RVAL(g_volume_can_mount(_SELF(self)));
|
59
|
+
}
|
60
|
+
|
61
|
+
static VALUE
|
62
|
+
volume_should_automount(VALUE self)
|
63
|
+
{
|
64
|
+
return CBOOL2RVAL(g_volume_should_automount(_SELF(self)));
|
65
|
+
}
|
66
|
+
|
67
|
+
static VALUE
|
68
|
+
volume_get_activation_root(VALUE self)
|
69
|
+
{
|
70
|
+
return GOBJ2RVAL_UNREF(g_volume_get_activation_root(_SELF(self)));
|
71
|
+
}
|
72
|
+
|
73
|
+
static VALUE
|
74
|
+
volume_mount(int argc, VALUE *argv, VALUE self)
|
75
|
+
{
|
76
|
+
VALUE rbflags, rbmount_operation, rbcancellable, block;
|
77
|
+
GMountMountFlags flags;
|
78
|
+
GMountOperation *mount_operation;
|
79
|
+
GCancellable *cancellable;
|
80
|
+
|
81
|
+
rb_scan_args(argc, argv, "03&", &rbflags, &rbmount_operation, &rbcancellable, &block);
|
82
|
+
flags = RVAL2GMOUNTMOUNTFLAGSDEFAULT(rbflags);
|
83
|
+
mount_operation = RVAL2GMOUNTOPERATION(rbmount_operation);
|
84
|
+
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
85
|
+
SAVE_BLOCK(block);
|
86
|
+
g_volume_mount(_SELF(self),
|
87
|
+
flags,
|
88
|
+
mount_operation,
|
89
|
+
cancellable,
|
90
|
+
rbgio_async_ready_callback,
|
91
|
+
(gpointer)block);
|
92
|
+
|
93
|
+
return self;
|
94
|
+
}
|
95
|
+
|
96
|
+
typedef gboolean (*BooleanFinishMethod)(GVolume *,
|
97
|
+
GAsyncResult *,
|
98
|
+
GError **);
|
99
|
+
|
100
|
+
static VALUE
|
101
|
+
boolean_finish_method(BooleanFinishMethod method, VALUE self, VALUE result)
|
102
|
+
{
|
103
|
+
GError *error = NULL;
|
104
|
+
|
105
|
+
if (!method(_SELF(self), RVAL2GASYNCRESULT(result), &error))
|
106
|
+
rbgio_raise_error(error);
|
107
|
+
|
108
|
+
return self;
|
109
|
+
}
|
110
|
+
|
111
|
+
static VALUE
|
112
|
+
volume_mount_finish(VALUE self, VALUE result)
|
113
|
+
{
|
114
|
+
return boolean_finish_method(g_volume_mount_finish, self, result);
|
115
|
+
}
|
116
|
+
|
117
|
+
static VALUE
|
118
|
+
volume_can_eject(VALUE self)
|
119
|
+
{
|
120
|
+
return CBOOL2RVAL(g_volume_can_eject(_SELF(self)));
|
121
|
+
}
|
122
|
+
|
123
|
+
static VALUE
|
124
|
+
volume_eject_with_operation(int argc, VALUE *argv, VALUE self)
|
125
|
+
{
|
126
|
+
VALUE rbflags, rbmount_operation, rbcancellable, block;
|
127
|
+
GMountUnmountFlags flags;
|
128
|
+
GMountOperation *mount_operation;
|
129
|
+
GCancellable *cancellable;
|
130
|
+
|
131
|
+
rb_scan_args(argc, argv, "03&", &rbflags, &rbmount_operation, &rbcancellable, &block);
|
132
|
+
flags = RVAL2GMOUNTUNMOUNTFLAGSDEFAULT(rbflags);
|
133
|
+
mount_operation = RVAL2GMOUNTOPERATION(rbmount_operation);
|
134
|
+
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
135
|
+
SAVE_BLOCK(block);
|
136
|
+
g_volume_eject_with_operation(_SELF(self),
|
137
|
+
flags,
|
138
|
+
mount_operation,
|
139
|
+
cancellable,
|
140
|
+
rbgio_async_ready_callback,
|
141
|
+
(gpointer)block);
|
142
|
+
|
143
|
+
return self;
|
144
|
+
}
|
145
|
+
|
146
|
+
static VALUE
|
147
|
+
volume_eject_with_operation_finish(VALUE self, VALUE result)
|
148
|
+
{
|
149
|
+
return boolean_finish_method(g_volume_eject_with_operation_finish, self, result);
|
150
|
+
}
|
151
|
+
|
152
|
+
static VALUE
|
153
|
+
volume_enumerate_identifiers(VALUE self)
|
154
|
+
{
|
155
|
+
return STRVECTOR2ARY_FREE(g_volume_enumerate_identifiers(_SELF(self)));
|
156
|
+
}
|
157
|
+
|
158
|
+
static VALUE
|
159
|
+
volume_get_identifier(VALUE self, VALUE kind)
|
160
|
+
{
|
161
|
+
return CSTR2RVAL_FREE(g_volume_get_identifier(_SELF(self), RVAL2CSTR(kind)));
|
162
|
+
}
|
163
|
+
|
164
|
+
void
|
165
|
+
Init_gvolume(VALUE glib)
|
166
|
+
{
|
167
|
+
VALUE volume = G_DEF_INTERFACE(G_TYPE_VOLUME, "Volume", glib);
|
168
|
+
|
169
|
+
rb_define_const(volume, "IDENTIFIER_KIND_HAL_UDI", CSTR2RVAL(G_VOLUME_IDENTIFIER_KIND_HAL_UDI));
|
170
|
+
rb_define_const(volume, "IDENTIFIER_KIND_LABEL", CSTR2RVAL(G_VOLUME_IDENTIFIER_KIND_LABEL));
|
171
|
+
rb_define_const(volume, "IDENTIFIER_KIND_NFS_MOUNT", CSTR2RVAL(G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT));
|
172
|
+
rb_define_const(volume, "IDENTIFIER_KIND_UNIX_DEVICE", CSTR2RVAL(G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE));
|
173
|
+
rb_define_const(volume, "IDENTIFIER_KIND_UUID", CSTR2RVAL(G_VOLUME_IDENTIFIER_KIND_UUID));
|
174
|
+
|
175
|
+
rb_define_method(volume, "name", volume_get_name, 0);
|
176
|
+
rb_define_method(volume, "uuid", volume_get_uuid, 0);
|
177
|
+
rb_define_method(volume, "icon", volume_get_icon, 0);
|
178
|
+
rb_define_method(volume, "drive", volume_get_drive, 0);
|
179
|
+
rb_define_method(volume, "mount", volume_get_mount, 0);
|
180
|
+
rb_define_method(volume, "can_mount?", volume_can_mount, 0);
|
181
|
+
rb_define_method(volume, "should_automount?", volume_should_automount, 0);
|
182
|
+
rb_define_method(volume, "activation_root", volume_get_activation_root, 0);
|
183
|
+
rb_define_method(volume, "mount", volume_mount, -1);
|
184
|
+
rb_define_method(volume, "mount_finish", volume_mount_finish, 1);
|
185
|
+
rb_define_method(volume, "can_eject?", volume_can_eject, 0);
|
186
|
+
rb_define_method(volume, "eject_with_operation", volume_eject_with_operation, -1);
|
187
|
+
rb_define_method(volume, "eject_with_operation_finish", volume_eject_with_operation_finish, 1);
|
188
|
+
rb_define_method(volume, "enumerate_identifiers", volume_enumerate_identifiers, -1);
|
189
|
+
rb_define_alias(volume, "identifiers", "enumerate_identifiers");
|
190
|
+
rb_define_method(volume, "get_identifier", volume_get_identifier, 1);
|
191
|
+
}
|
@@ -0,0 +1,77 @@
|
|
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
|
+
#define _SELF(value) G_VOLUME_MONITOR(RVAL2GOBJ(value))
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
volumemonitor_get(G_GNUC_UNUSED VALUE self)
|
27
|
+
{
|
28
|
+
return GOBJ2RVAL_UNREF(g_volume_monitor_get());
|
29
|
+
}
|
30
|
+
|
31
|
+
static VALUE
|
32
|
+
volumemonitor_get_connected_drives(VALUE self)
|
33
|
+
{
|
34
|
+
return GLIST2ARY_FREE(g_volume_monitor_get_connected_drives(_SELF(self)));
|
35
|
+
}
|
36
|
+
|
37
|
+
static VALUE
|
38
|
+
volumemonitor_get_volumes(VALUE self)
|
39
|
+
{
|
40
|
+
return GLIST2ARY_FREE(g_volume_monitor_get_volumes(_SELF(self)));
|
41
|
+
}
|
42
|
+
|
43
|
+
static VALUE
|
44
|
+
volumemonitor_get_mounts(VALUE self)
|
45
|
+
{
|
46
|
+
return GLIST2ARY_FREE(g_volume_monitor_get_mounts(_SELF(self)));
|
47
|
+
}
|
48
|
+
|
49
|
+
static VALUE
|
50
|
+
volumemonitor_get_mount_for_uuid(VALUE self, VALUE value)
|
51
|
+
{
|
52
|
+
return GOBJ2RVAL_UNREF(g_volume_monitor_get_mount_for_uuid(_SELF(self), RVAL2CSTR(value)));
|
53
|
+
}
|
54
|
+
|
55
|
+
static VALUE
|
56
|
+
volumemonitor_get_volume_for_uuid(VALUE self, VALUE value)
|
57
|
+
{
|
58
|
+
return GOBJ2RVAL_UNREF(g_volume_monitor_get_volume_for_uuid(_SELF(self), RVAL2CSTR(value)));
|
59
|
+
}
|
60
|
+
|
61
|
+
void
|
62
|
+
Init_gvolumemonitor(VALUE glib)
|
63
|
+
{
|
64
|
+
VALUE volumemonitor = G_DEF_CLASS(G_TYPE_VOLUME_MONITOR, "VolumeMonitor", glib);
|
65
|
+
|
66
|
+
rb_define_const(volumemonitor, "EXTENSION_POINT_NAME", CSTR2RVAL(G_VOLUME_MONITOR_EXTENSION_POINT_NAME));
|
67
|
+
|
68
|
+
rb_undef_alloc_func(volumemonitor);
|
69
|
+
|
70
|
+
rb_define_singleton_method(volumemonitor, "get", volumemonitor_get, 0);
|
71
|
+
|
72
|
+
rb_define_method(volumemonitor, "connected_drives", volumemonitor_get_connected_drives, 0);
|
73
|
+
rb_define_method(volumemonitor, "volumes", volumemonitor_get_volumes, 0);
|
74
|
+
rb_define_method(volumemonitor, "mounts", volumemonitor_get_mounts, 0);
|
75
|
+
rb_define_method(volumemonitor, "get_mount_for_uuid", volumemonitor_get_mount_for_uuid, 0);
|
76
|
+
rb_define_method(volumemonitor, "get_volume_for_uuid", volumemonitor_get_volume_for_uuid, 0);
|
77
|
+
}
|
@@ -0,0 +1,47 @@
|
|
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
|
+
#define _SELF(value) G_ZLIB_COMPRESSOR(RVAL2GOBJ(value))
|
24
|
+
|
25
|
+
#define RVAL2ZLIBCOMPRESSORLEVELDEFAULT(value) \
|
26
|
+
RVAL2TYPE_WITH_DEFAULT((value), FIX2INT, -1)
|
27
|
+
|
28
|
+
static VALUE
|
29
|
+
zlibcompressor_initialize(int argc, VALUE *argv, VALUE self)
|
30
|
+
{
|
31
|
+
VALUE format, level;
|
32
|
+
|
33
|
+
rb_scan_args(argc, argv, "02", &format, &level);
|
34
|
+
G_INITIALIZE(self,
|
35
|
+
g_zlib_compressor_new(RVAL2GZLIBCOMPRESSORFORMATDEFAULT(format),
|
36
|
+
RVAL2GZLIBCOMPRESSORFORMATDEFAULT(level)));
|
37
|
+
|
38
|
+
return Qnil;
|
39
|
+
}
|
40
|
+
|
41
|
+
void
|
42
|
+
Init_gzlibcompressor(VALUE glib)
|
43
|
+
{
|
44
|
+
VALUE zlibcompressor = G_DEF_CLASS(G_TYPE_ZLIB_COMPRESSOR, "ZlibCompressor", glib);
|
45
|
+
|
46
|
+
rb_define_method(zlibcompressor, "initialize", zlibcompressor_initialize, -1);
|
47
|
+
}
|
@@ -0,0 +1,43 @@
|
|
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
|
+
#define _SELF(value) G_ZLIB_DECOMPRESSOR(RVAL2GOBJ(value))
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
zlibdecompressor_initialize(int argc, VALUE *argv, VALUE self)
|
27
|
+
{
|
28
|
+
VALUE format;
|
29
|
+
|
30
|
+
rb_scan_args(argc, argv, "01", &format);
|
31
|
+
G_INITIALIZE(self,
|
32
|
+
g_zlib_decompressor_new(RVAL2GZLIBCOMPRESSORFORMATDEFAULT(format)));
|
33
|
+
|
34
|
+
return Qnil;
|
35
|
+
}
|
36
|
+
|
37
|
+
void
|
38
|
+
Init_gzlibdecompressor(VALUE glib)
|
39
|
+
{
|
40
|
+
VALUE zlibdecompressor = G_DEF_CLASS(G_TYPE_ZLIB_DECOMPRESSOR, "ZlibDecompressor", glib);
|
41
|
+
|
42
|
+
rb_define_method(zlibdecompressor, "initialize", zlibdecompressor_initialize, -1);
|
43
|
+
}
|
data/ext/gio2/util.c
ADDED
@@ -0,0 +1,323 @@
|
|
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
|
+
static ID s_id_enum_name;
|
24
|
+
static ID s_id_errors;
|
25
|
+
|
26
|
+
static VALUE s_errors;
|
27
|
+
|
28
|
+
VALUE
|
29
|
+
rbgio_cstr_to_rval_tainted(const char *string, gsize length)
|
30
|
+
{
|
31
|
+
VALUE result;
|
32
|
+
|
33
|
+
if (string == NULL)
|
34
|
+
return Qnil;
|
35
|
+
|
36
|
+
result = rb_str_new(string, length);
|
37
|
+
OBJ_TAINT(result);
|
38
|
+
|
39
|
+
return result;
|
40
|
+
}
|
41
|
+
|
42
|
+
struct rbgio_cstr_to_rval_tainted_free_data
|
43
|
+
{
|
44
|
+
char *string;
|
45
|
+
gsize length;
|
46
|
+
};
|
47
|
+
|
48
|
+
static VALUE
|
49
|
+
rbgio_cstr_to_rval_tainted_free_body(VALUE data)
|
50
|
+
{
|
51
|
+
struct rbgio_cstr_to_rval_tainted_free_data *real;
|
52
|
+
|
53
|
+
real = (struct rbgio_cstr_to_rval_tainted_free_data *)data;
|
54
|
+
|
55
|
+
return rbgio_cstr_to_rval_tainted(real->string, real->length);
|
56
|
+
}
|
57
|
+
|
58
|
+
static VALUE
|
59
|
+
rbgio_cstr_to_rval_tainted_free_ensure(VALUE data)
|
60
|
+
{
|
61
|
+
g_free(((struct rbgio_cstr_to_rval_tainted_free_data *)data)->string);
|
62
|
+
|
63
|
+
return Qnil;
|
64
|
+
}
|
65
|
+
|
66
|
+
VALUE
|
67
|
+
rbgio_cstr_to_rval_tainted_free(char *string, gsize length)
|
68
|
+
{
|
69
|
+
struct rbgio_cstr_to_rval_tainted_free_data data = { string, length };
|
70
|
+
|
71
|
+
return rb_ensure(rbgio_cstr_to_rval_tainted_free_body, (VALUE)&data,
|
72
|
+
rbgio_cstr_to_rval_tainted_free_ensure, (VALUE)&data);
|
73
|
+
}
|
74
|
+
|
75
|
+
VALUE
|
76
|
+
rbgio_glist_to_ary_unref_free(GList *list)
|
77
|
+
{
|
78
|
+
VALUE ary;
|
79
|
+
GList *i;
|
80
|
+
|
81
|
+
ary = rb_ary_new();
|
82
|
+
for (i = list; i != NULL; i = i->next)
|
83
|
+
rb_ary_push(ary, GOBJ2RVAL_UNREF(i->data));
|
84
|
+
g_list_free(list);
|
85
|
+
|
86
|
+
return ary;
|
87
|
+
}
|
88
|
+
|
89
|
+
VALUE
|
90
|
+
rbgio_fds_to_ary(const gint *fds)
|
91
|
+
{
|
92
|
+
int i, n;
|
93
|
+
VALUE ary;
|
94
|
+
|
95
|
+
for (i = n = 0; fds[i] != -1; i++)
|
96
|
+
n++;
|
97
|
+
|
98
|
+
ary = rb_ary_new2(n);
|
99
|
+
for (i = 0; i < n; i++)
|
100
|
+
RARRAY_PTR(ary)[i] = FD2RVAL(fds[i]);
|
101
|
+
|
102
|
+
return ary;
|
103
|
+
}
|
104
|
+
|
105
|
+
static VALUE
|
106
|
+
rbgio_fds_to_ary_free_ensure(gint *fds)
|
107
|
+
{
|
108
|
+
g_free(fds);
|
109
|
+
|
110
|
+
return Qnil;
|
111
|
+
}
|
112
|
+
|
113
|
+
VALUE
|
114
|
+
rbgio_fds_to_ary_free(gint *fds)
|
115
|
+
{
|
116
|
+
return rb_ensure(rbgio_fds_to_ary, (VALUE)fds,
|
117
|
+
rbgio_fds_to_ary_free_ensure, (VALUE)fds);
|
118
|
+
}
|
119
|
+
|
120
|
+
GList *
|
121
|
+
rbgio_gfile_ary_to_glist(VALUE ary)
|
122
|
+
{
|
123
|
+
int i, n;
|
124
|
+
volatile GFile *file;
|
125
|
+
GList *list = NULL;
|
126
|
+
|
127
|
+
ary = rb_ary_to_ary(ary);
|
128
|
+
n = RARRAY_LEN(ary);
|
129
|
+
|
130
|
+
for (i = 0; i < n; i++)
|
131
|
+
file = RVAL2GFILE(RARRAY_PTR(ary)[i]);
|
132
|
+
|
133
|
+
for (i = 0; i < n; i++)
|
134
|
+
list = g_list_append(list, RVAL2GFILE(RARRAY_PTR(ary)[i]));
|
135
|
+
|
136
|
+
return list;
|
137
|
+
}
|
138
|
+
|
139
|
+
GList *
|
140
|
+
rbgio_gfile_ary_to_glist_accept_nil(VALUE ary)
|
141
|
+
{
|
142
|
+
if (NIL_P(ary))
|
143
|
+
return NULL;
|
144
|
+
|
145
|
+
return rbgio_gfile_ary_to_glist(ary);
|
146
|
+
}
|
147
|
+
|
148
|
+
void
|
149
|
+
rbgio_rval_to_gtimeval(VALUE value, GTimeVal *time)
|
150
|
+
{
|
151
|
+
if (rb_respond_to(value, rb_intern("tv_sec"))) {
|
152
|
+
time->tv_sec = RVAL2GLONG(rb_funcall(value, rb_intern("tv_sec"), 0));
|
153
|
+
time->tv_usec = rb_respond_to(value, rb_intern("tv_usec")) ?
|
154
|
+
RVAL2GLONG(rb_funcall(value, rb_intern("tv_usec"), 0)) :
|
155
|
+
0;
|
156
|
+
} else if (rb_respond_to(value, rb_intern("to_ary"))) {
|
157
|
+
VALUE ary = rb_ary_to_ary(value);
|
158
|
+
if (RARRAY_LEN(ary) < 1 || RARRAY_LEN(ary) > 2)
|
159
|
+
rb_raise(rb_eArgError, "Array of length 1 or 2 expected");
|
160
|
+
time->tv_sec = RVAL2GLONG(RARRAY_PTR(ary)[0]);
|
161
|
+
time->tv_usec = RARRAY_LEN(ary) > 1 ? RVAL2GLONG(RARRAY_PTR(ary)[1]) : 0;
|
162
|
+
} else {
|
163
|
+
time->tv_sec = RVAL2GLONG(value);
|
164
|
+
time->tv_usec = 0;
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
VALUE
|
169
|
+
rbgio_str_vector_to_ary(const gchar * const *vector)
|
170
|
+
{
|
171
|
+
int i, n;
|
172
|
+
VALUE ary;
|
173
|
+
|
174
|
+
for (i = n = 0; vector[i] != NULL; i++)
|
175
|
+
n++;
|
176
|
+
ary = rb_ary_new2(n);
|
177
|
+
for (i = 0; i < n; i++)
|
178
|
+
RARRAY_PTR(ary)[i] = CSTR2RVAL(vector[i]);
|
179
|
+
|
180
|
+
return ary;
|
181
|
+
}
|
182
|
+
|
183
|
+
static VALUE
|
184
|
+
rbgio_str_vector_to_ary_free_ensure(gchar **vector)
|
185
|
+
{
|
186
|
+
g_strfreev(vector);
|
187
|
+
|
188
|
+
return Qnil;
|
189
|
+
}
|
190
|
+
|
191
|
+
VALUE
|
192
|
+
rbgio_str_vector_to_ary_free(gchar **vector)
|
193
|
+
{
|
194
|
+
return rb_ensure(rbgio_str_vector_to_ary, (VALUE)vector,
|
195
|
+
rbgio_str_vector_to_ary_free_ensure, (VALUE)vector);
|
196
|
+
}
|
197
|
+
|
198
|
+
char **
|
199
|
+
rbgio_ary_to_str_vector(VALUE ary)
|
200
|
+
{
|
201
|
+
int i, n;
|
202
|
+
char **strings;
|
203
|
+
|
204
|
+
ary = rb_ary_to_ary(ary);
|
205
|
+
n = RARRAY_LEN(ary);
|
206
|
+
|
207
|
+
for (i = 0; i < n; i++)
|
208
|
+
StringValue(RARRAY_PTR(ary)[i]);
|
209
|
+
|
210
|
+
strings = g_new(char *, n + 1);
|
211
|
+
for (i = 0; i < n; i++)
|
212
|
+
strings[i] = RVAL2CSTR(RARRAY_PTR(ary)[i]);
|
213
|
+
strings[n] = NULL;
|
214
|
+
|
215
|
+
return strings;
|
216
|
+
}
|
217
|
+
|
218
|
+
struct async_ready_callback_data
|
219
|
+
{
|
220
|
+
GAsyncResult *result;
|
221
|
+
gpointer data;
|
222
|
+
};
|
223
|
+
|
224
|
+
static VALUE
|
225
|
+
rbgio_async_ready_callback_call(VALUE data)
|
226
|
+
{
|
227
|
+
static VALUE s_id_call;
|
228
|
+
struct async_ready_callback_data *real;
|
229
|
+
VALUE block;
|
230
|
+
|
231
|
+
if (s_id_call == 0)
|
232
|
+
s_id_call = rb_intern("call");
|
233
|
+
|
234
|
+
real = (struct async_ready_callback_data *)data;
|
235
|
+
block = USE_BLOCK(real->data);
|
236
|
+
if (!NIL_P(block))
|
237
|
+
rb_funcall(block, s_id_call, 1, GOBJ2RVAL_UNREF(real->result));
|
238
|
+
|
239
|
+
return Qnil;
|
240
|
+
}
|
241
|
+
|
242
|
+
void
|
243
|
+
rbgio_async_ready_callback(G_GNUC_UNUSED GObject *source,
|
244
|
+
GAsyncResult *result,
|
245
|
+
gpointer data)
|
246
|
+
{
|
247
|
+
struct async_ready_callback_data real = { result, data };
|
248
|
+
|
249
|
+
G_PROTECT_CALLBACK(rbgio_async_ready_callback_call, &real);
|
250
|
+
}
|
251
|
+
|
252
|
+
VALUE
|
253
|
+
rbgio_child_remove_and_return(VALUE parent, VALUE child)
|
254
|
+
{
|
255
|
+
G_CHILD_REMOVE(parent, child);
|
256
|
+
|
257
|
+
return child;
|
258
|
+
}
|
259
|
+
|
260
|
+
VALUE
|
261
|
+
rbgio_define_domain_error(VALUE module,
|
262
|
+
const char *name,
|
263
|
+
GQuark domain,
|
264
|
+
const char *enum_name,
|
265
|
+
VALUE parent)
|
266
|
+
{
|
267
|
+
VALUE error;
|
268
|
+
|
269
|
+
error = rb_define_class_under(module, name, parent);
|
270
|
+
rb_ivar_set(error, s_id_enum_name, CSTR2RVAL(enum_name));
|
271
|
+
rb_ivar_set(error, s_id_errors, rb_hash_new());
|
272
|
+
rb_hash_aset(s_errors, UINT2NUM(domain), error);
|
273
|
+
|
274
|
+
return error;
|
275
|
+
}
|
276
|
+
|
277
|
+
VALUE
|
278
|
+
rbgio_define_error(VALUE module,
|
279
|
+
const char *name,
|
280
|
+
gint code,
|
281
|
+
VALUE domain_error)
|
282
|
+
{
|
283
|
+
VALUE error;
|
284
|
+
|
285
|
+
error = rb_define_class_under(module, name, domain_error);
|
286
|
+
rb_hash_aset(rb_ivar_get(domain_error, s_id_errors),
|
287
|
+
INT2NUM(code),
|
288
|
+
error);
|
289
|
+
|
290
|
+
return error;
|
291
|
+
}
|
292
|
+
|
293
|
+
void
|
294
|
+
rbgio_raise_error(GError *error)
|
295
|
+
{
|
296
|
+
VALUE domain_error, rberror;
|
297
|
+
|
298
|
+
domain_error = rb_hash_aref(s_errors, UINT2NUM(error->domain));
|
299
|
+
if (NIL_P(domain_error))
|
300
|
+
RAISE_GERROR(error);
|
301
|
+
|
302
|
+
rberror = rb_hash_aref(rb_ivar_get(domain_error, s_id_errors),
|
303
|
+
INT2NUM(error->code));
|
304
|
+
if (NIL_P(rberror)) {
|
305
|
+
VALUE enum_name = rb_ivar_get(domain_error, s_id_enum_name);
|
306
|
+
|
307
|
+
rb_raise(rb_eNotImpError,
|
308
|
+
"%s contains error codes that have not been implemented: %d",
|
309
|
+
RVAL2CSTR(enum_name), error->code);
|
310
|
+
}
|
311
|
+
|
312
|
+
rb_raise(rberror, "%s", error->message);
|
313
|
+
}
|
314
|
+
|
315
|
+
void
|
316
|
+
Init_util(void)
|
317
|
+
{
|
318
|
+
s_id_enum_name = rb_intern("@enum_name");
|
319
|
+
s_id_errors = rb_intern("@errors");
|
320
|
+
|
321
|
+
s_errors = rb_hash_new();
|
322
|
+
rb_global_variable(&s_errors);
|
323
|
+
}
|