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,30 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgtkinputdialog.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2003/02/01 16:46:23 $
8
+
9
+ Copyright (C) 2002,2003 Ruby-GNOME2 Project Team
10
+ Copyright (C) 1998-2000 Yukihiro Matsumoto,
11
+ Daisuke Kanda,
12
+ Hiroshi Igarashi
13
+ ************************************************/
14
+
15
+ #include "global.h"
16
+
17
+ static VALUE
18
+ idiag_initialize(self)
19
+ VALUE self;
20
+ {
21
+ RBGTK_INITIALIZE(self, gtk_input_dialog_new());
22
+ return Qnil;
23
+ }
24
+
25
+ void
26
+ Init_gtk_input_dialog()
27
+ {
28
+ VALUE gInputDialog = G_DEF_CLASS(GTK_TYPE_INPUT_DIALOG, "InputDialog", mGtk);
29
+ rb_define_method(gInputDialog, "initialize", idiag_initialize, 0);
30
+ }
@@ -0,0 +1,68 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgtkinvisible.c -
5
+
6
+ $Author: sakai $
7
+ $Date: 2003/11/20 18:27:54 $
8
+
9
+ Copyright (C) 2002,2003 OGASAWARA, Takeshi
10
+ ************************************************/
11
+ #include "global.h"
12
+
13
+ #define _SELF(s) GTK_INVISIBLE(RVAL2GOBJ(s))
14
+
15
+ static VALUE
16
+ invisible_initialize(argc, argv, self)
17
+ int argc;
18
+ VALUE *argv;
19
+ VALUE self;
20
+ {
21
+ VALUE screen;
22
+
23
+ rb_scan_args(argc, argv, "01", &screen);
24
+
25
+ if (argc == 0){
26
+ RBGTK_INITIALIZE(self, gtk_invisible_new());
27
+ } else {
28
+ #if GTK_CHECK_VERSION(2,2,0)
29
+ RBGTK_INITIALIZE(self, gtk_invisible_new_for_screen(
30
+ GDK_SCREEN(RVAL2GOBJ(screen))));
31
+ #else
32
+ rb_raise(rb_eArgError, "GTK+-2.2 feature. GTK+-2.0.x doesn't support this.");
33
+ #endif
34
+ }
35
+ return Qnil;
36
+ }
37
+
38
+ #if GTK_CHECK_VERSION(2,2,0)
39
+ static VALUE
40
+ invisible_set_screen(self, screen)
41
+ VALUE self, screen;
42
+ {
43
+ gtk_invisible_set_screen(_SELF(self), GDK_SCREEN(RVAL2GOBJ(screen)));
44
+ return self;
45
+ }
46
+
47
+ static VALUE
48
+ invisible_get_screen(self)
49
+ VALUE self;
50
+ {
51
+ return GOBJ2RVAL(gtk_invisible_get_screen(_SELF(self)));
52
+ }
53
+ #endif
54
+
55
+ void
56
+ Init_invisible()
57
+ {
58
+ VALUE gInvisible = G_DEF_CLASS(GTK_TYPE_INVISIBLE, "Invisible", mGtk);
59
+
60
+ rb_define_method(gInvisible, "initialize", invisible_initialize, -1);
61
+
62
+ #if GTK_CHECK_VERSION(2,2,0)
63
+ rb_define_method(gInvisible, "set_screen", invisible_set_screen, 1);
64
+ rb_define_method(gInvisible, "screen", invisible_get_screen, 0);
65
+ #endif
66
+
67
+ G_DEF_SETTERS(gInvisible);
68
+ }
@@ -0,0 +1,51 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgtkitem.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2003/02/01 16:46:23 $
8
+
9
+ Copyright (C) 2002,2003 Ruby-GNOME2 Project Team
10
+ Copyright (C) 1998-2000 Yukihiro Matsumoto,
11
+ Daisuke Kanda,
12
+ Hiroshi Igarashi
13
+ ************************************************/
14
+
15
+ #include "global.h"
16
+
17
+ /*
18
+ * Item
19
+ */
20
+ static VALUE
21
+ item_select(self)
22
+ VALUE self;
23
+ {
24
+ gtk_item_select(GTK_ITEM(RVAL2GOBJ(self)));
25
+ return self;
26
+ }
27
+
28
+ static VALUE
29
+ item_deselect(self)
30
+ VALUE self;
31
+ {
32
+ gtk_item_deselect(GTK_ITEM(RVAL2GOBJ(self)));
33
+ return self;
34
+ }
35
+
36
+ static VALUE
37
+ item_toggle(self)
38
+ VALUE self;
39
+ {
40
+ gtk_item_toggle(GTK_ITEM(RVAL2GOBJ(self)));
41
+ return self;
42
+ }
43
+
44
+ void
45
+ Init_gtk_item()
46
+ {
47
+ VALUE gItem = G_DEF_CLASS(GTK_TYPE_ITEM, "Item", mGtk);
48
+ rb_define_method(gItem, "select", item_select, 0);
49
+ rb_define_method(gItem, "deselect", item_deselect, 0);
50
+ rb_define_method(gItem, "toggle", item_toggle, 0);
51
+ }
@@ -0,0 +1,312 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgtkitemfactory.c -
5
+
6
+ $Author: sakai $
7
+ $Date: 2007/07/08 03:00:49 $
8
+
9
+ Copyright (C) 2002-2005 Ruby-GNOME2 Project Team
10
+ Copyright (C) 1998-2000 Hiroshi Igarashi,
11
+ dellin,
12
+ MUTOH Masao
13
+ ************************************************/
14
+
15
+ #include "global.h"
16
+ #include <gdk-pixbuf/gdk-pixdata.h>
17
+
18
+ #define _SELF(self) (GTK_ITEM_FACTORY(RVAL2GOBJ(self)))
19
+ #define RVAL2WIDGET(w) (GTK_WIDGET(RVAL2GOBJ(w)))
20
+ #define RVAL2ACCEL(a) (GTK_ACCEL_GROUP(RVAL2GOBJ(a)))
21
+
22
+ static VALUE action_table;
23
+ static guint action_id = 0;
24
+
25
+ static VALUE
26
+ ifact_initialize(self, type, path, accel)
27
+ VALUE self;
28
+ VALUE type, path, accel;
29
+ {
30
+ VALUE obj = rb_eval_string("eval('self', binding)");
31
+ G_RELATIVE(obj, self);
32
+ RBGTK_INITIALIZE(self, gtk_item_factory_new(FIX2INT(type), RVAL2CSTR(path),
33
+ RVAL2ACCEL(accel)));
34
+
35
+ return Qnil;
36
+ }
37
+
38
+ static VALUE
39
+ ifact_construct(argc, argv, self)
40
+ int argc;
41
+ VALUE *argv;
42
+ VALUE self;
43
+ {
44
+ VALUE type, path, accel;
45
+ GtkItemFactory* ifact = _SELF(self);
46
+ ifact->accel_group = NULL;
47
+
48
+ rb_scan_args(argc, argv, "21", &type, &path, &accel);
49
+ gtk_item_factory_construct(ifact, FIX2INT(type),
50
+ RVAL2CSTR(path), RVAL2ACCEL(accel));
51
+ return self;
52
+ }
53
+
54
+ static VALUE
55
+ ifact_s_from_widget(self, widget)
56
+ VALUE self, widget;
57
+ {
58
+ VALUE obj = GOBJ2RVAL(gtk_item_factory_from_widget(RVAL2WIDGET(widget)));
59
+ G_RELATIVE(obj, self);
60
+ return obj;
61
+ }
62
+
63
+ static VALUE
64
+ ifact_s_path_from_widget(self, widget)
65
+ VALUE self, widget;
66
+ {
67
+ return CSTR2RVAL(gtk_item_factory_path_from_widget(RVAL2WIDGET(widget)));
68
+ }
69
+
70
+ static VALUE
71
+ ifact_get_item(self, path)
72
+ VALUE self, path;
73
+ {
74
+ VALUE obj = Qnil;
75
+ GtkWidget* widget = gtk_item_factory_get_item(_SELF(self), RVAL2CSTR(path));
76
+ if (widget){
77
+ obj = GOBJ2RVAL(widget);
78
+ G_RELATIVE(obj, self);
79
+ }
80
+ return obj;
81
+ }
82
+
83
+ static VALUE
84
+ ifact_get_widget(self, path)
85
+ VALUE self, path;
86
+ {
87
+ VALUE obj = Qnil;
88
+ GtkWidget* widget = gtk_item_factory_get_widget(_SELF(self), RVAL2CSTR(path));
89
+ if (widget){
90
+ obj = GOBJ2RVAL(widget);
91
+ G_RELATIVE(obj, self);
92
+ }
93
+ return obj;
94
+ }
95
+
96
+ /* We can't implement them because actions are always 1.
97
+ GtkWidget* gtk_item_factory_get_widget_by_action
98
+ (GtkItemFactory *ifactory,
99
+ guint action);
100
+ GtkWidget* gtk_item_factory_get_item_by_action
101
+ (GtkItemFactory *ifactory,
102
+ guint action);
103
+ */
104
+
105
+ static int
106
+ menuitem_type_check(item_type)
107
+ char *item_type;
108
+ {
109
+ if (item_type == NULL || strcmp(item_type, "<Branch>") == 0
110
+ || (strcmp(item_type, "<LastBranch>") == 0)
111
+ || (strcmp(item_type, "<Separator>") == 0))
112
+ return 0;
113
+ else
114
+ return -1;
115
+ }
116
+
117
+ static void
118
+ items_exec_callback_wrap(callback_data, action_id, widget)
119
+ VALUE callback_data;
120
+ guint action_id;
121
+ GtkWidget* widget;
122
+ {
123
+ VALUE iter, data;
124
+ VALUE action = rb_hash_aref(action_table, UINT2NUM(action_id));
125
+
126
+ iter = RARRAY_PTR(action)[0];
127
+ data = RARRAY_PTR(action)[1];
128
+ if (!NIL_P(iter)) {
129
+ rb_funcall(iter, id_call, 2, data, GOBJ2RVAL(widget));
130
+ }
131
+ }
132
+
133
+ static void
134
+ create_factory_entry(entry, self, path, item_type, accel, extdata, func, data)
135
+ GtkItemFactoryEntry* entry;
136
+ VALUE self, path, item_type, accel, extdata, func, data;
137
+ {
138
+ VALUE action;
139
+
140
+ entry->path = NIL_P(path) ? NULL : RVAL2CSTR(path);
141
+ entry->item_type = NIL_P(item_type) ? "<Branch>" : RVAL2CSTR(item_type);
142
+ entry->accelerator = NIL_P(accel) ? NULL : RVAL2CSTR(accel);
143
+
144
+ if (menuitem_type_check(entry->item_type) == 0) {
145
+ entry->callback = NULL;
146
+ } else {
147
+ if (NIL_P(func)) {
148
+ entry->callback = NULL;
149
+ } else {
150
+ entry->callback = items_exec_callback_wrap;
151
+ }
152
+ }
153
+ action = rb_ary_new3(2, func, data);
154
+ G_RELATIVE(self, action);
155
+ rb_hash_aset(action_table, UINT2NUM(action_id), action);
156
+ entry->callback_action = action_id;
157
+ action_id++;
158
+
159
+ if (NIL_P(extdata)){
160
+ entry->extra_data = NULL;
161
+ } else if (TYPE(extdata) == T_STRING){
162
+ entry->extra_data = RVAL2CSTR(extdata);
163
+ } else if (TYPE(extdata) == T_SYMBOL){
164
+ entry->extra_data = rb_id2name(SYM2ID(extdata));
165
+ } else if (RVAL2GTYPE(extdata) == GDK_TYPE_PIXBUF){
166
+ GdkPixdata pixdata;
167
+ guint stream_length_p;
168
+ gdk_pixdata_from_pixbuf(&pixdata, GDK_PIXBUF(RVAL2GOBJ(extdata)), TRUE);
169
+ entry->extra_data = gdk_pixdata_serialize(&pixdata, &stream_length_p);
170
+ } else {
171
+ entry->extra_data = NULL;
172
+ }
173
+ }
174
+
175
+ static VALUE
176
+ ifact_create_item(argc, argv, self)
177
+ int argc;
178
+ VALUE *argv;
179
+ VALUE self;
180
+ {
181
+ VALUE path, type, accel, extdata, data, func;
182
+ GtkItemFactoryEntry *entry;
183
+
184
+ rb_scan_args(argc, argv, "14", &path, &type, &accel, &extdata, &data);
185
+
186
+ entry = ALLOC(GtkItemFactoryEntry);
187
+ func = rb_rescue((VALUE(*)())rb_block_proc, 0, NULL, 0);
188
+
189
+ create_factory_entry(entry, self, path, type, accel, extdata, func, data);
190
+
191
+ gtk_item_factory_create_item(_SELF(self), entry, (gpointer)self, 1);
192
+ g_free(entry);
193
+ return self;
194
+ }
195
+
196
+ static VALUE
197
+ ifact_create_items(self, ary)
198
+ VALUE self, ary;
199
+ {
200
+ VALUE entry, path, accel, type, func, data, extdata;
201
+ GtkItemFactoryEntry *entries;
202
+ guint i, len, n_menu_entries;
203
+
204
+ n_menu_entries = RARRAY_LEN(ary);
205
+ entries = ALLOC_N(GtkItemFactoryEntry, n_menu_entries);
206
+
207
+ for (i = 0; i < n_menu_entries; i++) {
208
+ entry = RARRAY_PTR(ary)[i];
209
+ len = RARRAY_LEN(entry);
210
+ Check_Type(entry, T_ARRAY);
211
+ path = RARRAY_PTR(entry)[0];
212
+ type = ((len > 1) ? RARRAY_PTR(entry)[1] : Qnil);
213
+ accel = ((len > 2) ? RARRAY_PTR(entry)[2] : Qnil);
214
+ extdata = ((len > 3) ? RARRAY_PTR(entry)[3] : Qnil);
215
+ func = ((len > 4) ? RARRAY_PTR(entry)[4] : Qnil);
216
+ data = ((len > 5) ? RARRAY_PTR(entry)[5] : Qnil);
217
+
218
+ create_factory_entry(&entries[i], self, path, type, accel, extdata, func, data);
219
+ }
220
+
221
+ gtk_item_factory_create_items (_SELF(self), n_menu_entries, entries, NULL);
222
+ g_free(entries);
223
+
224
+ return self;
225
+ }
226
+
227
+
228
+ static VALUE
229
+ ifact_delete_item(self, path)
230
+ VALUE self, path;
231
+ {
232
+ gtk_item_factory_delete_item(_SELF(self), RVAL2CSTR(path));
233
+ return self;
234
+ }
235
+
236
+ /*
237
+ Don't implement. Use Gtk::ItemFactory#delete_item instead.
238
+ void gtk_item_factory_delete_entry (GtkItemFactory *ifactory,
239
+ GtkItemFactoryEntry *entry);
240
+ void gtk_item_factory_delete_entries (GtkItemFactory *ifactory,
241
+ guint n_entries,
242
+ GtkItemFactoryEntry *entries);
243
+ */
244
+
245
+ static VALUE
246
+ ifact_popup(self, x, y, mouse_button, time)
247
+ VALUE self, x, y, mouse_button, time;
248
+ {
249
+ gtk_item_factory_popup(_SELF(self), NUM2UINT(x), NUM2UINT(y), NUM2UINT(mouse_button),
250
+ NUM2UINT(time));
251
+ return self;
252
+ }
253
+ /*
254
+ Do we need these methods?
255
+ void gtk_item_factory_popup_with_data
256
+ (GtkItemFactory *ifactory,
257
+ gpointer popup_data,
258
+ GtkDestroyNotify destroy,
259
+ guint x,
260
+ guint y,
261
+ guint mouse_button,
262
+ guint32 time);
263
+
264
+ gpointer gtk_item_factory_popup_data (GtkItemFactory *ifactory);
265
+ gpointer gtk_item_factory_popup_data_from_widget
266
+ (GtkWidget *widget);
267
+ void gtk_item_factory_set_translate_func
268
+ (GtkItemFactory *ifactory,
269
+ GtkTranslateFunc func,
270
+ gpointer data,
271
+ GtkDestroyNotify notify);
272
+ */
273
+
274
+
275
+ void
276
+ Init_gtk_itemfactory()
277
+ {
278
+ VALUE gItemFactory = G_DEF_CLASS(GTK_TYPE_ITEM_FACTORY, "ItemFactory", mGtk);
279
+
280
+ rb_define_singleton_method(gItemFactory, "from_widget", ifact_s_from_widget, 1);
281
+ rb_define_singleton_method(gItemFactory, "path_from_widget", ifact_s_path_from_widget, 1);
282
+
283
+ rb_define_method(gItemFactory, "initialize", ifact_initialize, 3);
284
+ rb_define_method(gItemFactory, "construct", ifact_construct, -1);
285
+ rb_define_method(gItemFactory, "get_item", ifact_get_item, 1);
286
+ rb_define_method(gItemFactory, "get_widget", ifact_get_widget, 1);
287
+ rb_define_method(gItemFactory, "create_item", ifact_create_item, -1);
288
+ rb_define_method(gItemFactory, "create_items", ifact_create_items, 1);
289
+ rb_define_method(gItemFactory, "delete_item", ifact_delete_item, 1);
290
+ rb_define_method(gItemFactory, "popup", ifact_popup, 4);
291
+
292
+ /* Ruby/GTK Original constants */
293
+ rb_define_const(gItemFactory, "TYPE_MENU_BAR", INT2FIX(GTK_TYPE_MENU_BAR));
294
+ rb_define_const(gItemFactory, "TYPE_MENU", INT2FIX(GTK_TYPE_MENU));
295
+ rb_define_const(gItemFactory, "TYPE_OPTION_MENU", INT2FIX(GTK_TYPE_OPTION_MENU));
296
+
297
+ rb_define_const(gItemFactory, "TITLE", CSTR2RVAL("<Title>"));
298
+ rb_define_const(gItemFactory, "ITEM", CSTR2RVAL("<Item>"));
299
+ rb_define_const(gItemFactory, "CHECK_ITEM", CSTR2RVAL("<CheckItem>"));
300
+ rb_define_const(gItemFactory, "TOGGLE_ITEM", CSTR2RVAL("<ToggleItem>"));
301
+ rb_define_const(gItemFactory, "RADIO_ITEM", CSTR2RVAL("<RadioItem>"));
302
+ rb_define_const(gItemFactory, "IMAGE_ITEM", CSTR2RVAL("<ImageItem>"));
303
+ rb_define_const(gItemFactory, "STOCK_ITEM", CSTR2RVAL("<StockItem>"));
304
+ rb_define_const(gItemFactory, "SEPARATOR", CSTR2RVAL("<Separator>"));
305
+ rb_define_const(gItemFactory, "BRANCH", CSTR2RVAL("<Branch>"));
306
+ rb_define_const(gItemFactory, "LAST_BRANCH", CSTR2RVAL("<LastBranch>"));
307
+ rb_define_const(gItemFactory, "TEAROFF", CSTR2RVAL("<Tearoff>"));
308
+
309
+ action_table = rb_hash_new();
310
+ rb_global_variable(&action_table);
311
+ }
312
+