gtk2 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6664 -0
- data/README +33 -0
- data/Rakefile +71 -0
- data/extconf.rb +116 -0
- data/src/global.h +33 -0
- data/src/init.c +39 -0
- data/src/lib/gtk2.rb +13 -0
- data/src/lib/gtk2/base.rb +95 -0
- data/src/makeinits.rb +57 -0
- data/src/makekeysyms.rb +5 -0
- data/src/rbgdk.c +395 -0
- data/src/rbgdk.h +50 -0
- data/src/rbgdkatom.c +122 -0
- data/src/rbgdkcairo.c +100 -0
- data/src/rbgdkcolor.c +151 -0
- data/src/rbgdkcolormap.c +142 -0
- data/src/rbgdkconst.c +29 -0
- data/src/rbgdkconversions.h +18 -0
- data/src/rbgdkcursor.c +115 -0
- data/src/rbgdkdevice.c +235 -0
- data/src/rbgdkdisplay.c +634 -0
- data/src/rbgdkdisplaymanager.c +50 -0
- data/src/rbgdkdragcontext.c +280 -0
- data/src/rbgdkdraw.c +487 -0
- data/src/rbgdkevent.c +1020 -0
- data/src/rbgdkgc.c +456 -0
- data/src/rbgdkgeometry.c +272 -0
- data/src/rbgdkimage.c +155 -0
- data/src/rbgdkinput.c +70 -0
- data/src/rbgdkkeymap.c +153 -0
- data/src/rbgdkkeysyms.h +2174 -0
- data/src/rbgdkkeyval.c +105 -0
- data/src/rbgdkpango.c +171 -0
- data/src/rbgdkpangorenderer.c +132 -0
- data/src/rbgdkpixbuf.c +178 -0
- data/src/rbgdkpixmap.c +255 -0
- data/src/rbgdkproperty.c +342 -0
- data/src/rbgdkrectangle.c +146 -0
- data/src/rbgdkregion.c +242 -0
- data/src/rbgdkrgb.c +197 -0
- data/src/rbgdkscreen.c +535 -0
- data/src/rbgdkselection.c +161 -0
- data/src/rbgdkthreads.c +68 -0
- data/src/rbgdktimecoord.c +118 -0
- data/src/rbgdkvisual.c +273 -0
- data/src/rbgdkwindow.c +1302 -0
- data/src/rbgdkwindowattr.c +213 -0
- data/src/rbgdkx11.c +256 -0
- data/src/rbgtk.c +93 -0
- data/src/rbgtk.h +121 -0
- data/src/rbgtkaboutdialog.c +195 -0
- data/src/rbgtkaccelerator.c +78 -0
- data/src/rbgtkaccelgroup.c +216 -0
- data/src/rbgtkaccelgroupentry.c +85 -0
- data/src/rbgtkaccelkey.c +116 -0
- data/src/rbgtkaccellabel.c +46 -0
- data/src/rbgtkaccelmap.c +162 -0
- data/src/rbgtkaccessible.c +29 -0
- data/src/rbgtkaction.c +277 -0
- data/src/rbgtkactiongroup.c +377 -0
- data/src/rbgtkadjustment.c +153 -0
- data/src/rbgtkalignment.c +71 -0
- data/src/rbgtkallocation.c +171 -0
- data/src/rbgtkarrow.c +47 -0
- data/src/rbgtkaspectframe.c +46 -0
- data/src/rbgtkassistant.c +230 -0
- data/src/rbgtkbbox.c +47 -0
- data/src/rbgtkbin.c +31 -0
- data/src/rbgtkbindingset.c +192 -0
- data/src/rbgtkborder.c +80 -0
- data/src/rbgtkbox.c +142 -0
- data/src/rbgtkbuildable.c +115 -0
- data/src/rbgtkbuilder.c +154 -0
- data/src/rbgtkbutton.c +151 -0
- data/src/rbgtkcalendar.c +159 -0
- data/src/rbgtkcelleditable.c +49 -0
- data/src/rbgtkcelllayout.c +144 -0
- data/src/rbgtkcellrenderer.c +139 -0
- data/src/rbgtkcellrendereraccel.c +42 -0
- data/src/rbgtkcellrenderercombo.c +37 -0
- data/src/rbgtkcellrendererpixbuf.c +33 -0
- data/src/rbgtkcellrendererprogress.c +37 -0
- data/src/rbgtkcellrendererspin.c +38 -0
- data/src/rbgtkcellrenderertext.c +45 -0
- data/src/rbgtkcellrenderertoggle.c +32 -0
- data/src/rbgtkcellview.c +134 -0
- data/src/rbgtkcheckbutton.c +55 -0
- data/src/rbgtkcheckmenuitem.c +56 -0
- data/src/rbgtkclipboard.c +473 -0
- data/src/rbgtkcolorbutton.c +63 -0
- data/src/rbgtkcolorsel.c +175 -0
- data/src/rbgtkcolorselectiondialog.c +72 -0
- data/src/rbgtkcombo.c +117 -0
- data/src/rbgtkcombobox.c +240 -0
- data/src/rbgtkcomboboxentry.c +60 -0
- data/src/rbgtkconst.c +163 -0
- data/src/rbgtkcontainer.c +776 -0
- data/src/rbgtkconversions.h +26 -0
- data/src/rbgtkcurve.c +105 -0
- data/src/rbgtkdialog.c +244 -0
- data/src/rbgtkdrag.c +436 -0
- data/src/rbgtkdrawingarea.c +31 -0
- data/src/rbgtkeditable.c +152 -0
- data/src/rbgtkentry.c +161 -0
- data/src/rbgtkentrycompletion.c +167 -0
- data/src/rbgtkeventbox.c +31 -0
- data/src/rbgtkexpander.c +67 -0
- data/src/rbgtkfilechooser.c +403 -0
- data/src/rbgtkfilechooserbutton.c +72 -0
- data/src/rbgtkfilechooserdialog.c +58 -0
- data/src/rbgtkfilechooserwidget.c +50 -0
- data/src/rbgtkfilefilter.c +139 -0
- data/src/rbgtkfilesel.c +155 -0
- data/src/rbgtkfixed.c +72 -0
- data/src/rbgtkfontbutton.c +69 -0
- data/src/rbgtkfontselection.c +30 -0
- data/src/rbgtkfontselectiondialog.c +106 -0
- data/src/rbgtkframe.c +64 -0
- data/src/rbgtkgamma.c +47 -0
- data/src/rbgtkhandlebox.c +42 -0
- data/src/rbgtkhbbox.c +31 -0
- data/src/rbgtkhbox.c +38 -0
- data/src/rbgtkhpaned.c +31 -0
- data/src/rbgtkhruler.c +31 -0
- data/src/rbgtkhscale.c +45 -0
- data/src/rbgtkhscrollbar.c +38 -0
- data/src/rbgtkhseparator.c +30 -0
- data/src/rbgtkiconfactory.c +80 -0
- data/src/rbgtkiconinfo.c +118 -0
- data/src/rbgtkiconset.c +87 -0
- data/src/rbgtkiconsize.c +90 -0
- data/src/rbgtkiconsource.c +176 -0
- data/src/rbgtkicontheme.c +309 -0
- data/src/rbgtkiconview.c +351 -0
- data/src/rbgtkimage.c +152 -0
- data/src/rbgtkimagemenuitem.c +52 -0
- data/src/rbgtkimcontext.c +134 -0
- data/src/rbgtkimcontextsimple.c +48 -0
- data/src/rbgtkimmulticontext.c +38 -0
- data/src/rbgtkinits.c +473 -0
- data/src/rbgtkinputdialog.c +30 -0
- data/src/rbgtkinvisible.c +68 -0
- data/src/rbgtkitem.c +51 -0
- data/src/rbgtkitemfactory.c +312 -0
- data/src/rbgtklabel.c +168 -0
- data/src/rbgtklayout.c +91 -0
- data/src/rbgtklinkbutton.c +68 -0
- data/src/rbgtkliststore.c +412 -0
- data/src/rbgtkmacros.h +26 -0
- data/src/rbgtkmain.c +532 -0
- data/src/rbgtkmenu.c +272 -0
- data/src/rbgtkmenubar.c +48 -0
- data/src/rbgtkmenuitem.c +171 -0
- data/src/rbgtkmenushell.c +128 -0
- data/src/rbgtkmenutoolbutton.c +74 -0
- data/src/rbgtkmessagedialog.c +102 -0
- data/src/rbgtkmisc.c +63 -0
- data/src/rbgtknotebook.c +484 -0
- data/src/rbgtkobject.c +186 -0
- data/src/rbgtkoptionmenu.c +65 -0
- data/src/rbgtkpagesetup.c +196 -0
- data/src/rbgtkpagesetupunixdialog.c +80 -0
- data/src/rbgtkpaned.c +114 -0
- data/src/rbgtkpapersize.c +186 -0
- data/src/rbgtkplug.c +84 -0
- data/src/rbgtkprintcontext.c +124 -0
- data/src/rbgtkprinter.c +155 -0
- data/src/rbgtkprintjob.c +151 -0
- data/src/rbgtkprintoperation.c +152 -0
- data/src/rbgtkprintoperationpreview.c +54 -0
- data/src/rbgtkprintsettings.c +794 -0
- data/src/rbgtkprintunixdialog.c +98 -0
- data/src/rbgtkprogress.c +21 -0
- data/src/rbgtkprogressbar.c +72 -0
- data/src/rbgtkradioaction.c +102 -0
- data/src/rbgtkradiobutton.c +83 -0
- data/src/rbgtkradiomenuitem.c +115 -0
- data/src/rbgtkradiotoolbutton.c +99 -0
- data/src/rbgtkrange.c +98 -0
- data/src/rbgtkrc.c +228 -0
- data/src/rbgtkrcstyle.c +184 -0
- data/src/rbgtkrecentaction.c +52 -0
- data/src/rbgtkrecentchooser.c +276 -0
- data/src/rbgtkrecentchooserdialog.c +59 -0
- data/src/rbgtkrecentchoosermenu.c +55 -0
- data/src/rbgtkrecentchooserwidget.c +45 -0
- data/src/rbgtkrecentdata.c +152 -0
- data/src/rbgtkrecentfilter.c +180 -0
- data/src/rbgtkrecentfilterinfo.c +197 -0
- data/src/rbgtkrecentinfo.c +232 -0
- data/src/rbgtkrecentmanager.c +164 -0
- data/src/rbgtkruler.c +82 -0
- data/src/rbgtkscale.c +47 -0
- data/src/rbgtkscalebutton.c +115 -0
- data/src/rbgtkscrollbar.c +21 -0
- data/src/rbgtkscrolledwindow.c +160 -0
- data/src/rbgtkselection.c +171 -0
- data/src/rbgtkselectiondata.c +333 -0
- data/src/rbgtkseparator.c +21 -0
- data/src/rbgtkseparatormenuitem.c +28 -0
- data/src/rbgtkseparatortoolitem.c +40 -0
- data/src/rbgtksettings.c +225 -0
- data/src/rbgtksizegroup.c +74 -0
- data/src/rbgtksocket.c +72 -0
- data/src/rbgtkspinbutton.c +138 -0
- data/src/rbgtkstatusbar.c +90 -0
- data/src/rbgtkstatusicon.c +120 -0
- data/src/rbgtkstock.c +264 -0
- data/src/rbgtkstyle.c +722 -0
- data/src/rbgtktable.c +190 -0
- data/src/rbgtktargetlist.c +148 -0
- data/src/rbgtktearoffmenuitem.c +30 -0
- data/src/rbgtktextappearance.c +173 -0
- data/src/rbgtktextattributes.c +209 -0
- data/src/rbgtktextbuffer.c +993 -0
- data/src/rbgtktextchild.c +49 -0
- data/src/rbgtktextiter.c +553 -0
- data/src/rbgtktextmark.c +87 -0
- data/src/rbgtktexttag.c +66 -0
- data/src/rbgtktexttagtable.c +94 -0
- data/src/rbgtktextview.c +351 -0
- data/src/rbgtktoggleaction.c +76 -0
- data/src/rbgtktogglebutton.c +84 -0
- data/src/rbgtktoggletoolbutton.c +70 -0
- data/src/rbgtktoolbar.c +373 -0
- data/src/rbgtktoolbutton.c +75 -0
- data/src/rbgtktoolitem.c +184 -0
- data/src/rbgtktooltip.c +76 -0
- data/src/rbgtktooltips.c +107 -0
- data/src/rbgtktreedragdest.c +19 -0
- data/src/rbgtktreedragsource.c +19 -0
- data/src/rbgtktreeiter.c +259 -0
- data/src/rbgtktreemodel.c +256 -0
- data/src/rbgtktreemodelfilter.c +214 -0
- data/src/rbgtktreemodelsort.c +113 -0
- data/src/rbgtktreepath.c +195 -0
- data/src/rbgtktreerowreference.c +168 -0
- data/src/rbgtktreeselection.c +235 -0
- data/src/rbgtktreesortable.c +127 -0
- data/src/rbgtktreestore.c +379 -0
- data/src/rbgtktreeview.c +881 -0
- data/src/rbgtktreeviewcolumn.c +331 -0
- data/src/rbgtkuimanager.c +210 -0
- data/src/rbgtkvbbox.c +31 -0
- data/src/rbgtkvbox.c +38 -0
- data/src/rbgtkviewport.c +33 -0
- data/src/rbgtkvolumebutton.c +36 -0
- data/src/rbgtkvpaned.c +31 -0
- data/src/rbgtkvruler.c +30 -0
- data/src/rbgtkvscale.c +45 -0
- data/src/rbgtkvscrollbar.c +38 -0
- data/src/rbgtkvseparator.c +30 -0
- data/src/rbgtkwidget.c +1414 -0
- data/src/rbgtkwindow.c +822 -0
- data/src/rbgtkwindowgroup.c +48 -0
- data/test/gtk-test-utils.rb +15 -0
- data/test/run-test.rb +30 -0
- data/test/test_gc.rb +25 -0
- data/test/test_gdk.rb +18 -0
- data/test/test_gdk_color.rb +10 -0
- data/test/test_gdk_display.rb +37 -0
- data/test/test_gdk_event.rb +11 -0
- data/test/test_gdk_gc.rb +7 -0
- data/test/test_gdk_keymap.rb +8 -0
- data/test/test_gdk_pango.rb +9 -0
- data/test/test_gdk_selection_data.rb +17 -0
- data/test/test_gdk_window.rb +29 -0
- data/test/test_gdk_window_attribute.rb +9 -0
- data/test/test_gtk_about_dialog.rb +14 -0
- data/test/test_gtk_buildable.rb +66 -0
- data/test/test_gtk_builder.rb +188 -0
- data/test/test_gtk_entry.rb +18 -0
- data/test/test_gtk_icon_theme.rb +30 -0
- data/test/test_gtk_image.rb +8 -0
- data/test/test_gtk_list_store.rb +65 -0
- data/test/test_gtk_menu_item.rb +13 -0
- data/test/test_gtk_rc_style.rb +14 -0
- data/test/test_gtk_tree_path.rb +20 -0
- data/test/test_gtk_unix_print.rb +14 -0
- data/test/test_gtk_widget.rb +32 -0
- metadata +393 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/************************************************
|
3
|
+
|
4
|
+
rbgtkconversions.h -
|
5
|
+
|
6
|
+
Copyright (C) 2008 Ruby-GNOME2 Project Team
|
7
|
+
************************************************/
|
8
|
+
|
9
|
+
#ifndef _RBGTKCONVERSIONS_H
|
10
|
+
#define _RBGTKCONVERSIONS_H
|
11
|
+
|
12
|
+
#include <rbgobject.h>
|
13
|
+
#include <gtk/gtk.h>
|
14
|
+
|
15
|
+
#include <rbgdkconversions.h>
|
16
|
+
|
17
|
+
#define GTKTREEPATH2RVAL(t) (BOXED2RVAL(t, GTK_TYPE_TREE_PATH))
|
18
|
+
#define RVAL2GTKTREEPATH(t) ((GtkTreePath *)RVAL2BOXED(t, GTK_TYPE_TREE_PATH))
|
19
|
+
#define GTKTREEITER2RVAL(i) (BOXED2RVAL(i, GTK_TYPE_TREE_ITER))
|
20
|
+
#define RVAL2GTKTREEITER(i) ((GtkTreeIter *)RVAL2BOXED(i, GTK_TYPE_TREE_ITER))
|
21
|
+
|
22
|
+
#define RVAL2GTKSTATETYPE(type) (RVAL2GENUM(type, GTK_TYPE_STATE_TYPE))
|
23
|
+
#define GTKRCFLAGS2RVAL(flags) (GFLAGS2RVAL(flags, GTK_TYPE_RC_FLAGS))
|
24
|
+
#define RVAL2GTKRCFLAGS(flags) (RVAL2GFLAGS(flags, GTK_TYPE_RC_FLAGS))
|
25
|
+
|
26
|
+
#endif /* _RBGTKCONVERSIONS_H */
|
data/src/rbgtkcurve.c
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/************************************************
|
3
|
+
|
4
|
+
rbgtkcurve.c -
|
5
|
+
|
6
|
+
$Author: mutoh $
|
7
|
+
$Date: 2006/05/07 23:51:20 $
|
8
|
+
|
9
|
+
Copyright (C) 2002,2003 Ruby-GNOME2 Project Team
|
10
|
+
Copyright (C) 1998-2000 Yukihiro Matsumoto,
|
11
|
+
Daisuke Kanda,
|
12
|
+
Hiroshi Igarashi
|
13
|
+
************************************************/
|
14
|
+
|
15
|
+
#include "global.h"
|
16
|
+
|
17
|
+
static VALUE
|
18
|
+
curve_initialize(self)
|
19
|
+
VALUE self;
|
20
|
+
{
|
21
|
+
RBGTK_INITIALIZE(self, gtk_curve_new());
|
22
|
+
return Qnil;
|
23
|
+
}
|
24
|
+
|
25
|
+
static VALUE
|
26
|
+
curve_reset(self)
|
27
|
+
VALUE self;
|
28
|
+
{
|
29
|
+
gtk_curve_reset(GTK_CURVE(RVAL2GOBJ(self)));
|
30
|
+
return self;
|
31
|
+
}
|
32
|
+
|
33
|
+
static VALUE
|
34
|
+
curve_set_gamma(self, gamma)
|
35
|
+
VALUE self, gamma;
|
36
|
+
{
|
37
|
+
gtk_curve_set_gamma(GTK_CURVE(RVAL2GOBJ(self)), NUM2DBL(gamma));
|
38
|
+
return self;
|
39
|
+
}
|
40
|
+
|
41
|
+
static VALUE
|
42
|
+
curve_set_range(self, min_x, max_x, min_y, max_y)
|
43
|
+
VALUE self, min_x, max_x, min_y, max_y;
|
44
|
+
{
|
45
|
+
gtk_curve_set_range(GTK_CURVE(RVAL2GOBJ(self)),
|
46
|
+
NUM2DBL(min_x), NUM2DBL(max_x),
|
47
|
+
NUM2DBL(min_y), NUM2DBL(max_y));
|
48
|
+
return self;
|
49
|
+
}
|
50
|
+
|
51
|
+
static VALUE
|
52
|
+
curve_set_vector(self, length, vector)
|
53
|
+
VALUE self, length, vector;
|
54
|
+
{
|
55
|
+
gint len = NUM2INT(length);
|
56
|
+
gfloat *c_vec;
|
57
|
+
gint i;
|
58
|
+
|
59
|
+
c_vec = ALLOCA_N(gfloat, len);
|
60
|
+
for (i = 0; i < len; i++)
|
61
|
+
c_vec[i] = NUM2DBL(RARRAY_PTR(vector)[i]);
|
62
|
+
|
63
|
+
gtk_curve_set_vector(GTK_CURVE(RVAL2GOBJ(self)), len, c_vec);
|
64
|
+
|
65
|
+
return self;
|
66
|
+
}
|
67
|
+
|
68
|
+
static VALUE
|
69
|
+
curve_get_vector(self, length)
|
70
|
+
VALUE self, length;
|
71
|
+
{
|
72
|
+
gint len = NUM2INT(length);
|
73
|
+
gfloat *c_vec;
|
74
|
+
gint i;
|
75
|
+
VALUE vector = rb_ary_new2(len);
|
76
|
+
|
77
|
+
c_vec = ALLOCA_N(gfloat, len);
|
78
|
+
gtk_curve_get_vector(GTK_CURVE(RVAL2GOBJ(self)), len, c_vec);
|
79
|
+
for (i = 0; i < len; i++)
|
80
|
+
rb_ary_push(vector, rb_float_new(c_vec[i]));
|
81
|
+
|
82
|
+
return vector;
|
83
|
+
}
|
84
|
+
|
85
|
+
void
|
86
|
+
Init_gtk_curve()
|
87
|
+
{
|
88
|
+
VALUE gCurve = G_DEF_CLASS(GTK_TYPE_CURVE, "Curve", mGtk);
|
89
|
+
|
90
|
+
rb_define_method(gCurve, "initialize", curve_initialize, 0);
|
91
|
+
rb_define_method(gCurve, "reset", curve_reset, 0);
|
92
|
+
rb_define_method(gCurve, "set_gamma", curve_set_gamma, 1);
|
93
|
+
rb_define_method(gCurve, "set_range", curve_set_range, 4);
|
94
|
+
rb_define_method(gCurve, "set_vector", curve_set_vector, 2);
|
95
|
+
rb_define_method(gCurve, "get_vector", curve_get_vector, 1);
|
96
|
+
|
97
|
+
/* GtkCurveType(from standard constants) */
|
98
|
+
|
99
|
+
G_DEF_CLASS(GTK_TYPE_CURVE_TYPE, "Type", gCurve);
|
100
|
+
G_DEF_CONSTANTS(gCurve, GTK_TYPE_CURVE_TYPE, "GTK_CURVE_");
|
101
|
+
|
102
|
+
G_DEF_SETTERS(gCurve);
|
103
|
+
}
|
104
|
+
|
105
|
+
|
data/src/rbgtkdialog.c
ADDED
@@ -0,0 +1,244 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/************************************************
|
3
|
+
|
4
|
+
rbgtkdialog.c -
|
5
|
+
|
6
|
+
$Author: ggc $
|
7
|
+
$Date: 2007/07/13 16:07:31 $
|
8
|
+
|
9
|
+
Copyright (C) 2002-2005 Ruby-GNOME2 Project Team
|
10
|
+
Copyright (C) 1998-2000 Yukihiro Matsumoto,
|
11
|
+
Daisuke Kanda,
|
12
|
+
Hiroshi Igarashi
|
13
|
+
************************************************/
|
14
|
+
|
15
|
+
#include "global.h"
|
16
|
+
|
17
|
+
#define _SELF(self) (GTK_DIALOG(RVAL2GOBJ(self)))
|
18
|
+
|
19
|
+
static ID id_to_a;
|
20
|
+
|
21
|
+
static VALUE
|
22
|
+
dialog_add_button(self, button_text, response_id)
|
23
|
+
VALUE self, button_text, response_id;
|
24
|
+
{
|
25
|
+
const gchar *name;
|
26
|
+
if (SYMBOL_P(button_text)) {
|
27
|
+
name = rb_id2name(SYM2ID(button_text));
|
28
|
+
} else {
|
29
|
+
name = RVAL2CSTR(button_text);
|
30
|
+
}
|
31
|
+
return GOBJ2RVAL(gtk_dialog_add_button(_SELF(self), name,
|
32
|
+
RVAL2GENUM(response_id, GTK_TYPE_RESPONSE_TYPE)));
|
33
|
+
}
|
34
|
+
|
35
|
+
VALUE
|
36
|
+
rbgtk_dialog_add_buttons_internal(self, button_ary)
|
37
|
+
VALUE self, button_ary;
|
38
|
+
{
|
39
|
+
int i;
|
40
|
+
GObject* obj = RVAL2GOBJ(self);
|
41
|
+
if (RARRAY_PTR(button_ary)[0] != Qnil){
|
42
|
+
g_object_freeze_notify(obj);
|
43
|
+
for (i = 0; i < RARRAY_LEN(button_ary); i++) {
|
44
|
+
Check_Type(RARRAY_PTR(button_ary)[i], T_ARRAY);
|
45
|
+
dialog_add_button(self, RARRAY_PTR(RARRAY_PTR(button_ary)[i])[0],
|
46
|
+
RARRAY_PTR(RARRAY_PTR(button_ary)[i])[1]);
|
47
|
+
}
|
48
|
+
g_object_thaw_notify(obj);
|
49
|
+
}
|
50
|
+
return self;
|
51
|
+
}
|
52
|
+
|
53
|
+
static VALUE
|
54
|
+
dialog_add_buttons(argc, argv, self)
|
55
|
+
int argc;
|
56
|
+
VALUE *argv;
|
57
|
+
VALUE self;
|
58
|
+
{
|
59
|
+
VALUE button_ary;
|
60
|
+
rb_scan_args(argc, argv, "*", &button_ary);
|
61
|
+
rbgtk_dialog_add_buttons_internal(self, button_ary);
|
62
|
+
return self;
|
63
|
+
}
|
64
|
+
|
65
|
+
static VALUE
|
66
|
+
dialog_initialize(argc, argv, self)
|
67
|
+
int argc;
|
68
|
+
VALUE *argv;
|
69
|
+
VALUE self;
|
70
|
+
{
|
71
|
+
VALUE title, parent, flags, button_ary;
|
72
|
+
rb_scan_args(argc, argv, "03*", &title, &parent, &flags, &button_ary);
|
73
|
+
|
74
|
+
if (argc == 0){
|
75
|
+
RBGTK_INITIALIZE(self, gtk_dialog_new());
|
76
|
+
} else if (argc > 0){
|
77
|
+
GtkDialog* dialog = GTK_DIALOG(g_object_new(GTK_TYPE_DIALOG, NULL));
|
78
|
+
GtkDialogFlags gflags = NIL_P(flags) ? 0 : RVAL2GFLAGS(flags, GTK_TYPE_DIALOG_FLAGS);
|
79
|
+
if (! NIL_P(title))
|
80
|
+
gtk_window_set_title(GTK_WINDOW(dialog), RVAL2CSTR(title));
|
81
|
+
if (! NIL_P(parent))
|
82
|
+
gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(RVAL2GOBJ(parent)));
|
83
|
+
|
84
|
+
if (gflags & GTK_DIALOG_MODAL)
|
85
|
+
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
|
86
|
+
if (gflags & GTK_DIALOG_DESTROY_WITH_PARENT)
|
87
|
+
gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
|
88
|
+
if (gflags & GTK_DIALOG_NO_SEPARATOR)
|
89
|
+
gtk_dialog_set_has_separator(dialog, FALSE);
|
90
|
+
|
91
|
+
RBGTK_INITIALIZE(self, dialog);
|
92
|
+
if (! NIL_P(button_ary))
|
93
|
+
rbgtk_dialog_add_buttons_internal(self, button_ary);
|
94
|
+
} else {
|
95
|
+
rb_raise(rb_eArgError, "invalid argument number");
|
96
|
+
}
|
97
|
+
return Qnil;
|
98
|
+
}
|
99
|
+
|
100
|
+
static VALUE
|
101
|
+
dialog_run(self)
|
102
|
+
VALUE self;
|
103
|
+
{
|
104
|
+
if (rb_block_given_p()){
|
105
|
+
VALUE ret = INT2NUM(gtk_dialog_run(_SELF(self)));
|
106
|
+
rb_yield(ret);
|
107
|
+
return ret;
|
108
|
+
} else {
|
109
|
+
return INT2NUM(gtk_dialog_run(_SELF(self)));
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
static VALUE
|
114
|
+
dialog_response(self, response_id)
|
115
|
+
VALUE self, response_id;
|
116
|
+
{
|
117
|
+
gtk_dialog_response(_SELF(self), NUM2INT(response_id));
|
118
|
+
return self;
|
119
|
+
}
|
120
|
+
|
121
|
+
static VALUE
|
122
|
+
dialog_add_action_widget(self, child, response_id)
|
123
|
+
VALUE self, child, response_id;
|
124
|
+
{
|
125
|
+
gtk_dialog_add_action_widget(_SELF(self), GTK_WIDGET(RVAL2GOBJ(child)),
|
126
|
+
NUM2INT(response_id));
|
127
|
+
return self;
|
128
|
+
}
|
129
|
+
|
130
|
+
static VALUE
|
131
|
+
dialog_set_default_response(self, response_id)
|
132
|
+
VALUE self, response_id;
|
133
|
+
{
|
134
|
+
gtk_dialog_set_default_response(_SELF(self), NUM2INT(response_id));
|
135
|
+
return self;
|
136
|
+
}
|
137
|
+
|
138
|
+
static VALUE
|
139
|
+
dialog_set_response_sensitive(self, response_id, setting)
|
140
|
+
VALUE self, response_id, setting;
|
141
|
+
{
|
142
|
+
gtk_dialog_set_response_sensitive(_SELF(self), NUM2INT(response_id), RVAL2CBOOL(setting));
|
143
|
+
return self;
|
144
|
+
}
|
145
|
+
|
146
|
+
#if GTK_CHECK_VERSION(2,6,0)
|
147
|
+
static VALUE
|
148
|
+
dialog_s_alternative_dialog_button_order(self, screen)
|
149
|
+
VALUE self, screen;
|
150
|
+
{
|
151
|
+
gboolean ret = gtk_alternative_dialog_button_order(NIL_P(screen) ? NULL :
|
152
|
+
GDK_SCREEN(RVAL2GOBJ(screen)));
|
153
|
+
return CBOOL2RVAL(ret);
|
154
|
+
}
|
155
|
+
|
156
|
+
/* Use gtk_dialog_set_alternative_button_order_from_array() instead.
|
157
|
+
void gtk_dialog_set_alternative_button_order
|
158
|
+
(GtkDialog *dialog,
|
159
|
+
gint first_response_id,
|
160
|
+
...);
|
161
|
+
*/
|
162
|
+
|
163
|
+
static VALUE
|
164
|
+
dialog_set_alternative_button_order(self, new_order)
|
165
|
+
VALUE self, new_order;
|
166
|
+
{
|
167
|
+
gint i;
|
168
|
+
gint len = RARRAY_LEN(new_order);
|
169
|
+
gint* gnew_order = g_new(gint, len);
|
170
|
+
|
171
|
+
for (i = 0; i < len; i++){
|
172
|
+
gnew_order[i] = NUM2INT(RARRAY_PTR(new_order)[i]);
|
173
|
+
}
|
174
|
+
|
175
|
+
gtk_dialog_set_alternative_button_order_from_array(_SELF(self), len, gnew_order);
|
176
|
+
g_free(gnew_order);
|
177
|
+
return self;
|
178
|
+
}
|
179
|
+
|
180
|
+
#endif
|
181
|
+
|
182
|
+
static VALUE
|
183
|
+
dialog_vbox(self)
|
184
|
+
VALUE self;
|
185
|
+
{
|
186
|
+
return GOBJ2RVAL(_SELF(self)->vbox);
|
187
|
+
}
|
188
|
+
|
189
|
+
static VALUE
|
190
|
+
dialog_action_area(self)
|
191
|
+
VALUE self;
|
192
|
+
{
|
193
|
+
return GOBJ2RVAL(_SELF(self)->action_area);
|
194
|
+
}
|
195
|
+
|
196
|
+
#if GTK_CHECK_VERSION(2,8,0)
|
197
|
+
static VALUE
|
198
|
+
dialog_get_response_for_widget(self, widget)
|
199
|
+
VALUE self, widget;
|
200
|
+
{
|
201
|
+
return INT2NUM(gtk_dialog_get_response_for_widget(_SELF(self), RVAL2GOBJ(widget)));
|
202
|
+
}
|
203
|
+
#endif
|
204
|
+
|
205
|
+
void
|
206
|
+
Init_gtk_dialog()
|
207
|
+
{
|
208
|
+
VALUE gDialog = G_DEF_CLASS(GTK_TYPE_DIALOG, "Dialog", mGtk);
|
209
|
+
|
210
|
+
id_to_a = rb_intern("to_a");
|
211
|
+
|
212
|
+
rb_define_method(gDialog, "initialize", dialog_initialize, -1);
|
213
|
+
rb_define_method(gDialog, "run", dialog_run, 0);
|
214
|
+
rb_define_method(gDialog, "response", dialog_response, 1);
|
215
|
+
rb_define_method(gDialog, "add_button", dialog_add_button, 2);
|
216
|
+
rb_define_method(gDialog, "add_buttons", dialog_add_buttons, -1);
|
217
|
+
rb_define_method(gDialog, "add_action_widget", dialog_add_action_widget, 2);
|
218
|
+
rb_define_method(gDialog, "set_default_response", dialog_set_default_response, 1);
|
219
|
+
|
220
|
+
#if GTK_CHECK_VERSION(2,6,0)
|
221
|
+
rb_define_singleton_method(gDialog, "alternative_dialog_button_order?",
|
222
|
+
dialog_s_alternative_dialog_button_order, 1);
|
223
|
+
rb_define_method(gDialog, "set_alternative_button_order", dialog_set_alternative_button_order, 1);
|
224
|
+
#endif
|
225
|
+
|
226
|
+
rb_define_method(gDialog, "set_response_sensitive", dialog_set_response_sensitive, 2);
|
227
|
+
rb_define_method(gDialog, "vbox", dialog_vbox, 0);
|
228
|
+
rb_define_method(gDialog, "action_area", dialog_action_area, 0);
|
229
|
+
|
230
|
+
#if GTK_CHECK_VERSION(2,8,0)
|
231
|
+
rb_define_method(gDialog, "get_response", dialog_get_response_for_widget, 1);
|
232
|
+
rb_define_method(gDialog, "get_response_for_widget", dialog_get_response_for_widget, 1);
|
233
|
+
#endif
|
234
|
+
|
235
|
+
G_DEF_SETTERS(gDialog);
|
236
|
+
|
237
|
+
/* GtkDialogFlags */
|
238
|
+
G_DEF_CLASS(GTK_TYPE_DIALOG_FLAGS, "Flags", gDialog);
|
239
|
+
G_DEF_CONSTANTS(gDialog, GTK_TYPE_DIALOG_FLAGS, "GTK_DIALOG_");
|
240
|
+
|
241
|
+
/* GtkResponseType */
|
242
|
+
G_DEF_CLASS(GTK_TYPE_RESPONSE_TYPE, "ResponseType", gDialog);
|
243
|
+
G_DEF_CONSTANTS(gDialog, GTK_TYPE_RESPONSE_TYPE, "GTK_");
|
244
|
+
}
|
data/src/rbgtkdrag.c
ADDED
@@ -0,0 +1,436 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/************************************************
|
3
|
+
|
4
|
+
rbgtkdrag.c -
|
5
|
+
|
6
|
+
$Author: ggc $
|
7
|
+
$Date: 2007/07/13 16:07:31 $
|
8
|
+
|
9
|
+
Copyright (C) 2002-2006 Masao Mutoh
|
10
|
+
************************************************/
|
11
|
+
|
12
|
+
|
13
|
+
#include "global.h"
|
14
|
+
|
15
|
+
#define RVAL2DC(c) (GDK_DRAG_CONTEXT(RVAL2GOBJ(c)))
|
16
|
+
#define RVAL2WIDGET(w) (GTK_WIDGET(RVAL2GOBJ(w)))
|
17
|
+
|
18
|
+
GtkTargetEntry*
|
19
|
+
rbgtk_get_target_entry(targets)
|
20
|
+
VALUE targets;
|
21
|
+
{
|
22
|
+
VALUE ary;
|
23
|
+
VALUE e_target, e_flags, e_info;
|
24
|
+
GtkTargetEntry *entries;
|
25
|
+
int i, n_targets;
|
26
|
+
|
27
|
+
if (NIL_P(targets)) return NULL;
|
28
|
+
Check_Type(targets, T_ARRAY);
|
29
|
+
|
30
|
+
n_targets = RARRAY_LEN(targets);
|
31
|
+
entries = ALLOC_N(GtkTargetEntry, n_targets);
|
32
|
+
|
33
|
+
for (i = 0; i < n_targets; i++) {
|
34
|
+
ary = rb_ary_entry(targets, i);
|
35
|
+
Check_Type(ary, T_ARRAY);
|
36
|
+
e_target = rb_ary_entry(ary, 0);
|
37
|
+
e_flags = rb_ary_entry(ary, 1);
|
38
|
+
e_info = rb_ary_entry(ary, 2);
|
39
|
+
|
40
|
+
entries[i].target = NIL_P(e_target) ? NULL:RVAL2CSTR(e_target);
|
41
|
+
entries[i].flags = NIL_P(e_flags) ? 0:RVAL2GFLAGS(e_flags, GTK_TYPE_TARGET_FLAGS);
|
42
|
+
entries[i].info = NIL_P(e_info) ? 0:NUM2INT(e_info);
|
43
|
+
|
44
|
+
}
|
45
|
+
return entries;
|
46
|
+
}
|
47
|
+
|
48
|
+
static VALUE
|
49
|
+
gtkdrag_dest_set(self, widget, flags, targets, actions)
|
50
|
+
VALUE self, widget, flags, targets, actions;
|
51
|
+
{
|
52
|
+
int num;
|
53
|
+
GtkTargetEntry* entries = rbgtk_get_target_entry(targets);
|
54
|
+
if (entries){
|
55
|
+
num = RARRAY_LEN(targets);
|
56
|
+
|
57
|
+
gtk_drag_dest_set(RVAL2WIDGET(widget), RVAL2GFLAGS(flags, GTK_TYPE_DEST_DEFAULTS),
|
58
|
+
entries,
|
59
|
+
num, RVAL2GFLAGS(actions, GDK_TYPE_DRAG_ACTION));
|
60
|
+
}
|
61
|
+
else
|
62
|
+
{
|
63
|
+
gtk_drag_dest_set(RVAL2WIDGET(widget), RVAL2GFLAGS(flags, GTK_TYPE_DEST_DEFAULTS),
|
64
|
+
NULL, 0, RVAL2GFLAGS(actions, GDK_TYPE_DRAG_ACTION));
|
65
|
+
}
|
66
|
+
return self;
|
67
|
+
}
|
68
|
+
|
69
|
+
static VALUE
|
70
|
+
gtkdrag_dest_set_proxy(self, widget, proxy_window, protocol, use_coordinates)
|
71
|
+
VALUE self, widget, proxy_window, protocol, use_coordinates;
|
72
|
+
{
|
73
|
+
gtk_drag_dest_set_proxy(RVAL2WIDGET(widget),
|
74
|
+
GDK_WINDOW(RVAL2GOBJ(proxy_window)),
|
75
|
+
RVAL2GENUM(protocol, GDK_TYPE_DRAG_PROTOCOL),
|
76
|
+
RVAL2CBOOL(use_coordinates));
|
77
|
+
return self;
|
78
|
+
}
|
79
|
+
|
80
|
+
static VALUE
|
81
|
+
gtkdrag_dest_unset(self, widget)
|
82
|
+
VALUE self,widget;
|
83
|
+
{
|
84
|
+
gtk_drag_dest_unset(RVAL2WIDGET(widget));
|
85
|
+
return self;
|
86
|
+
}
|
87
|
+
|
88
|
+
static VALUE
|
89
|
+
gtkdrag_dest_find_target(argc, argv, self)
|
90
|
+
int argc;
|
91
|
+
VALUE *argv;
|
92
|
+
VALUE self;
|
93
|
+
{
|
94
|
+
VALUE widget, context, target_list;
|
95
|
+
GdkAtom ret;
|
96
|
+
rb_scan_args(argc, argv, "21", &widget, &context, &target_list);
|
97
|
+
|
98
|
+
ret = gtk_drag_dest_find_target(
|
99
|
+
RVAL2WIDGET(widget), RVAL2DC(context),
|
100
|
+
NIL_P(target_list) ? NULL : RVAL2BOXED(target_list, GTK_TYPE_TARGET_LIST));
|
101
|
+
|
102
|
+
return BOXED2RVAL(ret, GDK_TYPE_ATOM);
|
103
|
+
}
|
104
|
+
|
105
|
+
static VALUE
|
106
|
+
gtkdrag_dest_get_target_list(self, widget)
|
107
|
+
VALUE self, widget;
|
108
|
+
{
|
109
|
+
GtkTargetList* list = gtk_drag_dest_get_target_list(RVAL2WIDGET(widget));
|
110
|
+
return BOXED2RVAL(list, GTK_TYPE_TARGET_LIST);
|
111
|
+
}
|
112
|
+
|
113
|
+
static VALUE
|
114
|
+
gtkdrag_dest_set_target_list(self, widget, target_list)
|
115
|
+
VALUE self, widget, target_list;
|
116
|
+
{
|
117
|
+
gtk_drag_dest_set_target_list(
|
118
|
+
RVAL2WIDGET(widget),
|
119
|
+
NIL_P(target_list) ? NULL : RVAL2BOXED(target_list, GTK_TYPE_TARGET_LIST));
|
120
|
+
|
121
|
+
return self;
|
122
|
+
}
|
123
|
+
|
124
|
+
|
125
|
+
#if GTK_CHECK_VERSION(2,6,0)
|
126
|
+
static VALUE
|
127
|
+
gtkdrag_dest_add_text_targets(self, widget)
|
128
|
+
VALUE self, widget;
|
129
|
+
{
|
130
|
+
gtk_drag_dest_add_text_targets(RVAL2WIDGET(widget));
|
131
|
+
return self;
|
132
|
+
}
|
133
|
+
static VALUE
|
134
|
+
gtkdrag_dest_add_image_targets(self, widget)
|
135
|
+
VALUE self, widget;
|
136
|
+
{
|
137
|
+
gtk_drag_dest_add_image_targets(RVAL2WIDGET(widget));
|
138
|
+
return self;
|
139
|
+
}
|
140
|
+
static VALUE
|
141
|
+
gtkdrag_dest_add_uri_targets(self, widget)
|
142
|
+
VALUE self, widget;
|
143
|
+
{
|
144
|
+
gtk_drag_dest_add_uri_targets(RVAL2WIDGET(widget));
|
145
|
+
return self;
|
146
|
+
}
|
147
|
+
#endif
|
148
|
+
|
149
|
+
#if GTK_CHECK_VERSION(2,10,0)
|
150
|
+
static VALUE
|
151
|
+
gtkdrag_dest_set_track_motion(self, widget, track_motion)
|
152
|
+
VALUE self, widget, track_motion;
|
153
|
+
{
|
154
|
+
gtk_drag_dest_set_track_motion(RVAL2WIDGET(widget), RVAL2CBOOL(track_motion));
|
155
|
+
return self;
|
156
|
+
}
|
157
|
+
|
158
|
+
static VALUE
|
159
|
+
gtkdrag_dest_get_track_motion(self, widget)
|
160
|
+
VALUE self, widget;
|
161
|
+
{
|
162
|
+
return CBOOL2RVAL(gtk_drag_dest_get_track_motion(RVAL2WIDGET(widget)));
|
163
|
+
}
|
164
|
+
#endif
|
165
|
+
|
166
|
+
static VALUE
|
167
|
+
gtkdrag_finish(self, context, success, del, time)
|
168
|
+
VALUE self, context, success, del, time;
|
169
|
+
{
|
170
|
+
gtk_drag_finish(RVAL2DC(context), RVAL2CBOOL(success),
|
171
|
+
RVAL2CBOOL(del), NUM2UINT(time));
|
172
|
+
return self;
|
173
|
+
}
|
174
|
+
|
175
|
+
static VALUE
|
176
|
+
gtkdrag_get_data(self, widget, context, target, time)
|
177
|
+
VALUE self, widget, context, target, time;
|
178
|
+
{
|
179
|
+
gtk_drag_get_data(RVAL2WIDGET(widget), RVAL2DC(context), RVAL2ATOM(target),
|
180
|
+
NUM2UINT(time));
|
181
|
+
return self;
|
182
|
+
}
|
183
|
+
|
184
|
+
static VALUE
|
185
|
+
gtkdrag_get_source_widget(self, context)
|
186
|
+
VALUE self, context;
|
187
|
+
{
|
188
|
+
return GOBJ2RVAL(gtk_drag_get_source_widget(RVAL2DC(context)));
|
189
|
+
}
|
190
|
+
|
191
|
+
static VALUE
|
192
|
+
gtkdrag_highlight(self, widget)
|
193
|
+
VALUE self, widget;
|
194
|
+
{
|
195
|
+
gtk_drag_highlight(RVAL2WIDGET(widget));
|
196
|
+
return self;
|
197
|
+
}
|
198
|
+
|
199
|
+
static VALUE
|
200
|
+
gtkdrag_unhighlight(self, widget)
|
201
|
+
VALUE self, widget;
|
202
|
+
{
|
203
|
+
gtk_drag_unhighlight(RVAL2WIDGET(widget));
|
204
|
+
return self;
|
205
|
+
}
|
206
|
+
|
207
|
+
static VALUE
|
208
|
+
gtkdrag_begin(self, widget, target_list, actions, button, event)
|
209
|
+
VALUE self, widget, target_list, actions, button, event;
|
210
|
+
{
|
211
|
+
return GOBJ2RVAL(gtk_drag_begin(RVAL2WIDGET(widget),
|
212
|
+
RVAL2BOXED(target_list, GTK_TYPE_TARGET_LIST),
|
213
|
+
RVAL2GFLAGS(actions, GDK_TYPE_DRAG_ACTION),
|
214
|
+
NUM2INT(button),
|
215
|
+
RVAL2GEV(event)));
|
216
|
+
}
|
217
|
+
|
218
|
+
static VALUE
|
219
|
+
gtkdrag_set_icon(argc, argv, self)
|
220
|
+
int argc;
|
221
|
+
VALUE *argv;
|
222
|
+
VALUE self;
|
223
|
+
{
|
224
|
+
VALUE context, obj, pixmap = Qnil, mask = Qnil, hot_x, hot_y;
|
225
|
+
|
226
|
+
if (argc == 6) {
|
227
|
+
rb_scan_args(argc, argv, "60", &context, &obj, &pixmap, &mask, &hot_x, &hot_y);
|
228
|
+
gtk_drag_set_icon_pixmap(RVAL2DC(context),
|
229
|
+
GDK_COLORMAP(RVAL2GOBJ(obj)),
|
230
|
+
GDK_PIXMAP(RVAL2GOBJ(pixmap)),
|
231
|
+
GDK_BITMAP(RVAL2GOBJ(mask)),
|
232
|
+
NUM2INT(hot_x), NUM2INT(hot_y));
|
233
|
+
} else {
|
234
|
+
rb_scan_args(argc, argv, "40", &context, &obj, &hot_x, &hot_y);
|
235
|
+
|
236
|
+
if (TYPE(obj) == T_SYMBOL){
|
237
|
+
gtk_drag_set_icon_stock(RVAL2DC(context), rb_id2name(SYM2ID(obj)),
|
238
|
+
NUM2INT(hot_x), NUM2INT(hot_y));
|
239
|
+
} else if (rb_obj_is_kind_of(obj, GTYPE2CLASS(GTK_TYPE_WIDGET))){
|
240
|
+
gtk_drag_set_icon_widget(RVAL2DC(context), RVAL2WIDGET(obj),
|
241
|
+
NUM2INT(hot_x), NUM2INT(hot_y));
|
242
|
+
} else if (rb_obj_is_kind_of(obj, GTYPE2CLASS(GDK_TYPE_PIXBUF))){
|
243
|
+
gtk_drag_set_icon_pixbuf(RVAL2DC(context),
|
244
|
+
GDK_PIXBUF(RVAL2GOBJ(obj)),
|
245
|
+
NUM2INT(hot_x), NUM2INT(hot_y));
|
246
|
+
} else {
|
247
|
+
rb_raise(rb_eArgError, "invalid argument %s", rb_class2name(CLASS_OF(obj)));
|
248
|
+
}
|
249
|
+
}
|
250
|
+
return self;
|
251
|
+
}
|
252
|
+
|
253
|
+
#if GTK_CHECK_VERSION(2,8,0)
|
254
|
+
static VALUE
|
255
|
+
gtkdrag_set_icon_name(self, context, name, hot_x, hot_y)
|
256
|
+
VALUE self, context, name, hot_x, hot_y;
|
257
|
+
{
|
258
|
+
gtk_drag_set_icon_name(RVAL2DC(context), RVAL2CSTR(name), NUM2INT(hot_x), NUM2INT(hot_y));
|
259
|
+
return self;
|
260
|
+
}
|
261
|
+
#endif
|
262
|
+
|
263
|
+
static VALUE
|
264
|
+
gtkdrag_set_icon_default(self, context)
|
265
|
+
VALUE self, context;
|
266
|
+
{
|
267
|
+
gtk_drag_set_icon_default(RVAL2DC(context));
|
268
|
+
return self;
|
269
|
+
}
|
270
|
+
|
271
|
+
static VALUE
|
272
|
+
gtkdrag_check_threshold(self, widget, start_x, start_y, current_x, current_y)
|
273
|
+
VALUE self, widget, start_x, start_y, current_x, current_y;
|
274
|
+
{
|
275
|
+
return CBOOL2RVAL(gtk_drag_check_threshold(RVAL2WIDGET(widget),
|
276
|
+
NUM2INT(start_x), NUM2INT(start_y),
|
277
|
+
NUM2INT(current_x), NUM2INT(current_y)));
|
278
|
+
}
|
279
|
+
|
280
|
+
static VALUE
|
281
|
+
gtkdrag_source_set(self, widget, flags, targets, actions)
|
282
|
+
VALUE self, widget, flags, targets, actions;
|
283
|
+
{
|
284
|
+
gtk_drag_source_set(RVAL2WIDGET(widget), RVAL2GFLAGS(flags, GDK_TYPE_MODIFIER_TYPE),
|
285
|
+
rbgtk_get_target_entry(targets),
|
286
|
+
RARRAY_LEN(targets),
|
287
|
+
RVAL2GFLAGS(actions, GDK_TYPE_DRAG_ACTION));
|
288
|
+
return self;
|
289
|
+
}
|
290
|
+
|
291
|
+
static VALUE
|
292
|
+
gtkdrag_source_set_icon(argc, argv, self)
|
293
|
+
int argc;
|
294
|
+
VALUE *argv;
|
295
|
+
VALUE self;
|
296
|
+
{
|
297
|
+
VALUE widget, obj, pixmap = Qnil, mask = Qnil;
|
298
|
+
|
299
|
+
rb_scan_args(argc, argv, "22", &widget, &obj, &pixmap, &mask);
|
300
|
+
if (argc == 4){
|
301
|
+
gtk_drag_source_set_icon(RVAL2WIDGET(widget), GDK_COLORMAP(RVAL2GOBJ(obj)),
|
302
|
+
GDK_PIXMAP(RVAL2GOBJ(pixmap)),
|
303
|
+
GDK_BITMAP(RVAL2GOBJ(mask)));
|
304
|
+
} else if (argc == 2){
|
305
|
+
if (TYPE(obj) == T_SYMBOL){
|
306
|
+
gtk_drag_source_set_icon_stock(RVAL2WIDGET(widget), rb_id2name(SYM2ID(obj)));
|
307
|
+
} else {
|
308
|
+
gtk_drag_source_set_icon_pixbuf(RVAL2WIDGET(widget), GDK_PIXBUF(RVAL2GOBJ(obj)));
|
309
|
+
}
|
310
|
+
} else {
|
311
|
+
rb_raise(rb_eArgError, "need 2 or 4 arguments");
|
312
|
+
}
|
313
|
+
return self;
|
314
|
+
}
|
315
|
+
|
316
|
+
#if GTK_CHECK_VERSION(2,8,0)
|
317
|
+
static VALUE
|
318
|
+
gtkdrag_source_set_icon_name(self, widget, icon_name)
|
319
|
+
VALUE self, widget, icon_name;
|
320
|
+
{
|
321
|
+
gtk_drag_source_set_icon_name(RVAL2WIDGET(widget), RVAL2CSTR(icon_name));
|
322
|
+
return self;
|
323
|
+
}
|
324
|
+
#endif
|
325
|
+
|
326
|
+
static VALUE
|
327
|
+
gtkdrag_source_unset(self, widget)
|
328
|
+
VALUE self, widget;
|
329
|
+
{
|
330
|
+
gtk_drag_source_unset(RVAL2WIDGET(widget));
|
331
|
+
return self;
|
332
|
+
}
|
333
|
+
|
334
|
+
#if GTK_CHECK_VERSION(2,4,0)
|
335
|
+
static VALUE
|
336
|
+
gtkdrag_source_set_target_list(self, widget, targetlist)
|
337
|
+
VALUE self, widget, targetlist;
|
338
|
+
{
|
339
|
+
GtkTargetList* tlist = NULL;
|
340
|
+
if (! NIL_P(targetlist))
|
341
|
+
tlist = (GtkTargetList*)RVAL2BOXED(targetlist, GTK_TYPE_TARGET_LIST);
|
342
|
+
|
343
|
+
gtk_drag_source_set_target_list(RVAL2WIDGET(widget),tlist);
|
344
|
+
return self;
|
345
|
+
}
|
346
|
+
|
347
|
+
static VALUE
|
348
|
+
gtkdrag_source_get_target_list(self, widget)
|
349
|
+
VALUE self, widget;
|
350
|
+
{
|
351
|
+
GtkTargetList* ret = gtk_drag_source_get_target_list(RVAL2WIDGET(widget));
|
352
|
+
return NIL_P(ret) ? Qnil : BOXED2RVAL(ret, GTK_TYPE_TARGET_LIST);
|
353
|
+
}
|
354
|
+
#endif
|
355
|
+
|
356
|
+
#if GTK_CHECK_VERSION(2,6,0)
|
357
|
+
static VALUE
|
358
|
+
gtkdrag_source_add_text_targets(self, widget)
|
359
|
+
VALUE self, widget;
|
360
|
+
{
|
361
|
+
gtk_drag_source_add_text_targets(RVAL2WIDGET(widget));
|
362
|
+
return self;
|
363
|
+
}
|
364
|
+
static VALUE
|
365
|
+
gtkdrag_source_add_image_targets(self, widget)
|
366
|
+
VALUE self, widget;
|
367
|
+
{
|
368
|
+
gtk_drag_source_add_image_targets(RVAL2WIDGET(widget));
|
369
|
+
return self;
|
370
|
+
}
|
371
|
+
static VALUE
|
372
|
+
gtkdrag_source_add_uri_targets(self, widget)
|
373
|
+
VALUE self, widget;
|
374
|
+
{
|
375
|
+
gtk_drag_source_add_uri_targets(RVAL2WIDGET(widget));
|
376
|
+
return self;
|
377
|
+
}
|
378
|
+
#endif
|
379
|
+
|
380
|
+
void
|
381
|
+
Init_gtk_drag()
|
382
|
+
{
|
383
|
+
VALUE mGtkDrag = rb_define_module_under(mGtk, "Drag");
|
384
|
+
|
385
|
+
rb_define_module_function(mGtkDrag, "dest_set", gtkdrag_dest_set, 4);
|
386
|
+
rb_define_module_function(mGtkDrag, "dest_set_proxy", gtkdrag_dest_set_proxy, 4);
|
387
|
+
rb_define_module_function(mGtkDrag, "dest_unset", gtkdrag_dest_unset, 1);
|
388
|
+
rb_define_module_function(mGtkDrag, "dest_find_target", gtkdrag_dest_find_target, -1);
|
389
|
+
rb_define_module_function(mGtkDrag, "dest_get_target_list", gtkdrag_dest_get_target_list, 1);
|
390
|
+
rb_define_module_function(mGtkDrag, "dest_set_target_list", gtkdrag_dest_set_target_list, 2);
|
391
|
+
#if GTK_CHECK_VERSION(2,6,0)
|
392
|
+
rb_define_module_function(mGtkDrag, "dest_add_text_targets", gtkdrag_dest_add_text_targets, 1);
|
393
|
+
rb_define_module_function(mGtkDrag, "dest_add_image_targets", gtkdrag_dest_add_image_targets, 1);
|
394
|
+
rb_define_module_function(mGtkDrag, "dest_add_uri_targets", gtkdrag_dest_add_uri_targets, 1);
|
395
|
+
#endif
|
396
|
+
#if GTK_CHECK_VERSION(2,10,0)
|
397
|
+
rb_define_module_function(mGtkDrag, "dest_set_track_motion", gtkdrag_dest_set_track_motion, 2);
|
398
|
+
rb_define_module_function(mGtkDrag, "dest_get_track_motion", gtkdrag_dest_get_track_motion, 1);
|
399
|
+
#endif
|
400
|
+
rb_define_module_function(mGtkDrag, "finish", gtkdrag_finish, 4);
|
401
|
+
rb_define_module_function(mGtkDrag, "get_data", gtkdrag_get_data, 4);
|
402
|
+
rb_define_module_function(mGtkDrag, "get_source_widget", gtkdrag_get_source_widget, 1);
|
403
|
+
rb_define_module_function(mGtkDrag, "highlight", gtkdrag_highlight, 1);
|
404
|
+
rb_define_module_function(mGtkDrag, "unhighlight", gtkdrag_unhighlight, 1);
|
405
|
+
rb_define_module_function(mGtkDrag, "begin", gtkdrag_begin, 5);
|
406
|
+
rb_define_module_function(mGtkDrag, "threshold?", gtkdrag_check_threshold, 5);
|
407
|
+
rb_define_module_function(mGtkDrag, "set_icon", gtkdrag_set_icon, -1);
|
408
|
+
#if GTK_CHECK_VERSION(2,8,0)
|
409
|
+
rb_define_module_function(mGtkDrag, "set_icon_name", gtkdrag_set_icon_name, 4);
|
410
|
+
#endif
|
411
|
+
rb_define_module_function(mGtkDrag, "set_icon_default", gtkdrag_set_icon_default, 1);
|
412
|
+
rb_define_module_function(mGtkDrag, "source_set", gtkdrag_source_set, 4);
|
413
|
+
rb_define_module_function(mGtkDrag, "source_set_icon", gtkdrag_source_set_icon, -1);
|
414
|
+
#if GTK_CHECK_VERSION(2,8,0)
|
415
|
+
rb_define_module_function(mGtkDrag, "source_set_icon_name", gtkdrag_source_set_icon_name, 2);
|
416
|
+
#endif
|
417
|
+
rb_define_module_function(mGtkDrag, "source_unset", gtkdrag_source_unset, 1);
|
418
|
+
#if GTK_CHECK_VERSION(2,4,0)
|
419
|
+
rb_define_module_function(mGtkDrag, "source_set_target_list", gtkdrag_source_set_target_list, 2);
|
420
|
+
rb_define_module_function(mGtkDrag, "source_get_target_list", gtkdrag_source_get_target_list, 1);
|
421
|
+
#endif
|
422
|
+
#if GTK_CHECK_VERSION(2,6,0)
|
423
|
+
rb_define_module_function(mGtkDrag, "source_add_text_targets", gtkdrag_source_add_text_targets, 1);
|
424
|
+
rb_define_module_function(mGtkDrag, "source_add_image_targets", gtkdrag_source_add_image_targets, 1);
|
425
|
+
rb_define_module_function(mGtkDrag, "source_add_uri_targets", gtkdrag_source_add_uri_targets, 1);
|
426
|
+
#endif
|
427
|
+
G_DEF_SETTERS(mGtkDrag);
|
428
|
+
|
429
|
+
/* GtkDestDefaults */
|
430
|
+
G_DEF_CLASS(GTK_TYPE_DEST_DEFAULTS, "DestDefaults", mGtkDrag);
|
431
|
+
G_DEF_CONSTANTS(mGtkDrag, GTK_TYPE_DEST_DEFAULTS, "GTK_");
|
432
|
+
|
433
|
+
/* GtkTargetFlags */
|
434
|
+
G_DEF_CLASS(GTK_TYPE_TARGET_FLAGS, "TargetFlags", mGtkDrag);
|
435
|
+
G_DEF_CONSTANTS(mGtkDrag, GTK_TYPE_TARGET_FLAGS, "GTK_");
|
436
|
+
}
|