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
@@ -0,0 +1,195 @@
|
|
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 GIOSchedulerJob *
|
24
|
+
ioschedulerjob_copy(const GIOSchedulerJob *job)
|
25
|
+
{
|
26
|
+
return (GIOSchedulerJob *)job;
|
27
|
+
}
|
28
|
+
|
29
|
+
static void
|
30
|
+
ioschedulerjob_free(G_GNUC_UNUSED GIOSchedulerJob *job)
|
31
|
+
{
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
|
35
|
+
static GType
|
36
|
+
g_io_scheduler_job_get_type(void)
|
37
|
+
{
|
38
|
+
static GType our_type = 0;
|
39
|
+
|
40
|
+
if (our_type == 0)
|
41
|
+
our_type = g_boxed_type_register_static("GIOSchedulerJob",
|
42
|
+
(GBoxedCopyFunc)ioschedulerjob_copy,
|
43
|
+
(GBoxedFreeFunc)ioschedulerjob_free);
|
44
|
+
|
45
|
+
return our_type;
|
46
|
+
}
|
47
|
+
|
48
|
+
#define G_TYPE_IO_SCHEDULER_JOB (g_io_scheduler_job_get_type())
|
49
|
+
|
50
|
+
#define RVAL2GIOSCHEDULERJOB(object) \
|
51
|
+
((GIOSchedulerJob *)(RVAL2BOXED(object, G_TYPE_IO_SCHEDULER_JOB)))
|
52
|
+
|
53
|
+
#define GIOSCHEDULERJOB2RVAL(object) \
|
54
|
+
BOXED2RVAL(object, G_TYPE_IO_SCHEDULER_JOB)
|
55
|
+
|
56
|
+
#define _SELF(value) RVAL2GIOSCHEDULERJOB(value)
|
57
|
+
|
58
|
+
struct ioscheduler_job_callback_data
|
59
|
+
{
|
60
|
+
GIOSchedulerJob *job;
|
61
|
+
GCancellable *cancellable;
|
62
|
+
gpointer data;
|
63
|
+
};
|
64
|
+
|
65
|
+
static VALUE
|
66
|
+
ioscheduler_job_callback_call(VALUE data)
|
67
|
+
{
|
68
|
+
static VALUE s_id_call;
|
69
|
+
struct ioscheduler_job_callback_data *real;
|
70
|
+
|
71
|
+
if (s_id_call == 0)
|
72
|
+
s_id_call = rb_intern("call");
|
73
|
+
|
74
|
+
real = (struct ioscheduler_job_callback_data *)data;
|
75
|
+
|
76
|
+
/* TODO: Totally unsure if _UNREF is correct here or not. */
|
77
|
+
return rb_funcall(USE_BLOCK_AND_SAVE(real->data), s_id_call, 2,
|
78
|
+
GOBJ2RVAL_UNREF(real->job),
|
79
|
+
GOBJ2RVAL_UNREF(real->cancellable));
|
80
|
+
}
|
81
|
+
|
82
|
+
static gboolean
|
83
|
+
ioscheduler_job_callback(GIOSchedulerJob *job,
|
84
|
+
GCancellable *cancellable,
|
85
|
+
gpointer data)
|
86
|
+
{
|
87
|
+
struct ioscheduler_job_callback_data real = { job, cancellable, data };
|
88
|
+
|
89
|
+
return RVAL2CBOOL(G_PROTECT_CALLBACK(ioscheduler_job_callback_call,
|
90
|
+
&real));
|
91
|
+
}
|
92
|
+
|
93
|
+
static void
|
94
|
+
ioscheduler_job_callback_free(gpointer data)
|
95
|
+
{
|
96
|
+
USE_BLOCK((VALUE)data);
|
97
|
+
}
|
98
|
+
|
99
|
+
static VALUE
|
100
|
+
ioscheduler_push_job(int argc, VALUE *argv, VALUE self)
|
101
|
+
{
|
102
|
+
VALUE rbio_priority, rbcancellable, block;
|
103
|
+
gint io_priority;
|
104
|
+
GCancellable *cancellable;
|
105
|
+
|
106
|
+
rb_scan_args(argc, argv, "01", &rbio_priority, &rbcancellable);
|
107
|
+
io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
|
108
|
+
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
109
|
+
block = rb_block_proc();
|
110
|
+
SAVE_BLOCK(block);
|
111
|
+
g_io_scheduler_push_job(ioscheduler_job_callback,
|
112
|
+
(gpointer)block,
|
113
|
+
ioscheduler_job_callback_free,
|
114
|
+
io_priority,
|
115
|
+
cancellable);
|
116
|
+
|
117
|
+
return self;
|
118
|
+
}
|
119
|
+
|
120
|
+
static VALUE
|
121
|
+
ioscheduler_cancel_all_jobs(VALUE self)
|
122
|
+
{
|
123
|
+
g_io_scheduler_cancel_all_jobs();
|
124
|
+
|
125
|
+
return self;
|
126
|
+
}
|
127
|
+
|
128
|
+
static VALUE
|
129
|
+
ioscheduler_source_callback_call(VALUE data)
|
130
|
+
{
|
131
|
+
static VALUE s_id_call;
|
132
|
+
|
133
|
+
if (s_id_call == 0)
|
134
|
+
s_id_call = rb_intern("call");
|
135
|
+
|
136
|
+
return rb_funcall(USE_BLOCK_AND_SAVE(data), s_id_call, 0);
|
137
|
+
}
|
138
|
+
|
139
|
+
static gboolean
|
140
|
+
ioscheduler_source_callback(gpointer data)
|
141
|
+
{
|
142
|
+
return RVAL2CBOOL(G_PROTECT_CALLBACK(ioscheduler_source_callback_call,
|
143
|
+
data));
|
144
|
+
}
|
145
|
+
|
146
|
+
static void
|
147
|
+
ioscheduler_source_callback_free(gpointer data)
|
148
|
+
{
|
149
|
+
USE_BLOCK(data);
|
150
|
+
}
|
151
|
+
|
152
|
+
static VALUE
|
153
|
+
ioschedulerjob_send_to_mainloop(VALUE self)
|
154
|
+
{
|
155
|
+
VALUE block;
|
156
|
+
|
157
|
+
block = rb_block_proc();
|
158
|
+
SAVE_BLOCK(block);
|
159
|
+
|
160
|
+
return CBOOL2RVAL(g_io_scheduler_job_send_to_mainloop(_SELF(self),
|
161
|
+
ioscheduler_source_callback,
|
162
|
+
(gpointer)block,
|
163
|
+
ioscheduler_source_callback_free));
|
164
|
+
}
|
165
|
+
|
166
|
+
static VALUE
|
167
|
+
ioschedulerjob_send_to_mainloop_async(VALUE self)
|
168
|
+
{
|
169
|
+
VALUE block;
|
170
|
+
|
171
|
+
block = rb_block_proc();
|
172
|
+
SAVE_BLOCK(block);
|
173
|
+
|
174
|
+
g_io_scheduler_job_send_to_mainloop_async(_SELF(self),
|
175
|
+
ioscheduler_source_callback,
|
176
|
+
(gpointer)block,
|
177
|
+
ioscheduler_source_callback_free);
|
178
|
+
|
179
|
+
return self;
|
180
|
+
}
|
181
|
+
|
182
|
+
void
|
183
|
+
Init_gioscheduler(VALUE glib)
|
184
|
+
{
|
185
|
+
VALUE ioschedulerjob = G_DEF_CLASS(G_TYPE_IO_SCHEDULER_JOB, "IOSchedulerJob", glib);
|
186
|
+
|
187
|
+
/* TODO: These don’t follow naming scheme exactly, but seems redundant
|
188
|
+
* to add GLib::IOScheduler. Perhaps rename them to push and
|
189
|
+
* cancel_all. */
|
190
|
+
rb_define_singleton_method(ioschedulerjob, "push_job", ioscheduler_push_job, -1);
|
191
|
+
rb_define_singleton_method(ioschedulerjob, "cancel_all_jobs", ioscheduler_cancel_all_jobs, 0);
|
192
|
+
|
193
|
+
rb_define_method(ioschedulerjob, "send_to_mainloop", ioschedulerjob_send_to_mainloop, 0);
|
194
|
+
rb_define_method(ioschedulerjob, "send_to_mainloop_async", ioschedulerjob_send_to_mainloop_async, 0);
|
195
|
+
}
|
@@ -0,0 +1,129 @@
|
|
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_IO_STREAM(RVAL2GOBJ(value))
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
iostream_get_input_stream(VALUE self)
|
27
|
+
{
|
28
|
+
return GOBJ2RVAL(g_io_stream_get_input_stream(_SELF(self)));
|
29
|
+
}
|
30
|
+
|
31
|
+
static VALUE
|
32
|
+
iostream_get_output_stream(VALUE self)
|
33
|
+
{
|
34
|
+
return GOBJ2RVAL(g_io_stream_get_output_stream(_SELF(self)));
|
35
|
+
}
|
36
|
+
|
37
|
+
static VALUE
|
38
|
+
iostream_close(VALUE self, VALUE cancellable)
|
39
|
+
{
|
40
|
+
GError *error = NULL;
|
41
|
+
|
42
|
+
if (!g_io_stream_close(_SELF(self), RVAL2GCANCELLABLE(cancellable), &error))
|
43
|
+
rbgio_raise_error(error);
|
44
|
+
|
45
|
+
return self;
|
46
|
+
}
|
47
|
+
|
48
|
+
static VALUE
|
49
|
+
iostream_close_async(int argc, VALUE *argv, VALUE self)
|
50
|
+
{
|
51
|
+
VALUE rbio_priority, rbcancellable, block;
|
52
|
+
int io_priority;
|
53
|
+
GCancellable *cancellable;
|
54
|
+
|
55
|
+
rb_scan_args(argc, argv, "01&", &rbio_priority, &rbcancellable, &block);
|
56
|
+
io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
|
57
|
+
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
58
|
+
SAVE_BLOCK(block);
|
59
|
+
g_io_stream_close_async(_SELF(self),
|
60
|
+
io_priority,
|
61
|
+
cancellable,
|
62
|
+
rbgio_async_ready_callback,
|
63
|
+
(gpointer)block);
|
64
|
+
|
65
|
+
return self;
|
66
|
+
}
|
67
|
+
|
68
|
+
static VALUE
|
69
|
+
iostream_close_finish(VALUE self, VALUE result)
|
70
|
+
{
|
71
|
+
GError *error = NULL;
|
72
|
+
|
73
|
+
if (!g_io_stream_close_finish(_SELF(self),
|
74
|
+
RVAL2GASYNCRESULT(result),
|
75
|
+
&error))
|
76
|
+
rbgio_raise_error(error);
|
77
|
+
|
78
|
+
return self;
|
79
|
+
}
|
80
|
+
|
81
|
+
static VALUE
|
82
|
+
iostream_is_closed(VALUE self)
|
83
|
+
{
|
84
|
+
return CBOOL2RVAL(g_io_stream_is_closed(_SELF(self)));
|
85
|
+
}
|
86
|
+
|
87
|
+
static VALUE
|
88
|
+
iostream_has_pending(VALUE self)
|
89
|
+
{
|
90
|
+
return CBOOL2RVAL(g_io_stream_has_pending(_SELF(self)));
|
91
|
+
}
|
92
|
+
|
93
|
+
static VALUE
|
94
|
+
iostream_set_pending(VALUE self)
|
95
|
+
{
|
96
|
+
GError *error = NULL;
|
97
|
+
|
98
|
+
if (!g_io_stream_set_pending(_SELF(self), &error))
|
99
|
+
rbgio_raise_error(error);
|
100
|
+
|
101
|
+
return self;
|
102
|
+
}
|
103
|
+
|
104
|
+
static VALUE
|
105
|
+
iostream_clear_pending(VALUE self)
|
106
|
+
{
|
107
|
+
g_io_stream_clear_pending(_SELF(self));
|
108
|
+
|
109
|
+
return self;
|
110
|
+
}
|
111
|
+
|
112
|
+
void
|
113
|
+
Init_giostream(VALUE glib)
|
114
|
+
{
|
115
|
+
VALUE iostream = G_DEF_CLASS(G_TYPE_IO_STREAM, "IOStream", glib);
|
116
|
+
|
117
|
+
rb_undef_alloc_func(iostream);
|
118
|
+
|
119
|
+
rb_define_method(iostream, "input_stream", iostream_get_input_stream, 0);
|
120
|
+
rb_define_method(iostream, "output_stream", iostream_get_output_stream, 0);
|
121
|
+
rb_define_method(iostream, "close", iostream_close, 1);
|
122
|
+
rb_define_method(iostream, "close_async", iostream_close_async, -1);
|
123
|
+
rb_define_method(iostream, "close_finish", iostream_close_finish, 1);
|
124
|
+
rb_define_method(iostream, "closed?", iostream_is_closed, 0);
|
125
|
+
rb_define_method(iostream, "has_pending?", iostream_has_pending, 0);
|
126
|
+
rb_define_method(iostream, "set_pending", iostream_set_pending, 0);
|
127
|
+
G_DEF_SETTER(iostream, "pending");
|
128
|
+
rb_define_method(iostream, "clear_pending", iostream_clear_pending, 0);
|
129
|
+
}
|
@@ -0,0 +1,91 @@
|
|
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_LOADABLE_ICON(RVAL2GOBJ(value))
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
loadableicon_load(int argc, VALUE *argv, VALUE self)
|
27
|
+
{
|
28
|
+
VALUE size, cancellable;
|
29
|
+
char *type;
|
30
|
+
GError *error = NULL;
|
31
|
+
GInputStream *stream;
|
32
|
+
|
33
|
+
rb_scan_args(argc, argv, "11", &size, &cancellable);
|
34
|
+
stream = g_loadable_icon_load(_SELF(self),
|
35
|
+
NUM2INT(size),
|
36
|
+
&type,
|
37
|
+
RVAL2GCANCELLABLE(cancellable),
|
38
|
+
&error);
|
39
|
+
if (error != NULL)
|
40
|
+
rbgio_raise_error(error);
|
41
|
+
|
42
|
+
/* TODO: Should type be freed? */
|
43
|
+
return rb_assoc_new(GOBJ2RVAL_UNREF(stream), CSTR2RVAL_FREE(type));
|
44
|
+
}
|
45
|
+
|
46
|
+
static VALUE
|
47
|
+
loadableicon_load_async(int argc, VALUE *argv, VALUE self)
|
48
|
+
{
|
49
|
+
VALUE rbsize, rbcancellable, block;
|
50
|
+
int size;
|
51
|
+
GCancellable *cancellable;
|
52
|
+
|
53
|
+
rb_scan_args(argc, argv, "11&", &rbsize, &rbcancellable, &block);
|
54
|
+
size = NUM2INT(rbsize);
|
55
|
+
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
56
|
+
SAVE_BLOCK(block);
|
57
|
+
g_loadable_icon_load_async(_SELF(self),
|
58
|
+
size,
|
59
|
+
cancellable,
|
60
|
+
rbgio_async_ready_callback,
|
61
|
+
(gpointer)block);
|
62
|
+
|
63
|
+
return self;
|
64
|
+
}
|
65
|
+
|
66
|
+
static VALUE
|
67
|
+
loadableicon_load_finish(VALUE self, VALUE result)
|
68
|
+
{
|
69
|
+
char *type;
|
70
|
+
GError *error = NULL;
|
71
|
+
GInputStream *stream;
|
72
|
+
|
73
|
+
stream = g_loadable_icon_load_finish(_SELF(self),
|
74
|
+
RVAL2GASYNCRESULT(result),
|
75
|
+
&type,
|
76
|
+
&error);
|
77
|
+
if (error != NULL)
|
78
|
+
rbgio_raise_error(error);
|
79
|
+
|
80
|
+
return rb_assoc_new(GOBJ2RVAL_UNREF(stream), CSTR2RVAL_FREE(type));
|
81
|
+
}
|
82
|
+
|
83
|
+
void
|
84
|
+
Init_gloadableicon(VALUE glib)
|
85
|
+
{
|
86
|
+
VALUE loadableicon = G_DEF_INTERFACE(G_TYPE_LOADABLE_ICON, "LoadableIcon", glib);
|
87
|
+
|
88
|
+
rb_define_method(loadableicon, "load", loadableicon_load, -1);
|
89
|
+
rb_define_method(loadableicon, "load_async", loadableicon_load_async, -1);
|
90
|
+
rb_define_method(loadableicon, "load_finish", loadableicon_load_finish, 1);
|
91
|
+
}
|
@@ -0,0 +1,65 @@
|
|
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_MEMORY_INPUT_STREAM(RVAL2GOBJ(value))
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
memoryinputstream_initialize(int argc, VALUE *argv, VALUE self)
|
27
|
+
{
|
28
|
+
VALUE data;
|
29
|
+
|
30
|
+
rb_scan_args(argc, argv, "01", &data);
|
31
|
+
if (NIL_P(data)) {
|
32
|
+
G_INITIALIZE(self, g_memory_input_stream_new());
|
33
|
+
return Qnil;
|
34
|
+
}
|
35
|
+
|
36
|
+
StringValue(data);
|
37
|
+
G_RELATIVE(self, data);
|
38
|
+
G_INITIALIZE(self, g_memory_input_stream_new_from_data(RSTRING_PTR(data),
|
39
|
+
RSTRING_LEN(data),
|
40
|
+
NULL));
|
41
|
+
|
42
|
+
return Qnil;
|
43
|
+
}
|
44
|
+
|
45
|
+
static VALUE
|
46
|
+
memoryinputstream_add_data(VALUE self, VALUE data)
|
47
|
+
{
|
48
|
+
StringValue(data);
|
49
|
+
G_RELATIVE(self, data);
|
50
|
+
g_memory_input_stream_add_data(_SELF(self),
|
51
|
+
RSTRING_PTR(data),
|
52
|
+
RSTRING_LEN(data),
|
53
|
+
NULL);
|
54
|
+
|
55
|
+
return self;
|
56
|
+
}
|
57
|
+
|
58
|
+
void
|
59
|
+
Init_gmemoryinputstream(VALUE glib)
|
60
|
+
{
|
61
|
+
VALUE memoryinputstream = G_DEF_CLASS(G_TYPE_MEMORY_INPUT_STREAM, "MemoryInputStream", glib);
|
62
|
+
|
63
|
+
rb_define_method(memoryinputstream, "initialize", memoryinputstream_initialize, -1);
|
64
|
+
rb_define_method(memoryinputstream, "add_data", memoryinputstream_add_data, 1);
|
65
|
+
}
|