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,82 @@
|
|
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_BUFFERED_OUTPUT_STREAM(RVAL2GOBJ(value))
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
bufferedoutputstream_initialize(int argc, VALUE *argv, VALUE self)
|
27
|
+
{
|
28
|
+
VALUE rbbase_stream, size;
|
29
|
+
GOutputStream *base_stream, *stream;
|
30
|
+
|
31
|
+
rb_scan_args(argc, argv, "11", &rbbase_stream, &size);
|
32
|
+
base_stream = RVAL2GOUTPUTSTREAM(rbbase_stream);
|
33
|
+
|
34
|
+
stream = NIL_P(size) ?
|
35
|
+
g_buffered_output_stream_new(base_stream) :
|
36
|
+
g_buffered_output_stream_new_sized(base_stream, RVAL2GSIZE(size));
|
37
|
+
G_INITIALIZE(self, stream);
|
38
|
+
|
39
|
+
return Qnil;
|
40
|
+
}
|
41
|
+
|
42
|
+
static VALUE
|
43
|
+
bufferedoutputstream_get_buffer_size(VALUE self)
|
44
|
+
{
|
45
|
+
return GSIZE2RVAL(g_buffered_output_stream_get_buffer_size(_SELF(self)));
|
46
|
+
}
|
47
|
+
|
48
|
+
static VALUE
|
49
|
+
bufferedoutputstream_set_buffer_size(VALUE self, VALUE size)
|
50
|
+
{
|
51
|
+
g_buffered_output_stream_set_buffer_size(_SELF(self), RVAL2GSIZE(size));
|
52
|
+
|
53
|
+
return self;
|
54
|
+
}
|
55
|
+
|
56
|
+
static VALUE
|
57
|
+
bufferedoutputstream_get_auto_grow(VALUE self)
|
58
|
+
{
|
59
|
+
return CBOOL2RVAL(g_buffered_output_stream_get_auto_grow(_SELF(self)));
|
60
|
+
}
|
61
|
+
|
62
|
+
static VALUE
|
63
|
+
bufferedoutputstream_set_auto_grow(VALUE self, VALUE grow)
|
64
|
+
{
|
65
|
+
g_buffered_output_stream_set_auto_grow(_SELF(self), RVAL2CBOOL(grow));
|
66
|
+
|
67
|
+
return self;
|
68
|
+
}
|
69
|
+
|
70
|
+
void
|
71
|
+
Init_gbufferedoutputstream(VALUE glib)
|
72
|
+
{
|
73
|
+
VALUE bufferedoutputstream = G_DEF_CLASS(G_TYPE_BUFFERED_OUTPUT_STREAM, "BufferedOutputStream", glib);
|
74
|
+
|
75
|
+
rb_define_method(bufferedoutputstream, "initialize", bufferedoutputstream_initialize, -1);
|
76
|
+
rb_define_method(bufferedoutputstream, "buffer_size", bufferedoutputstream_get_buffer_size, 0);
|
77
|
+
rb_define_method(bufferedoutputstream, "set_buffer_size", bufferedoutputstream_set_buffer_size, 1);
|
78
|
+
G_DEF_SETTER(bufferedoutputstream, "buffer_size");
|
79
|
+
rb_define_method(bufferedoutputstream, "auto_grow", bufferedoutputstream_get_auto_grow, 0);
|
80
|
+
rb_define_method(bufferedoutputstream, "set_auto_grow", bufferedoutputstream_set_auto_grow, 1);
|
81
|
+
G_DEF_SETTER(bufferedoutputstream, "auto_grow");
|
82
|
+
}
|
@@ -0,0 +1,177 @@
|
|
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) RVAL2GCANCELLABLE(value)
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
cancellable_initialize(VALUE self)
|
27
|
+
{
|
28
|
+
G_INITIALIZE(self, g_cancellable_new());
|
29
|
+
|
30
|
+
return Qnil;
|
31
|
+
}
|
32
|
+
|
33
|
+
static VALUE
|
34
|
+
cancellable_is_cancelled(VALUE self)
|
35
|
+
{
|
36
|
+
return CBOOL2RVAL(g_cancellable_is_cancelled(_SELF(self)));
|
37
|
+
}
|
38
|
+
|
39
|
+
static VALUE
|
40
|
+
cancellable_raise_error_if_cancelled(VALUE self)
|
41
|
+
{
|
42
|
+
GError *error = NULL;
|
43
|
+
|
44
|
+
if (g_cancellable_set_error_if_cancelled(_SELF(self), &error))
|
45
|
+
rbgio_raise_error(error);
|
46
|
+
|
47
|
+
return self;
|
48
|
+
}
|
49
|
+
|
50
|
+
static VALUE
|
51
|
+
cancellable_get_fd(VALUE self)
|
52
|
+
{
|
53
|
+
return FD2RVAL(g_cancellable_get_fd(_SELF(self)));
|
54
|
+
}
|
55
|
+
|
56
|
+
static VALUE
|
57
|
+
cancellable_make_pollfd(VALUE self)
|
58
|
+
{
|
59
|
+
GPollFD *gfd = g_new(GPollFD, 1);
|
60
|
+
|
61
|
+
g_cancellable_make_pollfd(_SELF(self), gfd);
|
62
|
+
|
63
|
+
return BOXED2RVAL(gfd, G_TYPE_POLL_FD);
|
64
|
+
}
|
65
|
+
|
66
|
+
G_GNUC_NORETURN static VALUE
|
67
|
+
cancellable_release_fd(VALUE self)
|
68
|
+
{
|
69
|
+
/* TODO: How do we implement this? Maybe not at all? */
|
70
|
+
self = self;
|
71
|
+
rb_raise(rb_eNotImpError, "release_fd has not been implemented yet");
|
72
|
+
#if 0
|
73
|
+
g_cancellable_release_fd(_SELF(self));
|
74
|
+
|
75
|
+
return self;
|
76
|
+
#endif
|
77
|
+
}
|
78
|
+
|
79
|
+
static VALUE
|
80
|
+
cancellable_get_current(G_GNUC_UNUSED VALUE self)
|
81
|
+
{
|
82
|
+
return GOBJ2RVAL(g_cancellable_get_current());
|
83
|
+
}
|
84
|
+
|
85
|
+
static VALUE
|
86
|
+
cancellable_pop_current(VALUE self)
|
87
|
+
{
|
88
|
+
g_cancellable_pop_current(_SELF(self));
|
89
|
+
|
90
|
+
return self;
|
91
|
+
}
|
92
|
+
|
93
|
+
static VALUE
|
94
|
+
cancellable_push_current(VALUE self)
|
95
|
+
{
|
96
|
+
g_cancellable_push_current(_SELF(self));
|
97
|
+
|
98
|
+
return self;
|
99
|
+
}
|
100
|
+
|
101
|
+
static VALUE
|
102
|
+
cancellable_reset(VALUE self)
|
103
|
+
{
|
104
|
+
g_cancellable_reset(_SELF(self));
|
105
|
+
|
106
|
+
return self;
|
107
|
+
}
|
108
|
+
|
109
|
+
static VALUE
|
110
|
+
cancellable_connect_callback_call(VALUE block)
|
111
|
+
{
|
112
|
+
static ID s_id_call;
|
113
|
+
|
114
|
+
if (s_id_call == 0)
|
115
|
+
s_id_call = rb_intern("call");
|
116
|
+
|
117
|
+
rb_funcall(block, s_id_call, 0);
|
118
|
+
|
119
|
+
return Qnil;
|
120
|
+
}
|
121
|
+
|
122
|
+
static void
|
123
|
+
cancellable_connect_callback(gpointer block)
|
124
|
+
{
|
125
|
+
G_PROTECT_CALLBACK(cancellable_connect_callback_call, block);
|
126
|
+
}
|
127
|
+
|
128
|
+
static VALUE
|
129
|
+
cancellable_connect(VALUE self)
|
130
|
+
{
|
131
|
+
VALUE block;
|
132
|
+
|
133
|
+
block = rb_block_proc();
|
134
|
+
G_RELATIVE(self, block);
|
135
|
+
|
136
|
+
return GULONG2RVAL(g_cancellable_connect(_SELF(self),
|
137
|
+
G_CALLBACK(cancellable_connect_callback),
|
138
|
+
(gpointer)block,
|
139
|
+
NULL));
|
140
|
+
}
|
141
|
+
|
142
|
+
static VALUE
|
143
|
+
cancellable_disconnect(VALUE self, VALUE handler_id)
|
144
|
+
{
|
145
|
+
g_cancellable_disconnect(_SELF(self), RVAL2GULONG(handler_id));
|
146
|
+
|
147
|
+
return self;
|
148
|
+
}
|
149
|
+
|
150
|
+
static VALUE
|
151
|
+
cancellable_cancel(VALUE self)
|
152
|
+
{
|
153
|
+
g_cancellable_cancel(_SELF(self));
|
154
|
+
|
155
|
+
return self;
|
156
|
+
}
|
157
|
+
|
158
|
+
void
|
159
|
+
Init_gcancellable(VALUE glib)
|
160
|
+
{
|
161
|
+
VALUE cancellable = G_DEF_CLASS(G_TYPE_CANCELLABLE, "Cancellable", glib);
|
162
|
+
|
163
|
+
rb_define_singleton_method(cancellable, "current", cancellable_get_current, 0);
|
164
|
+
|
165
|
+
rb_define_method(cancellable, "initialize", cancellable_initialize, 0);
|
166
|
+
rb_define_method(cancellable, "cancelled?", cancellable_is_cancelled, 0);
|
167
|
+
rb_define_method(cancellable, "raise_error_if_cancelled", cancellable_raise_error_if_cancelled, 0);
|
168
|
+
rb_define_method(cancellable, "fd", cancellable_get_fd, 0);
|
169
|
+
rb_define_method(cancellable, "make_pollfd", cancellable_make_pollfd, 0);
|
170
|
+
rb_define_method(cancellable, "release_fd", cancellable_release_fd, 0);
|
171
|
+
rb_define_method(cancellable, "pop_current", cancellable_pop_current, 0);
|
172
|
+
rb_define_method(cancellable, "push_current", cancellable_push_current, 0);
|
173
|
+
rb_define_method(cancellable, "reset", cancellable_reset, 0);
|
174
|
+
rb_define_method(cancellable, "connect", cancellable_connect, 0);
|
175
|
+
rb_define_method(cancellable, "disconnect", cancellable_disconnect, 1);
|
176
|
+
rb_define_method(cancellable, "cancel", cancellable_cancel, 0);
|
177
|
+
}
|
@@ -0,0 +1,72 @@
|
|
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_CHARSET_CONVERTER(RVAL2GOBJ(value))
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
charsetconverter_initialize(VALUE self, VALUE to, VALUE from)
|
27
|
+
{
|
28
|
+
GError *error = NULL;
|
29
|
+
GCharsetConverter *converter;
|
30
|
+
|
31
|
+
converter = g_charset_converter_new(RVAL2CSTR(to),
|
32
|
+
RVAL2CSTR(from),
|
33
|
+
&error);
|
34
|
+
if (converter == NULL)
|
35
|
+
rbgio_raise_error(error);
|
36
|
+
|
37
|
+
G_INITIALIZE(self, converter);
|
38
|
+
|
39
|
+
return Qnil;
|
40
|
+
}
|
41
|
+
|
42
|
+
static VALUE
|
43
|
+
charsetconverter_set_use_fallback(VALUE self, VALUE use_fallback)
|
44
|
+
{
|
45
|
+
g_charset_converter_set_use_fallback(_SELF(self), RVAL2CBOOL(use_fallback));
|
46
|
+
|
47
|
+
return self;
|
48
|
+
}
|
49
|
+
|
50
|
+
static VALUE
|
51
|
+
charsetconverter_get_use_fallback(VALUE self)
|
52
|
+
{
|
53
|
+
return CBOOL2RVAL(g_charset_converter_get_use_fallback(_SELF(self)));
|
54
|
+
}
|
55
|
+
|
56
|
+
static VALUE
|
57
|
+
charsetconverter_get_num_fallbacks(VALUE self)
|
58
|
+
{
|
59
|
+
return GUINT2RVAL(g_charset_converter_get_num_fallbacks(_SELF(self)));
|
60
|
+
}
|
61
|
+
|
62
|
+
void
|
63
|
+
Init_gcharsetconverter(VALUE glib)
|
64
|
+
{
|
65
|
+
VALUE charsetconverter = G_DEF_CLASS(G_TYPE_CHARSET_CONVERTER, "CharsetConverter", glib);
|
66
|
+
|
67
|
+
rb_define_method(charsetconverter, "initialize", charsetconverter_initialize, 2);
|
68
|
+
rb_define_method(charsetconverter, "set_use_fallback", charsetconverter_set_use_fallback, 1);
|
69
|
+
G_DEF_SETTER(charsetconverter, "use_fallback");
|
70
|
+
rb_define_method(charsetconverter, "use_fallback?", charsetconverter_get_use_fallback, 0);
|
71
|
+
rb_define_method(charsetconverter, "num_fallbacks", charsetconverter_get_num_fallbacks, 0);
|
72
|
+
}
|
@@ -0,0 +1,135 @@
|
|
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 VALUE
|
24
|
+
contenttype_equals(G_GNUC_UNUSED VALUE self, VALUE arg1, VALUE arg2)
|
25
|
+
{
|
26
|
+
return CBOOL2RVAL(g_content_type_equals(RVAL2CSTR(arg1), RVAL2CSTR(arg2)));
|
27
|
+
}
|
28
|
+
|
29
|
+
static VALUE
|
30
|
+
contenttype_is_a(G_GNUC_UNUSED VALUE self, VALUE arg1, VALUE arg2)
|
31
|
+
{
|
32
|
+
return CBOOL2RVAL(g_content_type_is_a(RVAL2CSTR(arg1), RVAL2CSTR(arg2)));
|
33
|
+
}
|
34
|
+
|
35
|
+
static VALUE
|
36
|
+
contenttype_is_unknown(G_GNUC_UNUSED VALUE type)
|
37
|
+
{
|
38
|
+
return CBOOL2RVAL(g_content_type_is_unknown(RVAL2CSTR(type)));
|
39
|
+
}
|
40
|
+
|
41
|
+
static VALUE
|
42
|
+
contenttype_get_description(G_GNUC_UNUSED VALUE type)
|
43
|
+
{
|
44
|
+
return CSTR2RVAL_FREE(g_content_type_get_description(RVAL2CSTR(type)));
|
45
|
+
}
|
46
|
+
|
47
|
+
static VALUE
|
48
|
+
contenttype_get_mime_type(G_GNUC_UNUSED VALUE type)
|
49
|
+
{
|
50
|
+
return CSTR2RVAL_FREE(g_content_type_get_mime_type(RVAL2CSTR(type)));
|
51
|
+
}
|
52
|
+
|
53
|
+
static VALUE
|
54
|
+
contenttype_get_icon(G_GNUC_UNUSED VALUE type)
|
55
|
+
{
|
56
|
+
return GOBJ2RVAL_UNREF(g_content_type_get_icon(RVAL2CSTR(type)));
|
57
|
+
}
|
58
|
+
|
59
|
+
static VALUE
|
60
|
+
contenttype_can_be_executable(G_GNUC_UNUSED VALUE type)
|
61
|
+
{
|
62
|
+
return CBOOL2RVAL(g_content_type_can_be_executable(RVAL2CSTR(type)));
|
63
|
+
}
|
64
|
+
|
65
|
+
static VALUE
|
66
|
+
contenttype_from_mime_type(G_GNUC_UNUSED VALUE type)
|
67
|
+
{
|
68
|
+
return CSTR2RVAL(g_content_type_from_mime_type(RVAL2CSTR(type)));
|
69
|
+
}
|
70
|
+
|
71
|
+
static VALUE
|
72
|
+
contenttype_guess(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
|
73
|
+
{
|
74
|
+
VALUE rbfilename,
|
75
|
+
rbdata;
|
76
|
+
const char *filename;
|
77
|
+
const guchar *data;
|
78
|
+
gsize data_size;
|
79
|
+
gboolean result_uncertain;
|
80
|
+
char *type;
|
81
|
+
|
82
|
+
rb_scan_args(argc, argv, "02", &rbfilename, &rbdata);
|
83
|
+
|
84
|
+
if (NIL_P(rbfilename) && NIL_P(rbdata))
|
85
|
+
rb_raise(rb_eArgError,
|
86
|
+
"Either filename or data can be nil but not both");
|
87
|
+
|
88
|
+
filename = RVAL2CSTR_ACCEPT_NIL(rbfilename);
|
89
|
+
data = (guchar *)RVAL2CSTR_ACCEPT_NIL(rbdata);
|
90
|
+
if (data != NULL) {
|
91
|
+
StringValue(rbdata);
|
92
|
+
data_size = RSTRING_LEN(rbdata);
|
93
|
+
} else {
|
94
|
+
data_size = 0;
|
95
|
+
}
|
96
|
+
|
97
|
+
type = g_content_type_guess(filename,
|
98
|
+
data,
|
99
|
+
data_size,
|
100
|
+
&result_uncertain);
|
101
|
+
|
102
|
+
return rb_assoc_new(CSTR2RVAL_FREE(type), CBOOL2RVAL(result_uncertain));
|
103
|
+
}
|
104
|
+
|
105
|
+
static VALUE
|
106
|
+
contenttype_guess_for_tree(G_GNUC_UNUSED VALUE self, VALUE root)
|
107
|
+
{
|
108
|
+
return STRVECTOR2ARY_FREE(g_content_type_guess_for_tree(RVAL2GFILE(root)));
|
109
|
+
}
|
110
|
+
|
111
|
+
static VALUE
|
112
|
+
contenttype_get_registered(G_GNUC_UNUSED VALUE self)
|
113
|
+
{
|
114
|
+
return GLIST2ARY_STR_FREE(g_content_types_get_registered());
|
115
|
+
}
|
116
|
+
|
117
|
+
void
|
118
|
+
Init_gcontenttype(VALUE glib)
|
119
|
+
{
|
120
|
+
VALUE contenttype = rb_define_module_under(glib, "ContentType");
|
121
|
+
|
122
|
+
/* TODO: Should wrap this in a class. */
|
123
|
+
rb_define_module_function(contenttype, "equals?", contenttype_equals, 2);
|
124
|
+
/* TODO: This name isn’t great. */
|
125
|
+
rb_define_module_function(contenttype, "is_a?", contenttype_is_a, 2);
|
126
|
+
rb_define_module_function(contenttype, "unknown?", contenttype_is_unknown, 1);
|
127
|
+
rb_define_module_function(contenttype, "get_description", contenttype_get_description, 1);
|
128
|
+
rb_define_module_function(contenttype, "get_mime_type", contenttype_get_mime_type, 1);
|
129
|
+
rb_define_module_function(contenttype, "get_icon", contenttype_get_icon, 1);
|
130
|
+
rb_define_module_function(contenttype, "can_be_executable?", contenttype_can_be_executable, 1);
|
131
|
+
rb_define_module_function(contenttype, "from_mime_type", contenttype_from_mime_type, 1);
|
132
|
+
rb_define_module_function(contenttype, "guess", contenttype_guess, -1);
|
133
|
+
rb_define_module_function(contenttype, "guess_for_tree", contenttype_guess_for_tree, 1);
|
134
|
+
rb_define_module_function(contenttype, "registered", contenttype_get_registered, 0);
|
135
|
+
}
|