gio2 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) 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/gio2.rb +38 -143
  9. data/lib/gio2/deprecated.rb +16 -0
  10. data/lib/gio2/inet-address.rb +33 -0
  11. data/lib/gio2/input-stream.rb +39 -0
  12. data/lib/gio2/loader.rb +244 -0
  13. data/lib/gio2/output-stream.rb +24 -0
  14. data/lib/gio2/pollable-input-stream.rb +51 -0
  15. data/lib/gio2/pollable-output-stream.rb +32 -0
  16. data/lib/gio2/resources.rb +62 -0
  17. data/test/fixture/content-type/x-content/unix-software/autorun.sh +1 -0
  18. data/test/fixture/resource/Rakefile +32 -0
  19. data/test/fixture/resource/logo.png +0 -0
  20. data/test/fixture/resource/ruby-gio2.gresource +0 -0
  21. data/test/fixture/resource/ruby-gio2.gresource.xml +6 -0
  22. data/test/gio2-test-utils.rb +21 -0
  23. data/test/gio2-test-utils/fixture.rb +24 -0
  24. data/test/gio2-test-utils/socket-client.rb +59 -0
  25. data/test/run-test.rb +45 -9
  26. data/test/test-buffered-input-stream.rb +23 -0
  27. data/test/test-charset-converter.rb +23 -0
  28. data/test/test-content-type.rb +31 -0
  29. data/test/test-data-input-stream.rb +21 -0
  30. data/test/test-file-enumerator.rb +26 -0
  31. data/test/test-file-monitor.rb +33 -0
  32. data/test/test-file.rb +28 -0
  33. data/test/test-inet-address.rb +34 -0
  34. data/test/test-input-stream.rb +36 -0
  35. data/test/test-output-stream.rb +39 -0
  36. data/test/test-pollable-input-stream.rb +54 -0
  37. data/test/test-pollable-output-stream.rb +53 -0
  38. data/test/test-resources.rb +58 -0
  39. metadata +49 -107
  40. data/README +0 -34
  41. data/ext/gio2/depend +0 -11
  42. data/ext/gio2/gio2.def +0 -2
  43. data/ext/gio2/gio2.h +0 -30
  44. data/ext/gio2/rbgio.c +0 -133
  45. data/ext/gio2/rbgio2.h +0 -158
  46. data/ext/gio2/rbgio2conversions.h +0 -154
  47. data/ext/gio2/rbgio2private.h +0 -148
  48. data/ext/gio2/rbgioappinfo.c +0 -317
  49. data/ext/gio2/rbgioapplaunchcontext.c +0 -81
  50. data/ext/gio2/rbgioasyncinitable.c +0 -246
  51. data/ext/gio2/rbgioasyncresult.c +0 -41
  52. data/ext/gio2/rbgiobufferedinputstream.c +0 -167
  53. data/ext/gio2/rbgiobufferedoutputstream.c +0 -50
  54. data/ext/gio2/rbgiocancellable.c +0 -180
  55. data/ext/gio2/rbgiocharsetconverter.c +0 -57
  56. data/ext/gio2/rbgiocontenttype.c +0 -131
  57. data/ext/gio2/rbgioconverter.c +0 -113
  58. data/ext/gio2/rbgioconverterinputstream.c +0 -43
  59. data/ext/gio2/rbgioconverteroutputstream.c +0 -43
  60. data/ext/gio2/rbgiodatainputstream.c +0 -309
  61. data/ext/gio2/rbgiodataoutputstream.c +0 -186
  62. data/ext/gio2/rbgiodesktopappinfo.c +0 -87
  63. data/ext/gio2/rbgiodrive.c +0 -266
  64. data/ext/gio2/rbgioemblem.c +0 -52
  65. data/ext/gio2/rbgioemblemedicon.c +0 -65
  66. data/ext/gio2/rbgiofile.c +0 -2045
  67. data/ext/gio2/rbgiofileattribute.c +0 -114
  68. data/ext/gio2/rbgiofileattributeinfo.c +0 -86
  69. data/ext/gio2/rbgiofileattributeinfolist.c +0 -108
  70. data/ext/gio2/rbgiofileattributematcher.c +0 -95
  71. data/ext/gio2/rbgiofiledescriptorbased.c +0 -45
  72. data/ext/gio2/rbgiofileenumerator.c +0 -166
  73. data/ext/gio2/rbgiofileicon.c +0 -41
  74. data/ext/gio2/rbgiofileinfo.c +0 -617
  75. data/ext/gio2/rbgiofileinputstream.c +0 -91
  76. data/ext/gio2/rbgiofileiostream.c +0 -98
  77. data/ext/gio2/rbgiofilemonitor.c +0 -46
  78. data/ext/gio2/rbgiofilenamecompleter.c +0 -73
  79. data/ext/gio2/rbgiofileoutputstream.c +0 -98
  80. data/ext/gio2/rbgiofilterinputstream.c +0 -28
  81. data/ext/gio2/rbgioicon.c +0 -69
  82. data/ext/gio2/rbgioinetaddress.c +0 -118
  83. data/ext/gio2/rbgioinetsocketaddress.c +0 -41
  84. data/ext/gio2/rbgioinitable.c +0 -199
  85. data/ext/gio2/rbgioinputstream.c +0 -341
  86. data/ext/gio2/rbgioio.c +0 -73
  87. data/ext/gio2/rbgioiomodule.c +0 -45
  88. data/ext/gio2/rbgioiomodules.c +0 -47
  89. data/ext/gio2/rbgioioscheduler.c +0 -102
  90. data/ext/gio2/rbgioioschedulerjob.c +0 -121
  91. data/ext/gio2/rbgioiostream.c +0 -107
  92. data/ext/gio2/rbgioloadableicon.c +0 -92
  93. data/ext/gio2/rbgiomemoryinputstream.c +0 -67
  94. data/ext/gio2/rbgiomemoryoutputstream.c +0 -44
  95. data/ext/gio2/rbgiomount.c +0 -286
  96. data/ext/gio2/rbgiomountoperation.c +0 -53
  97. data/ext/gio2/rbgionetworkaddress.c +0 -59
  98. data/ext/gio2/rbgionetworkservice.c +0 -45
  99. data/ext/gio2/rbgiooutputstream.c +0 -331
  100. data/ext/gio2/rbgioresolver.c +0 -230
  101. data/ext/gio2/rbgioseekable.c +0 -91
  102. data/ext/gio2/rbgiosimpleasyncresult.c +0 -152
  103. data/ext/gio2/rbgiosocket.c +0 -390
  104. data/ext/gio2/rbgiosocketaddress.c +0 -34
  105. data/ext/gio2/rbgiosocketaddressenumerator.c +0 -83
  106. data/ext/gio2/rbgiosocketclient.c +0 -207
  107. data/ext/gio2/rbgiosocketconnectable.c +0 -41
  108. data/ext/gio2/rbgiosocketconnection.c +0 -66
  109. data/ext/gio2/rbgiosocketconnectionfactory.c +0 -39
  110. data/ext/gio2/rbgiosocketcontrolmessage.c +0 -82
  111. data/ext/gio2/rbgiosocketlistener.c +0 -246
  112. data/ext/gio2/rbgiosocketservice.c +0 -66
  113. data/ext/gio2/rbgiosrvtarget.c +0 -76
  114. data/ext/gio2/rbgiotcpconnection.c +0 -28
  115. data/ext/gio2/rbgiothemedicon.c +0 -83
  116. data/ext/gio2/rbgiothreadedsocketservice.c +0 -43
  117. data/ext/gio2/rbgiotlscertificate.c +0 -89
  118. data/ext/gio2/rbgiounixconnection.c +0 -71
  119. data/ext/gio2/rbgiounixfdlist.c +0 -115
  120. data/ext/gio2/rbgiounixfdmessage.c +0 -74
  121. data/ext/gio2/rbgiounixinputstream.c +0 -51
  122. data/ext/gio2/rbgiounixmount.c +0 -164
  123. data/ext/gio2/rbgiounixmountmonitor.c +0 -65
  124. data/ext/gio2/rbgiounixmountpoint.c +0 -136
  125. data/ext/gio2/rbgiounixmountpoints.c +0 -58
  126. data/ext/gio2/rbgiounixmounts.c +0 -58
  127. data/ext/gio2/rbgiounixoutputstream.c +0 -51
  128. data/ext/gio2/rbgiounixsocketaddress.c +0 -69
  129. data/ext/gio2/rbgiovfs.c +0 -84
  130. data/ext/gio2/rbgiovolume.c +0 -193
  131. data/ext/gio2/rbgiovolumemonitor.c +0 -77
  132. data/ext/gio2/rbgiozlibcompressor.c +0 -52
  133. data/ext/gio2/rbgiozlibdecompressor.c +0 -45
  134. data/ext/gio2/util.c +0 -303
  135. data/test/test_bufferedinputstream.rb +0 -9
  136. data/test/test_charsetconverter.rb +0 -9
  137. data/test/test_datainputstream.rb +0 -7
  138. data/test/test_fileenumerator.rb +0 -8
  139. data/test/test_filemonitor.rb +0 -17
  140. data/test/test_inetaddress.rb +0 -8
@@ -1,73 +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 mIO
25
-
26
- /* NOTE: g_io_error_from_errno doesn't make sense from Ruby. */
27
-
28
- void
29
- Init_gioerror(VALUE mGio)
30
- {
31
- VALUE RG_TARGET_NAMESPACE, error;
32
-
33
- RG_TARGET_NAMESPACE = rb_define_module_under(mGio, "IO");
34
-
35
- error = rbgio_define_domain_error(RG_TARGET_NAMESPACE, "Error", G_IO_ERROR, "GIOErrorEnum", rb_eIOError);
36
-
37
- rbgio_define_error(RG_TARGET_NAMESPACE, "FailedError", G_IO_ERROR_FAILED, error);
38
- rbgio_define_error(RG_TARGET_NAMESPACE, "NotFoundError", G_IO_ERROR_NOT_FOUND, error);
39
- rbgio_define_error(RG_TARGET_NAMESPACE, "ExistsError", G_IO_ERROR_EXISTS, error);
40
- rbgio_define_error(RG_TARGET_NAMESPACE, "IsDirectoryError", G_IO_ERROR_IS_DIRECTORY, error);
41
- rbgio_define_error(RG_TARGET_NAMESPACE, "NotDirectoryError", G_IO_ERROR_NOT_DIRECTORY, error);
42
- rbgio_define_error(RG_TARGET_NAMESPACE, "NotEmptyError", G_IO_ERROR_NOT_EMPTY, error);
43
- rbgio_define_error(RG_TARGET_NAMESPACE, "NotRegularFileError", G_IO_ERROR_NOT_REGULAR_FILE, error);
44
- rbgio_define_error(RG_TARGET_NAMESPACE, "NotSymbolicLinkError", G_IO_ERROR_NOT_SYMBOLIC_LINK, error);
45
- rbgio_define_error(RG_TARGET_NAMESPACE, "NotMountableFileError", G_IO_ERROR_NOT_MOUNTABLE_FILE, error);
46
- rbgio_define_error(RG_TARGET_NAMESPACE, "FilenameTooLongError", G_IO_ERROR_FILENAME_TOO_LONG, error);
47
- rbgio_define_error(RG_TARGET_NAMESPACE, "InvalidFilenameError", G_IO_ERROR_INVALID_FILENAME, error);
48
- rbgio_define_error(RG_TARGET_NAMESPACE, "TooManyLinksError", G_IO_ERROR_TOO_MANY_LINKS, error);
49
- rbgio_define_error(RG_TARGET_NAMESPACE, "NoSpaceError", G_IO_ERROR_NO_SPACE, error);
50
- rbgio_define_error(RG_TARGET_NAMESPACE, "InvalidArgumentError", G_IO_ERROR_INVALID_ARGUMENT, error);
51
- rbgio_define_error(RG_TARGET_NAMESPACE, "PermissionDeniedError", G_IO_ERROR_PERMISSION_DENIED, error);
52
- rbgio_define_error(RG_TARGET_NAMESPACE, "NotSupportedError", G_IO_ERROR_NOT_SUPPORTED, error);
53
- rbgio_define_error(RG_TARGET_NAMESPACE, "NotMountedError", G_IO_ERROR_NOT_MOUNTED, error);
54
- rbgio_define_error(RG_TARGET_NAMESPACE, "AlreadyMountedError", G_IO_ERROR_ALREADY_MOUNTED, error);
55
- rbgio_define_error(RG_TARGET_NAMESPACE, "ClosedError", G_IO_ERROR_CLOSED, error);
56
- rbgio_define_error(RG_TARGET_NAMESPACE, "CancelledError", G_IO_ERROR_CANCELLED, error);
57
- rbgio_define_error(RG_TARGET_NAMESPACE, "PendingError", G_IO_ERROR_PENDING, error);
58
- rbgio_define_error(RG_TARGET_NAMESPACE, "ReadOnlyError", G_IO_ERROR_READ_ONLY, error);
59
- rbgio_define_error(RG_TARGET_NAMESPACE, "CantCreateBackupError", G_IO_ERROR_CANT_CREATE_BACKUP, error);
60
- rbgio_define_error(RG_TARGET_NAMESPACE, "WrongEtagError", G_IO_ERROR_WRONG_ETAG, error);
61
- rbgio_define_error(RG_TARGET_NAMESPACE, "TimedOutError", G_IO_ERROR_TIMED_OUT, error);
62
- rbgio_define_error(RG_TARGET_NAMESPACE, "WouldRecurseError", G_IO_ERROR_WOULD_RECURSE, error);
63
- rbgio_define_error(RG_TARGET_NAMESPACE, "BusyError", G_IO_ERROR_BUSY, error);
64
- rbgio_define_error(RG_TARGET_NAMESPACE, "WouldBlockError", G_IO_ERROR_WOULD_BLOCK, error);
65
- rbgio_define_error(RG_TARGET_NAMESPACE, "HostNotFoundError", G_IO_ERROR_HOST_NOT_FOUND, error);
66
- rbgio_define_error(RG_TARGET_NAMESPACE, "WouldMergeError", G_IO_ERROR_WOULD_MERGE, error);
67
- rbgio_define_error(RG_TARGET_NAMESPACE, "FailedHandledError", G_IO_ERROR_FAILED_HANDLED, error);
68
- rbgio_define_error(RG_TARGET_NAMESPACE, "TooManyOpenFilesError", G_IO_ERROR_TOO_MANY_OPEN_FILES, error);
69
- rbgio_define_error(RG_TARGET_NAMESPACE, "NotInitializedError", G_IO_ERROR_NOT_INITIALIZED, error);
70
- rbgio_define_error(RG_TARGET_NAMESPACE, "AddressInUseError", G_IO_ERROR_ADDRESS_IN_USE, error);
71
- rbgio_define_error(RG_TARGET_NAMESPACE, "PartialInputError", G_IO_ERROR_PARTIAL_INPUT, error);
72
- rbgio_define_error(RG_TARGET_NAMESPACE, "InvalidDataError", G_IO_ERROR_INVALID_DATA, error);
73
- }
@@ -1,45 +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 cIOModule
25
- #define _SELF(value) RVAL2GIOMODULE(value)
26
-
27
- static VALUE
28
- rg_initialize(VALUE self, VALUE filename)
29
- {
30
- G_INITIALIZE(self, g_io_module_new(RVAL2CSTR(filename)));
31
-
32
- return Qnil;
33
- }
34
-
35
- /* NOTE: No point in implementing g_io_module_query. */
36
-
37
- void
38
- Init_giomodule(VALUE mGio)
39
- {
40
- VALUE RG_TARGET_NAMESPACE;
41
-
42
- RG_TARGET_NAMESPACE = G_DEF_CLASS(G_IO_TYPE_MODULE, "IOModule", mGio);
43
-
44
- RG_DEF_METHOD(initialize, 1);
45
- }
@@ -1,47 +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 mIOModules
25
-
26
- static VALUE
27
- rg_s_load_all_in_directory(G_GNUC_UNUSED VALUE self, VALUE dirname)
28
- {
29
- return GLIST2ARY_FREE(g_io_modules_load_all_in_directory(RVAL2CSTR(dirname)));
30
- }
31
-
32
- static VALUE
33
- rg_s_scan_all_in_directory(VALUE self, VALUE dirname)
34
- {
35
- g_io_modules_scan_all_in_directory(RVAL2CSTR(dirname));
36
-
37
- return self;
38
- }
39
-
40
- void
41
- Init_giomodules(VALUE mGio)
42
- {
43
- VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGio, "IOModules");
44
-
45
- RG_DEF_SMETHOD(load_all_in_directory, 1);
46
- RG_DEF_SMETHOD(scan_all_in_directory, 1);
47
- }
@@ -1,102 +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 mIOScheduler
25
-
26
- struct ioscheduler_job_callback_data
27
- {
28
- GIOSchedulerJob *job;
29
- GCancellable *cancellable;
30
- gpointer data;
31
- };
32
-
33
- static VALUE
34
- ioscheduler_job_callback_call(VALUE data)
35
- {
36
- static VALUE s_id_call;
37
- struct ioscheduler_job_callback_data *real;
38
-
39
- if (s_id_call == 0)
40
- s_id_call = rb_intern("call");
41
-
42
- real = (struct ioscheduler_job_callback_data *)data;
43
-
44
- /* TODO: Totally unsure if _UNREF is correct here or not. */
45
- return rb_funcall(USE_BLOCK_AND_SAVE(real->data), s_id_call, 2,
46
- GOBJ2RVAL_UNREF(real->job),
47
- GOBJ2RVAL_UNREF(real->cancellable));
48
- }
49
-
50
- static gboolean
51
- ioscheduler_job_callback(GIOSchedulerJob *job,
52
- GCancellable *cancellable,
53
- gpointer data)
54
- {
55
- struct ioscheduler_job_callback_data real = { job, cancellable, data };
56
-
57
- return RVAL2CBOOL(G_PROTECT_CALLBACK(ioscheduler_job_callback_call,
58
- &real));
59
- }
60
-
61
- static void
62
- ioscheduler_job_callback_free(gpointer data)
63
- {
64
- USE_BLOCK((VALUE)data);
65
- }
66
-
67
- static VALUE
68
- rg_s_push_job(int argc, VALUE *argv, VALUE self)
69
- {
70
- VALUE rbio_priority, rbcancellable, block;
71
- gint io_priority;
72
- GCancellable *cancellable;
73
-
74
- rb_scan_args(argc, argv, "02", &rbio_priority, &rbcancellable);
75
- io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
76
- cancellable = RVAL2GCANCELLABLE(rbcancellable);
77
- block = rb_block_proc();
78
- SAVE_BLOCK(block);
79
- g_io_scheduler_push_job(ioscheduler_job_callback,
80
- (gpointer)block,
81
- ioscheduler_job_callback_free,
82
- io_priority,
83
- cancellable);
84
-
85
- return self;
86
- }
87
-
88
- static VALUE
89
- rg_s_cancel_all_jobs(VALUE self)
90
- {
91
- g_io_scheduler_cancel_all_jobs();
92
-
93
- return self;
94
- }
95
-
96
- void
97
- Init_gioscheduler(VALUE mGio)
98
- {
99
- VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGio, "IOScheduler");
100
- RG_DEF_SMETHOD(push_job, -1);
101
- RG_DEF_SMETHOD(cancel_all_jobs, 0);
102
- }
@@ -1,121 +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 G_TYPE_IO_SCHEDULER_JOB (g_io_scheduler_job_get_type())
25
-
26
- #define RVAL2GIOSCHEDULERJOB(object) \
27
- ((GIOSchedulerJob *)(RVAL2BOXED(object, G_TYPE_IO_SCHEDULER_JOB)))
28
-
29
- #define GIOSCHEDULERJOB2RVAL(object) \
30
- BOXED2RVAL(object, G_TYPE_IO_SCHEDULER_JOB)
31
-
32
- #define RG_TARGET_NAMESPACE cIOSchedulerJob
33
- #define _SELF(value) RVAL2GIOSCHEDULERJOB(value)
34
-
35
- static GIOSchedulerJob *
36
- ioschedulerjob_copy(const GIOSchedulerJob *job)
37
- {
38
- return (GIOSchedulerJob *)job;
39
- }
40
-
41
- static void
42
- ioschedulerjob_free(G_GNUC_UNUSED GIOSchedulerJob *job)
43
- {
44
- return;
45
- }
46
-
47
- static GType
48
- g_io_scheduler_job_get_type(void)
49
- {
50
- static GType our_type = 0;
51
-
52
- if (our_type == 0)
53
- our_type = g_boxed_type_register_static("GIOSchedulerJob",
54
- (GBoxedCopyFunc)ioschedulerjob_copy,
55
- (GBoxedFreeFunc)ioschedulerjob_free);
56
-
57
- return our_type;
58
- }
59
-
60
- static VALUE
61
- ioscheduler_source_callback_call(VALUE data)
62
- {
63
- static VALUE s_id_call;
64
-
65
- if (s_id_call == 0)
66
- s_id_call = rb_intern("call");
67
-
68
- return rb_funcall(USE_BLOCK_AND_SAVE(data), s_id_call, 0);
69
- }
70
-
71
- static gboolean
72
- ioscheduler_source_callback(gpointer data)
73
- {
74
- return RVAL2CBOOL(G_PROTECT_CALLBACK(ioscheduler_source_callback_call,
75
- data));
76
- }
77
-
78
- static void
79
- ioscheduler_source_callback_free(gpointer data)
80
- {
81
- USE_BLOCK(data);
82
- }
83
-
84
- static VALUE
85
- rg_send_to_mainloop(VALUE self)
86
- {
87
- VALUE block;
88
-
89
- block = rb_block_proc();
90
- SAVE_BLOCK(block);
91
-
92
- return CBOOL2RVAL(g_io_scheduler_job_send_to_mainloop(_SELF(self),
93
- ioscheduler_source_callback,
94
- (gpointer)block,
95
- ioscheduler_source_callback_free));
96
- }
97
-
98
- static VALUE
99
- rg_send_to_mainloop_async(VALUE self)
100
- {
101
- VALUE block;
102
-
103
- block = rb_block_proc();
104
- SAVE_BLOCK(block);
105
-
106
- g_io_scheduler_job_send_to_mainloop_async(_SELF(self),
107
- ioscheduler_source_callback,
108
- (gpointer)block,
109
- ioscheduler_source_callback_free);
110
-
111
- return self;
112
- }
113
-
114
- void
115
- Init_gioschedulerjob(VALUE mGio)
116
- {
117
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_IO_SCHEDULER_JOB, "IOSchedulerJob", mGio);
118
-
119
- RG_DEF_METHOD(send_to_mainloop, 0);
120
- RG_DEF_METHOD(send_to_mainloop_async, 0);
121
- }
@@ -1,107 +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 cIOStream
25
- #define _SELF(value) RVAL2GIOSTREAM(value)
26
-
27
- static VALUE
28
- rg_close(VALUE self, VALUE cancellable)
29
- {
30
- GError *error = NULL;
31
-
32
- if (!g_io_stream_close(_SELF(self), RVAL2GCANCELLABLE(cancellable), &error))
33
- rbgio_raise_error(error);
34
-
35
- return self;
36
- }
37
-
38
- static VALUE
39
- rg_close_async(int argc, VALUE *argv, VALUE self)
40
- {
41
- VALUE rbio_priority, rbcancellable, block;
42
- int io_priority;
43
- GCancellable *cancellable;
44
-
45
- rb_scan_args(argc, argv, "01&", &rbio_priority, &rbcancellable, &block);
46
- io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
47
- cancellable = RVAL2GCANCELLABLE(rbcancellable);
48
- SAVE_BLOCK(block);
49
- g_io_stream_close_async(_SELF(self),
50
- io_priority,
51
- cancellable,
52
- rbgio_async_ready_callback,
53
- (gpointer)block);
54
-
55
- return self;
56
- }
57
-
58
- static VALUE
59
- rg_close_finish(VALUE self, VALUE result)
60
- {
61
- GError *error = NULL;
62
-
63
- if (!g_io_stream_close_finish(_SELF(self),
64
- RVAL2GASYNCRESULT(result),
65
- &error))
66
- rbgio_raise_error(error);
67
-
68
- return self;
69
- }
70
-
71
- static VALUE
72
- rg_has_pending_p(VALUE self)
73
- {
74
- return CBOOL2RVAL(g_io_stream_has_pending(_SELF(self)));
75
- }
76
-
77
- static VALUE
78
- rg_set_pending(VALUE self)
79
- {
80
- GError *error = NULL;
81
-
82
- if (!g_io_stream_set_pending(_SELF(self), &error))
83
- rbgio_raise_error(error);
84
-
85
- return self;
86
- }
87
-
88
- static VALUE
89
- rg_clear_pending(VALUE self)
90
- {
91
- g_io_stream_clear_pending(_SELF(self));
92
-
93
- return self;
94
- }
95
-
96
- void
97
- Init_giostream(VALUE mGio)
98
- {
99
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_IO_STREAM, "IOStream", mGio);
100
-
101
- RG_DEF_METHOD(close, 1);
102
- RG_DEF_METHOD(close_async, -1);
103
- RG_DEF_METHOD(close_finish, 1);
104
- RG_DEF_METHOD_P(has_pending, 0);
105
- RG_DEF_METHOD(set_pending, 0);
106
- RG_DEF_METHOD(clear_pending, 0);
107
- }