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/rbgtkaccessible.c
CHANGED
@@ -1,28 +1,39 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
+
*/
|
11
21
|
|
12
22
|
#include "global.h"
|
13
23
|
|
24
|
+
#define RG_TARGET_NAMESPACE cAccessible
|
25
|
+
|
14
26
|
static VALUE
|
15
|
-
|
27
|
+
rg_connect_widget_destroyed(VALUE self)
|
16
28
|
{
|
17
29
|
gtk_accessible_connect_widget_destroyed(GTK_ACCESSIBLE(RVAL2GOBJ(self)));
|
18
30
|
return self;
|
19
31
|
}
|
20
32
|
|
21
33
|
void
|
22
|
-
Init_gtk_accessible()
|
34
|
+
Init_gtk_accessible(VALUE mGtk)
|
23
35
|
{
|
24
|
-
VALUE
|
36
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_ACCESSIBLE, "Accessible", mGtk);
|
25
37
|
|
26
|
-
|
38
|
+
RG_DEF_METHOD(connect_widget_destroyed, 0);
|
27
39
|
}
|
28
|
-
|
data/ext/gtk2/rbgtkaction.c
CHANGED
@@ -1,23 +1,34 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2004-2006 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
|
+
*/
|
11
21
|
|
12
22
|
#include "global.h"
|
13
23
|
|
14
24
|
#if GTK_CHECK_VERSION(2,4,0)
|
15
25
|
|
26
|
+
#define RG_TARGET_NAMESPACE cAction
|
16
27
|
#define _SELF(self) (GTK_ACTION(RVAL2GOBJ(self)))
|
17
28
|
#define RVAL2WIDGET(w) (GTK_WIDGET(RVAL2GOBJ(w)))
|
18
29
|
|
19
30
|
static VALUE
|
20
|
-
|
31
|
+
rg_initialize(int argc, VALUE *argv, VALUE self)
|
21
32
|
{
|
22
33
|
VALUE name, label, tooltip, stock_id;
|
23
34
|
const gchar *stock = NULL;
|
@@ -37,120 +48,109 @@ action_initialize(int argc, VALUE *argv, VALUE self)
|
|
37
48
|
}
|
38
49
|
|
39
50
|
static VALUE
|
40
|
-
|
51
|
+
rg_is_sensitive_p(VALUE self)
|
41
52
|
{
|
42
53
|
return CBOOL2RVAL(gtk_action_is_sensitive(_SELF(self)));
|
43
54
|
}
|
44
55
|
|
45
56
|
static VALUE
|
46
|
-
|
57
|
+
rg_is_visible_p(VALUE self)
|
47
58
|
{
|
48
59
|
return CBOOL2RVAL(gtk_action_is_visible(_SELF(self)));
|
49
60
|
}
|
50
61
|
|
51
|
-
/* Defined as property.
|
52
|
-
const gchar* gtk_action_get_name (GtkAction *action);
|
53
|
-
gboolean gtk_action_get_sensitive (GtkAction *action);
|
54
|
-
void gtk_action_set_sensitive (GtkAction *action,
|
55
|
-
gboolean
|
56
|
-
sensitive);
|
57
|
-
gboolean gtk_action_get_visible (GtkAction *action);
|
58
|
-
void gtk_action_set_visible (GtkAction *action,
|
59
|
-
gboolean visible);
|
60
|
-
*/
|
61
|
-
|
62
62
|
static VALUE
|
63
|
-
|
63
|
+
rg_activate(VALUE self)
|
64
64
|
{
|
65
65
|
gtk_action_activate(_SELF(self));
|
66
66
|
return self;
|
67
67
|
}
|
68
68
|
|
69
69
|
static VALUE
|
70
|
-
|
70
|
+
rg_create_icon(VALUE self, VALUE icon_size)
|
71
71
|
{
|
72
72
|
return GOBJ2RVAL(gtk_action_create_icon(_SELF(self),
|
73
73
|
RVAL2GENUM(icon_size, GTK_TYPE_ICON_SIZE)));
|
74
74
|
}
|
75
75
|
|
76
76
|
static VALUE
|
77
|
-
|
77
|
+
rg_create_menu_item(VALUE self)
|
78
78
|
{
|
79
79
|
return GOBJ2RVAL(gtk_action_create_menu_item(_SELF(self)));
|
80
80
|
}
|
81
81
|
|
82
82
|
#if GTK_CHECK_VERSION(2, 12, 0)
|
83
83
|
static VALUE
|
84
|
-
|
84
|
+
rg_create_menu(VALUE self)
|
85
85
|
{
|
86
86
|
return GOBJ2RVAL(gtk_action_create_menu(_SELF(self)));
|
87
87
|
}
|
88
88
|
#endif
|
89
89
|
|
90
90
|
static VALUE
|
91
|
-
|
91
|
+
rg_create_tool_item(VALUE self)
|
92
92
|
{
|
93
93
|
return GOBJ2RVAL(gtk_action_create_tool_item(_SELF(self)));
|
94
94
|
}
|
95
95
|
|
96
96
|
static VALUE
|
97
|
-
|
97
|
+
rg_connect_proxy(VALUE self, VALUE proxy)
|
98
98
|
{
|
99
99
|
gtk_action_connect_proxy(_SELF(self), RVAL2WIDGET(proxy));
|
100
100
|
return self;
|
101
101
|
}
|
102
102
|
|
103
103
|
static VALUE
|
104
|
-
|
104
|
+
rg_disconnect_proxy(VALUE self, VALUE proxy)
|
105
105
|
{
|
106
106
|
gtk_action_disconnect_proxy(_SELF(self), RVAL2WIDGET(proxy));
|
107
107
|
return self;
|
108
108
|
}
|
109
109
|
|
110
110
|
static VALUE
|
111
|
-
|
111
|
+
rg_proxies(VALUE self)
|
112
112
|
{
|
113
113
|
/* Owned by GTK+ */
|
114
114
|
return GSLIST2ARY(gtk_action_get_proxies(_SELF(self)));
|
115
115
|
}
|
116
116
|
|
117
117
|
static VALUE
|
118
|
-
|
118
|
+
rg_connect_accelerator(VALUE self)
|
119
119
|
{
|
120
120
|
gtk_action_connect_accelerator(_SELF(self));
|
121
121
|
return self;
|
122
122
|
}
|
123
123
|
|
124
124
|
static VALUE
|
125
|
-
|
125
|
+
rg_disconnect_accelerator(VALUE self)
|
126
126
|
{
|
127
127
|
gtk_action_disconnect_accelerator(_SELF(self));
|
128
128
|
return self;
|
129
129
|
}
|
130
130
|
|
131
131
|
static VALUE
|
132
|
-
|
132
|
+
rg_block_activate_from(VALUE self, VALUE proxy)
|
133
133
|
{
|
134
134
|
gtk_action_block_activate_from(_SELF(self), RVAL2WIDGET(proxy));
|
135
135
|
return self;
|
136
136
|
}
|
137
137
|
|
138
138
|
static VALUE
|
139
|
-
|
139
|
+
rg_unblock_activate_from(VALUE self, VALUE proxy)
|
140
140
|
{
|
141
141
|
gtk_action_unblock_activate_from(_SELF(self), RVAL2WIDGET(proxy));
|
142
142
|
return self;
|
143
143
|
}
|
144
144
|
|
145
145
|
static VALUE
|
146
|
-
|
146
|
+
rg_set_accel_path(VALUE self, VALUE accel_path)
|
147
147
|
{
|
148
148
|
gtk_action_set_accel_path(_SELF(self), RVAL2CSTR(accel_path));
|
149
149
|
return self;
|
150
150
|
}
|
151
151
|
|
152
152
|
static VALUE
|
153
|
-
|
153
|
+
rg_set_accel_group(VALUE self, VALUE accel_group)
|
154
154
|
{
|
155
155
|
gtk_action_set_accel_group(_SELF(self), RVAL2GOBJ(accel_group));
|
156
156
|
return self;
|
@@ -158,7 +158,7 @@ action_set_accel_group(VALUE self, VALUE accel_group)
|
|
158
158
|
|
159
159
|
#if GTK_CHECK_VERSION(2,6,0)
|
160
160
|
static VALUE
|
161
|
-
|
161
|
+
rg_accel_path(VALUE self)
|
162
162
|
{
|
163
163
|
return CSTR2RVAL(gtk_action_get_accel_path(_SELF(self)));
|
164
164
|
}
|
@@ -166,7 +166,7 @@ action_get_accel_path(VALUE self)
|
|
166
166
|
|
167
167
|
#if GTK_CHECK_VERSION(2,8,0)
|
168
168
|
static VALUE
|
169
|
-
|
169
|
+
rg_accel_closure(VALUE self)
|
170
170
|
{
|
171
171
|
return BOXED2RVAL(gtk_action_get_accel_closure(_SELF(self)), G_TYPE_CLOSURE);
|
172
172
|
}
|
@@ -180,24 +180,24 @@ action_mark(void *p)
|
|
180
180
|
|
181
181
|
action = GTK_ACTION(p);
|
182
182
|
for (node = gtk_action_get_proxies(action);
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
183
|
+
node;
|
184
|
+
node = g_slist_next(node)) {
|
185
|
+
GtkWidget *proxy = node->data;
|
186
|
+
rbgobj_gc_mark_instance(proxy);
|
187
187
|
}
|
188
188
|
}
|
189
189
|
#endif
|
190
190
|
|
191
191
|
void
|
192
|
-
Init_gtk_action()
|
192
|
+
Init_gtk_action(VALUE mGtk)
|
193
193
|
{
|
194
194
|
#if GTK_CHECK_VERSION(2,4,0)
|
195
|
-
VALUE
|
195
|
+
VALUE RG_TARGET_NAMESPACE;
|
196
196
|
|
197
|
-
|
198
|
-
|
197
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS_WITH_GC_FUNC(GTK_TYPE_ACTION, "Action", mGtk,
|
198
|
+
action_mark, NULL);
|
199
199
|
|
200
|
-
|
200
|
+
RG_DEF_METHOD(initialize, -1);
|
201
201
|
/* (NOTICE) Gtk::Action#is_sensitive?, #is_visible are special.
|
202
202
|
Because there are also Gtk::Action#sensitive?, #visible? as property
|
203
203
|
accessors.
|
@@ -205,33 +205,33 @@ Init_gtk_action()
|
|
205
205
|
action group.
|
206
206
|
Gtk::Action#sensitive?, #visible? returns the value of the properties.
|
207
207
|
*/
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
208
|
+
RG_DEF_METHOD_P(is_sensitive, 0);
|
209
|
+
RG_DEF_METHOD_P(is_visible, 0);
|
210
|
+
RG_DEF_METHOD(activate, 0);
|
211
|
+
RG_DEF_METHOD(create_icon, 1);
|
212
|
+
RG_DEF_METHOD(create_menu_item, 0);
|
213
213
|
#if GTK_CHECK_VERSION(2, 12, 0)
|
214
|
-
|
214
|
+
RG_DEF_METHOD(create_menu, 0);
|
215
215
|
#endif
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
G_DEF_SETTER(
|
226
|
-
|
227
|
-
G_DEF_SETTER(
|
216
|
+
RG_DEF_METHOD(create_tool_item, 0);
|
217
|
+
RG_DEF_METHOD(connect_proxy, 1);
|
218
|
+
RG_DEF_METHOD(disconnect_proxy, 1);
|
219
|
+
RG_DEF_METHOD(proxies, 0);
|
220
|
+
RG_DEF_METHOD(connect_accelerator, 0);
|
221
|
+
RG_DEF_METHOD(disconnect_accelerator, 0);
|
222
|
+
RG_DEF_METHOD(block_activate_from, 1);
|
223
|
+
RG_DEF_METHOD(unblock_activate_from, 1);
|
224
|
+
RG_DEF_METHOD(set_accel_path, 1);
|
225
|
+
G_DEF_SETTER(RG_TARGET_NAMESPACE, "accel_path");
|
226
|
+
RG_DEF_METHOD(set_accel_group, 1);
|
227
|
+
G_DEF_SETTER(RG_TARGET_NAMESPACE, "accel_group");
|
228
228
|
|
229
229
|
#if GTK_CHECK_VERSION(2,6,0)
|
230
|
-
|
230
|
+
RG_DEF_METHOD(accel_path, 0);
|
231
231
|
#endif
|
232
232
|
|
233
233
|
#if GTK_CHECK_VERSION(2,8,0)
|
234
|
-
|
234
|
+
RG_DEF_METHOD(accel_closure, 0);
|
235
235
|
#endif
|
236
236
|
#endif
|
237
237
|
}
|
data/ext/gtk2/rbgtkactiongroup.c
CHANGED
@@ -1,13 +1,23 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2004-2006 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
|
+
*/
|
11
21
|
|
12
22
|
#include "global.h"
|
13
23
|
|
@@ -16,40 +26,31 @@
|
|
16
26
|
static ID id_action_procs;
|
17
27
|
static ID id_toggle_action_procs;
|
18
28
|
|
29
|
+
#define RG_TARGET_NAMESPACE cActionGroup
|
19
30
|
#define _SELF(self) (GTK_ACTION_GROUP(RVAL2GOBJ(self)))
|
20
31
|
#define RVAL2WIDGET(w) (GTK_WIDGET(RVAL2GOBJ(w)))
|
21
32
|
|
22
33
|
static VALUE
|
23
|
-
|
34
|
+
rg_initialize(VALUE self, VALUE name)
|
24
35
|
{
|
25
36
|
G_INITIALIZE(self, gtk_action_group_new(RVAL2CSTR(name)));
|
26
37
|
return Qnil;
|
27
38
|
}
|
28
39
|
|
29
|
-
/* Defined as properties
|
30
|
-
const gchar* gtk_action_group_get_name (GtkActionGroup *action_group);
|
31
|
-
gboolean gtk_action_group_get_sensitive (GtkActionGroup *action_group);
|
32
|
-
void gtk_action_group_set_sensitive (GtkActionGroup *action_group,
|
33
|
-
gboolean sensitive);
|
34
|
-
gboolean gtk_action_group_get_visible (GtkActionGroup *action_group);
|
35
|
-
void gtk_action_group_set_visible (GtkActionGroup *action_group,
|
36
|
-
gboolean visible);
|
37
|
-
*/
|
38
|
-
|
39
40
|
static VALUE
|
40
|
-
|
41
|
+
rg_get_action(VALUE self, VALUE action_name)
|
41
42
|
{
|
42
43
|
return GOBJ2RVAL(gtk_action_group_get_action(_SELF(self), RVAL2CSTR(action_name)));
|
43
44
|
}
|
44
45
|
|
45
46
|
static VALUE
|
46
|
-
|
47
|
+
rg_actions(VALUE self)
|
47
48
|
{
|
48
49
|
return GLIST2ARYF(gtk_action_group_list_actions(_SELF(self)));
|
49
50
|
}
|
50
51
|
|
51
52
|
static VALUE
|
52
|
-
|
53
|
+
rg_add_action(int argc, VALUE *argv, VALUE self)
|
53
54
|
{
|
54
55
|
VALUE action, accelerator;
|
55
56
|
|
@@ -64,7 +65,7 @@ actiongroup_add_action(int argc, VALUE *argv, VALUE self)
|
|
64
65
|
}
|
65
66
|
|
66
67
|
static VALUE
|
67
|
-
|
68
|
+
rg_remove_action(VALUE self, VALUE action)
|
68
69
|
{
|
69
70
|
gtk_action_group_remove_action(_SELF(self), GTK_ACTION(RVAL2GOBJ(action)));
|
70
71
|
G_CHILD_REMOVE(self, action);
|
@@ -74,65 +75,105 @@ actiongroup_remove_action(VALUE self, VALUE action)
|
|
74
75
|
static void
|
75
76
|
activate_action(GtkAction *action, VALUE self)
|
76
77
|
{
|
77
|
-
VALUE
|
78
|
-
|
79
|
-
|
78
|
+
VALUE proc = rb_hash_aref(rb_ivar_get(self, id_action_procs),
|
79
|
+
CSTR2RVAL(gtk_action_get_name(action)));
|
80
|
+
|
81
|
+
if (!NIL_P(proc))
|
80
82
|
rb_funcall(proc, id_call, 2, self, GOBJ2RVAL(action));
|
81
83
|
}
|
82
84
|
|
85
|
+
struct rbg_rval2gtkactionentries_args {
|
86
|
+
VALUE ary;
|
87
|
+
long n;
|
88
|
+
GtkActionEntry *result;
|
89
|
+
VALUE procs;
|
90
|
+
};
|
91
|
+
|
83
92
|
static VALUE
|
84
|
-
|
93
|
+
rbg_rval2gtkactionentries_body(VALUE value)
|
85
94
|
{
|
86
|
-
|
87
|
-
|
88
|
-
guint n_entries = (guint)RARRAY_LEN(entries);
|
89
|
-
GtkActionEntry* gentries = g_new0(GtkActionEntry, n_entries);
|
90
|
-
|
91
|
-
if (rb_ivar_defined(self, id_action_procs) == Qtrue){
|
92
|
-
action_procs = rb_ivar_get(self, id_action_procs);
|
93
|
-
} else {
|
94
|
-
action_procs = rb_hash_new();
|
95
|
-
}
|
95
|
+
long i;
|
96
|
+
struct rbg_rval2gtkactionentries_args *args = (struct rbg_rval2gtkactionentries_args *)value;
|
96
97
|
|
97
|
-
for (i = 0; i <
|
98
|
+
for (i = 0; i < args->n; i++) {
|
98
99
|
VALUE entry;
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
100
|
+
long n;
|
101
|
+
|
102
|
+
RARRAY_PTR(args->ary)[i] = rb_ary_dup(rb_ary_to_ary(RARRAY_PTR(args->ary)[i]));
|
103
|
+
entry = RARRAY_PTR(args->ary)[i];
|
104
|
+
n = RARRAY_LEN(entry);
|
105
|
+
|
106
|
+
args->result[i].callback = G_CALLBACK(activate_action);
|
107
|
+
|
108
|
+
if (n < 1 || n > 6)
|
109
|
+
rb_raise(rb_eArgError, "entry does not contain right number of entries %ld (1..6)", n);
|
110
|
+
|
111
|
+
args->result[i].name = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[0]);
|
112
|
+
|
113
|
+
switch (n) {
|
114
|
+
case 6:
|
115
|
+
/* TODO: Call #to_proc on entry 5? */
|
116
|
+
rb_hash_aset(args->procs, RARRAY_PTR(entry)[0], RARRAY_PTR(entry)[5]);
|
117
|
+
case 5:
|
118
|
+
args->result[i].tooltip = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[4]);
|
119
|
+
case 4:
|
120
|
+
args->result[i].accelerator = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[3]);
|
121
|
+
case 3:
|
122
|
+
args->result[i].label = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[2]);
|
123
|
+
case 2:
|
124
|
+
args->result[i].stock_id = RVAL2CSTR_ACCEPT_SYMBOL_ACCEPT_NIL(RARRAY_PTR(entry)[1]);
|
125
|
+
break;
|
126
|
+
default:
|
127
|
+
break;
|
121
128
|
}
|
122
|
-
|
123
|
-
if (size < 3) continue;
|
124
|
-
gentries[i].label = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[2]);
|
125
|
-
if (size < 4) continue;
|
126
|
-
gentries[i].accelerator = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[3]);
|
127
|
-
if (size < 4) continue;
|
128
|
-
gentries[i].tooltip = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[4]);
|
129
|
-
if (size < 5) continue;
|
130
|
-
rb_hash_aset(action_procs, RARRAY_PTR(entry)[0], RARRAY_PTR(entry)[5]);
|
131
129
|
}
|
130
|
+
|
131
|
+
return Qnil;
|
132
|
+
}
|
133
|
+
|
134
|
+
static G_GNUC_NORETURN VALUE
|
135
|
+
rbg_rval2gtkactionentries_rescue(VALUE value)
|
136
|
+
{
|
137
|
+
g_free(((struct rbg_rval2gtkactionentries_args *)value)->result);
|
138
|
+
|
139
|
+
rb_exc_raise(rb_errinfo());
|
140
|
+
}
|
141
|
+
|
142
|
+
static GtkActionEntry *
|
143
|
+
rbg_rval2gtkactionentries(volatile VALUE *value, long *n, VALUE procs)
|
144
|
+
{
|
145
|
+
struct rbg_rval2gtkactionentries_args args;
|
146
|
+
|
147
|
+
args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value));
|
148
|
+
args.n = RARRAY_LEN(args.ary);
|
149
|
+
args.result = g_new0(GtkActionEntry, args.n + 1);
|
150
|
+
args.procs = procs;
|
151
|
+
|
152
|
+
rb_rescue(rbg_rval2gtkactionentries_body, (VALUE)&args,
|
153
|
+
rbg_rval2gtkactionentries_rescue, (VALUE)&args);
|
154
|
+
|
155
|
+
*n = args.n;
|
156
|
+
|
157
|
+
return args.result;
|
158
|
+
}
|
159
|
+
|
160
|
+
#define RVAL2GTKACTIONENTRIES(value, n, procs) rbg_rval2gtkactionentries(&(value), &(n), procs)
|
161
|
+
|
162
|
+
static VALUE
|
163
|
+
rg_add_actions(VALUE self, VALUE rbentries)
|
164
|
+
{
|
165
|
+
GtkActionGroup *group = _SELF(self);
|
166
|
+
VALUE action_procs = rb_ivar_defined(self, id_action_procs) == Qtrue ?
|
167
|
+
rb_ivar_get(self, id_action_procs) :
|
168
|
+
rb_hash_new();
|
169
|
+
long n;
|
170
|
+
GtkActionEntry *entries = RVAL2GTKACTIONENTRIES(rbentries, n, action_procs);
|
171
|
+
|
132
172
|
rb_ivar_set(self, id_action_procs, action_procs);
|
133
|
-
|
134
|
-
|
135
|
-
|
173
|
+
|
174
|
+
gtk_action_group_add_actions(group, entries, n, (gpointer)self);
|
175
|
+
|
176
|
+
g_free(entries);
|
136
177
|
|
137
178
|
return self;
|
138
179
|
}
|
@@ -140,135 +181,216 @@ actiongroup_add_actions(VALUE self, VALUE entries)
|
|
140
181
|
static void
|
141
182
|
activate_toggle_action(GtkAction *action, VALUE self)
|
142
183
|
{
|
143
|
-
VALUE
|
144
|
-
|
145
|
-
|
184
|
+
VALUE proc = rb_hash_aref(rb_ivar_get(self, id_toggle_action_procs),
|
185
|
+
CSTR2RVAL(gtk_action_get_name(action)));
|
186
|
+
|
187
|
+
if (!NIL_P(proc))
|
146
188
|
rb_funcall(proc, id_call, 2, self, GOBJ2RVAL(action));
|
147
189
|
}
|
148
190
|
|
191
|
+
struct rbg_rval2gtktoggleactionentries_args {
|
192
|
+
VALUE ary;
|
193
|
+
long n;
|
194
|
+
GtkToggleActionEntry *result;
|
195
|
+
VALUE procs;
|
196
|
+
};
|
197
|
+
|
149
198
|
static VALUE
|
150
|
-
|
199
|
+
rbg_rval2gtktoggleactionentries_body(VALUE value)
|
151
200
|
{
|
152
|
-
|
153
|
-
|
154
|
-
guint n_entries = (guint)RARRAY_LEN(entries);
|
155
|
-
GtkToggleActionEntry* gentries = g_new0(GtkToggleActionEntry, n_entries);
|
156
|
-
|
157
|
-
if (rb_ivar_defined(self, id_toggle_action_procs) == Qtrue){
|
158
|
-
toggle_action_procs = rb_ivar_get(self, id_toggle_action_procs);
|
159
|
-
} else {
|
160
|
-
toggle_action_procs = rb_hash_new();
|
161
|
-
}
|
201
|
+
long i;
|
202
|
+
struct rbg_rval2gtktoggleactionentries_args *args = (struct rbg_rval2gtktoggleactionentries_args *)value;
|
162
203
|
|
163
|
-
for (i = 0; i <
|
204
|
+
for (i = 0; i < args->n; i++) {
|
164
205
|
VALUE entry;
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
206
|
+
long n;
|
207
|
+
|
208
|
+
RARRAY_PTR(args->ary)[i] = rb_ary_dup(rb_ary_to_ary(RARRAY_PTR(args->ary)[i]));
|
209
|
+
entry = RARRAY_PTR(args->ary)[i];
|
210
|
+
n = RARRAY_LEN(entry);
|
211
|
+
|
212
|
+
args->result[i].callback = G_CALLBACK(activate_toggle_action);
|
213
|
+
|
214
|
+
if (n < 1 || n > 7)
|
215
|
+
rb_raise(rb_eArgError, "entry does not contain right number of entries %ld (1..7)", n);
|
216
|
+
|
217
|
+
args->result[i].name = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[0]);
|
218
|
+
|
219
|
+
switch (n) {
|
220
|
+
case 7:
|
221
|
+
args->result[i].is_active = RVAL2CBOOL(RARRAY_PTR(entry)[6]);
|
222
|
+
case 6:
|
223
|
+
/* TODO: Call #to_proc on entry 5? */
|
224
|
+
rb_hash_aset(args->procs, RARRAY_PTR(entry)[0], RARRAY_PTR(entry)[5]);
|
225
|
+
case 5:
|
226
|
+
args->result[i].tooltip = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[4]);
|
227
|
+
case 4:
|
228
|
+
args->result[i].accelerator = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[3]);
|
229
|
+
case 3:
|
230
|
+
args->result[i].label = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[2]);
|
231
|
+
case 2:
|
232
|
+
args->result[i].stock_id = RVAL2CSTR_ACCEPT_SYMBOL_ACCEPT_NIL(RARRAY_PTR(entry)[1]);
|
233
|
+
break;
|
234
|
+
default:
|
235
|
+
break;
|
186
236
|
}
|
187
|
-
|
188
|
-
if (size < 3) continue;
|
189
|
-
gentries[i].label = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[2]);
|
190
|
-
if (size < 4) continue;
|
191
|
-
gentries[i].accelerator = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[3]);
|
192
|
-
if (size < 4) continue;
|
193
|
-
gentries[i].tooltip = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[4]);
|
194
|
-
if (size < 5) continue;
|
195
|
-
rb_hash_aset(toggle_action_procs,
|
196
|
-
RARRAY_PTR(entry)[0], RARRAY_PTR(entry)[5]);
|
197
|
-
if (size < 6) continue;
|
198
|
-
gentries[i].is_active = RVAL2CBOOL(RARRAY_PTR(entry)[6]);
|
199
237
|
}
|
238
|
+
|
239
|
+
return Qnil;
|
240
|
+
}
|
241
|
+
|
242
|
+
static G_GNUC_NORETURN VALUE
|
243
|
+
rbg_rval2gtktoggleactionentries_rescue(VALUE value)
|
244
|
+
{
|
245
|
+
g_free(((struct rbg_rval2gtktoggleactionentries_args *)value)->result);
|
246
|
+
|
247
|
+
rb_exc_raise(rb_errinfo());
|
248
|
+
}
|
249
|
+
|
250
|
+
static GtkToggleActionEntry *
|
251
|
+
rbg_rval2gtktoggleactionentries(volatile VALUE *value, long *n, VALUE procs)
|
252
|
+
{
|
253
|
+
struct rbg_rval2gtktoggleactionentries_args args;
|
254
|
+
|
255
|
+
args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value));
|
256
|
+
args.n = RARRAY_LEN(args.ary);
|
257
|
+
args.result = g_new0(GtkToggleActionEntry, args.n + 1);
|
258
|
+
args.procs = procs;
|
259
|
+
|
260
|
+
rb_rescue(rbg_rval2gtktoggleactionentries_body, (VALUE)&args,
|
261
|
+
rbg_rval2gtktoggleactionentries_rescue, (VALUE)&args);
|
262
|
+
|
263
|
+
*n = args.n;
|
264
|
+
|
265
|
+
return args.result;
|
266
|
+
}
|
267
|
+
|
268
|
+
#define RVAL2GTKTOGGLEACTIONENTRIES(value, n, procs) rbg_rval2gtktoggleactionentries(&(value), &(n), procs)
|
269
|
+
|
270
|
+
static VALUE
|
271
|
+
rg_add_toggle_actions(VALUE self, VALUE rbentries)
|
272
|
+
{
|
273
|
+
GtkActionGroup *group = _SELF(self);
|
274
|
+
VALUE toggle_action_procs = rb_ivar_defined(self, id_toggle_action_procs) == Qtrue ?
|
275
|
+
rb_ivar_get(self, id_toggle_action_procs) :
|
276
|
+
rb_hash_new();
|
277
|
+
long n;
|
278
|
+
GtkToggleActionEntry *entries = RVAL2GTKTOGGLEACTIONENTRIES(rbentries, n, toggle_action_procs);
|
279
|
+
|
200
280
|
rb_ivar_set(self, id_toggle_action_procs, toggle_action_procs);
|
201
|
-
|
202
|
-
|
203
|
-
|
281
|
+
|
282
|
+
gtk_action_group_add_toggle_actions(group, entries, n, (gpointer)self);
|
283
|
+
|
284
|
+
g_free(entries);
|
204
285
|
|
205
286
|
return self;
|
206
287
|
}
|
207
288
|
|
208
289
|
static void
|
209
|
-
activate_radio_action(GtkAction *action, GtkRadioAction *current, VALUE
|
290
|
+
activate_radio_action(GtkAction *action, GtkRadioAction *current, VALUE proc)
|
210
291
|
{
|
211
|
-
if (!
|
212
|
-
rb_funcall(
|
292
|
+
if (!NIL_P(proc))
|
293
|
+
rb_funcall(proc, id_call, 2, GOBJ2RVAL(action), GOBJ2RVAL(current));
|
213
294
|
}
|
214
295
|
|
296
|
+
struct rbg_rval2gtkradioactionentries_args {
|
297
|
+
VALUE ary;
|
298
|
+
long n;
|
299
|
+
GtkRadioActionEntry *result;
|
300
|
+
};
|
301
|
+
|
215
302
|
static VALUE
|
216
|
-
|
303
|
+
rbg_rval2gtkradioactionentries_body(VALUE value)
|
217
304
|
{
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
305
|
+
long i;
|
306
|
+
struct rbg_rval2gtkradioactionentries_args *args = (struct rbg_rval2gtkradioactionentries_args *)value;
|
307
|
+
|
308
|
+
for (i = 0; i < args->n; i++) {
|
309
|
+
VALUE entry;
|
310
|
+
long n;
|
311
|
+
|
312
|
+
RARRAY_PTR(args->ary)[i] = rb_ary_dup(rb_ary_to_ary(RARRAY_PTR(args->ary)[i]));
|
313
|
+
entry = RARRAY_PTR(args->ary)[i];
|
314
|
+
n = RARRAY_LEN(entry);
|
315
|
+
|
316
|
+
switch (n) {
|
317
|
+
case 6:
|
318
|
+
args->result[i].value = NUM2INT(RARRAY_PTR(entry)[5]);
|
319
|
+
case 5:
|
320
|
+
args->result[i].tooltip = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[4]);
|
321
|
+
case 4:
|
322
|
+
args->result[i].accelerator = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[3]);
|
323
|
+
case 3:
|
324
|
+
args->result[i].label = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[2]);
|
325
|
+
case 2:
|
326
|
+
args->result[i].stock_id = RVAL2CSTR_ACCEPT_SYMBOL_ACCEPT_NIL(RARRAY_PTR(entry)[1]);
|
327
|
+
case 1:
|
328
|
+
args->result[i].name = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[0]);
|
329
|
+
default:
|
330
|
+
rb_raise(rb_eArgError, "entry does not contain right number of entries %ld (1..6)", n);
|
331
|
+
}
|
332
|
+
}
|
222
333
|
|
223
|
-
|
334
|
+
return Qnil;
|
335
|
+
}
|
224
336
|
|
225
|
-
|
226
|
-
|
337
|
+
static G_GNUC_NORETURN VALUE
|
338
|
+
rbg_rval2gtkradioactionentries_rescue(VALUE value)
|
339
|
+
{
|
340
|
+
g_free(((struct rbg_rval2gtkradioactionentries_args *)value)->result);
|
341
|
+
|
342
|
+
rb_exc_raise(rb_errinfo());
|
343
|
+
}
|
344
|
+
|
345
|
+
static GtkRadioActionEntry *
|
346
|
+
rbg_rval2gtkradioactionentries(volatile VALUE *value, long *n)
|
347
|
+
{
|
348
|
+
struct rbg_rval2gtkradioactionentries_args args;
|
349
|
+
|
350
|
+
args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value));
|
351
|
+
args.n = RARRAY_LEN(args.ary);
|
352
|
+
args.result = g_new0(GtkRadioActionEntry, args.n + 1);
|
353
|
+
|
354
|
+
rb_rescue(rbg_rval2gtkradioactionentries_body, (VALUE)&args,
|
355
|
+
rbg_rval2gtkradioactionentries_rescue, (VALUE)&args);
|
356
|
+
|
357
|
+
*n = args.n;
|
358
|
+
|
359
|
+
return args.result;
|
360
|
+
}
|
361
|
+
|
362
|
+
#define RVAL2GTKRADIOACTIONENTRIES(value, n) rbg_rval2gtkradioactionentries(&(value), &(n))
|
363
|
+
|
364
|
+
static VALUE
|
365
|
+
rg_add_radio_actions(int argc, VALUE *argv, VALUE self)
|
366
|
+
{
|
367
|
+
GtkActionGroup *group = _SELF(self);
|
368
|
+
VALUE rbentries, rbvalue, proc;
|
369
|
+
long n;
|
370
|
+
GtkRadioActionEntry *entries;
|
371
|
+
gint value;
|
372
|
+
|
373
|
+
rb_scan_args(argc, argv, "12", &rbentries, &rbvalue, &proc);
|
374
|
+
|
375
|
+
value = NIL_P(rbvalue) ? -1 : NUM2INT(rbvalue);
|
376
|
+
|
377
|
+
if (NIL_P(proc) && rb_block_given_p()) {
|
227
378
|
proc = rb_block_proc();
|
379
|
+
/* TODO: How do we remove this proc when all the radio actions passed
|
380
|
+
* have been removed? */
|
228
381
|
G_RELATIVE(self, proc);
|
229
382
|
}
|
230
|
-
n_entries = (guint)RARRAY_LEN(entries);
|
231
|
-
gentries = g_new0(GtkRadioActionEntry, n_entries);
|
232
383
|
|
233
|
-
|
234
|
-
VALUE entry;
|
235
|
-
int size;
|
236
|
-
|
237
|
-
entry = RARRAY_PTR(entries)[i];
|
238
|
-
size = RARRAY_LEN(entry);
|
239
|
-
if (size < 1)
|
240
|
-
rb_raise(rb_eArgError, "wrong array parameter");
|
241
|
-
|
242
|
-
gentries[i].name = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[0]);
|
243
|
-
|
244
|
-
if (size < 2) continue;
|
245
|
-
|
246
|
-
if (NIL_P(RARRAY_PTR(entry)[1])){
|
247
|
-
gentries[i].stock_id = NULL;
|
248
|
-
} else if (SYMBOL_P(RARRAY_PTR(entry)[1])){
|
249
|
-
gentries[i].stock_id = rb_id2name(SYM2ID(RARRAY_PTR(entry)[1]));
|
250
|
-
} else if (TYPE(RARRAY_PTR(entry)[1]) == T_STRING){
|
251
|
-
gentries[i].stock_id = RVAL2CSTR(RARRAY_PTR(entry)[1]);
|
252
|
-
} else{
|
253
|
-
rb_raise(rb_eArgError,
|
254
|
-
"invalid argument %s (expect Symbol or String)",
|
255
|
-
rb_class2name(CLASS_OF(RARRAY_PTR(entry)[1])));
|
256
|
-
}
|
384
|
+
entries = RVAL2GTKRADIOACTIONENTRIES(rbentries, n);
|
257
385
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
if (size < 4) continue;
|
263
|
-
gentries[i].tooltip = RVAL2CSTR_ACCEPT_NIL(RARRAY_PTR(entry)[4]);
|
264
|
-
if (size < 5) continue;
|
265
|
-
gentries[i].value = NUM2INT(RARRAY_PTR(entry)[5]);
|
266
|
-
}
|
267
|
-
gtk_action_group_add_radio_actions(_SELF(self), gentries,
|
268
|
-
n_entries, NUM2INT(value),
|
386
|
+
gtk_action_group_add_radio_actions(group,
|
387
|
+
entries,
|
388
|
+
n,
|
389
|
+
value,
|
269
390
|
G_CALLBACK(activate_radio_action),
|
270
|
-
|
271
|
-
|
391
|
+
(gpointer)proc);
|
392
|
+
|
393
|
+
g_free(entries);
|
272
394
|
|
273
395
|
return self;
|
274
396
|
}
|
@@ -281,7 +403,7 @@ translate_func(const gchar *path, gpointer func)
|
|
281
403
|
}
|
282
404
|
|
283
405
|
static VALUE
|
284
|
-
|
406
|
+
rg_set_translate_func(VALUE self)
|
285
407
|
{
|
286
408
|
VALUE func = rb_block_proc();
|
287
409
|
G_RELATIVE(self, func);
|
@@ -292,7 +414,7 @@ actiongroup_set_translate_func(VALUE self)
|
|
292
414
|
}
|
293
415
|
|
294
416
|
static VALUE
|
295
|
-
|
417
|
+
rg_set_translation_domain(VALUE self, VALUE domain)
|
296
418
|
{
|
297
419
|
gtk_action_group_set_translation_domain(_SELF(self),
|
298
420
|
NIL_P(domain) ? (const gchar*)NULL : RVAL2CSTR(domain));
|
@@ -301,7 +423,7 @@ actiongroup_set_translation_domain(VALUE self, VALUE domain)
|
|
301
423
|
|
302
424
|
#if GTK_CHECK_VERSION(2,6,0)
|
303
425
|
static VALUE
|
304
|
-
|
426
|
+
rg_translate_string(VALUE self, VALUE str)
|
305
427
|
{
|
306
428
|
return CSTR2RVAL(gtk_action_group_translate_string(_SELF(self), RVAL2CSTR(str)));
|
307
429
|
}
|
@@ -316,38 +438,38 @@ action_group_mark(void *p)
|
|
316
438
|
group = GTK_ACTION_GROUP(p);
|
317
439
|
actions = gtk_action_group_list_actions(group);
|
318
440
|
for (node = actions; node; node = g_list_next(node)) {
|
319
|
-
|
320
|
-
|
441
|
+
GtkWidget *action = node->data;
|
442
|
+
rbgobj_gc_mark_instance(action);
|
321
443
|
}
|
322
444
|
g_list_free(actions);
|
323
445
|
}
|
324
446
|
#endif
|
325
447
|
|
326
448
|
void
|
327
|
-
Init_gtk_actiongroup()
|
449
|
+
Init_gtk_actiongroup(VALUE mGtk)
|
328
450
|
{
|
329
451
|
#if GTK_CHECK_VERSION(2,4,0)
|
330
|
-
VALUE
|
452
|
+
VALUE RG_TARGET_NAMESPACE;
|
331
453
|
|
332
|
-
|
333
|
-
|
454
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS_WITH_GC_FUNC(GTK_TYPE_ACTION_GROUP, "ActionGroup",
|
455
|
+
mGtk, action_group_mark, NULL);
|
334
456
|
|
335
457
|
id_action_procs = rb_intern("@action_procs");
|
336
458
|
id_toggle_action_procs = rb_intern("@toggle_action_procs");
|
337
459
|
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
G_DEF_SETTER(
|
460
|
+
RG_DEF_METHOD(initialize, 1);
|
461
|
+
RG_DEF_METHOD(get_action, 1);
|
462
|
+
RG_DEF_METHOD(actions, 0);
|
463
|
+
RG_DEF_METHOD(add_action, -1);
|
464
|
+
RG_DEF_METHOD(remove_action, 1);
|
465
|
+
RG_DEF_METHOD(add_actions, 1);
|
466
|
+
RG_DEF_METHOD(add_toggle_actions, 1);
|
467
|
+
RG_DEF_METHOD(add_radio_actions, -1);
|
468
|
+
RG_DEF_METHOD(set_translate_func, 0);
|
469
|
+
RG_DEF_METHOD(set_translation_domain, 1);
|
470
|
+
G_DEF_SETTER(RG_TARGET_NAMESPACE, "translation_domain");
|
349
471
|
#if GTK_CHECK_VERSION(2,6,0)
|
350
|
-
|
472
|
+
RG_DEF_METHOD(translate_string, 1);
|
351
473
|
#endif
|
352
474
|
#endif
|
353
475
|
}
|