gio2 2.1.0-x86-mingw32 → 2.2.0-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.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +26 -9
  3. data/ext/gio2/extconf.rb +38 -28
  4. data/ext/gio2/rb-gio2-pollable-source.c +59 -0
  5. data/ext/gio2/{rbgiofilteroutputstream.c → rb-gio2.c} +9 -5
  6. data/ext/gio2/{gio2.c → rb-gio2.h} +5 -10
  7. data/extconf.rb +22 -6
  8. data/lib/1.9/gio2.so +0 -0
  9. data/lib/2.0/gio2.so +0 -0
  10. data/lib/2.1/gio2.so +0 -0
  11. data/lib/gio2/deprecated.rb +16 -0
  12. data/lib/gio2/inet-address.rb +33 -0
  13. data/lib/gio2/input-stream.rb +39 -0
  14. data/lib/gio2/loader.rb +244 -0
  15. data/lib/gio2/output-stream.rb +24 -0
  16. data/lib/gio2/pollable-input-stream.rb +51 -0
  17. data/lib/gio2/pollable-output-stream.rb +32 -0
  18. data/lib/gio2/resources.rb +62 -0
  19. data/lib/gio2.rb +38 -143
  20. data/test/fixture/content-type/x-content/unix-software/autorun.sh +1 -0
  21. data/test/fixture/resource/Rakefile +32 -0
  22. data/test/fixture/resource/logo.png +0 -0
  23. data/test/fixture/resource/ruby-gio2.gresource +0 -0
  24. data/test/fixture/resource/ruby-gio2.gresource.xml +6 -0
  25. data/test/gio2-test-utils/fixture.rb +24 -0
  26. data/test/gio2-test-utils/socket-client.rb +59 -0
  27. data/test/gio2-test-utils.rb +21 -0
  28. data/test/run-test.rb +45 -9
  29. data/test/test-buffered-input-stream.rb +23 -0
  30. data/test/test-charset-converter.rb +23 -0
  31. data/test/test-content-type.rb +31 -0
  32. data/test/test-data-input-stream.rb +21 -0
  33. data/test/test-file-enumerator.rb +26 -0
  34. data/test/test-file-monitor.rb +33 -0
  35. data/test/test-file.rb +28 -0
  36. data/test/test-inet-address.rb +34 -0
  37. data/test/test-input-stream.rb +36 -0
  38. data/test/test-output-stream.rb +39 -0
  39. data/test/test-pollable-input-stream.rb +54 -0
  40. data/test/test-pollable-output-stream.rb +53 -0
  41. data/test/test-resources.rb +58 -0
  42. metadata +49 -107
  43. data/README +0 -34
  44. data/ext/gio2/depend +0 -11
  45. data/ext/gio2/gio2.def +0 -2
  46. data/ext/gio2/gio2.h +0 -30
  47. data/ext/gio2/rbgio.c +0 -133
  48. data/ext/gio2/rbgio2.h +0 -158
  49. data/ext/gio2/rbgio2conversions.h +0 -154
  50. data/ext/gio2/rbgio2private.h +0 -148
  51. data/ext/gio2/rbgioappinfo.c +0 -317
  52. data/ext/gio2/rbgioapplaunchcontext.c +0 -81
  53. data/ext/gio2/rbgioasyncinitable.c +0 -246
  54. data/ext/gio2/rbgioasyncresult.c +0 -41
  55. data/ext/gio2/rbgiobufferedinputstream.c +0 -167
  56. data/ext/gio2/rbgiobufferedoutputstream.c +0 -50
  57. data/ext/gio2/rbgiocancellable.c +0 -180
  58. data/ext/gio2/rbgiocharsetconverter.c +0 -57
  59. data/ext/gio2/rbgiocontenttype.c +0 -131
  60. data/ext/gio2/rbgioconverter.c +0 -113
  61. data/ext/gio2/rbgioconverterinputstream.c +0 -43
  62. data/ext/gio2/rbgioconverteroutputstream.c +0 -43
  63. data/ext/gio2/rbgiodatainputstream.c +0 -309
  64. data/ext/gio2/rbgiodataoutputstream.c +0 -186
  65. data/ext/gio2/rbgiodesktopappinfo.c +0 -87
  66. data/ext/gio2/rbgiodrive.c +0 -266
  67. data/ext/gio2/rbgioemblem.c +0 -52
  68. data/ext/gio2/rbgioemblemedicon.c +0 -65
  69. data/ext/gio2/rbgiofile.c +0 -2045
  70. data/ext/gio2/rbgiofileattribute.c +0 -114
  71. data/ext/gio2/rbgiofileattributeinfo.c +0 -86
  72. data/ext/gio2/rbgiofileattributeinfolist.c +0 -108
  73. data/ext/gio2/rbgiofileattributematcher.c +0 -95
  74. data/ext/gio2/rbgiofiledescriptorbased.c +0 -45
  75. data/ext/gio2/rbgiofileenumerator.c +0 -166
  76. data/ext/gio2/rbgiofileicon.c +0 -41
  77. data/ext/gio2/rbgiofileinfo.c +0 -617
  78. data/ext/gio2/rbgiofileinputstream.c +0 -91
  79. data/ext/gio2/rbgiofileiostream.c +0 -98
  80. data/ext/gio2/rbgiofilemonitor.c +0 -46
  81. data/ext/gio2/rbgiofilenamecompleter.c +0 -73
  82. data/ext/gio2/rbgiofileoutputstream.c +0 -98
  83. data/ext/gio2/rbgiofilterinputstream.c +0 -28
  84. data/ext/gio2/rbgioicon.c +0 -69
  85. data/ext/gio2/rbgioinetaddress.c +0 -118
  86. data/ext/gio2/rbgioinetsocketaddress.c +0 -41
  87. data/ext/gio2/rbgioinitable.c +0 -199
  88. data/ext/gio2/rbgioinputstream.c +0 -341
  89. data/ext/gio2/rbgioio.c +0 -73
  90. data/ext/gio2/rbgioiomodule.c +0 -45
  91. data/ext/gio2/rbgioiomodules.c +0 -47
  92. data/ext/gio2/rbgioioscheduler.c +0 -102
  93. data/ext/gio2/rbgioioschedulerjob.c +0 -121
  94. data/ext/gio2/rbgioiostream.c +0 -107
  95. data/ext/gio2/rbgioloadableicon.c +0 -92
  96. data/ext/gio2/rbgiomemoryinputstream.c +0 -67
  97. data/ext/gio2/rbgiomemoryoutputstream.c +0 -44
  98. data/ext/gio2/rbgiomount.c +0 -286
  99. data/ext/gio2/rbgiomountoperation.c +0 -53
  100. data/ext/gio2/rbgionetworkaddress.c +0 -59
  101. data/ext/gio2/rbgionetworkservice.c +0 -45
  102. data/ext/gio2/rbgiooutputstream.c +0 -331
  103. data/ext/gio2/rbgioresolver.c +0 -230
  104. data/ext/gio2/rbgioseekable.c +0 -91
  105. data/ext/gio2/rbgiosimpleasyncresult.c +0 -152
  106. data/ext/gio2/rbgiosocket.c +0 -390
  107. data/ext/gio2/rbgiosocketaddress.c +0 -34
  108. data/ext/gio2/rbgiosocketaddressenumerator.c +0 -83
  109. data/ext/gio2/rbgiosocketclient.c +0 -207
  110. data/ext/gio2/rbgiosocketconnectable.c +0 -41
  111. data/ext/gio2/rbgiosocketconnection.c +0 -66
  112. data/ext/gio2/rbgiosocketconnectionfactory.c +0 -39
  113. data/ext/gio2/rbgiosocketcontrolmessage.c +0 -82
  114. data/ext/gio2/rbgiosocketlistener.c +0 -246
  115. data/ext/gio2/rbgiosocketservice.c +0 -66
  116. data/ext/gio2/rbgiosrvtarget.c +0 -76
  117. data/ext/gio2/rbgiotcpconnection.c +0 -28
  118. data/ext/gio2/rbgiothemedicon.c +0 -83
  119. data/ext/gio2/rbgiothreadedsocketservice.c +0 -43
  120. data/ext/gio2/rbgiotlscertificate.c +0 -89
  121. data/ext/gio2/rbgiounixconnection.c +0 -71
  122. data/ext/gio2/rbgiounixfdlist.c +0 -115
  123. data/ext/gio2/rbgiounixfdmessage.c +0 -74
  124. data/ext/gio2/rbgiounixinputstream.c +0 -51
  125. data/ext/gio2/rbgiounixmount.c +0 -164
  126. data/ext/gio2/rbgiounixmountmonitor.c +0 -65
  127. data/ext/gio2/rbgiounixmountpoint.c +0 -136
  128. data/ext/gio2/rbgiounixmountpoints.c +0 -58
  129. data/ext/gio2/rbgiounixmounts.c +0 -58
  130. data/ext/gio2/rbgiounixoutputstream.c +0 -51
  131. data/ext/gio2/rbgiounixsocketaddress.c +0 -69
  132. data/ext/gio2/rbgiovfs.c +0 -84
  133. data/ext/gio2/rbgiovolume.c +0 -193
  134. data/ext/gio2/rbgiovolumemonitor.c +0 -77
  135. data/ext/gio2/rbgiozlibcompressor.c +0 -52
  136. data/ext/gio2/rbgiozlibdecompressor.c +0 -45
  137. data/ext/gio2/util.c +0 -303
  138. data/test/test_bufferedinputstream.rb +0 -9
  139. data/test/test_charsetconverter.rb +0 -9
  140. data/test/test_datainputstream.rb +0 -7
  141. data/test/test_fileenumerator.rb +0 -8
  142. data/test/test_filemonitor.rb +0 -17
  143. data/test/test_inetaddress.rb +0 -8
@@ -1,167 +0,0 @@
1
- /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /*
3
- * Copyright (C) 2011 Ruby-GNOME2 Project Team
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, or (at your option) any later version.
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., 51 Franklin Street, Fifth Floor, Boston,
19
- * MA 02110-1301 USA
20
- */
21
-
22
- #include "rbgio2private.h"
23
-
24
- #define RG_TARGET_NAMESPACE cBufferedInputStream
25
- #define _SELF(value) RVAL2GBUFFEREDINPUTSTREAM(value)
26
-
27
- static VALUE
28
- rg_initialize(int argc, VALUE *argv, VALUE self)
29
- {
30
- VALUE rbbase_stream, size;
31
- GInputStream *base_stream, *stream;
32
-
33
- rb_scan_args(argc, argv, "11", &rbbase_stream, &size);
34
- base_stream = RVAL2GINPUTSTREAM(rbbase_stream);
35
-
36
- stream = NIL_P(size) ?
37
- g_buffered_input_stream_new(base_stream) :
38
- g_buffered_input_stream_new_sized(base_stream, RVAL2GSIZE(size));
39
- G_INITIALIZE(self, stream);
40
-
41
- return Qnil;
42
- }
43
-
44
- static VALUE
45
- rg_available(VALUE self)
46
- {
47
- return GSIZE2RVAL(g_buffered_input_stream_get_available(_SELF(self)));
48
- }
49
-
50
- static VALUE
51
- rg_peek_buffer(VALUE self)
52
- {
53
- gsize size;
54
- const void *buffer;
55
-
56
- buffer = g_buffered_input_stream_peek_buffer(_SELF(self), &size);
57
-
58
- return CSTR2RVAL_TAINTED(buffer, size);
59
- }
60
-
61
- static VALUE
62
- rg_peek(VALUE self, VALUE rboffset, VALUE rbcount)
63
- {
64
- gsize offset = RVAL2GSIZE(rboffset);
65
- gsize count = RVAL2GSIZE(rbcount);
66
- VALUE result = rb_str_new(NULL, count);
67
- gsize bytes_peeked = g_buffered_input_stream_peek(_SELF(self),
68
- RSTRING_PTR(result),
69
- offset,
70
- count);
71
-
72
- rb_str_set_len(result, bytes_peeked);
73
- rb_str_resize(result, bytes_peeked);
74
- OBJ_TAINT(result);
75
-
76
- return result;
77
- }
78
-
79
- static VALUE
80
- rg_fill(int argc, VALUE *argv, VALUE self)
81
- {
82
- VALUE count, cancellable;
83
- GError *error = NULL;
84
- gsize bytes_read;
85
-
86
- rb_scan_args(argc, argv, "02", &count, &cancellable);
87
- bytes_read = g_buffered_input_stream_fill(_SELF(self),
88
- NIL_P(count) ?
89
- -1 :
90
- RVAL2GSSIZE(count),
91
- RVAL2GCANCELLABLE(cancellable),
92
- &error);
93
- if (error != NULL)
94
- rbgio_raise_error(error);
95
-
96
- return GSSIZE2RVAL(bytes_read);
97
- }
98
-
99
- static VALUE
100
- rg_fill_async(int argc, VALUE *argv, VALUE self)
101
- {
102
- VALUE rbcount, rbio_priority, rbcancellable, block;
103
- gssize count;
104
- int io_priority;
105
- GCancellable *cancellable;
106
-
107
- rb_scan_args(argc, argv, "03&", &rbcount, &rbio_priority, &rbcancellable, &block);
108
- count = NIL_P(rbcount) ? -1 : RVAL2GSSIZE(rbcount);
109
- io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
110
- cancellable = RVAL2GCANCELLABLE(rbcancellable);
111
- SAVE_BLOCK(block);
112
- g_buffered_input_stream_fill_async(_SELF(self),
113
- count,
114
- io_priority,
115
- cancellable,
116
- rbgio_async_ready_callback,
117
- (gpointer)block);
118
-
119
- return self;
120
- }
121
-
122
- static VALUE
123
- rg_fill_finish(VALUE self, VALUE result)
124
- {
125
- GError *error = NULL;
126
- gsize bytes_read;
127
-
128
- bytes_read = g_buffered_input_stream_fill_finish(_SELF(self),
129
- RVAL2GASYNCRESULT(result),
130
- &error);
131
- if (error != NULL)
132
- rbgio_raise_error(error);
133
-
134
- return GSSIZE2RVAL(bytes_read);
135
- }
136
-
137
- static VALUE
138
- rg_read_byte(int argc, VALUE *argv, VALUE self)
139
- {
140
- VALUE cancellable;
141
- GError *error = NULL;
142
- int byte;
143
-
144
- rb_scan_args(argc, argv, "01", &cancellable);
145
- byte = g_buffered_input_stream_read_byte(_SELF(self),
146
- RVAL2GCANCELLABLE(cancellable),
147
- &error);
148
- if (error != NULL)
149
- rbgio_raise_error(error);
150
-
151
- return INT2FIX(byte);
152
- }
153
-
154
- void
155
- Init_gbufferedinputstream(VALUE mGio)
156
- {
157
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BUFFERED_INPUT_STREAM, "BufferedInputStream", mGio);
158
-
159
- RG_DEF_METHOD(initialize, -1);
160
- RG_DEF_METHOD(available, 0);
161
- RG_DEF_METHOD(peek_buffer, 0);
162
- RG_DEF_METHOD(peek, 2);
163
- RG_DEF_METHOD(fill, -1);
164
- RG_DEF_METHOD(fill_async, -1);
165
- RG_DEF_METHOD(fill_finish, 1);
166
- RG_DEF_METHOD(read_byte, -1);
167
- }
@@ -1,50 +0,0 @@
1
- /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /*
3
- * Copyright (C) 2011 Ruby-GNOME2 Project Team
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, or (at your option) any later version.
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., 51 Franklin Street, Fifth Floor, Boston,
19
- * MA 02110-1301 USA
20
- */
21
-
22
- #include "rbgio2private.h"
23
-
24
- #define RG_TARGET_NAMESPACE cBufferedOutputStream
25
- #define _SELF(value) RVAL2GBUFFEREDOUTPUTSTREAM(value)
26
-
27
- static VALUE
28
- rg_initialize(int argc, VALUE *argv, VALUE self)
29
- {
30
- VALUE rbbase_stream, size;
31
- GOutputStream *base_stream, *stream;
32
-
33
- rb_scan_args(argc, argv, "11", &rbbase_stream, &size);
34
- base_stream = RVAL2GOUTPUTSTREAM(rbbase_stream);
35
-
36
- stream = NIL_P(size) ?
37
- g_buffered_output_stream_new(base_stream) :
38
- g_buffered_output_stream_new_sized(base_stream, RVAL2GSIZE(size));
39
- G_INITIALIZE(self, stream);
40
-
41
- return Qnil;
42
- }
43
-
44
- void
45
- Init_gbufferedoutputstream(VALUE mGio)
46
- {
47
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BUFFERED_OUTPUT_STREAM, "BufferedOutputStream", mGio);
48
-
49
- RG_DEF_METHOD(initialize, -1);
50
- }
@@ -1,180 +0,0 @@
1
- /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /*
3
- * Copyright (C) 2011 Ruby-GNOME2 Project Team
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, or (at your option) any later version.
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., 51 Franklin Street, Fifth Floor, Boston,
19
- * MA 02110-1301 USA
20
- */
21
-
22
- #include "rbgio2private.h"
23
-
24
- #define RG_TARGET_NAMESPACE cCancellable
25
- #define _SELF(value) RVAL2GCANCELLABLE(value)
26
-
27
- static VALUE
28
- rg_initialize(VALUE self)
29
- {
30
- G_INITIALIZE(self, g_cancellable_new());
31
-
32
- return Qnil;
33
- }
34
-
35
- static VALUE
36
- rg_cancelled_p(VALUE self)
37
- {
38
- return CBOOL2RVAL(g_cancellable_is_cancelled(_SELF(self)));
39
- }
40
-
41
- static VALUE
42
- rg_raise_error_if_cancelled(VALUE self)
43
- {
44
- GError *error = NULL;
45
-
46
- if (g_cancellable_set_error_if_cancelled(_SELF(self), &error))
47
- rbgio_raise_error(error);
48
-
49
- return self;
50
- }
51
-
52
- static VALUE
53
- rg_fd(VALUE self)
54
- {
55
- return FD2RVAL(g_cancellable_get_fd(_SELF(self)));
56
- }
57
-
58
- static VALUE
59
- rg_make_pollfd(VALUE self)
60
- {
61
- GCancellable *cancellable = _SELF(self);
62
- GPollFD *gfd = g_new(GPollFD, 1);
63
-
64
- g_cancellable_make_pollfd(cancellable, gfd);
65
-
66
- return GPOLLFD2RVAL(gfd);
67
- }
68
-
69
- G_GNUC_NORETURN static VALUE
70
- rg_release_fd(VALUE self)
71
- {
72
- /* TODO: How do we implement this? Maybe not at all? */
73
- self = self;
74
- rb_raise(rb_eNotImpError, "release_fd has not been implemented yet");
75
- #if 0
76
- g_cancellable_release_fd(_SELF(self));
77
-
78
- return self;
79
- #endif
80
- }
81
-
82
- static VALUE
83
- rg_s_current(G_GNUC_UNUSED VALUE self)
84
- {
85
- return GOBJ2RVAL(g_cancellable_get_current());
86
- }
87
-
88
- static VALUE
89
- rg_pop_current(VALUE self)
90
- {
91
- g_cancellable_pop_current(_SELF(self));
92
-
93
- return self;
94
- }
95
-
96
- static VALUE
97
- rg_push_current(VALUE self)
98
- {
99
- g_cancellable_push_current(_SELF(self));
100
-
101
- return self;
102
- }
103
-
104
- static VALUE
105
- rg_reset(VALUE self)
106
- {
107
- g_cancellable_reset(_SELF(self));
108
-
109
- return self;
110
- }
111
-
112
- static VALUE
113
- cancellable_connect_callback_call(VALUE block)
114
- {
115
- static ID s_id_call;
116
-
117
- if (s_id_call == 0)
118
- s_id_call = rb_intern("call");
119
-
120
- rb_funcall(block, s_id_call, 0);
121
-
122
- return Qnil;
123
- }
124
-
125
- static void
126
- cancellable_connect_callback(gpointer block)
127
- {
128
- G_PROTECT_CALLBACK(cancellable_connect_callback_call, block);
129
- }
130
-
131
- static VALUE
132
- rg_connect(VALUE self)
133
- {
134
- VALUE block;
135
-
136
- block = rb_block_proc();
137
- G_RELATIVE(self, block);
138
-
139
- return GULONG2RVAL(g_cancellable_connect(_SELF(self),
140
- G_CALLBACK(cancellable_connect_callback),
141
- (gpointer)block,
142
- NULL));
143
- }
144
-
145
- static VALUE
146
- rg_disconnect(VALUE self, VALUE handler_id)
147
- {
148
- g_cancellable_disconnect(_SELF(self), RVAL2GULONG(handler_id));
149
-
150
- return self;
151
- }
152
-
153
- static VALUE
154
- rg_cancel(VALUE self)
155
- {
156
- g_cancellable_cancel(_SELF(self));
157
-
158
- return self;
159
- }
160
-
161
- void
162
- Init_gcancellable(VALUE mGio)
163
- {
164
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_CANCELLABLE, "Cancellable", mGio);
165
-
166
- RG_DEF_SMETHOD(current, 0);
167
-
168
- RG_DEF_METHOD(initialize, 0);
169
- RG_DEF_METHOD_P(cancelled, 0);
170
- RG_DEF_METHOD(raise_error_if_cancelled, 0);
171
- RG_DEF_METHOD(fd, 0);
172
- RG_DEF_METHOD(make_pollfd, 0);
173
- RG_DEF_METHOD(release_fd, 0);
174
- RG_DEF_METHOD(pop_current, 0);
175
- RG_DEF_METHOD(push_current, 0);
176
- RG_DEF_METHOD(reset, 0);
177
- RG_DEF_METHOD(connect, 0);
178
- RG_DEF_METHOD(disconnect, 1);
179
- RG_DEF_METHOD(cancel, 0);
180
- }
@@ -1,57 +0,0 @@
1
- /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /*
3
- * Copyright (C) 2011 Ruby-GNOME2 Project Team
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, or (at your option) any later version.
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., 51 Franklin Street, Fifth Floor, Boston,
19
- * MA 02110-1301 USA
20
- */
21
-
22
- #include "rbgio2private.h"
23
-
24
- #define RG_TARGET_NAMESPACE cCharsetConverter
25
- #define _SELF(value) RVAL2GCHARSETCONVERTER(value)
26
-
27
- static VALUE
28
- rg_initialize(VALUE self, VALUE to, VALUE from)
29
- {
30
- GError *error = NULL;
31
- GCharsetConverter *converter;
32
-
33
- converter = g_charset_converter_new(RVAL2CSTR(to),
34
- RVAL2CSTR(from),
35
- &error);
36
- if (converter == NULL)
37
- rbgio_raise_error(error);
38
-
39
- G_INITIALIZE(self, converter);
40
-
41
- return Qnil;
42
- }
43
-
44
- static VALUE
45
- rg_num_fallbacks(VALUE self)
46
- {
47
- return GUINT2RVAL(g_charset_converter_get_num_fallbacks(_SELF(self)));
48
- }
49
-
50
- void
51
- Init_gcharsetconverter(VALUE mGio)
52
- {
53
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_CHARSET_CONVERTER, "CharsetConverter", mGio);
54
-
55
- RG_DEF_METHOD(initialize, 2);
56
- RG_DEF_METHOD(num_fallbacks, 0);
57
- }
@@ -1,131 +0,0 @@
1
- /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /*
3
- * Copyright (C) 2011 Ruby-GNOME2 Project Team
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, or (at your option) any later version.
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., 51 Franklin Street, Fifth Floor, Boston,
19
- * MA 02110-1301 USA
20
- */
21
-
22
- #include "rbgio2private.h"
23
-
24
- #define RG_TARGET_NAMESPACE mContentType
25
-
26
- static VALUE
27
- rg_s_equals_p(G_GNUC_UNUSED VALUE self, VALUE arg1, VALUE arg2)
28
- {
29
- return CBOOL2RVAL(g_content_type_equals(RVAL2CSTR(arg1), RVAL2CSTR(arg2)));
30
- }
31
-
32
- static VALUE
33
- rg_s_is_a_p(G_GNUC_UNUSED VALUE self, VALUE arg1, VALUE arg2)
34
- {
35
- return CBOOL2RVAL(g_content_type_is_a(RVAL2CSTR(arg1), RVAL2CSTR(arg2)));
36
- }
37
-
38
- static VALUE
39
- rg_s_unknown_p(G_GNUC_UNUSED VALUE type)
40
- {
41
- return CBOOL2RVAL(g_content_type_is_unknown(RVAL2CSTR(type)));
42
- }
43
-
44
- static VALUE
45
- rg_s_get_description(G_GNUC_UNUSED VALUE type)
46
- {
47
- return CSTR2RVAL_FREE(g_content_type_get_description(RVAL2CSTR(type)));
48
- }
49
-
50
- static VALUE
51
- rg_s_get_mime_type(G_GNUC_UNUSED VALUE type)
52
- {
53
- return CSTR2RVAL_FREE(g_content_type_get_mime_type(RVAL2CSTR(type)));
54
- }
55
-
56
- static VALUE
57
- rg_s_get_icon(G_GNUC_UNUSED VALUE type)
58
- {
59
- return GOBJ2RVAL_UNREF(g_content_type_get_icon(RVAL2CSTR(type)));
60
- }
61
-
62
- static VALUE
63
- rg_s_can_be_executable_p(G_GNUC_UNUSED VALUE type)
64
- {
65
- return CBOOL2RVAL(g_content_type_can_be_executable(RVAL2CSTR(type)));
66
- }
67
-
68
- static VALUE
69
- rg_s_from_mime_type(G_GNUC_UNUSED VALUE type)
70
- {
71
- return CSTR2RVAL(g_content_type_from_mime_type(RVAL2CSTR(type)));
72
- }
73
-
74
- static VALUE
75
- rg_s_guess(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
76
- {
77
- VALUE rbfilename,
78
- rbdata;
79
- const char *filename;
80
- const guchar *data;
81
- gboolean result_uncertain;
82
- char *type;
83
-
84
- rb_scan_args(argc, argv, "02", &rbfilename, &rbdata);
85
-
86
- if (NIL_P(rbfilename) && NIL_P(rbdata))
87
- rb_raise(rb_eArgError,
88
- "Either filename or data can be nil but not both");
89
-
90
- filename = RVAL2CSTR_ACCEPT_NIL(rbfilename);
91
- data = (guchar *)RVAL2CSTR_ACCEPT_NIL(rbdata);
92
-
93
- type = g_content_type_guess(filename,
94
- data,
95
- (gsize)((data != NULL) ? RSTRING_LEN(rbdata) : 0),
96
- &result_uncertain);
97
-
98
- return rb_assoc_new(CSTR2RVAL_FREE(type), CBOOL2RVAL(result_uncertain));
99
- }
100
-
101
- static VALUE
102
- rg_s_guess_for_tree(G_GNUC_UNUSED VALUE self, VALUE root)
103
- {
104
- return STRV2RVAL_FREE(g_content_type_guess_for_tree(RVAL2GFILE(root)));
105
- }
106
-
107
- static VALUE
108
- rg_s_registered(G_GNUC_UNUSED VALUE self)
109
- {
110
- return GLIST2ARY_STR_FREE(g_content_types_get_registered());
111
- }
112
-
113
- void
114
- Init_gcontenttype(VALUE mGio)
115
- {
116
- VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGio, "ContentType");
117
-
118
- /* TODO: Should wrap this in a class. */
119
- RG_DEF_SMETHOD_P(equals, 2);
120
- /* TODO: This name isn't great. */
121
- RG_DEF_SMETHOD_P(is_a, 2);
122
- RG_DEF_SMETHOD_P(unknown, 1);
123
- RG_DEF_SMETHOD(get_description, 1);
124
- RG_DEF_SMETHOD(get_mime_type, 1);
125
- RG_DEF_SMETHOD(get_icon, 1);
126
- RG_DEF_SMETHOD_P(can_be_executable, 1);
127
- RG_DEF_SMETHOD(from_mime_type, 1);
128
- RG_DEF_SMETHOD(guess, -1);
129
- RG_DEF_SMETHOD(guess_for_tree, 1);
130
- RG_DEF_SMETHOD(registered, 0);
131
- }
@@ -1,113 +0,0 @@
1
- /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /*
3
- * Copyright (C) 2011 Ruby-GNOME2 Project Team
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, or (at your option) any later version.
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., 51 Franklin Street, Fifth Floor, Boston,
19
- * MA 02110-1301 USA
20
- */
21
-
22
- #include "rbgio2private.h"
23
-
24
- #define RG_TARGET_NAMESPACE mConverter
25
- #define _SELF(value) RVAL2GCONVERTER(value)
26
-
27
- #define RVAL2GCONVERTERFLAGSDEFAULT(value) \
28
- RVAL2TYPE_WITH_DEFAULT((value), \
29
- RVAL2GCONVERTERFLAGS, \
30
- G_CONVERTER_NO_FLAGS)
31
-
32
- /* TODO: Look at gconverteroutputstream for implementing this. */
33
- /* TODO: Actually, is there any point in implementing this? */
34
- static VALUE
35
- rg_convert(int argc, VALUE *argv, VALUE self)
36
- {
37
- VALUE input, rbflags;
38
- GConverter *converter;
39
- gsize input_remaining, output_size, output_remaining, bytes_read, bytes_written;
40
- GConverterFlags flags;
41
- /* TODO: Use a Ruby string instead. */
42
- char *output_base, *output;
43
- GError *error = NULL;
44
- GConverterResult result;
45
-
46
- rb_scan_args(argc, argv, "11", &input, &rbflags);
47
- converter = _SELF(self);
48
- StringValue(input);
49
- input_remaining = RSTRING_LEN(input);
50
- flags = RVAL2GCONVERTERFLAGSDEFAULT(rbflags);
51
- output_remaining = output_size = BUFSIZ;
52
- output_base = output = ALLOCA_N(char, output_size);
53
- do {
54
- result = g_converter_convert(converter,
55
- RSTRING_PTR(input),
56
- input_remaining,
57
- output,
58
- output_remaining,
59
- flags,
60
- &bytes_read,
61
- &bytes_written,
62
- &error);
63
- switch (result) {
64
- case G_CONVERTER_ERROR:
65
- switch (error->code) {
66
- case G_IO_ERROR_NO_SPACE:
67
- /* TODO: Expand the buffer? */
68
- break;
69
- case G_IO_ERROR_PARTIAL_INPUT:
70
- /* TODO: How do we request/tell the user that
71
- * they need to provide more data? */
72
- break;
73
- default:
74
- break;
75
- }
76
- rbgio_raise_error(error);
77
- break;
78
- case G_CONVERTER_CONVERTED:
79
- case G_CONVERTER_FLUSHED:
80
- input_remaining -= bytes_read;
81
- input += bytes_read;
82
- output_remaining -= bytes_written;
83
- output += bytes_written;
84
- /* TODO: Do we need to do anything else? */
85
- break;
86
- case G_CONVERTER_FINISHED:
87
- /* TODO: Do we simply break, or do we need to consider
88
- * something else? */
89
- break;
90
- default:
91
- break;
92
- }
93
- } while (input_remaining > 0);
94
-
95
- return CSTR2RVAL(output_base);
96
- }
97
-
98
- static VALUE
99
- rg_reset(VALUE self)
100
- {
101
- g_converter_reset(_SELF(self));
102
-
103
- return self;
104
- }
105
-
106
- void
107
- Init_gconverter(VALUE mGio)
108
- {
109
- VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_CONVERTER, "Converter", mGio);
110
-
111
- RG_DEF_METHOD(convert, -1);
112
- RG_DEF_METHOD(reset, 0);
113
- }