gdk3 1.2.0
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.
- 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
@@ -0,0 +1,146 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2002-2004 Masao Mutoh
|
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 "rbgdk3private.h"
|
23
|
+
|
24
|
+
#define RG_TARGET_NAMESPACE mSelection
|
25
|
+
|
26
|
+
static VALUE
|
27
|
+
rg_s_owner_set(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
|
28
|
+
{
|
29
|
+
VALUE owner, selection, time, send_event;
|
30
|
+
int ret;
|
31
|
+
|
32
|
+
if (argc == 4){
|
33
|
+
rb_scan_args(argc, argv, "40", &owner, &selection, &time, &send_event);
|
34
|
+
ret = gdk_selection_owner_set(RVAL2GDKWINDOW(owner),
|
35
|
+
RVAL2ATOM(selection),
|
36
|
+
NUM2UINT(time), RVAL2CBOOL(send_event));
|
37
|
+
} else {
|
38
|
+
VALUE display = Qnil;
|
39
|
+
rb_scan_args(argc, argv, "50", &display, &owner, &selection, &time, &send_event);
|
40
|
+
ret = gdk_selection_owner_set_for_display(RVAL2GDKDISPLAYOBJECT(display),
|
41
|
+
RVAL2GDKWINDOW(owner),
|
42
|
+
RVAL2ATOM(selection),
|
43
|
+
NUM2UINT(time), RVAL2CBOOL(send_event));
|
44
|
+
}
|
45
|
+
return CBOOL2RVAL(ret);
|
46
|
+
}
|
47
|
+
|
48
|
+
static VALUE
|
49
|
+
rg_s_owner_get(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
|
50
|
+
{
|
51
|
+
VALUE selection;
|
52
|
+
|
53
|
+
if (argc == 1) {
|
54
|
+
rb_scan_args(argc, argv, "10", &selection);
|
55
|
+
return GOBJ2RVAL(gdk_selection_owner_get(RVAL2ATOM(selection)));
|
56
|
+
} else {
|
57
|
+
VALUE display = Qnil;
|
58
|
+
rb_scan_args(argc, argv, "20", &display, &selection);
|
59
|
+
return GOBJ2RVAL(gdk_selection_owner_get_for_display(RVAL2GDKDISPLAYOBJECT(display),
|
60
|
+
RVAL2ATOM(selection)));
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
static VALUE
|
65
|
+
rg_s_convert(VALUE self, VALUE requestor, VALUE selection, VALUE target, VALUE time)
|
66
|
+
{
|
67
|
+
gdk_selection_convert(RVAL2GDKWINDOW(requestor),
|
68
|
+
RVAL2ATOM(selection),
|
69
|
+
RVAL2ATOM(target), NUM2INT(time));
|
70
|
+
return self;
|
71
|
+
}
|
72
|
+
|
73
|
+
static VALUE
|
74
|
+
rg_s_property_get(G_GNUC_UNUSED VALUE self, VALUE requestor)
|
75
|
+
{
|
76
|
+
guchar *data;
|
77
|
+
GdkAtom prop_type;
|
78
|
+
gint prop_format;
|
79
|
+
VALUE ary;
|
80
|
+
|
81
|
+
gdk_selection_property_get(RVAL2GDKWINDOW(requestor), &data,
|
82
|
+
&prop_type, &prop_format);
|
83
|
+
|
84
|
+
ary = rb_ary_new3(3, CSTR2RVAL((const char*)data), GDKATOM2RVAL(prop_type),
|
85
|
+
INT2NUM(prop_format));
|
86
|
+
g_free(data);
|
87
|
+
return ary;
|
88
|
+
}
|
89
|
+
|
90
|
+
static VALUE
|
91
|
+
rg_s_send_notify(int argc, VALUE *argv, VALUE self)
|
92
|
+
{
|
93
|
+
VALUE requestor, selection, target, property, time;
|
94
|
+
|
95
|
+
if (argc == 5) {
|
96
|
+
rb_scan_args(argc, argv, "50", &requestor, &selection, &target, &property, &time);
|
97
|
+
gdk_selection_send_notify(RVAL2GDKWINDOW(requestor), RVAL2ATOM(selection),
|
98
|
+
RVAL2ATOM(target),
|
99
|
+
NIL_P(property) ? GDK_NONE : RVAL2ATOM(property),
|
100
|
+
NUM2INT(time));
|
101
|
+
} else {
|
102
|
+
VALUE display = Qnil;
|
103
|
+
rb_scan_args(argc, argv, "60", &display, &requestor, &selection, &target, &property, &time);
|
104
|
+
gdk_selection_send_notify_for_display(RVAL2GDKDISPLAYOBJECT(display),
|
105
|
+
RVAL2GDKWINDOW(requestor), RVAL2ATOM(selection),
|
106
|
+
RVAL2ATOM(target),
|
107
|
+
NIL_P(property) ? GDK_NONE : RVAL2ATOM(property),
|
108
|
+
NUM2INT(time));
|
109
|
+
}
|
110
|
+
return self;
|
111
|
+
}
|
112
|
+
|
113
|
+
void
|
114
|
+
Init_gdk_selection(VALUE mGdk)
|
115
|
+
{
|
116
|
+
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "Selection");
|
117
|
+
|
118
|
+
RG_DEF_SMETHOD(owner_set, -1);
|
119
|
+
RG_DEF_SMETHOD(owner_get, -1);
|
120
|
+
RG_DEF_SMETHOD(convert, 4);
|
121
|
+
RG_DEF_SMETHOD(property_get, 1);
|
122
|
+
RG_DEF_SMETHOD(send_notify, -1);
|
123
|
+
|
124
|
+
/* Constants */
|
125
|
+
rb_define_const(RG_TARGET_NAMESPACE, "PRIMARY", GDKATOM2RVAL(GDK_SELECTION_PRIMARY));
|
126
|
+
rb_define_const(RG_TARGET_NAMESPACE, "SECONDARY", GDKATOM2RVAL(GDK_SELECTION_SECONDARY));
|
127
|
+
rb_define_const(RG_TARGET_NAMESPACE, "CLIPBOARD", GDKATOM2RVAL(GDK_SELECTION_CLIPBOARD));
|
128
|
+
|
129
|
+
/* GdkSelectionType */
|
130
|
+
rb_define_const(RG_TARGET_NAMESPACE, "TYPE_ATOM", GDKATOM2RVAL(GDK_SELECTION_TYPE_ATOM));
|
131
|
+
rb_define_const(RG_TARGET_NAMESPACE, "TYPE_BITMAP", GDKATOM2RVAL(GDK_SELECTION_TYPE_BITMAP));
|
132
|
+
rb_define_const(RG_TARGET_NAMESPACE, "TYPE_COLORMAP", GDKATOM2RVAL(GDK_SELECTION_TYPE_COLORMAP));
|
133
|
+
rb_define_const(RG_TARGET_NAMESPACE, "TYPE_DRAWABLE", GDKATOM2RVAL(GDK_SELECTION_TYPE_DRAWABLE));
|
134
|
+
rb_define_const(RG_TARGET_NAMESPACE, "TYPE_INTEGER", GDKATOM2RVAL(GDK_SELECTION_TYPE_INTEGER));
|
135
|
+
rb_define_const(RG_TARGET_NAMESPACE, "TYPE_PIXMAP", GDKATOM2RVAL(GDK_SELECTION_TYPE_PIXMAP));
|
136
|
+
rb_define_const(RG_TARGET_NAMESPACE, "TYPE_WINDOW", GDKATOM2RVAL(GDK_SELECTION_TYPE_WINDOW));
|
137
|
+
rb_define_const(RG_TARGET_NAMESPACE, "TYPE_STRING", GDKATOM2RVAL(GDK_SELECTION_TYPE_STRING));
|
138
|
+
|
139
|
+
/* GdkTarget */
|
140
|
+
rb_define_const(RG_TARGET_NAMESPACE, "TARGET_BITMAP", GDKATOM2RVAL(GDK_TARGET_BITMAP));
|
141
|
+
rb_define_const(RG_TARGET_NAMESPACE, "TARGET_COLORMAP", GDKATOM2RVAL(GDK_TARGET_COLORMAP));
|
142
|
+
rb_define_const(RG_TARGET_NAMESPACE, "TARGET_DRAWABLE", GDKATOM2RVAL(GDK_TARGET_DRAWABLE));
|
143
|
+
rb_define_const(RG_TARGET_NAMESPACE, "TARGET_PIXMAP", GDKATOM2RVAL(GDK_TARGET_PIXMAP));
|
144
|
+
rb_define_const(RG_TARGET_NAMESPACE, "TARGET_STRING", GDKATOM2RVAL(GDK_TARGET_STRING));
|
145
|
+
|
146
|
+
}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2003-2005 Masao Mutoh
|
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 "rbgdk3private.h"
|
23
|
+
|
24
|
+
#ifdef G_THREADS_ENABLED
|
25
|
+
|
26
|
+
#define RG_TARGET_NAMESPACE mThreads
|
27
|
+
|
28
|
+
static VALUE
|
29
|
+
rg_s_init(VALUE self)
|
30
|
+
{
|
31
|
+
#ifndef GDK_WINDOWING_WIN32
|
32
|
+
if (!g_thread_supported()){
|
33
|
+
g_thread_init(NULL);
|
34
|
+
}
|
35
|
+
gdk_threads_init();
|
36
|
+
#endif
|
37
|
+
return self;
|
38
|
+
}
|
39
|
+
|
40
|
+
static VALUE
|
41
|
+
rg_s_enter(VALUE self)
|
42
|
+
{
|
43
|
+
gdk_threads_enter();
|
44
|
+
return self;
|
45
|
+
}
|
46
|
+
|
47
|
+
static VALUE
|
48
|
+
rg_s_leave(VALUE self)
|
49
|
+
{
|
50
|
+
gdk_threads_leave();
|
51
|
+
return self;
|
52
|
+
}
|
53
|
+
|
54
|
+
static VALUE
|
55
|
+
rg_s_synchronize(G_GNUC_UNUSED VALUE self)
|
56
|
+
{
|
57
|
+
VALUE func = rb_block_proc();
|
58
|
+
gdk_threads_enter();
|
59
|
+
func = rb_block_proc();
|
60
|
+
rb_funcall(func, id_call, 0);
|
61
|
+
gdk_threads_leave();
|
62
|
+
return Qnil;
|
63
|
+
}
|
64
|
+
#endif
|
65
|
+
|
66
|
+
void
|
67
|
+
Init_gdk_threads(VALUE mGdk)
|
68
|
+
{
|
69
|
+
#ifdef G_THREADS_ENABLED
|
70
|
+
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "Threads");
|
71
|
+
|
72
|
+
RG_DEF_SMETHOD(init, 0);
|
73
|
+
RG_DEF_SMETHOD(enter, 0);
|
74
|
+
RG_DEF_SMETHOD(leave, 0);
|
75
|
+
RG_DEF_SMETHOD(synchronize, 0);
|
76
|
+
#endif
|
77
|
+
}
|
@@ -0,0 +1,133 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2003 Masao Mutoh
|
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 "rbgdk3private.h"
|
23
|
+
|
24
|
+
#define RG_TARGET_NAMESPACE cTimeCoord
|
25
|
+
#define _SELF(s) (RVAL2GDKTIMECOORD(s))
|
26
|
+
|
27
|
+
/**********************************/
|
28
|
+
static GdkTimeCoord*
|
29
|
+
timecoord_copy(const GdkTimeCoord* val)
|
30
|
+
{
|
31
|
+
GdkTimeCoord* new_val;
|
32
|
+
g_return_val_if_fail (val != NULL, NULL);
|
33
|
+
new_val = g_new(GdkTimeCoord, 1);
|
34
|
+
*new_val = *val;
|
35
|
+
return new_val;
|
36
|
+
}
|
37
|
+
|
38
|
+
GType
|
39
|
+
gdk_timecoord_get_type(void)
|
40
|
+
{
|
41
|
+
static GType our_type = 0;
|
42
|
+
|
43
|
+
if (our_type == 0)
|
44
|
+
our_type = g_boxed_type_register_static ("GdkTimeCoord",
|
45
|
+
(GBoxedCopyFunc)timecoord_copy,
|
46
|
+
(GBoxedFreeFunc)g_free);
|
47
|
+
return our_type;
|
48
|
+
}
|
49
|
+
/**********************************/
|
50
|
+
|
51
|
+
static VALUE
|
52
|
+
rg_initialize(VALUE self, VALUE rbtime, VALUE rbaxes)
|
53
|
+
{
|
54
|
+
guint32 time = NUM2UINT(rbtime);
|
55
|
+
long n;
|
56
|
+
gdouble *axes = RVAL2GDOUBLES(rbaxes, n);
|
57
|
+
GdkTimeCoord *coord;
|
58
|
+
|
59
|
+
if (n > GDK_MAX_TIMECOORD_AXES) {
|
60
|
+
g_free(axes);
|
61
|
+
|
62
|
+
rb_raise(rb_eArgError,
|
63
|
+
"axes out of range: %ld (0..%d)",
|
64
|
+
n, GDK_MAX_TIMECOORD_AXES);
|
65
|
+
}
|
66
|
+
|
67
|
+
coord = g_new(GdkTimeCoord, 1);
|
68
|
+
coord->time = time;
|
69
|
+
MEMCPY(coord->axes, axes, gdouble, n);
|
70
|
+
|
71
|
+
g_free(axes);
|
72
|
+
|
73
|
+
G_INITIALIZE(self, coord);
|
74
|
+
|
75
|
+
return Qnil;
|
76
|
+
}
|
77
|
+
|
78
|
+
static VALUE
|
79
|
+
rg_time(VALUE self)
|
80
|
+
{
|
81
|
+
return UINT2NUM(_SELF(self)->time);
|
82
|
+
}
|
83
|
+
|
84
|
+
static VALUE
|
85
|
+
rg_set_time(VALUE self, VALUE time)
|
86
|
+
{
|
87
|
+
_SELF(self)->time = NUM2UINT(time);
|
88
|
+
return self;
|
89
|
+
}
|
90
|
+
|
91
|
+
static VALUE
|
92
|
+
rg_axes(VALUE self)
|
93
|
+
{
|
94
|
+
VALUE ary = rb_ary_new();
|
95
|
+
int i;
|
96
|
+
for (i = 0; i < GDK_MAX_TIMECOORD_AXES; i++){
|
97
|
+
rb_ary_push(ary, rb_float_new(_SELF(self)->axes[i]));
|
98
|
+
}
|
99
|
+
return ary;
|
100
|
+
}
|
101
|
+
|
102
|
+
static VALUE
|
103
|
+
rg_set_axes(VALUE self, VALUE rbaxes)
|
104
|
+
{
|
105
|
+
GdkTimeCoord *coord = _SELF(self);
|
106
|
+
VALUE axes = rb_ary_to_ary(rbaxes);
|
107
|
+
long i;
|
108
|
+
long n = RARRAY_LEN(axes);
|
109
|
+
|
110
|
+
if (n < 0 || n > GDK_MAX_TIMECOORD_AXES)
|
111
|
+
rb_raise(rb_eArgError,
|
112
|
+
"axes out of range: %ld (0..%d)",
|
113
|
+
n, GDK_MAX_TIMECOORD_AXES);
|
114
|
+
|
115
|
+
for (i = 0; i < n; i++)
|
116
|
+
coord->axes[i] = NUM2DBL(RARRAY_PTR(axes)[i]);
|
117
|
+
|
118
|
+
return self;
|
119
|
+
}
|
120
|
+
|
121
|
+
void
|
122
|
+
Init_gdk_timecoord(VALUE mGdk)
|
123
|
+
{
|
124
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_TIME_COORD, "TimeCoord", mGdk);
|
125
|
+
|
126
|
+
RG_DEF_METHOD(initialize, 2);
|
127
|
+
RG_DEF_METHOD(time, 0);
|
128
|
+
RG_DEF_METHOD(set_time, 1);
|
129
|
+
RG_DEF_METHOD(axes, 0);
|
130
|
+
RG_DEF_METHOD(set_axes, 1);
|
131
|
+
|
132
|
+
rb_define_const(RG_TARGET_NAMESPACE, "MAX_AXES", INT2NUM(GDK_MAX_TIMECOORD_AXES));
|
133
|
+
}
|
@@ -0,0 +1,251 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2002-2004 Masao Mutoh
|
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 cVisual
|
28
|
+
#define _SELF(self) (RVAL2GDKVISUAL(self))
|
29
|
+
|
30
|
+
static VALUE
|
31
|
+
rg_s_query_depths(G_GNUC_UNUSED VALUE self)
|
32
|
+
{
|
33
|
+
gint *depth;
|
34
|
+
gint count;
|
35
|
+
VALUE ary;
|
36
|
+
int i;
|
37
|
+
|
38
|
+
gdk_query_depths(&depth, &count);
|
39
|
+
ary = rb_ary_new2(count);
|
40
|
+
for (i = 0; i < count; i++) {
|
41
|
+
rb_ary_push(ary, INT2NUM((depth)[i]));
|
42
|
+
}
|
43
|
+
return ary;
|
44
|
+
}
|
45
|
+
|
46
|
+
static VALUE
|
47
|
+
rg_s_query_visual_types(G_GNUC_UNUSED VALUE self)
|
48
|
+
{
|
49
|
+
GdkVisualType *visual_types;
|
50
|
+
gint count;
|
51
|
+
VALUE ary;
|
52
|
+
int i;
|
53
|
+
|
54
|
+
gdk_query_visual_types(&visual_types, &count);
|
55
|
+
ary = rb_ary_new2(count);
|
56
|
+
for (i = 0; i < count; i++) {
|
57
|
+
rb_ary_push(ary, GDKVISUALTYPE2RVAL((visual_types)[i]));
|
58
|
+
}
|
59
|
+
return ary;
|
60
|
+
}
|
61
|
+
|
62
|
+
static VALUE
|
63
|
+
rg_s_visuals(G_GNUC_UNUSED VALUE self)
|
64
|
+
{
|
65
|
+
GList *list = gdk_list_visuals(), *cur;
|
66
|
+
VALUE ary = rb_ary_new();
|
67
|
+
|
68
|
+
for (cur = list; cur != NULL; cur = cur->next) {
|
69
|
+
rb_ary_push(ary, GOBJ2RVAL((GdkVisual *)cur->data));
|
70
|
+
}
|
71
|
+
g_list_free(list);
|
72
|
+
return ary;
|
73
|
+
}
|
74
|
+
|
75
|
+
static VALUE
|
76
|
+
rg_s_best_depth(G_GNUC_UNUSED VALUE self)
|
77
|
+
{
|
78
|
+
return INT2NUM(gdk_visual_get_best_depth());
|
79
|
+
}
|
80
|
+
|
81
|
+
static VALUE
|
82
|
+
rg_s_best_type(G_GNUC_UNUSED VALUE self)
|
83
|
+
{
|
84
|
+
return INT2NUM(gdk_visual_get_best_type());
|
85
|
+
}
|
86
|
+
|
87
|
+
static VALUE
|
88
|
+
rg_s_system(G_GNUC_UNUSED VALUE self)
|
89
|
+
{
|
90
|
+
return GOBJ2RVAL(gdk_visual_get_system());
|
91
|
+
}
|
92
|
+
|
93
|
+
static VALUE
|
94
|
+
rg_s_best(G_GNUC_UNUSED VALUE self)
|
95
|
+
{
|
96
|
+
return GOBJ2RVAL(gdk_visual_get_best());
|
97
|
+
}
|
98
|
+
|
99
|
+
static VALUE
|
100
|
+
rg_s_best_with_depth(G_GNUC_UNUSED VALUE self, VALUE depth)
|
101
|
+
{
|
102
|
+
return GOBJ2RVAL(gdk_visual_get_best_with_depth(NUM2INT(depth)));
|
103
|
+
}
|
104
|
+
|
105
|
+
static VALUE
|
106
|
+
rg_s_best_with_type(G_GNUC_UNUSED VALUE self, VALUE type)
|
107
|
+
{
|
108
|
+
return GOBJ2RVAL(gdk_visual_get_best_with_depth(
|
109
|
+
(GdkVisualType)GDKVISUALTYPE2RVAL(type)));
|
110
|
+
}
|
111
|
+
|
112
|
+
static VALUE
|
113
|
+
rg_s_best_with_both(G_GNUC_UNUSED VALUE self, VALUE depth, VALUE type)
|
114
|
+
{
|
115
|
+
return GOBJ2RVAL(gdk_visual_get_best_with_both(
|
116
|
+
NUM2INT(depth),
|
117
|
+
(GdkVisualType)RVAL2GDKVISUALTYPE(type)));
|
118
|
+
}
|
119
|
+
|
120
|
+
static VALUE
|
121
|
+
rg_screen(VALUE self)
|
122
|
+
{
|
123
|
+
return GOBJ2RVAL(gdk_visual_get_screen(_SELF(self)));
|
124
|
+
}
|
125
|
+
|
126
|
+
/* Structure accessors */
|
127
|
+
static VALUE
|
128
|
+
rg_visual_type(VALUE self)
|
129
|
+
{
|
130
|
+
return GDKVISUALTYPE2RVAL(gdk_visual_get_visual_type(_SELF(self)));
|
131
|
+
}
|
132
|
+
|
133
|
+
static VALUE
|
134
|
+
rg_depth(VALUE self)
|
135
|
+
{
|
136
|
+
return INT2FIX(gdk_visual_get_depth(_SELF(self)));
|
137
|
+
}
|
138
|
+
|
139
|
+
static VALUE
|
140
|
+
rg_byte_order(VALUE self)
|
141
|
+
{
|
142
|
+
return GDKBYTEORDER2RVAL(gdk_visual_get_byte_order(_SELF(self)));
|
143
|
+
}
|
144
|
+
|
145
|
+
static VALUE
|
146
|
+
rg_colormap_size(VALUE self)
|
147
|
+
{
|
148
|
+
return INT2FIX(gdk_visual_get_colormap_size(_SELF(self)));
|
149
|
+
}
|
150
|
+
|
151
|
+
static VALUE
|
152
|
+
rg_bits_per_rgb(VALUE self)
|
153
|
+
{
|
154
|
+
return INT2FIX(gdk_visual_get_bits_per_rgb(_SELF(self)));
|
155
|
+
}
|
156
|
+
|
157
|
+
/* TODO
|
158
|
+
static VALUE
|
159
|
+
rg_red_mask(VALUE self)
|
160
|
+
{
|
161
|
+
return INT2FIX(_SELF(self)->red_mask);
|
162
|
+
}
|
163
|
+
|
164
|
+
static VALUE
|
165
|
+
rg_red_shift(VALUE self)
|
166
|
+
{
|
167
|
+
return INT2FIX(_SELF(self)->red_shift);
|
168
|
+
}
|
169
|
+
|
170
|
+
static VALUE
|
171
|
+
rg_red_prec(VALUE self)
|
172
|
+
{
|
173
|
+
return INT2FIX(_SELF(self)->red_prec);
|
174
|
+
}
|
175
|
+
|
176
|
+
static VALUE
|
177
|
+
rg_green_mask(VALUE self)
|
178
|
+
{
|
179
|
+
return INT2FIX(_SELF(self)->green_mask);
|
180
|
+
}
|
181
|
+
|
182
|
+
static VALUE
|
183
|
+
rg_green_shift(VALUE self)
|
184
|
+
{
|
185
|
+
return INT2FIX(_SELF(self)->green_shift);
|
186
|
+
}
|
187
|
+
|
188
|
+
static VALUE
|
189
|
+
rg_green_prec(VALUE self)
|
190
|
+
{
|
191
|
+
return INT2FIX(_SELF(self)->green_prec);
|
192
|
+
}
|
193
|
+
|
194
|
+
static VALUE
|
195
|
+
rg_blue_mask(VALUE self)
|
196
|
+
{
|
197
|
+
return INT2FIX(_SELF(self)->blue_mask);
|
198
|
+
}
|
199
|
+
|
200
|
+
static VALUE
|
201
|
+
rg_blue_shift(VALUE self)
|
202
|
+
{
|
203
|
+
return INT2FIX(_SELF(self)->blue_shift);
|
204
|
+
}
|
205
|
+
|
206
|
+
static VALUE
|
207
|
+
rg_blue_prec(VALUE self)
|
208
|
+
{
|
209
|
+
return INT2FIX(_SELF(self)->blue_prec);
|
210
|
+
}
|
211
|
+
*/
|
212
|
+
|
213
|
+
void
|
214
|
+
Init_gdk_visual(VALUE mGdk)
|
215
|
+
{
|
216
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_VISUAL, "Visual", mGdk);
|
217
|
+
|
218
|
+
/* class methods */
|
219
|
+
RG_DEF_SMETHOD(query_depths, 0);
|
220
|
+
RG_DEF_SMETHOD(query_visual_types, 0);
|
221
|
+
RG_DEF_SMETHOD(visuals, 0);
|
222
|
+
RG_DEF_SMETHOD(best_depth, 0);
|
223
|
+
RG_DEF_SMETHOD(best_type, 0);
|
224
|
+
RG_DEF_SMETHOD(system, 0);
|
225
|
+
RG_DEF_SMETHOD(best, 0);
|
226
|
+
RG_DEF_SMETHOD(best_with_depth, 1);
|
227
|
+
RG_DEF_SMETHOD(best_with_type, 1);
|
228
|
+
RG_DEF_SMETHOD(best_with_both, 2);
|
229
|
+
|
230
|
+
/* instance methods */
|
231
|
+
RG_DEF_METHOD(screen, 0);
|
232
|
+
RG_DEF_METHOD(visual_type, 0);
|
233
|
+
RG_DEF_METHOD(depth, 0);
|
234
|
+
RG_DEF_METHOD(byte_order, 0);
|
235
|
+
RG_DEF_METHOD(colormap_size, 0);
|
236
|
+
RG_DEF_METHOD(bits_per_rgb, 0);
|
237
|
+
/* TODO
|
238
|
+
RG_DEF_METHOD(red_mask, 0);
|
239
|
+
RG_DEF_METHOD(red_shift, 0);
|
240
|
+
RG_DEF_METHOD(red_prec, 0);
|
241
|
+
RG_DEF_METHOD(green_mask, 0);
|
242
|
+
RG_DEF_METHOD(green_shift, 0);
|
243
|
+
RG_DEF_METHOD(green_prec, 0);
|
244
|
+
RG_DEF_METHOD(blue_mask, 0);
|
245
|
+
RG_DEF_METHOD(blue_shift, 0);
|
246
|
+
RG_DEF_METHOD(blue_prec, 0);
|
247
|
+
*/
|
248
|
+
|
249
|
+
G_DEF_CLASS(GDK_TYPE_VISUAL_TYPE, "Type", RG_TARGET_NAMESPACE);
|
250
|
+
G_DEF_CLASS(GDK_TYPE_BYTE_ORDER, "ByteOrder", RG_TARGET_NAMESPACE);
|
251
|
+
}
|