glib2 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/ext/glib2/extconf.rb CHANGED
@@ -16,7 +16,13 @@ require 'mkmf-gnome2'
16
16
 
17
17
  setup_win32(module_name, base_dir)
18
18
 
19
- PKGConfig.have_package(package_id) or exit 1
19
+ unless required_pkg_config_package(package_id,
20
+ :debian => "libglib2.0-dev",
21
+ :redhat => "glib2-devel",
22
+ :homebrew => "glib",
23
+ :macports => "glib2")
24
+ exit(false)
25
+ end
20
26
  PKGConfig.have_package('gthread-2.0')
21
27
 
22
28
  have_header("unistd.h")
data/ext/glib2/glib2.def CHANGED
@@ -128,5 +128,6 @@ EXPORTS
128
128
  rbglib_num_to_int64
129
129
  rbglib_int64_to_num
130
130
 
131
+ g_source_get_type
131
132
  g_connect_flags_get_type
132
133
  g_poll_fd_get_type
data/ext/glib2/rbglib.c CHANGED
@@ -1109,6 +1109,7 @@ union GDoubleIEEE754;
1109
1109
  Init_glib_source();
1110
1110
  Init_glib_main_context();
1111
1111
  Init_glib_poll_fd();
1112
+ Init_glib_io_constants();
1112
1113
  Init_glib_io_channel();
1113
1114
  Init_glib_io_channelerror();
1114
1115
  Init_glib_io_channel_win32_socket();
data/ext/glib2/rbglib.h CHANGED
@@ -35,7 +35,7 @@ extern "C" {
35
35
 
36
36
  #define RBGLIB_MAJOR_VERSION 1
37
37
  #define RBGLIB_MINOR_VERSION 1
38
- #define RBGLIB_MICRO_VERSION 3
38
+ #define RBGLIB_MICRO_VERSION 4
39
39
 
40
40
  #ifndef RSTRING_PTR
41
41
  # define RSTRING_PTR(s) (RSTRING(s)->ptr)
@@ -44,8 +44,8 @@
44
44
  #define RVAL2GVALUE(o) ((GValue*)RVAL2BOXED(o, G_TYPE_VALUE))
45
45
  #define GVALUE2RVAL(o) (BOXED2RVAL(o, G_TYPE_VALUE))
46
46
 
47
- #define RVAL2GIOCONDITION(o) (RVAL2GENUM(o, G_TYPE_IO_CONDITION))
48
- #define GIOCONDITION2RVAL(o) (GENUM2RVAL(o, G_TYPE_IO_CONDITION))
47
+ #define RVAL2GIOCONDITION(o) (RVAL2GFLAGS(o, G_TYPE_IO_CONDITION))
48
+ #define GIOCONDITION2RVAL(o) (GFLAGS2RVAL(o, G_TYPE_IO_CONDITION))
49
49
  #define RVAL2GNORMALIZEMODE(o) (RVAL2GENUM(o, G_TYPE_NORMALIZE_MODE))
50
50
  #define GNORMALIZEMODE2RVAL(o) (GENUM2RVAL(o, G_TYPE_NORMALIZE_MODE))
51
51
 
@@ -0,0 +1,30 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011-2012 Ruby-GNOME2 Project Team
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
+ * MA 02110-1301 USA
19
+ */
20
+
21
+ #include "rbgprivate.h"
22
+
23
+ void
24
+ Init_glib_io_constants(void)
25
+ {
26
+ VALUE RG_TARGET_NAMESPACE = mGLib;
27
+
28
+ /* GIOCondition */
29
+ G_DEF_CLASS(G_TYPE_IO_CONDITION, "IOCondition", RG_TARGET_NAMESPACE);
30
+ }
@@ -799,12 +799,9 @@ Init_glib_io_channel(void)
799
799
  rb_define_const(RG_TARGET_NAMESPACE, "STATUS_AGAIN", INT2NUM(G_IO_STATUS_AGAIN));
800
800
 
801
801
  /* GIOCondition */
802
- rb_define_const(RG_TARGET_NAMESPACE, "IN", INT2NUM(G_IO_IN));
803
- rb_define_const(RG_TARGET_NAMESPACE, "OUT", INT2NUM(G_IO_OUT));
804
- rb_define_const(RG_TARGET_NAMESPACE, "PRI", INT2NUM(G_IO_PRI));
805
- rb_define_const(RG_TARGET_NAMESPACE, "ERR", INT2NUM(G_IO_ERR));
806
- rb_define_const(RG_TARGET_NAMESPACE, "HUP", INT2NUM(G_IO_HUP));
807
- rb_define_const(RG_TARGET_NAMESPACE, "NVAL", INT2NUM(G_IO_NVAL));
802
+ /* Deprecated. Just for bacakward compatibility. Use
803
+ * GLib::IOCondition::* instead. */
804
+ G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_IO_CONDITION, "G_IO_");
808
805
 
809
806
  /* GIOFlags */
810
807
  rb_define_const(RG_TARGET_NAMESPACE, "FLAG_APPEND", INT2NUM(G_IO_FLAG_APPEND));
@@ -54,9 +54,12 @@ GSource* g_source_new (GSourceFuncs *source_funcs,
54
54
  */
55
55
 
56
56
  static VALUE
57
- rg_attach(VALUE self, VALUE context)
57
+ rg_attach(int argc, VALUE *argv, VALUE self)
58
58
  {
59
- return UINT2NUM(g_source_attach(_SELF(self),
59
+ VALUE context;
60
+
61
+ rb_scan_args(argc, argv, "01", &context);
62
+ return UINT2NUM(g_source_attach(_SELF(self),
60
63
  RVAL2BOXED(context, G_TYPE_MAIN_CONTEXT)));
61
64
  }
62
65
 
@@ -168,7 +171,7 @@ Init_glib_source(void)
168
171
 
169
172
  id_call = rb_intern("call");
170
173
 
171
- RG_DEF_METHOD(attach, 1);
174
+ RG_DEF_METHOD(attach, -1);
172
175
  #if GLIB_CHECK_VERSION(2,12,0)
173
176
  RG_DEF_METHOD_P(destroyed, 0);
174
177
  #endif
@@ -131,6 +131,7 @@ G_GNUC_INTERNAL void Init_glib_main_loop(void);
131
131
  G_GNUC_INTERNAL void Init_glib_main_context(void);
132
132
  G_GNUC_INTERNAL void Init_glib_source(void);
133
133
  G_GNUC_INTERNAL void Init_glib_poll_fd(void);
134
+ G_GNUC_INTERNAL void Init_glib_io_constants(void);
134
135
  G_GNUC_INTERNAL void Init_glib_io_channel(void);
135
136
  G_GNUC_INTERNAL void Init_glib_io_channelerror(void);
136
137
  G_GNUC_INTERNAL void Init_glib_io_channel_win32_socket(void);
data/lib/glib-mkenums.rb CHANGED
@@ -21,7 +21,7 @@ module GLib
21
21
  @EnumName = name
22
22
  @g_type_prefix = g_type_prefix
23
23
  @constants = []
24
- @enum_name = @EnumName.sub(/^[A-Z]/){|v| v.downcase}.gsub(/[A-Z]+/){|v| "_" + v.downcase}.sub(/(^_|_$)/, "")
24
+ @enum_name = to_snail_case(@EnumName)
25
25
  @ENUM_NAME = @enum_name.upcase
26
26
  @ENUM_SHORT = @ENUM_NAME.sub(/^#{@g_type_prefix.sub(/_TYPE.*$/, "")}/, "").sub(/^_/, "")
27
27
 
@@ -92,22 +92,38 @@ GType #{@enum_name}_get_type (void);
92
92
  #define #{@g_type_prefix}#{@ENUM_SHORT} (#{@enum_name}_get_type())]
93
93
  end
94
94
 
95
+ private
96
+ def to_snail_case(name)
97
+ prefix_processed_name = name.sub(/^[A-Z]/) do |prefix|
98
+ prefix.downcase
99
+ end
100
+ snail_cased_name = prefix_processed_name.gsub(/[A-Z]+/) do |upper_case|
101
+ down_case = upper_case.downcase
102
+ if down_case.size == 1
103
+ "_#{down_case}"
104
+ else
105
+ "_#{down_case[0..-2]}_#{down_case[-1..-1]}"
106
+ end
107
+ end
108
+ snail_cased_name.sub(/(^_|_$)/, "")
109
+ end
95
110
 
96
111
  def self.parse(data, g_type_prefix, options={})
97
112
  options ||= {}
98
113
  enums = []
99
114
  data.force_encoding("utf-8") if data.respond_to?(:force_encoding)
100
- data.scan(/^\s*typedef\s+enum\s*
115
+ data.scan(/^\s*typedef\s+enum\s*(\/\*<\s*flags\s*>\*\/)?\s*
101
116
  \{?\s*(.*?)
102
- \}\s*(\w+);/mx){|constants, name|
117
+ \}\s*(\w+);/mx) do |force_flags, constants, name|
103
118
  enum_options = {}
119
+ enum_options[:force_flags] = !force_flags.nil?
104
120
  force_flags_patterns = [(options[:force_flags] || [])].flatten
105
121
  if force_flags_patterns.any? {|pattern| pattern === name}
106
122
  enum_options[:force_flags] = true
107
123
  end
108
124
  enum = new(name, constants, g_type_prefix, enum_options)
109
125
  enums << enum
110
- }
126
+ end
111
127
  enums
112
128
  end
113
129
  end
data/lib/mkmf-gnome2.rb CHANGED
@@ -429,6 +429,122 @@ def check_cairo(options={})
429
429
  PKGConfig.have_package('cairo') and have_header('rb_cairo.h')
430
430
  end
431
431
 
432
+ def package_platform
433
+ if File.exist?("/etc/debian_version")
434
+ :debian
435
+ elsif File.exist?("/etc/fedora-release")
436
+ :fedora
437
+ elsif File.exist?("/etc/redhat-release")
438
+ :redhat
439
+ elsif find_executable("brew")
440
+ :homebrew
441
+ elsif find_executable("port")
442
+ :macports
443
+ else
444
+ :unknown
445
+ end
446
+ end
447
+
448
+ def super_user?
449
+ Process.uid.zero?
450
+ end
451
+
452
+ def normalize_native_package_info(native_package_info)
453
+ native_package_info ||= {}
454
+ native_package_info = native_package_info.dup
455
+ native_package_info[:fedora] ||= native_package_info[:redhat]
456
+ native_package_info
457
+ end
458
+
459
+ def install_missing_native_package(native_package_info)
460
+ platform = package_platform
461
+ native_package_info = normalize_native_package_info(native_package_info)
462
+ package = native_package_info[platform]
463
+ return false if package.nil?
464
+
465
+ need_super_user_priviledge = true
466
+ case platform
467
+ when :debian
468
+ install_command = "apt-get install -V -y #{package}"
469
+ when :fedora, :redhat
470
+ install_command = "yum install -y #{package}"
471
+ when :homebrew
472
+ need_super_user_priviledge = false
473
+ install_command = "brew install #{package}"
474
+ when :macports
475
+ install_command = "port install -y #{package}"
476
+ else
477
+ return false
478
+ end
479
+
480
+ have_priviledge = (not need_super_user_priviledge or super_user?)
481
+ unless have_priviledge
482
+ sudo = find_executable("sudo")
483
+ end
484
+
485
+ installing_message = "installing '#{package}' native package... "
486
+ message("%s", installing_message)
487
+ failed_to_get_super_user_priviledge = false
488
+ if have_priviledge
489
+ succeeded = xsystem(install_command)
490
+ else
491
+ if sudo
492
+ install_command = "#{sudo} #{install_command}"
493
+ succeeded = xsystem(install_command)
494
+ else
495
+ succeeded = false
496
+ failed_to_get_super_user_priviledge = true
497
+ end
498
+ end
499
+
500
+ if failed_to_get_super_user_priviledge
501
+ result_message = "require super user privilege"
502
+ else
503
+ result_message = succeeded ? "succeeded" : "failed"
504
+ end
505
+ Logging.postpone do
506
+ "#{installing_message}#{result_message}\n"
507
+ end
508
+ message("#{result_message}\n")
509
+
510
+ error_message = nil
511
+ unless succeeded
512
+ if failed_to_get_super_user_priviledge
513
+ error_message = <<-EOM
514
+ '#{package}' native package is required.
515
+ run the following command as super user to install required native package:
516
+ \# #{install_command}
517
+ EOM
518
+ else
519
+ error_message = <<-EOM
520
+ failed to run '#{install_command}'.
521
+ EOM
522
+ end
523
+ end
524
+ if error_message
525
+ message("%s", error_message)
526
+ Logging.message("%s", error_message)
527
+ end
528
+
529
+ Logging.message("--------------------\n\n")
530
+
531
+ succeeded
532
+ end
533
+
534
+ def required_pkg_config_package(package_info, native_package_info=nil)
535
+ if package_info.is_a?(Array)
536
+ required_package_info = package_info
537
+ else
538
+ required_package_info = [package_info]
539
+ end
540
+ return true if PKGConfig.have_package(*required_package_info)
541
+
542
+ native_package_info ||= {}
543
+ return false unless install_missing_native_package(native_package_info)
544
+
545
+ PKGConfig.have_package(*required_package_info)
546
+ end
547
+
432
548
  add_include_path = Proc.new do |dir_variable|
433
549
  value = RbConfig::CONFIG[dir_variable]
434
550
  if value and File.exist?(value)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib2
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 3
10
- version: 1.1.3
9
+ - 4
10
+ version: 1.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - The Ruby-GNOME2 Project Team
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-08 00:00:00 Z
18
+ date: 2012-07-21 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: pkg-config
@@ -99,6 +99,7 @@ files:
99
99
  - ext/glib2/rbgobj_enums.c
100
100
  - ext/glib2/rbglib_win32.c
101
101
  - ext/glib2/rbglib_int64.c
102
+ - ext/glib2/rbglib_io_constants.c
102
103
  - ext/glib2/glib2.def
103
104
  - ext/glib2/rbgobj_fundamental.c
104
105
  - ext/glib2/rbgcompat.h
@@ -191,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
192
  requirements: []
192
193
 
193
194
  rubyforge_project:
194
- rubygems_version: 1.8.15
195
+ rubygems_version: 1.8.24
195
196
  signing_key:
196
197
  specification_version: 3
197
198
  summary: Ruby/GLib2 is a Ruby binding of GLib-2.x.