gdk3 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +53 -0
- data/ext/gdk3/depend +11 -0
- data/ext/gdk3/extconf.rb +127 -0
- data/ext/gdk3/gdk3.def +12 -0
- data/ext/gdk3/init.c +35 -0
- data/ext/gdk3/rbgdk.c +540 -0
- data/ext/gdk3/rbgdk3.h +71 -0
- data/ext/gdk3/rbgdk3conversions.h +118 -0
- data/ext/gdk3/rbgdk3private.h +93 -0
- data/ext/gdk3/rbgdkatom.c +122 -0
- data/ext/gdk3/rbgdkcairo.c +95 -0
- data/ext/gdk3/rbgdkcolor.c +137 -0
- data/ext/gdk3/rbgdkconst.c +33 -0
- data/ext/gdk3/rbgdkcursor.c +99 -0
- data/ext/gdk3/rbgdkdevice.c +197 -0
- data/ext/gdk3/rbgdkdisplay.c +482 -0
- data/ext/gdk3/rbgdkdisplaymanager.c +55 -0
- data/ext/gdk3/rbgdkdragcontext.c +191 -0
- data/ext/gdk3/rbgdkdraw.c +520 -0
- data/ext/gdk3/rbgdkevent.c +926 -0
- data/ext/gdk3/rbgdkgeometry.c +252 -0
- data/ext/gdk3/rbgdkkeymap.c +151 -0
- data/ext/gdk3/rbgdkkeyval.c +108 -0
- data/ext/gdk3/rbgdkpango.c +197 -0
- data/ext/gdk3/rbgdkpangorenderer.c +144 -0
- data/ext/gdk3/rbgdkpixbuf.c +176 -0
- data/ext/gdk3/rbgdkproperty.c +305 -0
- data/ext/gdk3/rbgdkrectangle.c +140 -0
- data/ext/gdk3/rbgdkrgb.c +199 -0
- data/ext/gdk3/rbgdkrgba.c +142 -0
- data/ext/gdk3/rbgdkscreen.c +443 -0
- data/ext/gdk3/rbgdkselection.c +146 -0
- data/ext/gdk3/rbgdkthreads.c +77 -0
- data/ext/gdk3/rbgdktimecoord.c +133 -0
- data/ext/gdk3/rbgdkvisual.c +251 -0
- data/ext/gdk3/rbgdkwindow.c +1044 -0
- data/ext/gdk3/rbgdkwindowattr.c +191 -0
- data/ext/gdk3/rbgdkx11.c +102 -0
- data/ext/gdk3/rbgdkx11x11window.c +66 -0
- data/extconf.rb +49 -0
- data/lib/gdk3.rb +3 -0
- data/lib/gdk3/base.rb +50 -0
- data/lib/gdk3/deprecated.rb +152 -0
- metadata +156 -0
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift("./../glib2/lib")
|
4
|
+
require 'gnome2-raketask'
|
5
|
+
|
6
|
+
package = GNOME2Package.new do |_package|
|
7
|
+
_package.summary = "Ruby/GDK3 is a Ruby binding of GDK-3.x."
|
8
|
+
_package.description = "Ruby/GDK3 is a Ruby binding of GDK-3.x."
|
9
|
+
_package.dependency.gem.runtime = ["atk", "pango", "gdk_pixbuf2"]
|
10
|
+
_package.win32.packages = []
|
11
|
+
_package.win32.dependencies = []
|
12
|
+
_package.win32.build_dependencies = [
|
13
|
+
"glib2", "atk", "pango", "gdk_pixbuf2",
|
14
|
+
]
|
15
|
+
_package.win32.build_packages = [
|
16
|
+
{
|
17
|
+
:name => "gtk+",
|
18
|
+
:download_site => :gnome,
|
19
|
+
:label => "gtk+",
|
20
|
+
:version => "3.6.4",
|
21
|
+
:configure_args => [],
|
22
|
+
:compression_method => "xz",
|
23
|
+
:need_autoreconf => true,
|
24
|
+
:patches => [
|
25
|
+
"gtk+-3.6.4-add-missing-exeext.diff",
|
26
|
+
"gtk+-3.6.4-backport-gtk-launch-build-error.diff",
|
27
|
+
],
|
28
|
+
}
|
29
|
+
]
|
30
|
+
_package.required_ruby_version = ">= 1.9.2"
|
31
|
+
_package.post_install_message = "This library is experimental."
|
32
|
+
end
|
33
|
+
package.define_tasks
|
34
|
+
|
35
|
+
|
36
|
+
namespace :win32 do
|
37
|
+
desc "create default settings.ini"
|
38
|
+
task :settings do
|
39
|
+
config_dir = File.join("vendor", "local", "etc", "gtk-3.0")
|
40
|
+
mkdir_p(config_dir)
|
41
|
+
settings_ini_path = File.join(config_dir, "settings.ini")
|
42
|
+
File.open(settings_ini_path, "w") do |settings_ini|
|
43
|
+
settings_ini.puts(<<-EOS)
|
44
|
+
[Settings]
|
45
|
+
# gtk-theme-name = MS-Windows
|
46
|
+
EOS
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
namespace :builder do
|
51
|
+
task :after => ["win32:settings"]
|
52
|
+
end
|
53
|
+
end
|
data/ext/gdk3/depend
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
install-so: install-headers
|
2
|
+
install-headers:
|
3
|
+
$(INSTALL_DATA) $(srcdir)/rbgdk3.h $(RUBYARCHDIR)
|
4
|
+
$(INSTALL_DATA) $(srcdir)/rbgdk3conversions.h $(RUBYARCHDIR)
|
5
|
+
|
6
|
+
install: install-pc
|
7
|
+
install-pc:
|
8
|
+
if test -n "$(pkgconfigdir)"; then \
|
9
|
+
$(MAKEDIRS) $(pkgconfigdir); \
|
10
|
+
$(INSTALL_DATA) ruby-gdk3.pc $(pkgconfigdir); \
|
11
|
+
fi
|
data/ext/gdk3/extconf.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
=begin
|
2
|
+
extconf.rb for Ruby/GDK extention library
|
3
|
+
=end
|
4
|
+
|
5
|
+
require 'pathname'
|
6
|
+
|
7
|
+
source_dir = Pathname(__FILE__).dirname
|
8
|
+
base_dir = source_dir.parent.parent.expand_path
|
9
|
+
top_dir = base_dir.parent.expand_path
|
10
|
+
top_build_dir = Pathname(".").parent.parent.parent.expand_path
|
11
|
+
|
12
|
+
mkmf_gnome2_dir = top_dir + "glib2" + 'lib'
|
13
|
+
version_suffix = ""
|
14
|
+
unless mkmf_gnome2_dir.exist?
|
15
|
+
if /(-\d+\.\d+\.\d+)(?:\.\d+)?\z/ =~ base_dir.basename.to_s
|
16
|
+
version_suffix = $1
|
17
|
+
mkmf_gnome2_dir = top_dir + "glib2#{version_suffix}" + 'lib'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
$LOAD_PATH.unshift(mkmf_gnome2_dir.to_s)
|
22
|
+
|
23
|
+
module_name = "gdk3"
|
24
|
+
package_id = "gdk-3.0"
|
25
|
+
|
26
|
+
begin
|
27
|
+
require 'mkmf-gnome2'
|
28
|
+
rescue LoadError
|
29
|
+
require 'rubygems'
|
30
|
+
gem 'glib2'
|
31
|
+
require 'mkmf-gnome2'
|
32
|
+
end
|
33
|
+
|
34
|
+
have_func("rb_errinfo")
|
35
|
+
|
36
|
+
["glib2", "pango", "gdk_pixbuf2"].each do |package|
|
37
|
+
directory = "#{package}#{version_suffix}"
|
38
|
+
build_dir = "#{directory}/tmp/#{RUBY_PLATFORM}/#{package}/#{RUBY_VERSION}"
|
39
|
+
add_depend_package(package, "#{directory}/ext/#{package}",
|
40
|
+
top_dir.to_s,
|
41
|
+
:top_build_dir => top_build_dir.to_s,
|
42
|
+
:target_build_dir => build_dir)
|
43
|
+
end
|
44
|
+
|
45
|
+
rcairo_options = {}
|
46
|
+
rcairo_source_dir_names = ["rcairo"]
|
47
|
+
if /mingw|cygwin|mswin32/ =~ RUBY_PLATFORM
|
48
|
+
rcairo_source_dir_names.unshift("rcairo.win32")
|
49
|
+
end
|
50
|
+
rcairo_source_dir_names.each do |rcairo_source_dir_name|
|
51
|
+
rcairo_source_dir = top_dir.parent.expand_path + rcairo_source_dir_name
|
52
|
+
if rcairo_source_dir.exist?
|
53
|
+
rcairo_options[:rcairo_source_dir] = rcairo_source_dir.to_s
|
54
|
+
break
|
55
|
+
end
|
56
|
+
end
|
57
|
+
check_cairo(rcairo_options)
|
58
|
+
|
59
|
+
setup_win32(module_name, base_dir)
|
60
|
+
|
61
|
+
unless required_pkg_config_package(package_id,
|
62
|
+
:debian => "libgtk-3-dev",
|
63
|
+
:fedora => "gtk3-devel",
|
64
|
+
:homebrew => "gtk+3",
|
65
|
+
:macports => "gtk3")
|
66
|
+
exit(false)
|
67
|
+
end
|
68
|
+
|
69
|
+
have_header("st.h")
|
70
|
+
have_header("ruby/st.h")
|
71
|
+
|
72
|
+
STDOUT.print("checking for target... ")
|
73
|
+
STDOUT.flush
|
74
|
+
target = PKGConfig.variable(package_id, "target")
|
75
|
+
$defs << "-DRUBY_GDK3_TARGET=\\\"#{target}\\\""
|
76
|
+
STDOUT.print(target, "\n")
|
77
|
+
|
78
|
+
gdk_include_path = nil
|
79
|
+
include_paths = $CFLAGS.gsub(/-D\w+/, '').split(/-I/) + ['/usr/include']
|
80
|
+
include_paths.each do |path|
|
81
|
+
path.strip!
|
82
|
+
|
83
|
+
if FileTest.exist?("#{path}/gdk/gdkkeysyms.h")
|
84
|
+
gdk_include_path = Pathname("#{path}/gdk")
|
85
|
+
break
|
86
|
+
end
|
87
|
+
end
|
88
|
+
raise "can't find gdkkeysyms.h" if gdk_include_path.nil?
|
89
|
+
|
90
|
+
xlib_header = "X11/Xlib.h"
|
91
|
+
if target == "x11" and have_header('X11/Xlib.h') and have_library("X11")
|
92
|
+
have_func("XReadBitmapFileData", xlib_header)
|
93
|
+
have_func("XGetErrorText", xlib_header)
|
94
|
+
end
|
95
|
+
|
96
|
+
create_pkg_config_file("Ruby/GDK3", package_id, ruby_gnome2_version)
|
97
|
+
|
98
|
+
rbgdkkeysyms_h_path = Pathname("rbgdkkeysyms.h")
|
99
|
+
gdkkeysyms_h_paths = []
|
100
|
+
gdkkeysyms_h_paths << gdk_include_path + "gdkkeysyms.h"
|
101
|
+
gdkkeysyms_h_paths << gdk_include_path + "gdkkeysyms-compat.h"
|
102
|
+
rbgdkkeysyms_h_path.open("w") do |rbgdkkeysyms_h|
|
103
|
+
gdkkeysyms_h_paths.each do |path|
|
104
|
+
next unless path.exist?
|
105
|
+
path.each_line do |line|
|
106
|
+
if /^#define\s+(GDK_KEY_\w+)\s+\d+/ =~ line
|
107
|
+
define_line = "rb_define_const(mGdkKeyval, \"#{$1}\", INT2FIX(#{$1}));"
|
108
|
+
rbgdkkeysyms_h.puts(define_line)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
add_distcleanfile("rbgdkkeysyms.h")
|
115
|
+
|
116
|
+
ensure_objs
|
117
|
+
|
118
|
+
$defs << "-DRUBY_GDK3_COMPILATION"
|
119
|
+
create_makefile(module_name)
|
120
|
+
|
121
|
+
pkg_config_dir = with_config("pkg-config-dir")
|
122
|
+
if pkg_config_dir.is_a?(String)
|
123
|
+
File.open("Makefile", "ab") do |makefile|
|
124
|
+
makefile.puts
|
125
|
+
makefile.puts("pkgconfigdir=#{pkg_config_dir}")
|
126
|
+
end
|
127
|
+
end
|
data/ext/gdk3/gdk3.def
ADDED
data/ext/gdk3/init.c
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2002-2006 Ruby-GNOME2 Project Team
|
5
|
+
* Copyright (C) 1998-2001 Yukihiro Matsumoto,
|
6
|
+
* Daisuke Kanda,
|
7
|
+
* Hiroshi Igarashi
|
8
|
+
*
|
9
|
+
* This library is free software; you can redistribute it and/or
|
10
|
+
* modify it under the terms of the GNU Lesser General Public
|
11
|
+
* License as published by the Free Software Foundation; either
|
12
|
+
* version 2.1 of the License, or (at your option) any later version.
|
13
|
+
*
|
14
|
+
* This library is distributed in the hope that it will be useful,
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
+
* Lesser General Public License for more details.
|
18
|
+
*
|
19
|
+
* You should have received a copy of the GNU Lesser General Public
|
20
|
+
* License along with this library; if not, write to the Free Software
|
21
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
22
|
+
* MA 02110-1301 USA
|
23
|
+
*/
|
24
|
+
|
25
|
+
#include "rbgdk3private.h"
|
26
|
+
#include "gmodule.h"
|
27
|
+
|
28
|
+
extern void Init_gdk3(void);
|
29
|
+
|
30
|
+
void
|
31
|
+
Init_gdk3(void)
|
32
|
+
{
|
33
|
+
Init_gdk();
|
34
|
+
Init_gdkx11();
|
35
|
+
}
|
data/ext/gdk3/rbgdk.c
ADDED
@@ -0,0 +1,540 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2002,2003 Ruby-GNOME2 Project Team
|
5
|
+
* Copyright (C) 1998-2000 Yukihiro Matsumoto,
|
6
|
+
* Daisuke Kanda,
|
7
|
+
* Hiroshi Igarashi
|
8
|
+
*
|
9
|
+
* This library is free software; you can redistribute it and/or
|
10
|
+
* modify it under the terms of the GNU Lesser General Public
|
11
|
+
* License as published by the Free Software Foundation; either
|
12
|
+
* version 2.1 of the License, or (at your option) any later version.
|
13
|
+
*
|
14
|
+
* This library is distributed in the hope that it will be useful,
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
+
* Lesser General Public License for more details.
|
18
|
+
*
|
19
|
+
* You should have received a copy of the GNU Lesser General Public
|
20
|
+
* License along with this library; if not, write to the Free Software
|
21
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
22
|
+
* MA 02110-1301 USA
|
23
|
+
*/
|
24
|
+
|
25
|
+
#include "rbgdk3private.h"
|
26
|
+
|
27
|
+
#define RG_TARGET_NAMESPACE mGdk
|
28
|
+
|
29
|
+
ID id_call;
|
30
|
+
|
31
|
+
/* We don't need them.
|
32
|
+
void gdk_init (gint *argc,
|
33
|
+
gchar ***argv);
|
34
|
+
gboolean gdk_init_check (gint *argc,
|
35
|
+
gchar ***argv);
|
36
|
+
void gdk_parse_args (gint *argc,
|
37
|
+
gchar ***argv);
|
38
|
+
*/
|
39
|
+
|
40
|
+
struct rbgdk_rval2gdkpoints_args {
|
41
|
+
VALUE ary;
|
42
|
+
long n;
|
43
|
+
GdkPoint *result;
|
44
|
+
};
|
45
|
+
|
46
|
+
static VALUE
|
47
|
+
rbgdk_rval2gdkpoints_body(VALUE value)
|
48
|
+
{
|
49
|
+
long i;
|
50
|
+
struct rbgdk_rval2gdkpoints_args *args = (struct rbgdk_rval2gdkpoints_args *)value;
|
51
|
+
|
52
|
+
for (i = 0; i < args->n; i++) {
|
53
|
+
VALUE points = rb_ary_to_ary(RARRAY_PTR(args->ary)[i]);
|
54
|
+
|
55
|
+
if (RARRAY_LEN(points) != 2)
|
56
|
+
rb_raise(rb_eArgError, "point %ld should be array of size 2", i);
|
57
|
+
|
58
|
+
args->result[i].x = NUM2INT(RARRAY_PTR(points)[0]);
|
59
|
+
args->result[i].y = NUM2INT(RARRAY_PTR(points)[1]);
|
60
|
+
}
|
61
|
+
|
62
|
+
return Qnil;
|
63
|
+
}
|
64
|
+
|
65
|
+
static G_GNUC_NORETURN VALUE
|
66
|
+
rbgdk_rval2gdkpoints_rescue(VALUE value)
|
67
|
+
{
|
68
|
+
g_free(((struct rbgdk_rval2gdkpoints_args *)value)->result);
|
69
|
+
|
70
|
+
rb_exc_raise(rb_errinfo());
|
71
|
+
}
|
72
|
+
|
73
|
+
GdkPoint *
|
74
|
+
rbgdk_rval2gdkpoints(VALUE value, long *n)
|
75
|
+
{
|
76
|
+
struct rbgdk_rval2gdkpoints_args args;
|
77
|
+
|
78
|
+
args.ary = rb_ary_to_ary(value);
|
79
|
+
args.n = RARRAY_LEN(args.ary);
|
80
|
+
args.result = g_new(GdkPoint, args.n + 1);
|
81
|
+
|
82
|
+
rb_rescue(rbgdk_rval2gdkpoints_body, (VALUE)&args,
|
83
|
+
rbgdk_rval2gdkpoints_rescue, (VALUE)&args);
|
84
|
+
|
85
|
+
*n = args.n;
|
86
|
+
|
87
|
+
return args.result;
|
88
|
+
}
|
89
|
+
|
90
|
+
struct rbgdk_rval2gdkatoms_args {
|
91
|
+
VALUE ary;
|
92
|
+
long n;
|
93
|
+
GdkAtom *result;
|
94
|
+
};
|
95
|
+
|
96
|
+
static VALUE
|
97
|
+
rbgdk_rval2gdkatoms_body(VALUE value)
|
98
|
+
{
|
99
|
+
long i;
|
100
|
+
struct rbgdk_rval2gdkatoms_args *args = (struct rbgdk_rval2gdkatoms_args *)value;
|
101
|
+
|
102
|
+
for (i = 0; i < args->n; i++)
|
103
|
+
args->result[i] = RVAL2ATOM(RARRAY_PTR(args->ary)[i]);
|
104
|
+
|
105
|
+
return Qnil;
|
106
|
+
}
|
107
|
+
|
108
|
+
static G_GNUC_NORETURN VALUE
|
109
|
+
rbgdk_rval2gdkatoms_rescue(VALUE value)
|
110
|
+
{
|
111
|
+
g_free(((struct rbgdk_rval2gdkatoms_args *)value)->result);
|
112
|
+
|
113
|
+
rb_exc_raise(rb_errinfo());
|
114
|
+
}
|
115
|
+
|
116
|
+
GdkAtom *
|
117
|
+
rbgdk_rval2gdkatoms(VALUE value, long *n)
|
118
|
+
{
|
119
|
+
struct rbgdk_rval2gdkatoms_args args;
|
120
|
+
|
121
|
+
args.ary = rb_ary_to_ary(value);
|
122
|
+
args.n = RARRAY_LEN(args.ary);
|
123
|
+
args.result = g_new(GdkAtom, args.n + 1);
|
124
|
+
|
125
|
+
rb_rescue(rbgdk_rval2gdkatoms_body, (VALUE)&args,
|
126
|
+
rbgdk_rval2gdkatoms_rescue, (VALUE)&args);
|
127
|
+
|
128
|
+
*n = args.n;
|
129
|
+
|
130
|
+
return args.result;
|
131
|
+
}
|
132
|
+
|
133
|
+
struct rval2gdkpixbufglist_args {
|
134
|
+
VALUE ary;
|
135
|
+
long n;
|
136
|
+
GList *result;
|
137
|
+
};
|
138
|
+
|
139
|
+
static VALUE
|
140
|
+
rbgdk_rval2gdkpixbufglist_body(VALUE value)
|
141
|
+
{
|
142
|
+
long i;
|
143
|
+
struct rval2gdkpixbufglist_args *args = (struct rval2gdkpixbufglist_args *)value;
|
144
|
+
|
145
|
+
for (i = 0; i < args->n; i++)
|
146
|
+
args->result = g_list_append(args->result, RVAL2GDKPIXBUF(RARRAY_PTR(args->ary)[i]));
|
147
|
+
|
148
|
+
return Qnil;
|
149
|
+
}
|
150
|
+
|
151
|
+
static G_GNUC_NORETURN VALUE
|
152
|
+
rbgdk_rval2gdkpixbufglist_rescue(VALUE value)
|
153
|
+
{
|
154
|
+
g_list_free(((struct rval2gdkpixbufglist_args *)value)->result);
|
155
|
+
|
156
|
+
rb_exc_raise(rb_errinfo());
|
157
|
+
}
|
158
|
+
|
159
|
+
GList *
|
160
|
+
rbgdk_rval2gdkpixbufglist(VALUE value)
|
161
|
+
{
|
162
|
+
struct rval2gdkpixbufglist_args args;
|
163
|
+
|
164
|
+
args.ary = rb_ary_to_ary(value);
|
165
|
+
args.n = RARRAY_LEN(args.ary);
|
166
|
+
args.result = NULL;
|
167
|
+
|
168
|
+
rb_rescue(rbgdk_rval2gdkpixbufglist_body, (VALUE)&args,
|
169
|
+
rbgdk_rval2gdkpixbufglist_rescue, (VALUE)&args);
|
170
|
+
|
171
|
+
return args.result;
|
172
|
+
}
|
173
|
+
|
174
|
+
static VALUE
|
175
|
+
rg_s_display_arg_name(G_GNUC_UNUSED VALUE self)
|
176
|
+
{
|
177
|
+
return CSTR2RVAL(gdk_get_display_arg_name());
|
178
|
+
}
|
179
|
+
|
180
|
+
/* deprecated
|
181
|
+
static VALUE
|
182
|
+
rg_s_set_locale(G_GNUC_UNUSED VALUE self)
|
183
|
+
{
|
184
|
+
return CSTR2RVAL(gdk_set_locale());
|
185
|
+
}
|
186
|
+
*/
|
187
|
+
|
188
|
+
/* deprecated
|
189
|
+
static VALUE
|
190
|
+
rg_s_set_sm_client_id(VALUE self, VALUE id)
|
191
|
+
{
|
192
|
+
gdk_set_sm_client_id(RVAL2CSTR_ACCEPT_NIL(id));
|
193
|
+
return self;
|
194
|
+
}
|
195
|
+
*/
|
196
|
+
|
197
|
+
static VALUE
|
198
|
+
rg_s_notify_startup_complete(int argc, VALUE *argv, VALUE self)
|
199
|
+
{
|
200
|
+
VALUE startup_id;
|
201
|
+
|
202
|
+
rb_scan_args(argc, argv, "01", &startup_id);
|
203
|
+
|
204
|
+
if (NIL_P(startup_id)) {
|
205
|
+
gdk_notify_startup_complete();
|
206
|
+
} else {
|
207
|
+
gdk_notify_startup_complete_with_id(RVAL2CSTR(startup_id));
|
208
|
+
}
|
209
|
+
return self;
|
210
|
+
}
|
211
|
+
|
212
|
+
static VALUE
|
213
|
+
rg_s_program_class(G_GNUC_UNUSED VALUE self)
|
214
|
+
{
|
215
|
+
return CSTR2RVAL(gdk_get_program_class());
|
216
|
+
}
|
217
|
+
|
218
|
+
static VALUE
|
219
|
+
rg_s_set_program_class(VALUE self, VALUE program_class)
|
220
|
+
{
|
221
|
+
gdk_set_program_class(RVAL2CSTR(program_class));
|
222
|
+
return self;
|
223
|
+
}
|
224
|
+
|
225
|
+
static VALUE
|
226
|
+
rg_s_display(G_GNUC_UNUSED VALUE self)
|
227
|
+
{
|
228
|
+
return CSTR2RVAL(gdk_get_display());
|
229
|
+
}
|
230
|
+
|
231
|
+
#ifdef HAVE_X11_XLIB_H
|
232
|
+
#ifdef HAVE_XGETERRORTEXT
|
233
|
+
#include <X11/Xlib.h>
|
234
|
+
#include <errno.h>
|
235
|
+
|
236
|
+
static VALUE rb_x_error;
|
237
|
+
static VALUE rb_x_io_error;
|
238
|
+
|
239
|
+
static int
|
240
|
+
rbgdk_x_error(Display *display, XErrorEvent *error)
|
241
|
+
{
|
242
|
+
gchar buf[64];
|
243
|
+
|
244
|
+
XGetErrorText(display, error->error_code, buf, 63);
|
245
|
+
|
246
|
+
rb_funcall((VALUE)rb_x_error, id_call, 4, INT2NUM(error->serial),
|
247
|
+
INT2NUM(error->error_code), INT2NUM(error->request_code),
|
248
|
+
INT2NUM(error->minor_code));
|
249
|
+
return 0;
|
250
|
+
}
|
251
|
+
|
252
|
+
static int
|
253
|
+
rbgdk_x_io_error(Display *display)
|
254
|
+
{
|
255
|
+
int errno_saved = errno;
|
256
|
+
const gchar* disp;
|
257
|
+
const gchar* error;
|
258
|
+
|
259
|
+
disp = display ? DisplayString(display) : gdk_get_display_arg_name();
|
260
|
+
if (! disp)
|
261
|
+
disp = "(none)";
|
262
|
+
|
263
|
+
error = g_strerror(errno_saved);
|
264
|
+
|
265
|
+
rb_funcall((VALUE)rb_x_io_error, id_call, 3, CSTR2RVAL(disp),
|
266
|
+
INT2NUM(errno), CSTR2RVAL(error));
|
267
|
+
return 0;
|
268
|
+
}
|
269
|
+
#endif
|
270
|
+
#endif
|
271
|
+
|
272
|
+
static VALUE
|
273
|
+
rg_s_set_x_error_handler(VALUE self)
|
274
|
+
{
|
275
|
+
#ifdef HAVE_XGETERRORTEXT
|
276
|
+
rb_x_error = rb_block_proc();
|
277
|
+
G_RELATIVE(self, rb_x_error);
|
278
|
+
XSetErrorHandler(rbgdk_x_error);
|
279
|
+
#else
|
280
|
+
rb_warn("Not supported on this environment.");
|
281
|
+
#endif
|
282
|
+
return self;
|
283
|
+
}
|
284
|
+
|
285
|
+
static VALUE
|
286
|
+
rg_s_set_x_io_error_handler(VALUE self)
|
287
|
+
{
|
288
|
+
#ifdef HAVE_XGETERRORTEXT
|
289
|
+
rb_x_io_error = rb_block_proc();
|
290
|
+
G_RELATIVE(self, rb_x_io_error);
|
291
|
+
XSetIOErrorHandler(rbgdk_x_io_error);
|
292
|
+
#else
|
293
|
+
rb_warn("Not supported on this environment.");
|
294
|
+
#endif
|
295
|
+
return self;
|
296
|
+
}
|
297
|
+
|
298
|
+
static VALUE
|
299
|
+
rg_s_flush(VALUE self)
|
300
|
+
{
|
301
|
+
gdk_flush();
|
302
|
+
return self;
|
303
|
+
}
|
304
|
+
|
305
|
+
static VALUE
|
306
|
+
rg_s_screen_width(G_GNUC_UNUSED VALUE self)
|
307
|
+
{
|
308
|
+
return INT2NUM(gdk_screen_width());
|
309
|
+
}
|
310
|
+
|
311
|
+
static VALUE
|
312
|
+
rg_s_screen_width_mm(G_GNUC_UNUSED VALUE self)
|
313
|
+
{
|
314
|
+
return INT2NUM(gdk_screen_width_mm());
|
315
|
+
}
|
316
|
+
|
317
|
+
static VALUE
|
318
|
+
rg_s_screen_height(G_GNUC_UNUSED VALUE self)
|
319
|
+
{
|
320
|
+
return INT2NUM(gdk_screen_height());
|
321
|
+
}
|
322
|
+
|
323
|
+
static VALUE
|
324
|
+
rg_s_screen_height_mm(G_GNUC_UNUSED VALUE self)
|
325
|
+
{
|
326
|
+
return INT2NUM(gdk_screen_height_mm());
|
327
|
+
}
|
328
|
+
|
329
|
+
static VALUE
|
330
|
+
rg_s_pointer_grab(G_GNUC_UNUSED VALUE self, VALUE win, VALUE owner_events, VALUE event_mask, VALUE confine_to, VALUE cursor, VALUE time)
|
331
|
+
{
|
332
|
+
return GDKGRABSTATUS2RVAL(gdk_pointer_grab(RVAL2GDKWINDOW(win),
|
333
|
+
RVAL2CBOOL(owner_events),
|
334
|
+
RVAL2GDKEVENTMASK(event_mask),
|
335
|
+
NIL_P(confine_to) ? NULL : RVAL2GDKWINDOW(confine_to),
|
336
|
+
NIL_P(cursor) ? NULL : RVAL2GDKCURSOR(cursor),
|
337
|
+
NUM2INT(time)));
|
338
|
+
}
|
339
|
+
|
340
|
+
static VALUE
|
341
|
+
rg_s_pointer_ungrab(VALUE self, VALUE time)
|
342
|
+
{
|
343
|
+
gdk_pointer_ungrab(NUM2INT(time));
|
344
|
+
return self;
|
345
|
+
}
|
346
|
+
|
347
|
+
static VALUE
|
348
|
+
rg_s_keyboard_grab(G_GNUC_UNUSED VALUE self, VALUE win, VALUE owner_events, VALUE time)
|
349
|
+
{
|
350
|
+
return GDKGRABSTATUS2RVAL(gdk_keyboard_grab(RVAL2GDKWINDOW(win),
|
351
|
+
RVAL2CBOOL(owner_events), NUM2INT(time)));
|
352
|
+
}
|
353
|
+
|
354
|
+
static VALUE
|
355
|
+
rg_s_keyboard_ungrab(VALUE self, VALUE time)
|
356
|
+
{
|
357
|
+
gdk_keyboard_ungrab(NUM2INT(time));
|
358
|
+
return self;
|
359
|
+
}
|
360
|
+
|
361
|
+
static VALUE
|
362
|
+
rg_s_pointer_is_grabbed_p(G_GNUC_UNUSED VALUE self)
|
363
|
+
{
|
364
|
+
return CBOOL2RVAL(gdk_pointer_is_grabbed());
|
365
|
+
}
|
366
|
+
|
367
|
+
static VALUE
|
368
|
+
rg_s_set_double_click_time(VALUE self, VALUE msec)
|
369
|
+
{
|
370
|
+
gdk_set_double_click_time(NUM2UINT(msec));
|
371
|
+
return self;
|
372
|
+
}
|
373
|
+
|
374
|
+
static VALUE
|
375
|
+
rg_s_beep(VALUE self)
|
376
|
+
{
|
377
|
+
gdk_beep();
|
378
|
+
return self;
|
379
|
+
}
|
380
|
+
|
381
|
+
static VALUE
|
382
|
+
rg_s_error_trap_push(VALUE self)
|
383
|
+
{
|
384
|
+
gdk_error_trap_push();
|
385
|
+
return self;
|
386
|
+
}
|
387
|
+
|
388
|
+
static VALUE
|
389
|
+
rg_s_error_trap_pop(VALUE self)
|
390
|
+
{
|
391
|
+
gdk_error_trap_pop();
|
392
|
+
return self;
|
393
|
+
}
|
394
|
+
|
395
|
+
static VALUE
|
396
|
+
rg_s_windowing_x11_p(G_GNUC_UNUSED VALUE self)
|
397
|
+
{
|
398
|
+
#ifdef GDK_WINDOWING_X11
|
399
|
+
return Qtrue;
|
400
|
+
#else
|
401
|
+
return Qfalse;
|
402
|
+
#endif
|
403
|
+
}
|
404
|
+
|
405
|
+
static VALUE
|
406
|
+
rg_s_windowing_win32_p(G_GNUC_UNUSED VALUE self)
|
407
|
+
{
|
408
|
+
#ifdef GDK_WINDOWING_WIN32
|
409
|
+
return Qtrue;
|
410
|
+
#else
|
411
|
+
return Qfalse;
|
412
|
+
#endif
|
413
|
+
}
|
414
|
+
|
415
|
+
static VALUE
|
416
|
+
rg_s_windowing_fb_p(G_GNUC_UNUSED VALUE self)
|
417
|
+
{
|
418
|
+
#ifdef GDK_WINDOWING_FB
|
419
|
+
return Qtrue;
|
420
|
+
#else
|
421
|
+
return Qfalse;
|
422
|
+
#endif
|
423
|
+
}
|
424
|
+
|
425
|
+
static VALUE
|
426
|
+
rg_s_windowing_quartz_p(G_GNUC_UNUSED VALUE self)
|
427
|
+
{
|
428
|
+
#ifdef GDK_WINDOWING_QUARTZ
|
429
|
+
return Qtrue;
|
430
|
+
#else
|
431
|
+
return Qfalse;
|
432
|
+
#endif
|
433
|
+
}
|
434
|
+
|
435
|
+
static VALUE
|
436
|
+
rg_s_windowing_directfb_p(G_GNUC_UNUSED VALUE self)
|
437
|
+
{
|
438
|
+
#ifdef GDK_WINDOWING_DIRECTFB
|
439
|
+
return Qtrue;
|
440
|
+
#else
|
441
|
+
return Qfalse;
|
442
|
+
#endif
|
443
|
+
}
|
444
|
+
|
445
|
+
static VALUE
|
446
|
+
rg_s_target(G_GNUC_UNUSED VALUE self)
|
447
|
+
{
|
448
|
+
return CSTR2RVAL(RUBY_GDK3_TARGET);
|
449
|
+
}
|
450
|
+
|
451
|
+
static VALUE
|
452
|
+
rg_s_cairo_available_p(G_GNUC_UNUSED VALUE self)
|
453
|
+
{
|
454
|
+
#if CAIRO_AVAILABLE
|
455
|
+
return Qtrue;
|
456
|
+
#else
|
457
|
+
return Qfalse;
|
458
|
+
#endif
|
459
|
+
}
|
460
|
+
|
461
|
+
void
|
462
|
+
Init_gdk(void)
|
463
|
+
{
|
464
|
+
id_call = rb_intern("call");
|
465
|
+
|
466
|
+
VALUE RG_TARGET_NAMESPACE = rb_define_module("Gdk");
|
467
|
+
|
468
|
+
RG_DEF_SMETHOD(display_arg_name, 0);
|
469
|
+
/* deprecated
|
470
|
+
RG_DEF_SMETHOD(set_locale, 0);
|
471
|
+
RG_DEF_SMETHOD(set_sm_client_id, 1);
|
472
|
+
*/
|
473
|
+
RG_DEF_SMETHOD(notify_startup_complete, -1);
|
474
|
+
RG_DEF_SMETHOD(program_class, 0);
|
475
|
+
RG_DEF_SMETHOD(set_program_class, 1);
|
476
|
+
RG_DEF_SMETHOD(display, 0);
|
477
|
+
|
478
|
+
RG_DEF_SMETHOD(set_x_error_handler, 0);
|
479
|
+
RG_DEF_SMETHOD(set_x_io_error_handler, 0);
|
480
|
+
RG_DEF_SMETHOD(screen_width, 0);
|
481
|
+
RG_DEF_SMETHOD(screen_width_mm, 0);
|
482
|
+
RG_DEF_SMETHOD(screen_height, 0);
|
483
|
+
RG_DEF_SMETHOD(screen_height_mm, 0);
|
484
|
+
RG_DEF_SMETHOD(beep, 0);
|
485
|
+
RG_DEF_SMETHOD(flush, 0);
|
486
|
+
RG_DEF_SMETHOD(set_double_click_time, 1);
|
487
|
+
RG_DEF_SMETHOD(pointer_grab, 6);
|
488
|
+
RG_DEF_SMETHOD(pointer_ungrab, 1);
|
489
|
+
RG_DEF_SMETHOD(keyboard_grab, 3);
|
490
|
+
RG_DEF_SMETHOD(keyboard_ungrab, 1);
|
491
|
+
RG_DEF_SMETHOD_P(pointer_is_grabbed, 0);
|
492
|
+
RG_DEF_SMETHOD(error_trap_push, 0);
|
493
|
+
RG_DEF_SMETHOD(error_trap_pop, 0);
|
494
|
+
RG_DEF_SMETHOD_P(windowing_x11, 0);
|
495
|
+
RG_DEF_SMETHOD_P(windowing_win32, 0);
|
496
|
+
RG_DEF_SMETHOD_P(windowing_fb, 0);
|
497
|
+
RG_DEF_SMETHOD_P(windowing_quartz, 0);
|
498
|
+
RG_DEF_SMETHOD_P(windowing_directfb, 0);
|
499
|
+
|
500
|
+
RG_DEF_SMETHOD(target, 0);
|
501
|
+
|
502
|
+
RG_DEF_SMETHOD_P(cairo_available, 0);
|
503
|
+
|
504
|
+
G_DEF_CLASS(GDK_TYPE_GRAB_STATUS, "GrabStatus", RG_TARGET_NAMESPACE);
|
505
|
+
|
506
|
+
Init_gdk_atom(RG_TARGET_NAMESPACE);
|
507
|
+
Init_gdk_cairo();
|
508
|
+
Init_gdk_color(RG_TARGET_NAMESPACE);
|
509
|
+
Init_gdk_const(RG_TARGET_NAMESPACE);
|
510
|
+
Init_gdk_cursor(RG_TARGET_NAMESPACE);
|
511
|
+
Init_gdk_device(RG_TARGET_NAMESPACE);
|
512
|
+
Init_gdk_display(RG_TARGET_NAMESPACE);
|
513
|
+
Init_gdk_display_manager(RG_TARGET_NAMESPACE);
|
514
|
+
Init_gdk_dragcontext(RG_TARGET_NAMESPACE);
|
515
|
+
Init_gdk_event(RG_TARGET_NAMESPACE);
|
516
|
+
Init_gdk_geometry(RG_TARGET_NAMESPACE);
|
517
|
+
Init_gdk_keymap(RG_TARGET_NAMESPACE);
|
518
|
+
Init_gdk_keyval(RG_TARGET_NAMESPACE);
|
519
|
+
Init_gdk_pango(RG_TARGET_NAMESPACE);
|
520
|
+
/* deprecated
|
521
|
+
Init_gdk_pangorenderer(RG_TARGET_NAMESPACE);
|
522
|
+
*/
|
523
|
+
Init_gdk_pixbuf(RG_TARGET_NAMESPACE);
|
524
|
+
Init_gdk_property(RG_TARGET_NAMESPACE);
|
525
|
+
Init_gdk_rectangle(RG_TARGET_NAMESPACE);
|
526
|
+
/* deprecated
|
527
|
+
Init_gdk_rgb(RG_TARGET_NAMESPACE);
|
528
|
+
*/
|
529
|
+
Init_gdk_rgba(RG_TARGET_NAMESPACE);
|
530
|
+
Init_gdk_screen(RG_TARGET_NAMESPACE);
|
531
|
+
Init_gdk_selection(RG_TARGET_NAMESPACE);
|
532
|
+
Init_gdk_threads(RG_TARGET_NAMESPACE);
|
533
|
+
Init_gdk_timecoord(RG_TARGET_NAMESPACE);
|
534
|
+
Init_gdk_visual(RG_TARGET_NAMESPACE);
|
535
|
+
Init_gdk_window(RG_TARGET_NAMESPACE);
|
536
|
+
Init_gdk_windowattr(RG_TARGET_NAMESPACE);
|
537
|
+
/* deprecated
|
538
|
+
Init_gdk_draw(RG_TARGET_NAMESPACE);
|
539
|
+
*/
|
540
|
+
}
|