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,331 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/************************************************
|
3
|
+
|
4
|
+
rbgtktreeviewcolumn.c -
|
5
|
+
|
6
|
+
$Author: ggc $
|
7
|
+
$Date: 2007/07/13 16:07:32 $
|
8
|
+
|
9
|
+
Copyright (C) 2002-2004 Masao Mutoh
|
10
|
+
************************************************/
|
11
|
+
|
12
|
+
#include "global.h"
|
13
|
+
|
14
|
+
#define _SELF(s) (GTK_TREE_VIEW_COLUMN(RVAL2GOBJ(s)))
|
15
|
+
#define RVAL2CELLRENDERER(c) (GTK_CELL_RENDERER(RVAL2GOBJ(c)))
|
16
|
+
|
17
|
+
static VALUE
|
18
|
+
tvc_initialize(argc, argv, self)
|
19
|
+
int argc;
|
20
|
+
VALUE *argv;
|
21
|
+
VALUE self;
|
22
|
+
{
|
23
|
+
int i;
|
24
|
+
int col;
|
25
|
+
GtkTreeViewColumn *tvc;
|
26
|
+
GtkCellRenderer *renderer;
|
27
|
+
const gchar *name;
|
28
|
+
VALUE ary, val;
|
29
|
+
|
30
|
+
tvc = gtk_tree_view_column_new();
|
31
|
+
if (argc > 0){
|
32
|
+
gtk_tree_view_column_set_title(tvc, RVAL2CSTR(argv[0]));
|
33
|
+
if (argc > 1) {
|
34
|
+
gtk_tree_view_column_pack_start(tvc, RVAL2CELLRENDERER(argv[1]), TRUE);
|
35
|
+
G_CHILD_ADD(self, argv[1]);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
RBGTK_INITIALIZE(self, tvc);
|
40
|
+
|
41
|
+
if (argc == 3){
|
42
|
+
ary = rb_funcall(argv[2], rb_intern("to_a"), 0);
|
43
|
+
renderer = RVAL2CELLRENDERER(argv[1]);
|
44
|
+
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
45
|
+
val = RARRAY_PTR(RARRAY_PTR(ary)[i])[0];
|
46
|
+
if (SYMBOL_P(val)) {
|
47
|
+
name = rb_id2name(SYM2ID(val));
|
48
|
+
} else {
|
49
|
+
name = RVAL2CSTR(val);
|
50
|
+
}
|
51
|
+
col = NUM2INT(RARRAY_PTR(RARRAY_PTR(ary)[i])[1]);
|
52
|
+
gtk_tree_view_column_add_attribute(_SELF(self), renderer, name, col);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
return Qnil;
|
57
|
+
}
|
58
|
+
|
59
|
+
static VALUE
|
60
|
+
tvc_pack_start(self, cell, expand)
|
61
|
+
VALUE self, cell, expand;
|
62
|
+
{
|
63
|
+
G_CHILD_ADD(self, cell);
|
64
|
+
gtk_tree_view_column_pack_start(_SELF(self), RVAL2CELLRENDERER(cell), RVAL2CBOOL(expand));
|
65
|
+
return self;
|
66
|
+
}
|
67
|
+
|
68
|
+
static VALUE
|
69
|
+
tvc_pack_end(self, cell, expand)
|
70
|
+
VALUE self, cell, expand;
|
71
|
+
{
|
72
|
+
G_CHILD_ADD(self, cell);
|
73
|
+
gtk_tree_view_column_pack_end(_SELF(self), RVAL2CELLRENDERER(cell), RVAL2CBOOL(expand));
|
74
|
+
return self;
|
75
|
+
}
|
76
|
+
|
77
|
+
static VALUE
|
78
|
+
tvc_clear(self)
|
79
|
+
VALUE self;
|
80
|
+
{
|
81
|
+
G_CHILD_REMOVE_ALL(self);
|
82
|
+
gtk_tree_view_column_clear(_SELF(self));
|
83
|
+
return self;
|
84
|
+
}
|
85
|
+
|
86
|
+
static VALUE
|
87
|
+
tvc_get_cell_renderers(self)
|
88
|
+
VALUE self;
|
89
|
+
{
|
90
|
+
return GLIST2ARYF(gtk_tree_view_column_get_cell_renderers(_SELF(self)));
|
91
|
+
}
|
92
|
+
|
93
|
+
static VALUE
|
94
|
+
tvc_add_attribute(self, cell, attribute, column)
|
95
|
+
VALUE self, cell, attribute, column;
|
96
|
+
{
|
97
|
+
const gchar *name;
|
98
|
+
if (SYMBOL_P(attribute)) {
|
99
|
+
name = rb_id2name(SYM2ID(attribute));
|
100
|
+
} else {
|
101
|
+
name = RVAL2CSTR(attribute);
|
102
|
+
}
|
103
|
+
gtk_tree_view_column_add_attribute(_SELF(self), RVAL2CELLRENDERER(cell),
|
104
|
+
name, NUM2INT(column));
|
105
|
+
return self;
|
106
|
+
}
|
107
|
+
|
108
|
+
static VALUE
|
109
|
+
tvc_set_attributes(self, renderer, attributes)
|
110
|
+
VALUE self, renderer, attributes;
|
111
|
+
{
|
112
|
+
GtkTreeViewColumn *tvc;
|
113
|
+
GtkCellRenderer *grenderer;
|
114
|
+
const gchar *name;
|
115
|
+
int i, col;
|
116
|
+
VALUE ary, val;
|
117
|
+
|
118
|
+
Check_Type(attributes, T_HASH);
|
119
|
+
|
120
|
+
tvc = _SELF(self);
|
121
|
+
grenderer = RVAL2CELLRENDERER(renderer);
|
122
|
+
gtk_tree_view_column_clear_attributes(tvc, grenderer);
|
123
|
+
|
124
|
+
ary = rb_funcall(attributes, rb_intern("to_a"), 0);
|
125
|
+
for (i = 0; i < RARRAY_LEN(ary); i++) {
|
126
|
+
val = RARRAY_PTR(RARRAY_PTR(ary)[i])[0];
|
127
|
+
if (SYMBOL_P(val)) {
|
128
|
+
name = rb_id2name(SYM2ID(val));
|
129
|
+
} else {
|
130
|
+
name = RVAL2CSTR(val);
|
131
|
+
}
|
132
|
+
col = NUM2INT(RARRAY_PTR(RARRAY_PTR(ary)[i])[1]);
|
133
|
+
gtk_tree_view_column_add_attribute(tvc, grenderer, name, col);
|
134
|
+
}
|
135
|
+
return self;
|
136
|
+
}
|
137
|
+
|
138
|
+
static void
|
139
|
+
cell_data_func(tree_column, cell, model, iter, func)
|
140
|
+
GtkTreeViewColumn* tree_column;
|
141
|
+
GtkCellRenderer* cell;
|
142
|
+
GtkTreeModel* model;
|
143
|
+
GtkTreeIter* iter;
|
144
|
+
gpointer func;
|
145
|
+
{
|
146
|
+
iter->user_data3 = model;
|
147
|
+
rb_funcall((VALUE)func, id_call, 4, GOBJ2RVAL(tree_column),
|
148
|
+
GOBJ2RVAL(cell), GOBJ2RVAL(model),
|
149
|
+
GTKTREEITER2RVAL(iter));
|
150
|
+
}
|
151
|
+
|
152
|
+
|
153
|
+
static VALUE
|
154
|
+
tvc_set_cell_data_func(self, renderer)
|
155
|
+
VALUE self, renderer;
|
156
|
+
{
|
157
|
+
volatile VALUE func = rb_block_proc();
|
158
|
+
G_RELATIVE(self, func);
|
159
|
+
G_RELATIVE(renderer, func);
|
160
|
+
gtk_tree_view_column_set_cell_data_func(_SELF(self), RVAL2CELLRENDERER(renderer),
|
161
|
+
(GtkTreeCellDataFunc)cell_data_func, (gpointer)func, NULL);
|
162
|
+
return self;
|
163
|
+
}
|
164
|
+
|
165
|
+
static VALUE
|
166
|
+
tvc_clear_attributes(self, cell)
|
167
|
+
VALUE self, cell;
|
168
|
+
{
|
169
|
+
gtk_tree_view_column_clear_attributes(_SELF(self), RVAL2CELLRENDERER(cell));
|
170
|
+
return self;
|
171
|
+
}
|
172
|
+
|
173
|
+
static VALUE
|
174
|
+
tvc_set_spacing(self, spacing)
|
175
|
+
VALUE self, spacing;
|
176
|
+
{
|
177
|
+
gtk_tree_view_column_set_spacing(_SELF(self), NUM2INT(spacing));
|
178
|
+
return self;
|
179
|
+
}
|
180
|
+
|
181
|
+
static VALUE
|
182
|
+
tvc_get_spacing(self)
|
183
|
+
VALUE self;
|
184
|
+
{
|
185
|
+
return INT2NUM(gtk_tree_view_column_get_spacing(_SELF(self)));
|
186
|
+
}
|
187
|
+
|
188
|
+
static VALUE
|
189
|
+
tvc_clicked(self)
|
190
|
+
VALUE self;
|
191
|
+
{
|
192
|
+
gtk_tree_view_column_clicked(_SELF(self));
|
193
|
+
return self;
|
194
|
+
}
|
195
|
+
|
196
|
+
static VALUE
|
197
|
+
tvc_set_sort_column_id(self, sort_column_id)
|
198
|
+
VALUE self, sort_column_id;
|
199
|
+
{
|
200
|
+
gtk_tree_view_column_set_sort_column_id(_SELF(self),
|
201
|
+
NUM2INT(sort_column_id));
|
202
|
+
return self;
|
203
|
+
}
|
204
|
+
|
205
|
+
static VALUE
|
206
|
+
tvc_get_sort_column_id(self)
|
207
|
+
VALUE self;
|
208
|
+
{
|
209
|
+
return INT2NUM(gtk_tree_view_column_get_sort_column_id(_SELF(self)));
|
210
|
+
}
|
211
|
+
|
212
|
+
static VALUE
|
213
|
+
tvc_cell_set_cell_data(self, model, iter, is_expander, is_expanded)
|
214
|
+
VALUE self, model, iter, is_expander, is_expanded;
|
215
|
+
{
|
216
|
+
gtk_tree_view_column_cell_set_cell_data(_SELF(self),
|
217
|
+
GTK_TREE_MODEL(RVAL2GOBJ(model)),
|
218
|
+
RVAL2GTKTREEITER(iter),
|
219
|
+
RVAL2CBOOL(is_expander),
|
220
|
+
RVAL2CBOOL(is_expanded));
|
221
|
+
return self;
|
222
|
+
}
|
223
|
+
|
224
|
+
static VALUE
|
225
|
+
tvc_cell_get_size(self)
|
226
|
+
VALUE self;
|
227
|
+
{
|
228
|
+
GdkRectangle cell_area;
|
229
|
+
gint x_offset, y_offset, width, height;
|
230
|
+
VALUE cell;
|
231
|
+
|
232
|
+
/* Is this collect implement for cell_area ? */
|
233
|
+
cell_area.x = -1;
|
234
|
+
cell_area.y = -1;
|
235
|
+
cell_area.width = -1;
|
236
|
+
cell_area.height = -1;
|
237
|
+
|
238
|
+
gtk_tree_view_column_cell_get_size(_SELF(self), &cell_area,
|
239
|
+
&x_offset, &y_offset,
|
240
|
+
&width, &height);
|
241
|
+
if (cell_area.x == -1 || cell_area.y == -1 ||
|
242
|
+
cell_area.width == -1 || cell_area.height == -1){
|
243
|
+
cell = Qnil;
|
244
|
+
} else {
|
245
|
+
cell = BOXED2RVAL(&cell_area, GDK_TYPE_RECTANGLE);
|
246
|
+
}
|
247
|
+
return rb_ary_new3(5, cell,
|
248
|
+
x_offset ? INT2NUM(x_offset) : Qnil,
|
249
|
+
y_offset ? INT2NUM(y_offset) : Qnil,
|
250
|
+
width ? INT2NUM(width) : Qnil,
|
251
|
+
height ? INT2NUM(height) : Qnil);
|
252
|
+
}
|
253
|
+
|
254
|
+
static VALUE
|
255
|
+
tvc_cell_is_visible(self)
|
256
|
+
{
|
257
|
+
return CBOOL2RVAL(gtk_tree_view_column_cell_is_visible(_SELF(self)));
|
258
|
+
}
|
259
|
+
|
260
|
+
#if GTK_CHECK_VERSION(2,2,0)
|
261
|
+
|
262
|
+
static VALUE
|
263
|
+
tvc_focus_cell(self, renderer)
|
264
|
+
VALUE self, renderer;
|
265
|
+
{
|
266
|
+
gtk_tree_view_column_focus_cell(_SELF(self), RVAL2CELLRENDERER(renderer));
|
267
|
+
|
268
|
+
return self;
|
269
|
+
}
|
270
|
+
|
271
|
+
#endif
|
272
|
+
|
273
|
+
#if GTK_CHECK_VERSION(2,8,0)
|
274
|
+
static VALUE
|
275
|
+
tvc_queue_resize(self)
|
276
|
+
VALUE self;
|
277
|
+
{
|
278
|
+
gtk_tree_view_column_queue_resize(_SELF(self));
|
279
|
+
return self;
|
280
|
+
}
|
281
|
+
#endif
|
282
|
+
|
283
|
+
#if GTK_CHECK_VERSION(2,12,0)
|
284
|
+
static VALUE
|
285
|
+
tvc_get_tree_view(self)
|
286
|
+
VALUE self;
|
287
|
+
{
|
288
|
+
return GOBJ2RVAL(gtk_tree_view_column_get_tree_view(_SELF(self)));
|
289
|
+
}
|
290
|
+
#endif
|
291
|
+
|
292
|
+
|
293
|
+
void
|
294
|
+
Init_gtk_treeviewcolumn()
|
295
|
+
{
|
296
|
+
VALUE tvc = G_DEF_CLASS(GTK_TYPE_TREE_VIEW_COLUMN, "TreeViewColumn", mGtk);
|
297
|
+
|
298
|
+
rb_define_method(tvc, "initialize", tvc_initialize, -1);
|
299
|
+
rb_define_method(tvc, "pack_start", tvc_pack_start, 2);
|
300
|
+
rb_define_method(tvc, "pack_end", tvc_pack_end, 2);
|
301
|
+
rb_define_method(tvc, "clear", tvc_clear, 0);
|
302
|
+
rb_define_method(tvc, "cell_renderers", tvc_get_cell_renderers, 0);
|
303
|
+
rb_define_method(tvc, "add_attribute", tvc_add_attribute, 3);
|
304
|
+
rb_define_method(tvc, "set_attributes", tvc_set_attributes, 2);
|
305
|
+
rb_define_method(tvc, "set_cell_data_func", tvc_set_cell_data_func, 1);
|
306
|
+
rb_define_method(tvc, "clear_attributes", tvc_clear_attributes, 1);
|
307
|
+
rb_define_method(tvc, "set_spacing", tvc_set_spacing, 1);
|
308
|
+
rb_define_method(tvc, "spacing", tvc_get_spacing, 0);
|
309
|
+
rb_define_method(tvc, "clicked", tvc_clicked, 0);
|
310
|
+
rb_define_method(tvc, "set_sort_column_id", tvc_set_sort_column_id, 1);
|
311
|
+
rb_define_method(tvc, "sort_column_id", tvc_get_sort_column_id, 0);
|
312
|
+
rb_define_method(tvc, "cell_set_cell_data", tvc_cell_set_cell_data, 4);
|
313
|
+
rb_define_method(tvc, "cell_size", tvc_cell_get_size, 0);
|
314
|
+
rb_define_method(tvc, "cell_is_visible?", tvc_cell_is_visible, 0);
|
315
|
+
#if GTK_CHECK_VERSION(2,2,0)
|
316
|
+
rb_define_method(tvc, "focus_cell", tvc_focus_cell, 1);
|
317
|
+
#endif
|
318
|
+
#if GTK_CHECK_VERSION(2,8,0)
|
319
|
+
rb_define_method(tvc, "queue_resize", tvc_queue_resize, 0);
|
320
|
+
#endif
|
321
|
+
#if GTK_CHECK_VERSION(2,12,0)
|
322
|
+
rb_define_method(tvc, "tree_view", tvc_get_tree_view, 0);
|
323
|
+
#endif
|
324
|
+
/* GtkTreeViewColumnSizing */
|
325
|
+
G_DEF_CLASS(GTK_TYPE_TREE_VIEW_COLUMN_SIZING, "Sizing", tvc);
|
326
|
+
G_DEF_CONSTANTS(tvc, GTK_TYPE_TREE_VIEW_COLUMN_SIZING, "GTK_TREE_VIEW_COLUMN_");
|
327
|
+
|
328
|
+
G_DEF_SETTERS(tvc);
|
329
|
+
|
330
|
+
rb_undef_method(tvc, "cell_data_func=");
|
331
|
+
}
|
@@ -0,0 +1,210 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/************************************************
|
3
|
+
|
4
|
+
rbgtkuimanager.c -
|
5
|
+
|
6
|
+
$Author: ggc $
|
7
|
+
$Date: 2007/07/13 16:07:32 $
|
8
|
+
|
9
|
+
Copyright (C) 2004-2006 Masao Mutoh
|
10
|
+
************************************************/
|
11
|
+
|
12
|
+
#include "global.h"
|
13
|
+
|
14
|
+
|
15
|
+
#if GTK_CHECK_VERSION(2,4,0)
|
16
|
+
|
17
|
+
#define _SELF(self) (GTK_UI_MANAGER(RVAL2GOBJ(self)))
|
18
|
+
|
19
|
+
static VALUE
|
20
|
+
rbuimanager_initialize(self)
|
21
|
+
VALUE self;
|
22
|
+
{
|
23
|
+
G_INITIALIZE(self, gtk_ui_manager_new());
|
24
|
+
return Qnil;
|
25
|
+
}
|
26
|
+
|
27
|
+
/* Defined as Properties.
|
28
|
+
void gtk_ui_manager_set_add_tearoffs (GtkUIManager *self,
|
29
|
+
gboolean add_tearoffs);
|
30
|
+
gboolean gtk_ui_manager_get_add_tearoffs (GtkUIManager *self);
|
31
|
+
*/
|
32
|
+
|
33
|
+
static VALUE
|
34
|
+
rbuimanager_insert_action_group(self, action_group, pos)
|
35
|
+
VALUE self, action_group, pos;
|
36
|
+
{
|
37
|
+
gtk_ui_manager_insert_action_group(_SELF(self), RVAL2GOBJ(action_group), NUM2INT(pos));
|
38
|
+
G_CHILD_ADD(self, action_group);
|
39
|
+
return self;
|
40
|
+
}
|
41
|
+
|
42
|
+
static VALUE
|
43
|
+
rbuimanager_remove_action_group(self, action_group)
|
44
|
+
VALUE self, action_group;
|
45
|
+
{
|
46
|
+
gtk_ui_manager_remove_action_group(_SELF(self), RVAL2GOBJ(action_group));
|
47
|
+
G_CHILD_REMOVE(self, action_group);
|
48
|
+
return self;
|
49
|
+
}
|
50
|
+
|
51
|
+
static VALUE
|
52
|
+
rbuimanager_get_action_groups(self)
|
53
|
+
VALUE self;
|
54
|
+
{
|
55
|
+
/* Owned by GTK+ */
|
56
|
+
return GLIST2ARY(gtk_ui_manager_get_action_groups(_SELF(self)));
|
57
|
+
}
|
58
|
+
|
59
|
+
static VALUE
|
60
|
+
rbuimanager_get_accel_group(self)
|
61
|
+
VALUE self;
|
62
|
+
{
|
63
|
+
return GOBJ2RVAL(gtk_ui_manager_get_accel_group(_SELF(self)));
|
64
|
+
}
|
65
|
+
|
66
|
+
static VALUE
|
67
|
+
rbuimanager_get_widget(self, path)
|
68
|
+
VALUE self, path;
|
69
|
+
{
|
70
|
+
GtkWidget* widget = gtk_ui_manager_get_widget(_SELF(self), RVAL2CSTR(path));
|
71
|
+
if (! widget)
|
72
|
+
rb_raise(rb_eArgError, "no widget was found.");
|
73
|
+
|
74
|
+
return GOBJ2RVAL(widget);
|
75
|
+
}
|
76
|
+
|
77
|
+
static VALUE
|
78
|
+
rbuimanager_get_toplevels(self, types)
|
79
|
+
VALUE self, types;
|
80
|
+
{
|
81
|
+
return GSLIST2ARYF(gtk_ui_manager_get_toplevels(_SELF(self),
|
82
|
+
RVAL2GFLAGS(types, GTK_TYPE_UI_MANAGER_ITEM_TYPE)));
|
83
|
+
}
|
84
|
+
|
85
|
+
static VALUE
|
86
|
+
rbuimanager_get_action(self, path)
|
87
|
+
VALUE self, path;
|
88
|
+
{
|
89
|
+
return GOBJ2RVAL(gtk_ui_manager_get_action(_SELF(self), RVAL2CSTR(path)));
|
90
|
+
}
|
91
|
+
|
92
|
+
static VALUE
|
93
|
+
rbuimanager_add_ui(argc, argv, self)
|
94
|
+
int argc;
|
95
|
+
VALUE *argv;
|
96
|
+
VALUE self;
|
97
|
+
{
|
98
|
+
GError* error = NULL;
|
99
|
+
guint ret;
|
100
|
+
VALUE buffer;
|
101
|
+
|
102
|
+
if (argc == 1) {
|
103
|
+
VALUE buffer_or_filename;
|
104
|
+
rb_scan_args(argc, argv, "10", &buffer_or_filename);
|
105
|
+
|
106
|
+
Check_Type(buffer_or_filename, T_STRING);
|
107
|
+
buffer = rb_funcall(buffer_or_filename, rb_intern("include?"), 1, CSTR2RVAL("<ui>"));
|
108
|
+
|
109
|
+
if (RVAL2CBOOL(buffer)){
|
110
|
+
StringValue(buffer_or_filename);
|
111
|
+
ret = gtk_ui_manager_add_ui_from_string(_SELF(self), RVAL2CSTR(buffer_or_filename),
|
112
|
+
RSTRING_LEN(buffer_or_filename),
|
113
|
+
&error);
|
114
|
+
} else {
|
115
|
+
ret = gtk_ui_manager_add_ui_from_file(_SELF(self), RVAL2CSTR(buffer_or_filename),
|
116
|
+
&error);
|
117
|
+
}
|
118
|
+
} else {
|
119
|
+
VALUE merge_id, path, name, action, type, top;
|
120
|
+
|
121
|
+
rb_scan_args(argc, argv, "60", &merge_id, &path, &name, &action, &type, &top);
|
122
|
+
|
123
|
+
ret = NUM2UINT(merge_id);
|
124
|
+
gtk_ui_manager_add_ui(_SELF(self), ret, RVAL2CSTR(path),
|
125
|
+
RVAL2CSTR(name), RVAL2CSTR(action),
|
126
|
+
RVAL2GFLAGS(type, GTK_TYPE_UI_MANAGER_ITEM_TYPE),
|
127
|
+
RVAL2CBOOL(top));
|
128
|
+
}
|
129
|
+
|
130
|
+
if (ret == 0) RAISE_GERROR(error);
|
131
|
+
|
132
|
+
return UINT2NUM(ret);
|
133
|
+
}
|
134
|
+
|
135
|
+
static VALUE
|
136
|
+
rbuimanager_new_merge_id(self)
|
137
|
+
VALUE self;
|
138
|
+
{
|
139
|
+
return UINT2NUM(gtk_ui_manager_new_merge_id(_SELF(self)));
|
140
|
+
}
|
141
|
+
|
142
|
+
static VALUE
|
143
|
+
rbuimanager_remove_ui(self, merge_id)
|
144
|
+
VALUE self, merge_id;
|
145
|
+
{
|
146
|
+
gtk_ui_manager_remove_ui(_SELF(self), NUM2UINT(merge_id));
|
147
|
+
return self;
|
148
|
+
}
|
149
|
+
|
150
|
+
/* Defined as Properties
|
151
|
+
gchar* gtk_ui_manager_get_ui (GtkUIManager *self);
|
152
|
+
*/
|
153
|
+
|
154
|
+
static VALUE
|
155
|
+
rbuimanager_ensure_update(self)
|
156
|
+
VALUE self;
|
157
|
+
{
|
158
|
+
gtk_ui_manager_ensure_update(_SELF(self));
|
159
|
+
return self;
|
160
|
+
}
|
161
|
+
|
162
|
+
static void
|
163
|
+
rbuimanager_mark(void *p)
|
164
|
+
{
|
165
|
+
GtkUIManager *manager;
|
166
|
+
GList *node;
|
167
|
+
|
168
|
+
manager = GTK_UI_MANAGER(p);
|
169
|
+
for (node = gtk_ui_manager_get_action_groups(manager);
|
170
|
+
node;
|
171
|
+
node = g_list_next(node)) {
|
172
|
+
GtkWidget *action_group = node->data;
|
173
|
+
rbgobj_gc_mark_instance(action_group);
|
174
|
+
}
|
175
|
+
|
176
|
+
rbgobj_gc_mark_instance(gtk_ui_manager_get_accel_group(manager));
|
177
|
+
}
|
178
|
+
#endif
|
179
|
+
|
180
|
+
void
|
181
|
+
Init_gtk_uimanager()
|
182
|
+
{
|
183
|
+
#if GTK_CHECK_VERSION(2,4,0)
|
184
|
+
VALUE gUI;
|
185
|
+
|
186
|
+
gUI = G_DEF_CLASS_WITH_GC_FUNC(GTK_TYPE_UI_MANAGER, "UIManager", mGtk,
|
187
|
+
rbuimanager_mark, NULL);
|
188
|
+
|
189
|
+
rb_define_method(gUI, "initialize", rbuimanager_initialize, 0);
|
190
|
+
rb_define_method(gUI, "insert_action_group", rbuimanager_insert_action_group, 2);
|
191
|
+
rb_define_method(gUI, "remove_action_group", rbuimanager_remove_action_group, 1);
|
192
|
+
rb_define_method(gUI, "action_groups", rbuimanager_get_action_groups, 0);
|
193
|
+
rb_define_method(gUI, "accel_group", rbuimanager_get_accel_group, 0);
|
194
|
+
rb_define_method(gUI, "get_widget", rbuimanager_get_widget, 1);
|
195
|
+
rb_define_alias(gUI, "[]", "get_widget");
|
196
|
+
rb_define_method(gUI, "get_toplevels", rbuimanager_get_toplevels, 1);
|
197
|
+
rb_define_method(gUI, "get_action", rbuimanager_get_action, 1);
|
198
|
+
rb_define_method(gUI, "add_ui", rbuimanager_add_ui, -1);
|
199
|
+
rb_define_method(gUI, "new_merge_id", rbuimanager_new_merge_id, 0);
|
200
|
+
rb_define_method(gUI, "remove_ui", rbuimanager_remove_ui, 1);
|
201
|
+
rb_define_method(gUI, "ensure_update", rbuimanager_ensure_update, 0);
|
202
|
+
|
203
|
+
G_DEF_SETTERS(gUI);
|
204
|
+
|
205
|
+
/* GtkUIManagerItemType */
|
206
|
+
G_DEF_CLASS(GTK_TYPE_UI_MANAGER_ITEM_TYPE, "ItemType", gUI);
|
207
|
+
G_DEF_CONSTANTS(gUI, GTK_TYPE_UI_MANAGER_ITEM_TYPE, "GTK_UI_MANAGER_");
|
208
|
+
|
209
|
+
#endif
|
210
|
+
}
|