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,255 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgdkpixmap.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2006/11/25 17:50:41 $
8
+
9
+ Copyright (C) 2002-2004 Ruby-GNOME2 Project Team
10
+ Copyright (C) 1998-2000 Yukihiro Matsumoto,
11
+ Daisuke Kanda,
12
+ Hiroshi Igarashi
13
+ ************************************************/
14
+
15
+ #include "global.h"
16
+ #ifdef HAVE_XREADBITMAPFILEDATA
17
+ #include <X11/Xlib.h>
18
+ #endif /* HAVE_XREADBITMAPFILEDATA */
19
+
20
+ static VALUE
21
+ gdkpmap_initialize(self, win, w, h, depth)
22
+ VALUE self, win, w, h, depth;
23
+ {
24
+ G_INITIALIZE(self, gdk_pixmap_new(GDK_WINDOW(RVAL2GOBJ(win)),
25
+ NUM2INT(w), NUM2INT(h),
26
+ NUM2INT(depth)));
27
+ return Qnil;
28
+ }
29
+
30
+ static VALUE
31
+ gdkpmap_create_from_data(argc, argv, self)
32
+ int argc;
33
+ VALUE *argv;
34
+ VALUE self;
35
+ {
36
+ VALUE win, data, w, h, depth, fg, bg, ret;
37
+
38
+ rb_scan_args(argc, argv, "43", &win, &data, &w, &h, &depth, &fg, &bg);
39
+
40
+ Check_Type(data, T_STRING);
41
+ if (NIL_P(depth)){
42
+ ret = GOBJ2RVAL(gdk_bitmap_create_from_data(NIL_P(win) ? NULL : GDK_WINDOW(RVAL2GOBJ(win)),
43
+ RVAL2CSTR(data), NUM2INT(w), NUM2INT(h)));
44
+ } else {
45
+ ret = GOBJ2RVAL(gdk_pixmap_create_from_data(NIL_P(win) ? NULL : GDK_WINDOW(RVAL2GOBJ(win)),
46
+ RVAL2CSTR(data), NUM2INT(w), NUM2INT(h),
47
+ NUM2INT(depth),
48
+ RVAL2GDKCOLOR(fg),
49
+ RVAL2GDKCOLOR(bg)));
50
+ }
51
+ return ret;
52
+ }
53
+
54
+ static VALUE
55
+ gdkpmap_create_from_xpm(self, win, color, fname)
56
+ VALUE self, win, color, fname;
57
+ {
58
+ GdkPixmap *new;
59
+ GdkBitmap *mask;
60
+
61
+ new = gdk_pixmap_create_from_xpm(GDK_WINDOW(RVAL2GOBJ(win)), &mask,
62
+ RVAL2GDKCOLOR(color), RVAL2CSTR(fname));
63
+ if (!new) {
64
+ rb_raise(rb_eArgError, "Pixmap not created from %s", RVAL2CSTR(fname));
65
+ }
66
+ return rb_assoc_new(GOBJ2RVAL(new),GOBJ2RVAL(mask));
67
+ }
68
+
69
+ static VALUE
70
+ gdkpmap_create_from_xpm_d(self, win, tcolor, data)
71
+ VALUE self, win, tcolor, data;
72
+ {
73
+ GdkPixmap *new;
74
+ GdkBitmap *mask;
75
+ int i;
76
+ gchar **buf;
77
+
78
+ Check_Type(data, T_ARRAY);
79
+ buf = ALLOCA_N(char*, RARRAY_LEN(data));
80
+ for (i=0; i < RARRAY_LEN(data); i++) {
81
+ buf[i] = RVAL2CSTR(RARRAY_PTR(data)[i]);
82
+ }
83
+ new = gdk_pixmap_create_from_xpm_d(GDK_WINDOW(RVAL2GOBJ(win)),
84
+ &mask, RVAL2GDKCOLOR(tcolor), buf);
85
+
86
+ return rb_assoc_new(GOBJ2RVAL(new),GOBJ2RVAL(mask));
87
+ }
88
+
89
+ static VALUE
90
+ gdkpmap_colormap_create_from_xpm(self, win, colormap, tcolor, fname)
91
+ VALUE self, win, colormap, tcolor, fname;
92
+ {
93
+ GdkPixmap *new;
94
+ GdkBitmap *mask;
95
+
96
+ new = gdk_pixmap_colormap_create_from_xpm(NIL_P(win) ? NULL : GDK_WINDOW(RVAL2GOBJ(win)),
97
+ GDK_COLORMAP(RVAL2GOBJ(colormap)),
98
+ &mask, RVAL2GDKCOLOR(tcolor),
99
+ RVAL2CSTR(fname));
100
+ if (!new) {
101
+ rb_raise(rb_eArgError, "Pixmap not created from %s", RVAL2CSTR(fname));
102
+ }
103
+ return rb_assoc_new(GOBJ2RVAL(new),GOBJ2RVAL(mask));
104
+ }
105
+
106
+ static VALUE
107
+ gdkpmap_colormap_create_from_xpm_d(self, win, colormap, tcolor, data)
108
+ VALUE self, win, colormap, tcolor, data;
109
+ {
110
+ GdkPixmap *new;
111
+ GdkBitmap *mask;
112
+ int i;
113
+ gchar **buf;
114
+
115
+ Check_Type(data, T_ARRAY);
116
+ buf = ALLOCA_N(char*, RARRAY_LEN(data));
117
+ for (i=0; i<RARRAY_LEN(data); i++) {
118
+ buf[i] = RVAL2CSTR(RARRAY_PTR(data)[i]);
119
+ }
120
+
121
+ new = gdk_pixmap_colormap_create_from_xpm_d(NIL_P(win) ? NULL : GDK_WINDOW(RVAL2GOBJ(win)),
122
+ GDK_COLORMAP(RVAL2GOBJ(colormap)),
123
+ &mask, RVAL2GDKCOLOR(tcolor),
124
+ buf);
125
+
126
+ return rb_assoc_new(GOBJ2RVAL(new),GOBJ2RVAL(mask));
127
+ }
128
+
129
+ #ifdef HAVE_XREADBITMAPFILEDATA
130
+ static VALUE
131
+ gdkpmap_create_from_xbm(self, win, fname)
132
+ VALUE self, win, fname;
133
+ {
134
+ GdkBitmap *new;
135
+ unsigned char *data;
136
+ unsigned int width, height;
137
+ int x, y;
138
+
139
+ Check_Type(fname, T_STRING);
140
+ if (XReadBitmapFileData(RVAL2CSTR(fname), &width, &height, &data, &x, &y))
141
+ rb_raise(rb_eArgError, "Bitmap not created from %s", RVAL2CSTR(fname));
142
+
143
+ new = gdk_bitmap_create_from_data(GDK_WINDOW(RVAL2GOBJ(win)),
144
+ (const gchar*)data, width, height);
145
+ XFree(data);
146
+ return GOBJ2RVAL(new);
147
+ }
148
+ #endif /* HAVE_XREADBITMAPFILEDATA */
149
+
150
+ /* From X Window System Interaction */
151
+ /*
152
+ Gdk::Window.foreign_new(anid)
153
+ Gdk::Window.foreign_new(display, anid) # Since GTK+-2.2
154
+ Gdk::Window.foreign_new(screen, anid, width, height, depth) # Since GTK+-2.10
155
+ */
156
+
157
+ static VALUE
158
+ gdkpmap_foreign_new(argc, argv, self)
159
+ int argc;
160
+ VALUE *argv;
161
+ VALUE self;
162
+ {
163
+ VALUE arg[5];
164
+ GdkPixmap* win = NULL;
165
+
166
+ rb_scan_args(argc, argv, "14", &arg[0], &arg[1], &arg[2], &arg[3], &arg[4]);
167
+
168
+ switch(argc)
169
+ {
170
+ case 1:
171
+ win = gdk_pixmap_foreign_new(NUM2UINT(arg[0]));
172
+ break;
173
+ case 2:
174
+ #if GTK_CHECK_VERSION(2,2,0)
175
+ win = gdk_pixmap_foreign_new_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(arg[0])),
176
+ NUM2UINT(arg[1]));
177
+ #else
178
+ win = gdk_pixmap_foreign_new(NUM2UINT(arg[1]));
179
+ rb_warn("Not supported. Use GTK+-2.2.0 or later.");
180
+ #endif
181
+ break;
182
+ case 5:
183
+ #if GTK_CHECK_VERSION(2,10,0)
184
+ win = gdk_pixmap_foreign_new_for_screen(GDK_SCREEN(RVAL2GOBJ(arg[0])),
185
+ NUM2UINT(arg[1]), /* anid */
186
+ NUM2INT(arg[2]), /* width */
187
+ NUM2INT(arg[3]), /* height */
188
+ NUM2INT(arg[4])); /* depth */
189
+ #else
190
+ win = gdk_pixmap_foreign_new(NUM2UINT(arg[1]));
191
+ rb_warn("Not supported. GTK+-2.10.0 or later.");
192
+ #endif
193
+ break;
194
+ }
195
+ return win ? GOBJ2RVAL(win) : Qnil;
196
+ }
197
+
198
+ static VALUE
199
+ gdkpmap_lookup(argc, argv, self)
200
+ int argc;
201
+ VALUE *argv;
202
+ VALUE self;
203
+ {
204
+ VALUE arg[2];
205
+ GdkPixmap* win = NULL;
206
+
207
+ rb_scan_args(argc, argv, "11", &arg[0], &arg[1]);
208
+
209
+ switch(argc)
210
+ {
211
+ case 1:
212
+ win = gdk_pixmap_lookup(NUM2UINT(arg[0]));
213
+ break;
214
+ case 2:
215
+ #if GTK_CHECK_VERSION(2,2,0)
216
+ win = gdk_pixmap_lookup_for_display(RVAL2GOBJ(arg[0]), NUM2UINT(arg[1]));
217
+ #else
218
+ win = gdk_pixmap_lookup(NUM2UINT(arg[1]));
219
+ rb_warn("Not supported in GTK+-2.0.x.");
220
+ #endif
221
+ break;
222
+ }
223
+ if (win == NULL)
224
+ return Qnil;
225
+ else {
226
+ return GOBJ2RVAL(win);
227
+ }
228
+ }
229
+
230
+ void
231
+ Init_gtk_gdk_pixmap()
232
+ {
233
+ VALUE gdkPixmap = G_DEF_CLASS(GDK_TYPE_PIXMAP, "Pixmap", mGdk);
234
+
235
+ rb_define_method(gdkPixmap, "initialize", gdkpmap_initialize, 4);
236
+ rb_define_singleton_method(gdkPixmap, "create_from_data", gdkpmap_create_from_data, -1);
237
+ rb_define_singleton_method(gdkPixmap, "create_from_xpm", gdkpmap_create_from_xpm, 3);
238
+ rb_define_singleton_method(gdkPixmap, "create_from_xpm_d", gdkpmap_create_from_xpm_d, 3);
239
+ rb_define_singleton_method(gdkPixmap, "colormap_create_from_xpm", gdkpmap_colormap_create_from_xpm, 4);
240
+ rb_define_singleton_method(gdkPixmap, "colormap_create_from_xpm_d", gdkpmap_colormap_create_from_xpm_d, 4);
241
+ #ifdef HAVE_XREADBITMAPFILEDATA
242
+ rb_define_singleton_method(gdkPixmap, "create_from_xbm", gdkpmap_create_from_xbm, 2);
243
+ #endif /* HAVE_XREADBITMAPFILEDATA */
244
+ #ifdef GDK_WINDOWING_X11
245
+ G_DEF_CLASS3("GdkPixmapImplX11", "PixmapImplX11", mGdk);
246
+ #elif defined(GDK_WINDOWING_WIN32)
247
+ G_DEF_CLASS3("GdkPixmapImplWin32", "PixmapImplWin32", mGdk);
248
+ #elif defined(GDK_WINDOWING_FB)
249
+ G_DEF_CLASS3("GdkPixmapFB", "PixmapFB", mGdk);
250
+ #endif
251
+
252
+ rb_define_singleton_method(gdkPixmap, "foreign_new", gdkpmap_foreign_new, -1);
253
+ rb_define_singleton_method(gdkPixmap, "lookup", gdkpmap_lookup, -1);
254
+
255
+ }
@@ -0,0 +1,342 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgdkproperty.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 16:07:31 $
8
+
9
+
10
+ Copyright (C) 2003,2004 Ruby-GNOME2 Project Team
11
+
12
+ Devided from rbgdkwindow.c
13
+ rbgdkwindow.c -
14
+ Copyright (C) 2002,2003 Ruby-GNOME2 Project Team
15
+ Copyright (C) 1998-2000 Yukihiro Matsumoto,
16
+ Daisuke Kanda,
17
+ Hiroshi Igarashi
18
+ ************************************************/
19
+ #include "global.h"
20
+
21
+ static VALUE
22
+ gdkprop_text_property_to_text_list(argc, argv, self)
23
+ int argc;
24
+ VALUE *argv;
25
+ VALUE self;
26
+ {
27
+ gint num, i;
28
+ gchar** list;
29
+ VALUE ret = Qnil;
30
+
31
+ if (argc == 3) {
32
+ VALUE encoding, format, text;
33
+ rb_scan_args(argc, argv, "30", &encoding, &format, &text);
34
+ StringValue(text);
35
+
36
+ num = gdk_text_property_to_text_list(RVAL2ATOM(encoding),
37
+ NUM2INT(format),
38
+ (const guchar*)RVAL2CSTR(text),
39
+ RSTRING_LEN(text), &list);
40
+ } else {
41
+ #if GTK_CHECK_VERSION(2,2,0)
42
+ VALUE display, encoding, format, text;
43
+ rb_scan_args(argc, argv, "40", &display, &encoding, &format, &text);
44
+ StringValue(text);
45
+
46
+ num = gdk_text_property_to_text_list_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)),
47
+ RVAL2ATOM(encoding),
48
+ NUM2INT(format),
49
+ (const guchar*)RVAL2CSTR(text),
50
+ RSTRING_LEN(text),
51
+ &list);
52
+ #else
53
+ VALUE encoding, format, text;
54
+ rb_scan_args(argc, argv, "30", &encoding, &format, &text);
55
+ rb_warn("Gdk::Property.text_property_to_text_list: Not supported arguments in GTK+-2.0.x.");
56
+ num = gdk_text_property_to_text_list(RVAL2ATOM(encoding),
57
+ NUM2INT(format),
58
+ (const guchar*)RVAL2CSTR(text),
59
+ RSTRING_LEN(text), &list);
60
+ #endif
61
+ }
62
+
63
+ ret = rb_ary_new2(num);
64
+ for (i =0; i < num; i++){
65
+ rb_ary_push(ret, CSTR2RVAL(list[i]));
66
+ }
67
+ gdk_free_text_list(list);
68
+ return ret;
69
+ }
70
+
71
+ static VALUE
72
+ gdkprop_text_property_to_utf8_list(argc, argv, self)
73
+ int argc;
74
+ VALUE *argv;
75
+ VALUE self;
76
+ {
77
+ gint num, i;
78
+ gchar** list;
79
+ VALUE ret = Qnil;
80
+
81
+ if (argc == 3) {
82
+ VALUE encoding, format, text;
83
+ rb_scan_args(argc, argv, "30", &encoding, &format, &text);
84
+ StringValue(text);
85
+
86
+ num = gdk_text_property_to_utf8_list(RVAL2ATOM(encoding),
87
+ NUM2INT(format),
88
+ (const guchar*)RVAL2CSTR(text),
89
+ RSTRING_LEN(text), &list);
90
+ } else {
91
+ #if GTK_CHECK_VERSION(2,2,0)
92
+ VALUE display, encoding, format, text;
93
+ rb_scan_args(argc, argv, "40", &display, &encoding, &format, &text);
94
+ StringValue(text);
95
+
96
+ num = gdk_text_property_to_utf8_list_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)),
97
+ RVAL2ATOM(encoding),
98
+ NUM2INT(format),
99
+ (const guchar*)RVAL2CSTR(text),
100
+ RSTRING_LEN(text),
101
+ &list);
102
+ #else
103
+ VALUE encoding, format, text;
104
+ rb_scan_args(argc, argv, "30", &encoding, &format, &text);
105
+ StringValue(text);
106
+
107
+ rb_warn("Gdk::Property.text_property_to_utf8_list: Not supported arguments in GTK+-2.0.x.");
108
+ num = gdk_text_property_to_utf8_list(RVAL2ATOM(encoding),
109
+ NUM2INT(format),
110
+ (const guchar*)RVAL2CSTR(text),
111
+ RSTRING_LEN(text), &list);
112
+ #endif
113
+ }
114
+
115
+ ret = rb_ary_new2(num);
116
+ for (i =0; i < num; i++){
117
+ rb_ary_push(ret, CSTR2RVAL(list[i]));
118
+ }
119
+ g_strfreev(list);
120
+ return ret;
121
+ }
122
+
123
+ static VALUE
124
+ gdkprop_string_to_compound_text(argc, argv, self)
125
+ int argc;
126
+ VALUE *argv;
127
+ VALUE self;
128
+ {
129
+ gint num;
130
+ GdkAtom encoding;
131
+ gint format;
132
+ guchar *ctext;
133
+ gint length;
134
+
135
+ if (argc == 1) {
136
+ VALUE str;
137
+ rb_scan_args(argc, argv, "10", &str);
138
+ num = gdk_string_to_compound_text(RVAL2CSTR(str),
139
+ &encoding, &format,
140
+ &ctext, &length);
141
+ } else {
142
+ #if GTK_CHECK_VERSION(2,2,0)
143
+ VALUE display, str;
144
+
145
+ rb_scan_args(argc, argv, "20", &display, &str);
146
+ num = gdk_string_to_compound_text_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)),
147
+ RVAL2CSTR(str),
148
+ &encoding, &format,
149
+ &ctext, &length);
150
+ #else
151
+ VALUE str;
152
+ rb_scan_args(argc, argv, "10", &str);
153
+ rb_warn("Gdk::Property.string_to_compound_text: Not supported arguments in GTK+-2.0.x.");
154
+ num = gdk_string_to_compound_text(RVAL2CSTR(str),
155
+ &encoding, &format,
156
+ &ctext, &length);
157
+ #endif
158
+ }
159
+
160
+ if (num == 0){
161
+ VALUE ret = CSTR2RVAL((const char*)ctext);
162
+ gdk_free_compound_text(ctext);
163
+ return rb_ary_new3(3, BOXED2RVAL(encoding, GDK_TYPE_ATOM),
164
+ INT2NUM(format), ret);
165
+ } else {
166
+ rb_raise(rb_eRuntimeError, "failed to converts a string %d\n", num);
167
+ }
168
+ return Qnil;
169
+ }
170
+
171
+ static VALUE
172
+ gdkprop_utf8_to_string_target(self, str)
173
+ VALUE self, str;
174
+ {
175
+ return CSTR2RVAL((const char*)gdk_utf8_to_string_target(RVAL2CSTR(str)));
176
+ }
177
+
178
+ static VALUE
179
+ gdkprop_utf8_to_compound_text(argc, argv, self)
180
+ int argc;
181
+ VALUE *argv;
182
+ VALUE self;
183
+ {
184
+ GdkAtom encoding;
185
+ gint format;
186
+ guchar *ctext;
187
+ gint length;
188
+ gint ret;
189
+
190
+ if (argc == 1) {
191
+ VALUE str;
192
+ rb_scan_args(argc, argv, "10", &str);
193
+
194
+ ret = gdk_utf8_to_compound_text(RVAL2CSTR(str),
195
+ &encoding, &format,
196
+ &ctext, &length);
197
+ } else {
198
+ #if GTK_CHECK_VERSION(2,2,0)
199
+ VALUE display, str;
200
+
201
+ rb_scan_args(argc, argv, "20", &display, &str);
202
+ ret = gdk_utf8_to_compound_text_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)),
203
+ RVAL2CSTR(str),
204
+ &encoding, &format,
205
+ &ctext, &length);
206
+ #else
207
+ VALUE str;
208
+ rb_scan_args(argc, argv, "10", &str);
209
+
210
+ rb_warn("Gdk::Property.utf8_to_compound_text: Not supported arguments in GTK+-2.0.x.");
211
+ ret = gdk_utf8_to_compound_text(RVAL2CSTR(str),
212
+ &encoding, &format,
213
+ &ctext, &length);
214
+ #endif
215
+ }
216
+
217
+ if (ret){
218
+ VALUE val = CSTR2RVAL((const char*)ctext);
219
+ gdk_free_compound_text(ctext);
220
+ return rb_ary_new3(3, BOXED2RVAL(encoding, GDK_TYPE_ATOM),
221
+ INT2NUM(format), val);
222
+ } else {
223
+ rb_raise(rb_eRuntimeError, "failed to converts a string %d\n", ret);
224
+ }
225
+ return Qnil;
226
+ }
227
+
228
+
229
+ static VALUE
230
+ gdkprop_change(argc, argv, self)
231
+ int argc;
232
+ VALUE *argv;
233
+ VALUE self;
234
+ {
235
+ int fmt, len;
236
+ void* dat;
237
+ GdkAtom ntype;
238
+ VALUE win, property, type, size= Qnil, mode, src;
239
+
240
+ if(6 == argc)
241
+ rb_scan_args(argc, argv, "60", &win, &property, &type, &size, &mode, &src);
242
+ else
243
+ rb_scan_args(argc, argv, "50", &win, &property, &type, &mode, &src);
244
+
245
+ rbgtk_atom2selectiondata(type, size, src, &ntype, &dat, &fmt, &len);
246
+
247
+ gdk_property_change(GDK_WINDOW(RVAL2GOBJ(win)), RVAL2ATOM(property),
248
+ ntype, fmt, RVAL2GENUM(mode, GDK_TYPE_PROP_MODE), dat, len);
249
+
250
+ rbgtk_atom2selectiondata_free(ntype, dat);
251
+
252
+ return self;
253
+ }
254
+
255
+ static VALUE
256
+ gdkprop_get(argc, argv, self)
257
+ int argc;
258
+ VALUE *argv;
259
+ VALUE self;
260
+ {
261
+ /* for argument processing */
262
+ GdkAtom rtype;
263
+ gint rfmt, rlen;
264
+ guchar* rdat;
265
+ VALUE win, property, type, offset=INT2FIX(0), length=INT2FIX(9999), delete;
266
+
267
+ /* for inner processing */
268
+ int i;
269
+ VALUE ret = 0;
270
+
271
+ if(6 == argc)
272
+ rb_scan_args(argc, argv, "60", &win, &property, &type, &offset, &length, &delete);
273
+ else
274
+ rb_scan_args(argc, argv, "40", &win, &property, &type, &delete);
275
+
276
+
277
+ if(gdk_property_get(GDK_WINDOW(RVAL2GOBJ(win)), RVAL2ATOM(property), RVAL2ATOM(type),
278
+ NUM2INT(offset), NUM2INT(length),
279
+ RVAL2CBOOL(delete), &rtype, &rfmt, &rlen, &rdat) == FALSE){
280
+ return Qnil;
281
+ }
282
+
283
+ switch(rfmt){
284
+ case 8:
285
+ default:
286
+ ret = rb_str_new((const char*)rdat, rlen);
287
+ break;
288
+
289
+ case 16:
290
+ ret = rb_ary_new();
291
+
292
+ for( i = 0; i < rlen; i++){
293
+ rb_ary_push(ret, rb_Integer(((unsigned short*)rdat)[i]));
294
+ }
295
+ break;
296
+
297
+ case 32:
298
+ ret = rb_ary_new();
299
+
300
+ if(rtype != GDK_SELECTION_TYPE_ATOM){
301
+ for(i = 0; i < (rlen/sizeof(unsigned long)); i++){
302
+ rb_ary_push(ret, INT2FIX(((unsigned long*)rdat)[i]));
303
+ }
304
+ } else {
305
+ for(i = 0; i < (rlen/sizeof(unsigned long)); i++){
306
+ rb_ary_push(ret, BOXED2RVAL((GdkAtom)((unsigned long*)rdat)[i], GDK_TYPE_ATOM));
307
+ }
308
+ }
309
+ break;
310
+ }
311
+
312
+ return rb_ary_new3(3, BOXED2RVAL(rtype, GDK_TYPE_ATOM),
313
+ ret, INT2NUM(rlen));
314
+ }
315
+
316
+ static VALUE
317
+ gdkprop_delete(self, win, property)
318
+ VALUE self, win, property;
319
+ {
320
+ gdk_property_delete(GDK_WINDOW(RVAL2GOBJ(win)), RVAL2ATOM(property));
321
+ return self;
322
+ }
323
+
324
+ void
325
+ Init_gtk_gdk_property()
326
+ {
327
+ VALUE gdkProperty = rb_define_module_under(mGdk, "Property");
328
+
329
+ rb_define_module_function(gdkProperty, "text_property_to_text_list", gdkprop_text_property_to_text_list, -1);
330
+ rb_define_module_function(gdkProperty, "text_property_to_utf8_list", gdkprop_text_property_to_utf8_list, -1);
331
+ rb_define_module_function(gdkProperty, "string_to_compound_text", gdkprop_string_to_compound_text, -1);
332
+ rb_define_module_function(gdkProperty, "utf8_to_string_target", gdkprop_utf8_to_string_target, 1);
333
+ rb_define_module_function(gdkProperty, "utf8_to_compound_text", gdkprop_utf8_to_compound_text, -1);
334
+ rb_define_module_function(gdkProperty, "change", gdkprop_change, -1);
335
+ rb_define_module_function(gdkProperty, "get", gdkprop_get, -1);
336
+ rb_define_module_function(gdkProperty, "delete", gdkprop_delete, 2);
337
+
338
+ /* GdkPropMode from GdkProperties */
339
+ G_DEF_CLASS(GDK_TYPE_PROP_MODE, "PropMode", gdkProperty);
340
+ G_DEF_CONSTANTS(gdkProperty, GDK_TYPE_PROP_MODE, "GDK_PROP_");
341
+
342
+ }