gtk2 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +66 -1
- data/ext/gtk2/extconf.rb +0 -96
- data/ext/gtk2/global.h +274 -13
- data/ext/gtk2/gtk2.def +5 -3
- data/ext/gtk2/init.c +263 -19
- data/ext/gtk2/rbgdk.c +245 -89
- data/ext/gtk2/rbgdk.h +32 -6
- data/ext/gtk2/rbgdkatom.c +38 -28
- data/ext/gtk2/rbgdkcairo.c +32 -42
- data/ext/gtk2/rbgdkcolor.c +52 -42
- data/ext/gtk2/rbgdkcolormap.c +42 -37
- data/ext/gtk2/rbgdkconst.c +23 -13
- data/ext/gtk2/rbgdkconversions.h +19 -6
- data/ext/gtk2/rbgdkcursor.c +37 -25
- data/ext/gtk2/rbgdkdevice.c +77 -67
- data/ext/gtk2/rbgdkdisplay.c +158 -150
- data/ext/gtk2/rbgdkdisplaymanager.c +27 -15
- data/ext/gtk2/rbgdkdragcontext.c +121 -70
- data/ext/gtk2/rbgdkdraw.c +252 -160
- data/ext/gtk2/rbgdkevent.c +30 -20
- data/ext/gtk2/rbgdkgc.c +123 -116
- data/ext/gtk2/rbgdkgeometry.c +77 -68
- data/ext/gtk2/rbgdkimage.c +58 -47
- data/ext/gtk2/rbgdkinput.c +33 -26
- data/ext/gtk2/rbgdkkeymap.c +38 -27
- data/ext/gtk2/rbgdkkeyval.c +44 -32
- data/ext/gtk2/rbgdkpango.c +66 -39
- data/ext/gtk2/rbgdkpangorenderer.c +63 -35
- data/ext/gtk2/rbgdkpixbuf.c +36 -25
- data/ext/gtk2/rbgdkpixmap.c +65 -49
- data/ext/gtk2/rbgdkproperty.c +66 -60
- data/ext/gtk2/rbgdkrectangle.c +54 -46
- data/ext/gtk2/rbgdkregion.c +144 -79
- data/ext/gtk2/rbgdkrgb.c +74 -58
- data/ext/gtk2/rbgdkscreen.c +103 -97
- data/ext/gtk2/rbgdkselection.c +49 -39
- data/ext/gtk2/rbgdkthreads.c +32 -19
- data/ext/gtk2/rbgdktimecoord.c +60 -38
- data/ext/gtk2/rbgdkvisual.c +79 -71
- data/ext/gtk2/rbgdkwindow.c +284 -305
- data/ext/gtk2/rbgdkwindowattr.c +69 -58
- data/ext/gtk2/rbgdkx11.c +41 -28
- data/ext/gtk2/rbgtk.c +498 -19
- data/ext/gtk2/rbgtk.h +35 -20
- data/ext/gtk2/rbgtkaboutdialog.c +33 -80
- data/ext/gtk2/rbgtkaccelerator.c +36 -23
- data/ext/gtk2/rbgtkaccelgroup.c +50 -40
- data/ext/gtk2/rbgtkaccelgroupentry.c +32 -20
- data/ext/gtk2/rbgtkaccelkey.c +40 -28
- data/ext/gtk2/rbgtkaccellabel.c +30 -18
- data/ext/gtk2/rbgtkaccelmap.c +55 -42
- data/ext/gtk2/rbgtkaccessible.c +25 -14
- data/ext/gtk2/rbgtkaction.c +68 -68
- data/ext/gtk2/rbgtkactiongroup.c +317 -195
- data/ext/gtk2/rbgtkadjustment.c +33 -46
- data/ext/gtk2/rbgtkalignment.c +36 -24
- data/ext/gtk2/rbgtkallocation.c +53 -42
- data/ext/gtk2/rbgtkarrow.c +34 -22
- data/ext/gtk2/rbgtkaspectframe.c +32 -20
- data/ext/gtk2/rbgtkassistant.c +81 -61
- data/ext/gtk2/rbgtkbbox.c +32 -20
- data/ext/gtk2/rbgtkbin.c +28 -16
- data/ext/gtk2/rbgtkbindingset.c +42 -35
- data/ext/gtk2/rbgtkborder.c +34 -23
- data/ext/gtk2/rbgtkbox.c +40 -29
- data/ext/gtk2/rbgtkbuildable.c +57 -45
- data/ext/gtk2/rbgtkbuilder.c +53 -38
- data/ext/gtk2/rbgtkbutton.c +41 -55
- data/ext/gtk2/rbgtkcalendar.c +51 -40
- data/ext/gtk2/rbgtkcelleditable.c +28 -17
- data/ext/gtk2/rbgtkcelllayout.c +41 -30
- data/ext/gtk2/rbgtkcellrenderer.c +43 -32
- data/ext/gtk2/rbgtkcellrendereraccel.c +26 -18
- data/ext/gtk2/rbgtkcellrenderercombo.c +25 -17
- data/ext/gtk2/rbgtkcellrendererpixbuf.c +24 -17
- data/ext/gtk2/rbgtkcellrendererprogress.c +25 -17
- data/ext/gtk2/rbgtkcellrendererspin.c +24 -16
- data/ext/gtk2/rbgtkcellrendererspinner.c +23 -11
- data/ext/gtk2/rbgtkcellrenderertext.c +28 -21
- data/ext/gtk2/rbgtkcellrenderertoggle.c +24 -16
- data/ext/gtk2/rbgtkcellview.c +34 -33
- data/ext/gtk2/rbgtkcheckbutton.c +28 -16
- data/ext/gtk2/rbgtkcheckmenuitem.c +31 -19
- data/ext/gtk2/rbgtkclipboard.c +123 -77
- data/ext/gtk2/rbgtkcolorbutton.c +26 -31
- data/ext/gtk2/rbgtkcolorsel.c +109 -55
- data/ext/gtk2/rbgtkcolorselectiondialog.c +28 -19
- data/ext/gtk2/rbgtkcombo.c +43 -32
- data/ext/gtk2/rbgtkcombobox.c +44 -83
- data/ext/gtk2/rbgtkcomboboxentry.c +26 -21
- data/ext/gtk2/rbgtkconst.c +23 -13
- data/ext/gtk2/rbgtkcontainer.c +153 -100
- data/ext/gtk2/rbgtkconversions.h +19 -6
- data/ext/gtk2/rbgtkcurve.c +46 -36
- data/ext/gtk2/rbgtkdialog.c +104 -70
- data/ext/gtk2/rbgtkdrag.c +173 -121
- data/ext/gtk2/rbgtkdrawingarea.c +28 -16
- data/ext/gtk2/rbgtkeditable.c +63 -51
- data/ext/gtk2/rbgtkentry.c +48 -85
- data/ext/gtk2/rbgtkentrycompletion.c +42 -55
- data/ext/gtk2/rbgtkeventbox.c +28 -16
- data/ext/gtk2/rbgtkexpander.c +26 -35
- data/ext/gtk2/rbgtkfilechooser.c +87 -143
- data/ext/gtk2/rbgtkfilechooserbutton.c +26 -32
- data/ext/gtk2/rbgtkfilechooserdialog.c +25 -15
- data/ext/gtk2/rbgtkfilechooserwidget.c +26 -15
- data/ext/gtk2/rbgtkfilefilter.c +45 -35
- data/ext/gtk2/rbgtkfilesel.c +54 -43
- data/ext/gtk2/rbgtkfilesystemerror.c +51 -0
- data/ext/gtk2/rbgtkfixed.c +36 -25
- data/ext/gtk2/rbgtkfontbutton.c +26 -37
- data/ext/gtk2/rbgtkfontselection.c +27 -15
- data/ext/gtk2/rbgtkfontselectiondialog.c +43 -32
- data/ext/gtk2/rbgtkframe.c +39 -28
- data/ext/gtk2/rbgtkgamma.c +32 -20
- data/ext/gtk2/rbgtkhandlebox.c +31 -19
- data/ext/gtk2/rbgtkhbbox.c +28 -16
- data/ext/gtk2/rbgtkhbox.c +29 -17
- data/ext/gtk2/rbgtkhpaned.c +28 -16
- data/ext/gtk2/rbgtkhruler.c +28 -16
- data/ext/gtk2/rbgtkhscale.c +28 -16
- data/ext/gtk2/rbgtkhscrollbar.c +28 -16
- data/ext/gtk2/rbgtkhseparator.c +28 -16
- data/ext/gtk2/rbgtkiconfactory.c +35 -23
- data/ext/gtk2/rbgtkiconinfo.c +42 -30
- data/ext/gtk2/rbgtkiconset.c +31 -19
- data/ext/gtk2/rbgtkiconsize.c +38 -25
- data/ext/gtk2/rbgtkiconsource.c +62 -50
- data/ext/gtk2/rbgtkicontheme.c +95 -95
- data/ext/gtk2/rbgtkiconview.c +87 -121
- data/ext/gtk2/rbgtkimage.c +31 -40
- data/ext/gtk2/rbgtkimagemenuitem.c +26 -14
- data/ext/gtk2/rbgtkimcontext.c +46 -34
- data/ext/gtk2/rbgtkimcontextsimple.c +47 -24
- data/ext/gtk2/rbgtkimmulticontext.c +26 -14
- data/ext/gtk2/rbgtkinputdialog.c +28 -16
- data/ext/gtk2/rbgtkinvisible.c +24 -18
- data/ext/gtk2/rbgtkitem.c +32 -20
- data/ext/gtk2/rbgtkitemfactory.c +65 -57
- data/ext/gtk2/rbgtklabel.c +46 -57
- data/ext/gtk2/rbgtklayout.c +40 -29
- data/ext/gtk2/rbgtklinkbutton.c +26 -15
- data/ext/gtk2/rbgtkliststore.c +145 -102
- data/ext/gtk2/rbgtkmacros.h +19 -6
- data/ext/gtk2/rbgtkmenu.c +47 -59
- data/ext/gtk2/rbgtkmenubar.c +30 -30
- data/ext/gtk2/rbgtkmenuitem.c +34 -41
- data/ext/gtk2/rbgtkmenushell.c +43 -42
- data/ext/gtk2/rbgtkmenutoolbutton.c +27 -16
- data/ext/gtk2/rbgtkmessagedialog.c +31 -25
- data/ext/gtk2/rbgtkmisc.c +33 -22
- data/ext/gtk2/rbgtknotebook.c +98 -134
- data/ext/gtk2/rbgtkobject.c +46 -81
- data/ext/gtk2/rbgtkoptionmenu.c +35 -23
- data/ext/gtk2/rbgtkpagesetup.c +64 -54
- data/ext/gtk2/rbgtkpagesetupunixdialog.c +34 -27
- data/ext/gtk2/rbgtkpaned.c +46 -36
- data/ext/gtk2/rbgtkpapersize.c +60 -54
- data/ext/gtk2/rbgtkplug.c +32 -20
- data/ext/gtk2/rbgtkprintcontext.c +43 -35
- data/ext/gtk2/rbgtkprinter.c +36 -37
- data/ext/gtk2/rbgtkprintjob.c +36 -37
- data/ext/gtk2/rbgtkprintoperation.c +44 -33
- data/ext/gtk2/rbgtkprintoperationpreview.c +30 -18
- data/ext/gtk2/rbgtkprintsettings.c +248 -192
- data/ext/gtk2/rbgtkprintunixdialog.c +33 -45
- data/ext/gtk2/rbgtkprogress.c +23 -13
- data/ext/gtk2/rbgtkprogressbar.c +47 -46
- data/ext/gtk2/rbgtkradioaction.c +84 -39
- data/ext/gtk2/rbgtkradiobutton.c +33 -21
- data/ext/gtk2/rbgtkradiomenuitem.c +86 -45
- data/ext/gtk2/rbgtkradiotoolbutton.c +99 -53
- data/ext/gtk2/rbgtkrange.c +36 -56
- data/ext/gtk2/rbgtkrc.c +61 -49
- data/ext/gtk2/rbgtkrcstyle.c +59 -48
- data/ext/gtk2/rbgtkrecentaction.c +28 -16
- data/ext/gtk2/rbgtkrecentchooser.c +58 -92
- data/ext/gtk2/rbgtkrecentchooserdialog.c +29 -18
- data/ext/gtk2/rbgtkrecentchoosermenu.c +25 -21
- data/ext/gtk2/rbgtkrecentchooserwidget.c +24 -13
- data/ext/gtk2/rbgtkrecentdata.c +47 -36
- data/ext/gtk2/rbgtkrecentfilter.c +55 -46
- data/ext/gtk2/rbgtkrecentfilterinfo.c +51 -40
- data/ext/gtk2/rbgtkrecentinfo.c +66 -56
- data/ext/gtk2/rbgtkrecentmanager.c +47 -43
- data/ext/gtk2/rbgtkruler.c +35 -30
- data/ext/gtk2/rbgtkscale.c +29 -18
- data/ext/gtk2/rbgtkscalebutton.c +27 -27
- data/ext/gtk2/rbgtkscrollbar.c +23 -13
- data/ext/gtk2/rbgtkscrolledwindow.c +44 -60
- data/ext/gtk2/rbgtkselection.c +87 -67
- data/ext/gtk2/rbgtkselectiondata.c +74 -65
- data/ext/gtk2/rbgtkseparator.c +23 -13
- data/ext/gtk2/rbgtkseparatormenuitem.c +25 -13
- data/ext/gtk2/rbgtkseparatortoolitem.c +26 -21
- data/ext/gtk2/rbgtksettings.c +123 -103
- data/ext/gtk2/rbgtksizegroup.c +33 -30
- data/ext/gtk2/rbgtksocket.c +32 -20
- data/ext/gtk2/rbgtkspinbutton.c +48 -38
- data/ext/gtk2/rbgtkspinner.c +27 -14
- data/ext/gtk2/rbgtkstatusbar.c +36 -31
- data/ext/gtk2/rbgtkstatusicon.c +31 -44
- data/ext/gtk2/rbgtkstock.c +137 -125
- data/ext/gtk2/rbgtkstyle.c +177 -161
- data/ext/gtk2/rbgtktable.c +58 -47
- data/ext/gtk2/rbgtktargetlist.c +56 -36
- data/ext/gtk2/rbgtktearoffmenuitem.c +28 -16
- data/ext/gtk2/rbgtktextappearance.c +44 -34
- data/ext/gtk2/rbgtktextattributes.c +54 -42
- data/ext/gtk2/rbgtktextbuffer.c +188 -191
- data/ext/gtk2/rbgtktextchild.c +29 -18
- data/ext/gtk2/rbgtktextiter.c +153 -145
- data/ext/gtk2/rbgtktextmark.c +33 -30
- data/ext/gtk2/rbgtktexttag.c +34 -22
- data/ext/gtk2/rbgtktexttagtable.c +36 -25
- data/ext/gtk2/rbgtktextview.c +85 -73
- data/ext/gtk2/rbgtktoggleaction.c +27 -22
- data/ext/gtk2/rbgtktogglebutton.c +37 -26
- data/ext/gtk2/rbgtktoggletoolbutton.c +26 -20
- data/ext/gtk2/rbgtktoolbar.c +66 -69
- data/ext/gtk2/rbgtktoolbutton.c +27 -40
- data/ext/gtk2/rbgtktoolitem.c +60 -62
- data/ext/gtk2/rbgtktooltip.c +36 -25
- data/ext/gtk2/rbgtktooltips.c +42 -34
- data/ext/gtk2/rbgtktreedragdest.c +20 -11
- data/ext/gtk2/rbgtktreedragsource.c +20 -11
- data/ext/gtk2/rbgtktreeiter.c +58 -47
- data/ext/gtk2/rbgtktreemodel.c +83 -65
- data/ext/gtk2/rbgtktreemodelfilter.c +47 -35
- data/ext/gtk2/rbgtktreemodelsort.c +38 -27
- data/ext/gtk2/rbgtktreepath.c +55 -44
- data/ext/gtk2/rbgtktreerowreference.c +60 -42
- data/ext/gtk2/rbgtktreeselection.c +61 -52
- data/ext/gtk2/rbgtktreesortable.c +52 -42
- data/ext/gtk2/rbgtktreestore.c +88 -67
- data/ext/gtk2/rbgtktreeview.c +157 -185
- data/ext/gtk2/rbgtktreeviewcolumn.c +57 -62
- data/ext/gtk2/rbgtkuimanager.c +61 -61
- data/ext/gtk2/rbgtkvbbox.c +28 -16
- data/ext/gtk2/rbgtkvbox.c +29 -17
- data/ext/gtk2/rbgtkviewport.c +28 -16
- data/ext/gtk2/rbgtkvolumebutton.c +28 -16
- data/ext/gtk2/rbgtkvpaned.c +28 -16
- data/ext/gtk2/rbgtkvruler.c +28 -16
- data/ext/gtk2/rbgtkvscale.c +28 -16
- data/ext/gtk2/rbgtkvscrollbar.c +28 -16
- data/ext/gtk2/rbgtkvseparator.c +28 -16
- data/ext/gtk2/rbgtkwidget.c +284 -296
- data/ext/gtk2/rbgtkwindow.c +156 -214
- data/ext/gtk2/rbgtkwindowgroup.c +35 -24
- data/sample/testgtk/labels.rb +1 -0
- data/sample/testgtk/testgtk.rb +2 -0
- metadata +16 -17
- data/ChangeLog +0 -6902
- data/ext/gtk2/rbgtkmain.c +0 -493
data/ext/gtk2/rbgdkregion.c
CHANGED
@@ -1,18 +1,30 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2002,2003 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
|
+
*/
|
3
24
|
|
4
|
-
rbgdkregion.c -
|
5
|
-
|
6
|
-
$Author: ggc $
|
7
|
-
$Date: 2007/07/13 16:07:31 $
|
8
|
-
|
9
|
-
Copyright (C) 2002,2003 Masao Mutoh
|
10
|
-
Copyright (C) 1998-2000 Yukihiro Matsumoto,
|
11
|
-
Daisuke Kanda,
|
12
|
-
Hiroshi Igarashi
|
13
|
-
************************************************/
|
14
25
|
#include "global.h"
|
15
26
|
|
27
|
+
#define RG_TARGET_NAMESPACE cRegion
|
16
28
|
#define _SELF(r) ((GdkRegion*)RVAL2BOXED(r, GDK_TYPE_REGION))
|
17
29
|
|
18
30
|
/**********************************/
|
@@ -29,30 +41,23 @@ gdk_region_get_type(void)
|
|
29
41
|
}
|
30
42
|
/**********************************/
|
31
43
|
static VALUE
|
32
|
-
|
44
|
+
rg_initialize(int argc, VALUE *argv, VALUE self)
|
33
45
|
{
|
34
|
-
VALUE points_or_rectangle,
|
35
|
-
GdkRegion*
|
36
|
-
GdkPoint *gpoints;
|
37
|
-
int i;
|
46
|
+
VALUE points_or_rectangle, rbfill_rule;
|
47
|
+
GdkRegion *region;
|
38
48
|
|
39
|
-
rb_scan_args(argc, argv, "02", &points_or_rectangle, &
|
40
|
-
if (NIL_P(points_or_rectangle)){
|
49
|
+
rb_scan_args(argc, argv, "02", &points_or_rectangle, &rbfill_rule);
|
50
|
+
if (NIL_P(points_or_rectangle)) {
|
41
51
|
region = gdk_region_new();
|
42
|
-
} else if (TYPE(points_or_rectangle) == T_ARRAY){
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
gpoints[i].y = NUM2INT(RARRAY_PTR(RARRAY_PTR(points_or_rectangle)[i])[1]);
|
52
|
-
}
|
53
|
-
region = gdk_region_polygon(gpoints, RARRAY_LEN(points_or_rectangle),
|
54
|
-
RVAL2GENUM(fill_rule, GDK_TYPE_FILL_RULE));
|
55
|
-
} else if (RVAL2GTYPE(points_or_rectangle) == GDK_TYPE_RECTANGLE){
|
52
|
+
} else if (TYPE(points_or_rectangle) == T_ARRAY) {
|
53
|
+
GdkFillRule fill_rule = RVAL2GENUM(rbfill_rule, GDK_TYPE_FILL_RULE);
|
54
|
+
long n;
|
55
|
+
GdkPoint *points = RVAL2GDKPOINTS(points_or_rectangle, &n);
|
56
|
+
|
57
|
+
region = gdk_region_polygon(points, n, fill_rule);
|
58
|
+
|
59
|
+
g_free(points);
|
60
|
+
} else if (RVAL2GTYPE(points_or_rectangle) == GDK_TYPE_RECTANGLE) {
|
56
61
|
region = gdk_region_rectangle((GdkRectangle*)RVAL2BOXED(points_or_rectangle,
|
57
62
|
GDK_TYPE_RECTANGLE));
|
58
63
|
} else {
|
@@ -62,11 +67,12 @@ gdkregion_initialize(int argc, VALUE *argv, VALUE self)
|
|
62
67
|
}
|
63
68
|
|
64
69
|
G_INITIALIZE(self, region);
|
70
|
+
|
65
71
|
return Qnil;
|
66
72
|
}
|
67
73
|
|
68
74
|
static VALUE
|
69
|
-
|
75
|
+
rg_rectangles(VALUE self)
|
70
76
|
{
|
71
77
|
GdkRectangle* rectangles;
|
72
78
|
gint n_rect, i;
|
@@ -88,27 +94,87 @@ gdkregion_span_func(GdkSpan *span, gpointer func)
|
|
88
94
|
INT2NUM(span->x), INT2NUM(span->y), INT2NUM(span->width));
|
89
95
|
}
|
90
96
|
|
97
|
+
struct rbgdk_rval2gdkspans_args {
|
98
|
+
VALUE ary;
|
99
|
+
long n;
|
100
|
+
GdkSpan *result;
|
101
|
+
};
|
102
|
+
|
91
103
|
static VALUE
|
92
|
-
|
104
|
+
rbgdk_rval2gdkspans_body(VALUE value)
|
93
105
|
{
|
94
|
-
|
95
|
-
|
96
|
-
volatile VALUE func = rb_block_proc();
|
106
|
+
long i;
|
107
|
+
struct rbgdk_rval2gdkspans_args *args = (struct rbgdk_rval2gdkspans_args *)value;
|
97
108
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
109
|
+
for (i = 0; i < args->n; i++) {
|
110
|
+
VALUE points = rb_ary_to_ary(RARRAY_PTR(args->ary)[i]);
|
111
|
+
|
112
|
+
if (RARRAY_LEN(points) != 2)
|
113
|
+
rb_raise(rb_eArgError, "point %ld should be array of size 3", i);
|
114
|
+
|
115
|
+
args->result[i].x = NUM2INT(RARRAY_PTR(points)[0]);
|
116
|
+
args->result[i].y = NUM2INT(RARRAY_PTR(points)[1]);
|
117
|
+
args->result[i].width = NUM2INT(RARRAY_PTR(points)[1]);
|
103
118
|
}
|
104
|
-
|
105
|
-
|
106
|
-
|
119
|
+
|
120
|
+
return Qnil;
|
121
|
+
}
|
122
|
+
|
123
|
+
static G_GNUC_NORETURN VALUE
|
124
|
+
rbgdk_rval2gdkspans_rescue(VALUE value)
|
125
|
+
{
|
126
|
+
g_free(((struct rbgdk_rval2gdkspans_args *)value)->result);
|
127
|
+
|
128
|
+
rb_exc_raise(rb_errinfo());
|
129
|
+
}
|
130
|
+
|
131
|
+
static GdkSpan *
|
132
|
+
rbgdk_rval2gdkspans(VALUE value, long *n)
|
133
|
+
{
|
134
|
+
struct rbgdk_rval2gdkspans_args args;
|
135
|
+
|
136
|
+
args.ary = rb_ary_to_ary(value);
|
137
|
+
args.n = RARRAY_LEN(args.ary);
|
138
|
+
args.result = g_new(GdkSpan, args.n + 1);
|
139
|
+
|
140
|
+
rb_rescue(rbgdk_rval2gdkspans_body, (VALUE)&args,
|
141
|
+
rbgdk_rval2gdkspans_rescue, (VALUE)&args);
|
142
|
+
|
143
|
+
if (n != NULL)
|
144
|
+
*n = args.n;
|
145
|
+
|
146
|
+
return args.result;
|
147
|
+
}
|
148
|
+
|
149
|
+
#define RVAL2GDKSPANS(value, n) rbgdk_rval2gdkspans(value, n)
|
150
|
+
|
151
|
+
static VALUE
|
152
|
+
rg_spans_intersect_each(VALUE self, VALUE rbspans, VALUE rbsorted)
|
153
|
+
{
|
154
|
+
GdkRegion *region = _SELF(self);
|
155
|
+
gboolean sorted = RVAL2CBOOL(rbsorted);
|
156
|
+
VALUE func = rb_block_proc();
|
157
|
+
long n;
|
158
|
+
GdkSpan *spans;
|
159
|
+
|
160
|
+
G_RELATIVE(self, func);
|
161
|
+
|
162
|
+
spans = RVAL2GDKSPANS(rbspans, &n);
|
163
|
+
|
164
|
+
gdk_region_spans_intersect_foreach(region,
|
165
|
+
spans,
|
166
|
+
n,
|
167
|
+
sorted,
|
168
|
+
(GdkSpanFunc)gdkregion_span_func,
|
169
|
+
(gpointer)func);
|
170
|
+
|
171
|
+
g_free(spans);
|
172
|
+
|
107
173
|
return self;
|
108
174
|
}
|
109
175
|
|
110
176
|
static VALUE
|
111
|
-
|
177
|
+
rg_clipbox(VALUE self)
|
112
178
|
{
|
113
179
|
GdkRectangle rect;
|
114
180
|
gdk_region_get_clipbox(_SELF(self), &rect);
|
@@ -116,13 +182,13 @@ gdkregion_get_clipbox(VALUE self)
|
|
116
182
|
}
|
117
183
|
|
118
184
|
static VALUE
|
119
|
-
|
185
|
+
rg_empty_p(VALUE self)
|
120
186
|
{
|
121
187
|
return CBOOL2RVAL(gdk_region_empty(_SELF(self)));
|
122
188
|
}
|
123
189
|
|
124
190
|
static VALUE
|
125
|
-
|
191
|
+
rg_operator_equal(VALUE self, VALUE obj)
|
126
192
|
{
|
127
193
|
if (!rb_obj_is_instance_of(obj, GTYPE2CLASS(GDK_TYPE_REGION))) {
|
128
194
|
return Qnil;
|
@@ -131,14 +197,14 @@ gdkregion_equal(VALUE self, VALUE obj)
|
|
131
197
|
}
|
132
198
|
|
133
199
|
static VALUE
|
134
|
-
|
200
|
+
rg_point_in_p(VALUE self, VALUE x, VALUE y)
|
135
201
|
{
|
136
202
|
return CBOOL2RVAL(gdk_region_point_in(_SELF(self), NUM2INT(x),
|
137
203
|
NUM2INT(y)));
|
138
204
|
}
|
139
205
|
|
140
206
|
static VALUE
|
141
|
-
|
207
|
+
rg_rect_in(VALUE self, VALUE rect)
|
142
208
|
{
|
143
209
|
return GENUM2RVAL(gdk_region_rect_in(
|
144
210
|
_SELF(self),
|
@@ -147,28 +213,28 @@ gdkregion_rect_in(VALUE self, VALUE rect)
|
|
147
213
|
}
|
148
214
|
|
149
215
|
static VALUE
|
150
|
-
|
216
|
+
rg_offset(VALUE self, VALUE dx, VALUE dy)
|
151
217
|
{
|
152
218
|
gdk_region_offset(_SELF(self), NUM2INT(dx), NUM2INT(dy));
|
153
219
|
return self;
|
154
220
|
}
|
155
221
|
|
156
222
|
static VALUE
|
157
|
-
|
223
|
+
rg_shrink(VALUE self, VALUE dx, VALUE dy)
|
158
224
|
{
|
159
225
|
gdk_region_shrink(_SELF(self), NUM2INT(dx), NUM2INT(dy));
|
160
226
|
return self;
|
161
227
|
}
|
162
228
|
|
163
229
|
static VALUE
|
164
|
-
|
230
|
+
rg_intersect(VALUE self, VALUE region)
|
165
231
|
{
|
166
232
|
gdk_region_intersect(_SELF(self), _SELF(region));
|
167
233
|
return self;
|
168
234
|
}
|
169
235
|
|
170
236
|
static VALUE
|
171
|
-
|
237
|
+
rg_union(VALUE self, VALUE other)
|
172
238
|
{
|
173
239
|
if (RVAL2GTYPE(other) == GDK_TYPE_RECTANGLE){
|
174
240
|
gdk_region_union_with_rect(_SELF(self),
|
@@ -180,45 +246,44 @@ gdkregion_union(VALUE self, VALUE other)
|
|
180
246
|
}
|
181
247
|
|
182
248
|
static VALUE
|
183
|
-
|
249
|
+
rg_subtract(VALUE self, VALUE region)
|
184
250
|
{
|
185
251
|
gdk_region_subtract(_SELF(self), _SELF(region));
|
186
252
|
return self;
|
187
253
|
}
|
188
254
|
|
189
255
|
static VALUE
|
190
|
-
|
256
|
+
rg_xor(VALUE self, VALUE region)
|
191
257
|
{
|
192
258
|
gdk_region_xor(_SELF(self), _SELF(region));
|
193
259
|
return self;
|
194
260
|
}
|
195
261
|
|
196
|
-
|
197
262
|
void
|
198
|
-
Init_gtk_gdk_region()
|
199
|
-
{
|
200
|
-
VALUE
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
263
|
+
Init_gtk_gdk_region(VALUE mGdk)
|
264
|
+
{
|
265
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_REGION, "Region", mGdk);
|
266
|
+
|
267
|
+
RG_DEF_METHOD(initialize, -1);
|
268
|
+
RG_DEF_METHOD(rectangles, 0);
|
269
|
+
RG_DEF_METHOD(spans_intersect_each, 2);
|
270
|
+
RG_DEF_METHOD(clipbox, 0);
|
271
|
+
RG_DEF_METHOD_P(empty, 0);
|
272
|
+
RG_DEF_METHOD_OPERATOR("==", equal, 1);
|
273
|
+
RG_DEF_METHOD_P(point_in, 2);
|
274
|
+
RG_DEF_METHOD(rect_in, 1);
|
275
|
+
RG_DEF_METHOD(offset, 2);
|
276
|
+
RG_DEF_METHOD(shrink, 2);
|
277
|
+
RG_DEF_METHOD(intersect, 1);
|
278
|
+
RG_DEF_METHOD(union, 1);
|
279
|
+
RG_DEF_METHOD(subtract, 1);
|
280
|
+
RG_DEF_METHOD(xor, 1);
|
216
281
|
|
217
282
|
/* GdkOverlapType */
|
218
|
-
G_DEF_CLASS(GDK_TYPE_OVERLAP_TYPE, "OverlapType",
|
219
|
-
G_DEF_CONSTANTS(
|
283
|
+
G_DEF_CLASS(GDK_TYPE_OVERLAP_TYPE, "OverlapType", RG_TARGET_NAMESPACE);
|
284
|
+
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_OVERLAP_TYPE, "GDK_");
|
220
285
|
|
221
286
|
/* GdkFillRule */
|
222
|
-
G_DEF_CLASS(GDK_TYPE_FILL_RULE, "FillRule",
|
223
|
-
G_DEF_CONSTANTS(
|
287
|
+
G_DEF_CLASS(GDK_TYPE_FILL_RULE, "FillRule", RG_TARGET_NAMESPACE);
|
288
|
+
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_FILL_RULE, "GDK_");
|
224
289
|
}
|
data/ext/gtk2/rbgdkrgb.c
CHANGED
@@ -1,24 +1,34 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
+
*/
|
14
24
|
|
15
25
|
#include "global.h"
|
16
26
|
|
27
|
+
#define RG_TARGET_NAMESPACE mRGB
|
17
28
|
#define RVAL2DRAW(s) GDK_DRAWABLE(RVAL2GOBJ(s))
|
18
29
|
|
19
|
-
|
20
30
|
static VALUE
|
21
|
-
|
31
|
+
rg_m_draw_rgb_image(int argc, VALUE *argv, VALUE self)
|
22
32
|
{
|
23
33
|
VALUE win, gc, x, y, w, h, dither, buf, rowstride, xdith, ydith;
|
24
34
|
|
@@ -46,36 +56,42 @@ rgb_draw_rgb_image(int argc, VALUE *argv, VALUE self)
|
|
46
56
|
}
|
47
57
|
|
48
58
|
static VALUE
|
49
|
-
|
59
|
+
rg_m_draw_indexed_image(VALUE self, VALUE win, VALUE rbgc, VALUE rbx, VALUE rby,
|
60
|
+
VALUE rbwidth, VALUE rbheight, VALUE rbdither,
|
61
|
+
VALUE rbbuf, VALUE rbrowstride, VALUE rbcolors)
|
50
62
|
{
|
51
|
-
|
52
|
-
|
53
|
-
gint
|
63
|
+
GdkDrawable *drawable = RVAL2DRAW(win);
|
64
|
+
GdkGC *gc = GDK_GC(RVAL2GOBJ(rbgc));
|
65
|
+
gint x = NUM2INT(rbx);
|
66
|
+
gint y = NUM2INT(rby);
|
67
|
+
gint width = NUM2INT(rbwidth);
|
68
|
+
gint height = NUM2INT(rbheight);
|
69
|
+
GdkRgbDither dither = RVAL2GENUM(rbdither, GDK_TYPE_RGB_DITHER);
|
70
|
+
const guchar *buf = (const guchar *)RVAL2CSTR(rbbuf);
|
71
|
+
gint rowstride = NUM2INT(rbrowstride);
|
72
|
+
long n;
|
73
|
+
guint32 *colors = RVAL2GUINT32S(rbcolors, n);
|
74
|
+
GdkRgbCmap *cmap;
|
75
|
+
|
76
|
+
if (n < 0 || n > 255) {
|
77
|
+
g_free(colors);
|
54
78
|
|
55
|
-
n_colors = RARRAY_LEN(colors);
|
56
|
-
|
57
|
-
if (n_colors > 255)
|
58
79
|
rb_raise(rb_eArgError, "colors: out of range (0 - 255)");
|
59
|
-
|
60
|
-
gcolors = g_new(guint32, n_colors);
|
61
|
-
for (i = 0; i < n_colors; i++) {
|
62
|
-
gcolors[i] = NUM2UINT(RARRAY_PTR(colors)[i]);
|
63
80
|
}
|
64
81
|
|
65
|
-
cmap = gdk_rgb_cmap_new(
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
(guchar*)RVAL2CSTR(buf),
|
72
|
-
NUM2INT(rowstride), cmap);
|
82
|
+
cmap = gdk_rgb_cmap_new(colors, n);
|
83
|
+
|
84
|
+
g_free(colors);
|
85
|
+
|
86
|
+
gdk_draw_indexed_image(drawable, gc, x, y, width, height, dither, buf, rowstride, cmap);
|
87
|
+
|
73
88
|
gdk_rgb_cmap_free(cmap);
|
89
|
+
|
74
90
|
return self;
|
75
91
|
}
|
76
92
|
|
77
93
|
static VALUE
|
78
|
-
|
94
|
+
rg_m_draw_gray_image(VALUE self, VALUE win, VALUE gc, VALUE x, VALUE y, VALUE w, VALUE h, VALUE dither, VALUE buf, VALUE rowstride)
|
79
95
|
{
|
80
96
|
gdk_draw_gray_image(RVAL2DRAW(win), GDK_GC(RVAL2GOBJ(gc)),
|
81
97
|
NUM2INT(x), NUM2INT(y),
|
@@ -87,7 +103,7 @@ rgb_draw_gray_image(VALUE self, VALUE win, VALUE gc, VALUE x, VALUE y, VALUE w,
|
|
87
103
|
}
|
88
104
|
|
89
105
|
static VALUE
|
90
|
-
|
106
|
+
rg_m_draw_rgb_32_image(int argc, VALUE *argv, VALUE self)
|
91
107
|
{
|
92
108
|
VALUE win, gc, x, y, w, h, dither, buf, rowstride, xdith, ydith;
|
93
109
|
|
@@ -113,7 +129,7 @@ rgb_draw_rgb_32_image(int argc, VALUE *argv, VALUE self)
|
|
113
129
|
}
|
114
130
|
|
115
131
|
static VALUE
|
116
|
-
|
132
|
+
rg_m_find_color(VALUE self, VALUE colormap, VALUE color)
|
117
133
|
{
|
118
134
|
gdk_rgb_find_color(GDK_COLORMAP(RVAL2GOBJ(colormap)),
|
119
135
|
RVAL2GDKCOLOR(color));
|
@@ -121,62 +137,62 @@ rgb_find_color(VALUE self, VALUE colormap, VALUE color)
|
|
121
137
|
}
|
122
138
|
|
123
139
|
static VALUE
|
124
|
-
|
140
|
+
rg_m_set_install(VALUE self, VALUE install)
|
125
141
|
{
|
126
142
|
gdk_rgb_set_install(RVAL2CBOOL(install));
|
127
143
|
return self;
|
128
144
|
}
|
129
145
|
|
130
146
|
static VALUE
|
131
|
-
|
147
|
+
rg_m_set_min_colors(VALUE self, VALUE min_colors)
|
132
148
|
{
|
133
149
|
gdk_rgb_set_min_colors(NUM2INT(min_colors));
|
134
150
|
return self;
|
135
151
|
}
|
136
152
|
|
137
153
|
static VALUE
|
138
|
-
|
154
|
+
rg_m_visual(G_GNUC_UNUSED VALUE self)
|
139
155
|
{
|
140
156
|
return GOBJ2RVAL(gdk_rgb_get_visual());
|
141
157
|
}
|
142
158
|
|
143
159
|
static VALUE
|
144
|
-
|
160
|
+
rg_m_colormap(G_GNUC_UNUSED VALUE self)
|
145
161
|
{
|
146
162
|
return GOBJ2RVAL(gdk_rgb_get_colormap());
|
147
163
|
}
|
148
164
|
|
149
165
|
static VALUE
|
150
|
-
|
166
|
+
rg_m_ditherable_p(G_GNUC_UNUSED VALUE self)
|
151
167
|
{
|
152
168
|
return CBOOL2RVAL(gdk_rgb_ditherable());
|
153
169
|
}
|
154
170
|
|
155
171
|
static VALUE
|
156
|
-
|
172
|
+
rg_m_set_verbose(VALUE self, VALUE verbose)
|
157
173
|
{
|
158
174
|
gdk_rgb_set_verbose(RVAL2CBOOL(verbose));
|
159
175
|
return self;
|
160
176
|
}
|
161
177
|
|
162
178
|
void
|
163
|
-
Init_gtk_gdk_rgb()
|
179
|
+
Init_gtk_gdk_rgb(VALUE mGdk)
|
164
180
|
{
|
165
|
-
VALUE
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
181
|
+
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "RGB");
|
182
|
+
|
183
|
+
RG_DEF_MODFUNC(draw_rgb_image, -1);
|
184
|
+
RG_DEF_MODFUNC(draw_indexed_image, 10);
|
185
|
+
RG_DEF_MODFUNC(draw_gray_image, 9);
|
186
|
+
RG_DEF_MODFUNC(draw_rgb_32_image, -1);
|
187
|
+
RG_DEF_MODFUNC(find_color, 2);
|
188
|
+
RG_DEF_MODFUNC(set_install, 1);
|
189
|
+
RG_DEF_MODFUNC(set_min_colors, 0);
|
190
|
+
RG_DEF_MODFUNC(visual, 0);
|
191
|
+
RG_DEF_MODFUNC(colormap, 0);
|
192
|
+
RG_DEF_MODFUNC_P(ditherable, 0);
|
193
|
+
RG_DEF_MODFUNC(set_verbose, 1);
|
178
194
|
|
179
195
|
/* GdkRgbDither */
|
180
|
-
G_DEF_CLASS(GDK_TYPE_RGB_DITHER, "Dither",
|
181
|
-
G_DEF_CONSTANTS(
|
196
|
+
G_DEF_CLASS(GDK_TYPE_RGB_DITHER, "Dither", RG_TARGET_NAMESPACE);
|
197
|
+
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_RGB_DITHER, "GDK_RGB_");
|
182
198
|
}
|