gtk2 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (281) hide show
  1. data/ChangeLog +6664 -0
  2. data/README +33 -0
  3. data/Rakefile +71 -0
  4. data/extconf.rb +116 -0
  5. data/src/global.h +33 -0
  6. data/src/init.c +39 -0
  7. data/src/lib/gtk2.rb +13 -0
  8. data/src/lib/gtk2/base.rb +95 -0
  9. data/src/makeinits.rb +57 -0
  10. data/src/makekeysyms.rb +5 -0
  11. data/src/rbgdk.c +395 -0
  12. data/src/rbgdk.h +50 -0
  13. data/src/rbgdkatom.c +122 -0
  14. data/src/rbgdkcairo.c +100 -0
  15. data/src/rbgdkcolor.c +151 -0
  16. data/src/rbgdkcolormap.c +142 -0
  17. data/src/rbgdkconst.c +29 -0
  18. data/src/rbgdkconversions.h +18 -0
  19. data/src/rbgdkcursor.c +115 -0
  20. data/src/rbgdkdevice.c +235 -0
  21. data/src/rbgdkdisplay.c +634 -0
  22. data/src/rbgdkdisplaymanager.c +50 -0
  23. data/src/rbgdkdragcontext.c +280 -0
  24. data/src/rbgdkdraw.c +487 -0
  25. data/src/rbgdkevent.c +1020 -0
  26. data/src/rbgdkgc.c +456 -0
  27. data/src/rbgdkgeometry.c +272 -0
  28. data/src/rbgdkimage.c +155 -0
  29. data/src/rbgdkinput.c +70 -0
  30. data/src/rbgdkkeymap.c +153 -0
  31. data/src/rbgdkkeysyms.h +2174 -0
  32. data/src/rbgdkkeyval.c +105 -0
  33. data/src/rbgdkpango.c +171 -0
  34. data/src/rbgdkpangorenderer.c +132 -0
  35. data/src/rbgdkpixbuf.c +178 -0
  36. data/src/rbgdkpixmap.c +255 -0
  37. data/src/rbgdkproperty.c +342 -0
  38. data/src/rbgdkrectangle.c +146 -0
  39. data/src/rbgdkregion.c +242 -0
  40. data/src/rbgdkrgb.c +197 -0
  41. data/src/rbgdkscreen.c +535 -0
  42. data/src/rbgdkselection.c +161 -0
  43. data/src/rbgdkthreads.c +68 -0
  44. data/src/rbgdktimecoord.c +118 -0
  45. data/src/rbgdkvisual.c +273 -0
  46. data/src/rbgdkwindow.c +1302 -0
  47. data/src/rbgdkwindowattr.c +213 -0
  48. data/src/rbgdkx11.c +256 -0
  49. data/src/rbgtk.c +93 -0
  50. data/src/rbgtk.h +121 -0
  51. data/src/rbgtkaboutdialog.c +195 -0
  52. data/src/rbgtkaccelerator.c +78 -0
  53. data/src/rbgtkaccelgroup.c +216 -0
  54. data/src/rbgtkaccelgroupentry.c +85 -0
  55. data/src/rbgtkaccelkey.c +116 -0
  56. data/src/rbgtkaccellabel.c +46 -0
  57. data/src/rbgtkaccelmap.c +162 -0
  58. data/src/rbgtkaccessible.c +29 -0
  59. data/src/rbgtkaction.c +277 -0
  60. data/src/rbgtkactiongroup.c +377 -0
  61. data/src/rbgtkadjustment.c +153 -0
  62. data/src/rbgtkalignment.c +71 -0
  63. data/src/rbgtkallocation.c +171 -0
  64. data/src/rbgtkarrow.c +47 -0
  65. data/src/rbgtkaspectframe.c +46 -0
  66. data/src/rbgtkassistant.c +230 -0
  67. data/src/rbgtkbbox.c +47 -0
  68. data/src/rbgtkbin.c +31 -0
  69. data/src/rbgtkbindingset.c +192 -0
  70. data/src/rbgtkborder.c +80 -0
  71. data/src/rbgtkbox.c +142 -0
  72. data/src/rbgtkbuildable.c +115 -0
  73. data/src/rbgtkbuilder.c +154 -0
  74. data/src/rbgtkbutton.c +151 -0
  75. data/src/rbgtkcalendar.c +159 -0
  76. data/src/rbgtkcelleditable.c +49 -0
  77. data/src/rbgtkcelllayout.c +144 -0
  78. data/src/rbgtkcellrenderer.c +139 -0
  79. data/src/rbgtkcellrendereraccel.c +42 -0
  80. data/src/rbgtkcellrenderercombo.c +37 -0
  81. data/src/rbgtkcellrendererpixbuf.c +33 -0
  82. data/src/rbgtkcellrendererprogress.c +37 -0
  83. data/src/rbgtkcellrendererspin.c +38 -0
  84. data/src/rbgtkcellrenderertext.c +45 -0
  85. data/src/rbgtkcellrenderertoggle.c +32 -0
  86. data/src/rbgtkcellview.c +134 -0
  87. data/src/rbgtkcheckbutton.c +55 -0
  88. data/src/rbgtkcheckmenuitem.c +56 -0
  89. data/src/rbgtkclipboard.c +473 -0
  90. data/src/rbgtkcolorbutton.c +63 -0
  91. data/src/rbgtkcolorsel.c +175 -0
  92. data/src/rbgtkcolorselectiondialog.c +72 -0
  93. data/src/rbgtkcombo.c +117 -0
  94. data/src/rbgtkcombobox.c +240 -0
  95. data/src/rbgtkcomboboxentry.c +60 -0
  96. data/src/rbgtkconst.c +163 -0
  97. data/src/rbgtkcontainer.c +776 -0
  98. data/src/rbgtkconversions.h +26 -0
  99. data/src/rbgtkcurve.c +105 -0
  100. data/src/rbgtkdialog.c +244 -0
  101. data/src/rbgtkdrag.c +436 -0
  102. data/src/rbgtkdrawingarea.c +31 -0
  103. data/src/rbgtkeditable.c +152 -0
  104. data/src/rbgtkentry.c +161 -0
  105. data/src/rbgtkentrycompletion.c +167 -0
  106. data/src/rbgtkeventbox.c +31 -0
  107. data/src/rbgtkexpander.c +67 -0
  108. data/src/rbgtkfilechooser.c +403 -0
  109. data/src/rbgtkfilechooserbutton.c +72 -0
  110. data/src/rbgtkfilechooserdialog.c +58 -0
  111. data/src/rbgtkfilechooserwidget.c +50 -0
  112. data/src/rbgtkfilefilter.c +139 -0
  113. data/src/rbgtkfilesel.c +155 -0
  114. data/src/rbgtkfixed.c +72 -0
  115. data/src/rbgtkfontbutton.c +69 -0
  116. data/src/rbgtkfontselection.c +30 -0
  117. data/src/rbgtkfontselectiondialog.c +106 -0
  118. data/src/rbgtkframe.c +64 -0
  119. data/src/rbgtkgamma.c +47 -0
  120. data/src/rbgtkhandlebox.c +42 -0
  121. data/src/rbgtkhbbox.c +31 -0
  122. data/src/rbgtkhbox.c +38 -0
  123. data/src/rbgtkhpaned.c +31 -0
  124. data/src/rbgtkhruler.c +31 -0
  125. data/src/rbgtkhscale.c +45 -0
  126. data/src/rbgtkhscrollbar.c +38 -0
  127. data/src/rbgtkhseparator.c +30 -0
  128. data/src/rbgtkiconfactory.c +80 -0
  129. data/src/rbgtkiconinfo.c +118 -0
  130. data/src/rbgtkiconset.c +87 -0
  131. data/src/rbgtkiconsize.c +90 -0
  132. data/src/rbgtkiconsource.c +176 -0
  133. data/src/rbgtkicontheme.c +309 -0
  134. data/src/rbgtkiconview.c +351 -0
  135. data/src/rbgtkimage.c +152 -0
  136. data/src/rbgtkimagemenuitem.c +52 -0
  137. data/src/rbgtkimcontext.c +134 -0
  138. data/src/rbgtkimcontextsimple.c +48 -0
  139. data/src/rbgtkimmulticontext.c +38 -0
  140. data/src/rbgtkinits.c +473 -0
  141. data/src/rbgtkinputdialog.c +30 -0
  142. data/src/rbgtkinvisible.c +68 -0
  143. data/src/rbgtkitem.c +51 -0
  144. data/src/rbgtkitemfactory.c +312 -0
  145. data/src/rbgtklabel.c +168 -0
  146. data/src/rbgtklayout.c +91 -0
  147. data/src/rbgtklinkbutton.c +68 -0
  148. data/src/rbgtkliststore.c +412 -0
  149. data/src/rbgtkmacros.h +26 -0
  150. data/src/rbgtkmain.c +532 -0
  151. data/src/rbgtkmenu.c +272 -0
  152. data/src/rbgtkmenubar.c +48 -0
  153. data/src/rbgtkmenuitem.c +171 -0
  154. data/src/rbgtkmenushell.c +128 -0
  155. data/src/rbgtkmenutoolbutton.c +74 -0
  156. data/src/rbgtkmessagedialog.c +102 -0
  157. data/src/rbgtkmisc.c +63 -0
  158. data/src/rbgtknotebook.c +484 -0
  159. data/src/rbgtkobject.c +186 -0
  160. data/src/rbgtkoptionmenu.c +65 -0
  161. data/src/rbgtkpagesetup.c +196 -0
  162. data/src/rbgtkpagesetupunixdialog.c +80 -0
  163. data/src/rbgtkpaned.c +114 -0
  164. data/src/rbgtkpapersize.c +186 -0
  165. data/src/rbgtkplug.c +84 -0
  166. data/src/rbgtkprintcontext.c +124 -0
  167. data/src/rbgtkprinter.c +155 -0
  168. data/src/rbgtkprintjob.c +151 -0
  169. data/src/rbgtkprintoperation.c +152 -0
  170. data/src/rbgtkprintoperationpreview.c +54 -0
  171. data/src/rbgtkprintsettings.c +794 -0
  172. data/src/rbgtkprintunixdialog.c +98 -0
  173. data/src/rbgtkprogress.c +21 -0
  174. data/src/rbgtkprogressbar.c +72 -0
  175. data/src/rbgtkradioaction.c +102 -0
  176. data/src/rbgtkradiobutton.c +83 -0
  177. data/src/rbgtkradiomenuitem.c +115 -0
  178. data/src/rbgtkradiotoolbutton.c +99 -0
  179. data/src/rbgtkrange.c +98 -0
  180. data/src/rbgtkrc.c +228 -0
  181. data/src/rbgtkrcstyle.c +184 -0
  182. data/src/rbgtkrecentaction.c +52 -0
  183. data/src/rbgtkrecentchooser.c +276 -0
  184. data/src/rbgtkrecentchooserdialog.c +59 -0
  185. data/src/rbgtkrecentchoosermenu.c +55 -0
  186. data/src/rbgtkrecentchooserwidget.c +45 -0
  187. data/src/rbgtkrecentdata.c +152 -0
  188. data/src/rbgtkrecentfilter.c +180 -0
  189. data/src/rbgtkrecentfilterinfo.c +197 -0
  190. data/src/rbgtkrecentinfo.c +232 -0
  191. data/src/rbgtkrecentmanager.c +164 -0
  192. data/src/rbgtkruler.c +82 -0
  193. data/src/rbgtkscale.c +47 -0
  194. data/src/rbgtkscalebutton.c +115 -0
  195. data/src/rbgtkscrollbar.c +21 -0
  196. data/src/rbgtkscrolledwindow.c +160 -0
  197. data/src/rbgtkselection.c +171 -0
  198. data/src/rbgtkselectiondata.c +333 -0
  199. data/src/rbgtkseparator.c +21 -0
  200. data/src/rbgtkseparatormenuitem.c +28 -0
  201. data/src/rbgtkseparatortoolitem.c +40 -0
  202. data/src/rbgtksettings.c +225 -0
  203. data/src/rbgtksizegroup.c +74 -0
  204. data/src/rbgtksocket.c +72 -0
  205. data/src/rbgtkspinbutton.c +138 -0
  206. data/src/rbgtkstatusbar.c +90 -0
  207. data/src/rbgtkstatusicon.c +120 -0
  208. data/src/rbgtkstock.c +264 -0
  209. data/src/rbgtkstyle.c +722 -0
  210. data/src/rbgtktable.c +190 -0
  211. data/src/rbgtktargetlist.c +148 -0
  212. data/src/rbgtktearoffmenuitem.c +30 -0
  213. data/src/rbgtktextappearance.c +173 -0
  214. data/src/rbgtktextattributes.c +209 -0
  215. data/src/rbgtktextbuffer.c +993 -0
  216. data/src/rbgtktextchild.c +49 -0
  217. data/src/rbgtktextiter.c +553 -0
  218. data/src/rbgtktextmark.c +87 -0
  219. data/src/rbgtktexttag.c +66 -0
  220. data/src/rbgtktexttagtable.c +94 -0
  221. data/src/rbgtktextview.c +351 -0
  222. data/src/rbgtktoggleaction.c +76 -0
  223. data/src/rbgtktogglebutton.c +84 -0
  224. data/src/rbgtktoggletoolbutton.c +70 -0
  225. data/src/rbgtktoolbar.c +373 -0
  226. data/src/rbgtktoolbutton.c +75 -0
  227. data/src/rbgtktoolitem.c +184 -0
  228. data/src/rbgtktooltip.c +76 -0
  229. data/src/rbgtktooltips.c +107 -0
  230. data/src/rbgtktreedragdest.c +19 -0
  231. data/src/rbgtktreedragsource.c +19 -0
  232. data/src/rbgtktreeiter.c +259 -0
  233. data/src/rbgtktreemodel.c +256 -0
  234. data/src/rbgtktreemodelfilter.c +214 -0
  235. data/src/rbgtktreemodelsort.c +113 -0
  236. data/src/rbgtktreepath.c +195 -0
  237. data/src/rbgtktreerowreference.c +168 -0
  238. data/src/rbgtktreeselection.c +235 -0
  239. data/src/rbgtktreesortable.c +127 -0
  240. data/src/rbgtktreestore.c +379 -0
  241. data/src/rbgtktreeview.c +881 -0
  242. data/src/rbgtktreeviewcolumn.c +331 -0
  243. data/src/rbgtkuimanager.c +210 -0
  244. data/src/rbgtkvbbox.c +31 -0
  245. data/src/rbgtkvbox.c +38 -0
  246. data/src/rbgtkviewport.c +33 -0
  247. data/src/rbgtkvolumebutton.c +36 -0
  248. data/src/rbgtkvpaned.c +31 -0
  249. data/src/rbgtkvruler.c +30 -0
  250. data/src/rbgtkvscale.c +45 -0
  251. data/src/rbgtkvscrollbar.c +38 -0
  252. data/src/rbgtkvseparator.c +30 -0
  253. data/src/rbgtkwidget.c +1414 -0
  254. data/src/rbgtkwindow.c +822 -0
  255. data/src/rbgtkwindowgroup.c +48 -0
  256. data/test/gtk-test-utils.rb +15 -0
  257. data/test/run-test.rb +30 -0
  258. data/test/test_gc.rb +25 -0
  259. data/test/test_gdk.rb +18 -0
  260. data/test/test_gdk_color.rb +10 -0
  261. data/test/test_gdk_display.rb +37 -0
  262. data/test/test_gdk_event.rb +11 -0
  263. data/test/test_gdk_gc.rb +7 -0
  264. data/test/test_gdk_keymap.rb +8 -0
  265. data/test/test_gdk_pango.rb +9 -0
  266. data/test/test_gdk_selection_data.rb +17 -0
  267. data/test/test_gdk_window.rb +29 -0
  268. data/test/test_gdk_window_attribute.rb +9 -0
  269. data/test/test_gtk_about_dialog.rb +14 -0
  270. data/test/test_gtk_buildable.rb +66 -0
  271. data/test/test_gtk_builder.rb +188 -0
  272. data/test/test_gtk_entry.rb +18 -0
  273. data/test/test_gtk_icon_theme.rb +30 -0
  274. data/test/test_gtk_image.rb +8 -0
  275. data/test/test_gtk_list_store.rb +65 -0
  276. data/test/test_gtk_menu_item.rb +13 -0
  277. data/test/test_gtk_rc_style.rb +14 -0
  278. data/test/test_gtk_tree_path.rb +20 -0
  279. data/test/test_gtk_unix_print.rb +14 -0
  280. data/test/test_gtk_widget.rb +32 -0
  281. 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
+ }