glib2 3.1.9 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1c8eb28db7aee6ac06f5a721e2f16b7c49e1d9f
4
- data.tar.gz: 98d3afb3b78d83dc43a9a57d308cf9308b8a31a5
3
+ metadata.gz: 7d43d9ed5f11b3fccdab8aafc21a2fdb6b1aa371
4
+ data.tar.gz: d1f0fd447c1f7bda052bd3a9b70b5f3880b6e69a
5
5
  SHA512:
6
- metadata.gz: 0fdd234ca217c0ac8a5a193b8b10baf64506a116c0838fe43ee70e996531ff16ec0f4a7beb96e40c529a7abd9d188d9ebe2aa9f57979e8258a6bb0364e49bf36
7
- data.tar.gz: 5585355516dee22a8f55c8c78fc5e38ee5e4dcb8755570947b57c71a8b25230a17c27b7a2c62a6f37b9ffb4789bb91e744f304b6bd86d23c139c14af5571f134
6
+ metadata.gz: 2f5909e8f1fca4f41d19ff39412e437f5519d33a8f763f215936b2e91044cce33b3aff3de17380c0dd131a6d04618234b3ebf924b3713ff0a80e815708b658da
7
+ data.tar.gz: 28a379fd75d9024aa5365db8bee8fe2a820983b28bcfe93ec8a386960a7e57b8f7b0512256bb60002ba2a48c8c64e3e0404c2f3475ced6651d67c21b54b16990
@@ -35,8 +35,8 @@ extern "C" {
35
35
  #endif /* __cplusplus */
36
36
 
37
37
  #define RBGLIB_MAJOR_VERSION 3
38
- #define RBGLIB_MINOR_VERSION 1
39
- #define RBGLIB_MICRO_VERSION 9
38
+ #define RBGLIB_MINOR_VERSION 2
39
+ #define RBGLIB_MICRO_VERSION 0
40
40
 
41
41
  #ifndef RB_ZALLOC
42
42
  # ifdef ZALLOC
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2011 Ruby-GNOME2 Project Team
3
+ * Copyright (C) 2011-2017 Ruby-GNOME2 Project Team
4
4
  * Copyright (C) 2005 Masao Mutoh
5
5
  *
6
6
  * This library is free software; you can redistribute it and/or
@@ -27,6 +27,8 @@ static ID id_unpack;
27
27
 
28
28
  static VALUE default_rs;
29
29
 
30
+ static VALUE rb_mIOChannelSource;
31
+
30
32
  #define RG_TARGET_NAMESPACE cIOChannel
31
33
  #define _SELF(s) ((GIOChannel*)RVAL2BOXED(s, G_TYPE_IO_CHANNEL))
32
34
 
@@ -499,8 +501,17 @@ rg_close(gint argc, VALUE *argv, VALUE self)
499
501
  static VALUE
500
502
  rg_create_watch(VALUE self, VALUE condition)
501
503
  {
502
- return BOXED2RVAL(g_io_create_watch(_SELF(self), NUM2INT(condition)),
503
- G_TYPE_SOURCE);
504
+ VALUE rb_source;
505
+
506
+ rb_source = BOXED2RVAL(g_io_create_watch(_SELF(self), NUM2INT(condition)),
507
+ G_TYPE_SOURCE);
508
+ rb_extend_object(rb_source, rb_mIOChannelSource);
509
+ if (rb_block_given_p()) {
510
+ ID id_set_callback;
511
+ CONST_ID(id_set_callback, "set_callback");
512
+ rb_funcall(rb_source, id_set_callback, 0);
513
+ }
514
+ return rb_source;
504
515
  }
505
516
 
506
517
  static gboolean
@@ -529,6 +540,20 @@ guint g_io_add_watch_full (GIOChannel *channel,
529
540
  GDestroyNotify notify);
530
541
  */
531
542
 
543
+ static VALUE
544
+ rg_io_channel_source_set_callback(VALUE self)
545
+ {
546
+ VALUE callback;
547
+
548
+ callback = rb_block_proc();
549
+ G_RELATIVE(self, callback);
550
+ g_source_set_callback(RVAL2BOXED(self, G_TYPE_SOURCE),
551
+ (GSourceFunc)io_func,
552
+ (gpointer)callback,
553
+ (GDestroyNotify)NULL);
554
+ return self;
555
+ }
556
+
532
557
  static VALUE
533
558
  rg_buffer_size(VALUE self)
534
559
  {
@@ -818,4 +843,10 @@ Init_glib_io_channel(void)
818
843
  rb_define_const(RG_TARGET_NAMESPACE, "FLAG_MASK", INT2NUM(G_IO_FLAG_MASK));
819
844
  rb_define_const(RG_TARGET_NAMESPACE, "FLAG_GET_MASK", INT2NUM(G_IO_FLAG_GET_MASK));
820
845
  rb_define_const(RG_TARGET_NAMESPACE, "FLAG_SET_MASK", INT2NUM(G_IO_FLAG_SET_MASK));
846
+
847
+ rb_mIOChannelSource = rb_define_module_under(mGLib, "IOChannelSource");
848
+ rb_define_method(rb_mIOChannelSource,
849
+ "set_callback",
850
+ rg_io_channel_source_set_callback,
851
+ 0);
821
852
  }
@@ -28,6 +28,10 @@ static ID id_call;
28
28
  static void
29
29
  source_free(GSource *source)
30
30
  {
31
+ if (g_source_is_destroyed(source)) {
32
+ return;
33
+ }
34
+
31
35
  g_source_unref(source);
32
36
  g_source_destroy(source);
33
37
  }
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015 Ruby-GNOME2 Project Team
1
+ # Copyright (C) 2015-2017 Ruby-GNOME2 Project Team
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -13,19 +13,16 @@
13
13
  # You should have received a copy of the GNU Lesser General Public
14
14
  # License along with this library; if not, write to the Free Software
15
15
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
-
16
+
17
17
  require 'test/unit'
18
18
  require 'glib2'
19
19
 
20
20
  require 'tempfile'
21
- require 'nkf'
22
-
23
- $KCODE = "U" unless defined?(:Encoding)
24
21
 
25
22
  class TestGIOChannel < Test::Unit::TestCase
26
23
  def setup
27
24
  @content = "aaa\nbbb\nccc\nあああ\n"
28
- @sjis_content = NKF.nkf("-sW", @content)
25
+ @sjis_content = @content.encode("CP932")
29
26
 
30
27
  @file = Tempfile.new("glib2-content")
31
28
  @file.open
@@ -65,7 +62,7 @@ class TestGIOChannel < Test::Unit::TestCase
65
62
  GLib::IOChannel.open(write_test_file.path, "w") do |_io|
66
63
  io = _io
67
64
  assert_raises(RuntimeError) do
68
- assert_equal(@content, io.read)
65
+ assert_equal(@content, io.read)
69
66
  end
70
67
  end
71
68
 
@@ -81,8 +78,8 @@ class TestGIOChannel < Test::Unit::TestCase
81
78
  def test_getc
82
79
  io = GLib::IOChannel.new(@file.path)
83
80
  ["a", "b", "c", "あ"].each do |v|
84
- 3.times do
85
- assert_equal(v.unpack("U")[0], io.getc)
81
+ 3.times do
82
+ assert_equal(v.unpack("U")[0], io.getc)
86
83
  end
87
84
  assert_equal("\n".unpack("U")[0], io.getc)
88
85
  end
@@ -162,7 +159,7 @@ class TestGIOChannel < Test::Unit::TestCase
162
159
  io = GLib::IOChannel.new(@file.path)
163
160
  assert_raises(RuntimeError) {
164
161
  io.each {|line|
165
- raise "test"
162
+ raise "test"
166
163
  }
167
164
  }
168
165
  io.close
@@ -179,7 +176,7 @@ class TestGIOChannel < Test::Unit::TestCase
179
176
  GLib::IOChannel.open(@file.path) do |_io|
180
177
  io = _io
181
178
  io.each_with_index do |line, _i|
182
- assert_equal(lines[_i], line)
179
+ assert_equal(lines[_i], line)
183
180
  end
184
181
  end
185
182
 
@@ -286,4 +283,50 @@ class TestGIOChannel < Test::Unit::TestCase
286
283
  GLib::IOChannel.new("foo")
287
284
  }
288
285
  end
286
+
287
+ sub_test_case("#create_watch") do
288
+ def setup
289
+ super
290
+ @context = GLib::MainContext.new
291
+ end
292
+
293
+ def test_with_block
294
+ GLib::IOChannel.open(@file.path) do |channel|
295
+ received_condition = nil
296
+ source = channel.create_watch(GLib::IOChannel::IN) do |_, condition|
297
+ received_condition = condition
298
+ GLib::Source::CONTINUE
299
+ end
300
+ begin
301
+ source.attach(@context)
302
+ 10.times do
303
+ @context.iteration(false)
304
+ end
305
+ assert_equal(GLib::IOCondition::IN, received_condition)
306
+ ensure
307
+ source.destroy
308
+ end
309
+ end
310
+ end
311
+
312
+ def test_set_callback
313
+ GLib::IOChannel.open(@file.path) do |channel|
314
+ received_condition = nil
315
+ source = channel.create_watch(GLib::IOChannel::IN)
316
+ source.set_callback do |_, condition|
317
+ received_condition = condition
318
+ GLib::Source::CONTINUE
319
+ end
320
+ begin
321
+ source.attach(@context)
322
+ 10.times do
323
+ @context.iteration(false)
324
+ end
325
+ assert_equal(GLib::IOCondition::IN, received_condition)
326
+ ensure
327
+ source.destroy
328
+ end
329
+ end
330
+ end
331
+ end
289
332
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib2
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.9
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Ruby-GNOME2 Project Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-16 00:00:00.000000000 Z
11
+ date: 2017-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pkg-config
@@ -171,6 +171,7 @@ files:
171
171
  - test/test-binding.rb
172
172
  - test/test-bytes.rb
173
173
  - test/test-date-time.rb
174
+ - test/test-iochannel.rb
174
175
  - test/test-match-info.rb
175
176
  - test/test-regex.rb
176
177
  - test/test-time-zone.rb
@@ -181,7 +182,6 @@ files:
181
182
  - test/test_file_utils.rb
182
183
  - test/test_flags.rb
183
184
  - test/test_glib2.rb
184
- - test/test_iochannel.rb
185
185
  - test/test_key_file.rb
186
186
  - test/test_mkenums.rb
187
187
  - test/test_poll_fd.rb