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,29 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgdkconst.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2003/11/02 18:29:28 $
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
+ * Gdk module constants
19
+ */
20
+ void
21
+ Init_gtk_gdk_const()
22
+ {
23
+ /* GdkStatus */
24
+ G_DEF_CLASS(GDK_TYPE_STATUS, "Status", mGdk);
25
+ G_DEF_CONSTANTS(mGdk, GDK_TYPE_STATUS, "GDK_");
26
+
27
+ }
28
+
29
+
@@ -0,0 +1,18 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgdkconversions.h -
5
+
6
+ Copyright (C) 2008 Ruby-GNOME2 Project Team
7
+ ************************************************/
8
+
9
+ #ifndef __RB_GDK_CONVERSIONS_H__
10
+ #define __RB_GDK_CONVERSIONS_H__
11
+
12
+ #include <rbgobject.h>
13
+ #include <gdk/gdk.h>
14
+
15
+ #define RVAL2GDKCOLOR(color) ((GdkColor *)RVAL2BOXED(color, GDK_TYPE_COLOR))
16
+ #define GDKCOLOR2RVAL(color) (BOXED2RVAL(color, GDK_TYPE_COLOR))
17
+
18
+ #endif /* __RB_GDK_CONVERSIONS_H__ */
@@ -0,0 +1,115 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgdkcursor.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 14:27:08 $
8
+
9
+ Copyright (C) 2001-2004 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "global.h"
13
+
14
+ static VALUE
15
+ gdkcursor_initialize(argc, argv, self)
16
+ int argc;
17
+ VALUE *argv;
18
+ VALUE self;
19
+ {
20
+ GdkCursor* cursor = NULL;
21
+
22
+ if (argc == 1){
23
+ VALUE type;
24
+ rb_scan_args(argc, argv, "10", &type);
25
+ cursor = gdk_cursor_new(RVAL2GENUM(type, GDK_TYPE_CURSOR_TYPE));
26
+ } else if (argc == 2) {
27
+ #if GTK_CHECK_VERSION(2,2,0)
28
+ VALUE display, type_or_name;
29
+ rb_scan_args(argc, argv, "20", &display, &type_or_name);
30
+ #if GTK_CHECK_VERSION(2,8,0)
31
+ if (TYPE(type_or_name) == T_STRING)
32
+ cursor = gdk_cursor_new_from_name(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)),
33
+ RVAL2CSTR(type_or_name));
34
+ else
35
+ #endif
36
+ cursor = gdk_cursor_new_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)),
37
+ RVAL2GENUM(type_or_name, GDK_TYPE_CURSOR_TYPE));
38
+ #else
39
+ rb_raise(rb_eRuntimeError, "Gdk::Cursor.new(display, cursor_type) has been supported since GTK+-2.2.");
40
+ #endif
41
+ } else if (argc == 4) {
42
+ #if GTK_CHECK_VERSION(2,4,0)
43
+ VALUE display, pixbuf, x, y;
44
+ rb_scan_args(argc, argv, "40", &display, &pixbuf, &x, &y);
45
+ cursor = gdk_cursor_new_from_pixbuf(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)),
46
+ GDK_PIXBUF(RVAL2GOBJ(pixbuf)),
47
+ NUM2INT(x), NUM2INT(y));
48
+ #else
49
+ rb_raise(rb_eRuntimeError, "Gdk::Cursor.new(pixbuf) has been supported since GTK+-2.4.");
50
+ #endif
51
+ } else if (argc == 6) {
52
+ VALUE pixmap, mask, fg, bg, x, y;
53
+ rb_scan_args(argc, argv, "60", &pixmap, &mask, &fg, &bg, &x, &y);
54
+ cursor = gdk_cursor_new_from_pixmap(GDK_PIXMAP(RVAL2GOBJ(pixmap)),
55
+ NIL_P(mask)?NULL:GDK_PIXMAP(RVAL2GOBJ(mask)),
56
+ RVAL2GDKCOLOR(fg),
57
+ RVAL2GDKCOLOR(bg),
58
+ NUM2INT(x), NUM2INT(y));
59
+ }
60
+ G_INITIALIZE(self, cursor);
61
+
62
+ return Qnil;
63
+ }
64
+
65
+ #if GTK_CHECK_VERSION(2,2,0)
66
+ static VALUE
67
+ gdkcursor_get_display(self)
68
+ VALUE self;
69
+ {
70
+ return GOBJ2RVAL(gdk_cursor_get_display((GdkCursor*)RVAL2BOXED(self, GDK_TYPE_CURSOR)));
71
+ }
72
+ #endif
73
+
74
+ static VALUE
75
+ gdkcursor_is_pixmap(self)
76
+ VALUE self;
77
+ {
78
+ return CBOOL2RVAL(((GdkCursor*)RVAL2BOXED(self, GDK_TYPE_COLOR))->type ==
79
+ GDK_CURSOR_IS_PIXMAP);
80
+ }
81
+
82
+ static VALUE
83
+ gdkcursor_cursor_type(self)
84
+ VALUE self;
85
+ {
86
+ return GENUM2RVAL(((GdkCursor*)RVAL2BOXED(self, GDK_TYPE_CURSOR))->type, GDK_TYPE_CURSOR_TYPE);
87
+ }
88
+
89
+ #if GTK_CHECK_VERSION(2,8,0)
90
+ static VALUE
91
+ gdkcursor_get_image(self)
92
+ VALUE self;
93
+ {
94
+ return GOBJ2RVAL(gdk_cursor_get_image((GdkCursor*)RVAL2BOXED(self, GDK_TYPE_CURSOR)));
95
+ }
96
+ #endif
97
+
98
+ void
99
+ Init_gtk_gdk_cursor()
100
+ {
101
+ VALUE gdkCursor = G_DEF_CLASS(GDK_TYPE_CURSOR, "Cursor", mGdk);
102
+
103
+ rb_define_method(gdkCursor, "initialize", gdkcursor_initialize, -1);
104
+ #if GTK_CHECK_VERSION(2,2,0)
105
+ rb_define_method(gdkCursor, "display", gdkcursor_get_display, 0);
106
+ #endif
107
+ rb_define_method(gdkCursor, "pixmap?", gdkcursor_is_pixmap, 0);
108
+ rb_define_method(gdkCursor, "cursor_type", gdkcursor_cursor_type, 0);
109
+ #if GTK_CHECK_VERSION(2,8,0)
110
+ rb_define_method(gdkCursor, "image", gdkcursor_get_image, 0);
111
+ #endif
112
+
113
+ G_DEF_CLASS(GDK_TYPE_CURSOR_TYPE, "Type", gdkCursor);
114
+ G_DEF_CONSTANTS(gdkCursor, GDK_TYPE_CURSOR_TYPE, "GDK_");
115
+ }
@@ -0,0 +1,235 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgdkdevice.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2006/06/17 06:59:32 $
8
+
9
+ Copyright (C) 2003-2006 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "global.h"
13
+
14
+ #define _SELF(self) (GDK_DEVICE(RVAL2GOBJ(self)))
15
+
16
+ /* Methods */
17
+ static VALUE
18
+ device_s_list(self)
19
+ VALUE self;
20
+ {
21
+ /* Owned by GDK */
22
+ return GLIST2ARY(gdk_devices_list());
23
+ }
24
+
25
+ static VALUE
26
+ device_s_set_extension_events(self, window, mask, mode)
27
+ VALUE self, window, mask, mode;
28
+ {
29
+ gdk_input_set_extension_events(GDK_WINDOW(RVAL2GOBJ(window)),
30
+ NUM2INT(mask), FIX2INT(mode));
31
+ return Qnil;
32
+ }
33
+
34
+
35
+ static VALUE
36
+ device_set_source(self, source)
37
+ VALUE self, source;
38
+ {
39
+ gdk_device_set_source(_SELF(self), RVAL2GENUM(source, GDK_TYPE_INPUT_SOURCE));
40
+ return self;
41
+ }
42
+
43
+ static VALUE
44
+ device_set_mode(self, mode)
45
+ VALUE self, mode;
46
+ {
47
+ return CBOOL2RVAL(gdk_device_set_mode(_SELF(self), RVAL2GENUM(mode, GDK_TYPE_INPUT_MODE)));
48
+ }
49
+
50
+ static VALUE
51
+ device_set_key(self, index, keyval, modifiers)
52
+ VALUE self, index, keyval, modifiers;
53
+ {
54
+ gdk_device_set_key(_SELF(self), NUM2UINT(index), NUM2UINT(keyval),
55
+ RVAL2GFLAGS(modifiers, GDK_TYPE_MODIFIER_TYPE));
56
+ return self;
57
+ }
58
+
59
+ static VALUE
60
+ device_set_axis_use(self, index, use)
61
+ VALUE self, index, use;
62
+ {
63
+ gdk_device_set_axis_use(_SELF(self), NUM2UINT(index),
64
+ RVAL2GENUM(use, GDK_TYPE_AXIS_USE));
65
+ return self;
66
+ }
67
+
68
+ static VALUE
69
+ device_s_get_core_pointer(self)
70
+ VALUE self;
71
+ {
72
+ return GOBJ2RVAL(gdk_device_get_core_pointer());
73
+ }
74
+
75
+ static VALUE
76
+ device_get_state(self, window)
77
+ VALUE self, window;
78
+ {
79
+ gdouble axes[2];
80
+ GdkModifierType mask;
81
+
82
+ gdk_device_get_state(_SELF(self), GDK_WINDOW(RVAL2GOBJ(window)),
83
+ axes, &mask);
84
+ return rb_ary_new3(3, rb_float_new(axes[0]), rb_float_new(axes[1]),
85
+ GFLAGS2RVAL(mask, GDK_TYPE_MODIFIER_TYPE));
86
+ }
87
+
88
+ static VALUE
89
+ device_get_history(self, window, start, stop)
90
+ VALUE self, window, start, stop;
91
+ {
92
+ gboolean ret;
93
+ GdkTimeCoord** events;
94
+ gint i, n_events;
95
+ VALUE ary = Qnil;
96
+ ret = gdk_device_get_history(_SELF(self),
97
+ GDK_WINDOW(RVAL2GOBJ(window)),
98
+ NUM2UINT(start), NUM2UINT(stop),
99
+ &events, &n_events);
100
+ if (ret){
101
+ ary = rb_ary_new();
102
+ for (i = 0; i < n_events; i++){
103
+ rb_ary_push(ary, BOXED2RVAL(events, GDK_TYPE_TIME_COORD));
104
+ }
105
+ gdk_device_free_history(events, n_events);
106
+ }
107
+ return ary;
108
+ }
109
+
110
+ static VALUE
111
+ device_get_axis(self, axes, use)
112
+ VALUE self, axes, use;
113
+ {
114
+ gdouble value;
115
+ gboolean ret;
116
+ gdouble* gaxes;
117
+ gint i;
118
+ gint len = RARRAY_LEN(axes);
119
+
120
+ gaxes = g_new(gdouble, len);
121
+
122
+ for (i = 0; i < len; i++){
123
+ gaxes[i] = RARRAY_PTR(axes)[i];
124
+ }
125
+
126
+ ret = gdk_device_get_axis(_SELF(self), gaxes, RVAL2GENUM(use, GDK_TYPE_AXIS_USE),
127
+ &value);
128
+
129
+ g_free(gaxes);
130
+
131
+ return ret ? rb_float_new(value) : Qnil;
132
+ }
133
+
134
+ /* Accessor */
135
+ static VALUE
136
+ device_name(self)
137
+ VALUE self;
138
+ {
139
+ return CSTR2RVAL(_SELF(self)->name);
140
+ }
141
+
142
+ static VALUE
143
+ device_source(self)
144
+ VALUE self;
145
+ {
146
+ return GENUM2RVAL(_SELF(self)->source, GDK_TYPE_INPUT_SOURCE);
147
+ }
148
+
149
+ static VALUE
150
+ device_mode(self)
151
+ VALUE self;
152
+ {
153
+ return GENUM2RVAL(_SELF(self)->mode, GDK_TYPE_INPUT_MODE);
154
+ }
155
+
156
+ static VALUE
157
+ device_has_cursor(self)
158
+ VALUE self;
159
+ {
160
+ return CBOOL2RVAL(_SELF(self)->has_cursor);
161
+ }
162
+
163
+ static VALUE
164
+ device_axes(self)
165
+ VALUE self;
166
+ {
167
+ gint i;
168
+ VALUE ary = rb_ary_new();
169
+ GdkDeviceAxis* axes = _SELF(self)->axes;
170
+
171
+ for (i = 0; i < _SELF(self)->num_axes; i++){
172
+ rb_ary_push(ary, rb_ary_new3(3, GENUM2RVAL(axes[i].use, GDK_TYPE_AXIS_USE),
173
+ rb_float_new(axes[i].min), rb_float_new(axes[i].max)));
174
+ }
175
+ return ary;
176
+ }
177
+
178
+ static VALUE
179
+ device_keys(self)
180
+ VALUE self;
181
+ {
182
+ gint i;
183
+ VALUE ary = rb_ary_new();
184
+ GdkDeviceKey* keys = _SELF(self)->keys;
185
+
186
+ for (i = 0; i < _SELF(self)->num_keys; i++){
187
+ rb_ary_push(ary, rb_ary_new3(2, UINT2NUM(keys[i].keyval),
188
+ GFLAGS2RVAL(keys[i].modifiers, GDK_TYPE_MODIFIER_TYPE)));
189
+ }
190
+ return ary;
191
+ }
192
+
193
+ void
194
+ Init_gtk_gdk_device()
195
+ {
196
+ VALUE dev = G_DEF_CLASS(GDK_TYPE_DEVICE, "Device", mGdk);
197
+
198
+ rb_define_singleton_method(dev, "list", device_s_list, 0);
199
+ rb_define_singleton_method(dev, "core_pointer", device_s_get_core_pointer, 0);
200
+ rb_define_singleton_method(dev, "set_extension_events", device_s_set_extension_events, 3);
201
+
202
+ rb_define_method(dev, "set_source", device_set_source, 1);
203
+ rb_define_method(dev, "set_mode", device_set_mode, 1);
204
+ rb_define_method(dev, "set_key", device_set_key, 3);
205
+ rb_define_method(dev, "set_axis_use", device_set_axis_use, 2);
206
+ rb_define_method(dev, "get_state", device_get_state, 1);
207
+ rb_define_method(dev, "get_history", device_get_history, 3);
208
+ rb_define_method(dev, "get_axis", device_get_axis, 2);
209
+
210
+ rb_define_method(dev, "name", device_name, 0);
211
+ rb_define_method(dev, "source", device_source, 0);
212
+ rb_define_method(dev, "mode", device_mode, 0);
213
+ rb_define_method(dev, "has_cursor?", device_has_cursor, 0);
214
+ rb_define_method(dev, "axes", device_axes, 0);
215
+ rb_define_method(dev, "keys", device_keys, 0);
216
+
217
+ G_DEF_SETTERS(dev);
218
+
219
+ /* GdkInputSource */
220
+ G_DEF_CLASS(GDK_TYPE_INPUT_SOURCE, "InputSource", dev);
221
+ G_DEF_CONSTANTS(dev, GDK_TYPE_INPUT_SOURCE, "GDK_");
222
+
223
+ /* GdkInputMode */
224
+ G_DEF_CLASS(GDK_TYPE_INPUT_MODE, "InputMode", dev);
225
+ G_DEF_CONSTANTS(dev, GDK_TYPE_INPUT_MODE, "GDK_");
226
+
227
+ /* GdkAxisUse */
228
+ G_DEF_CLASS(GDK_TYPE_AXIS_USE, "AxisUse", dev);
229
+ G_DEF_CONSTANTS(dev, GDK_TYPE_AXIS_USE, "GDK_");
230
+
231
+ /* GdkExtensionMode */
232
+ G_DEF_CLASS(GDK_TYPE_EXTENSION_MODE, "ExtensionMode", dev);
233
+ G_DEF_CONSTANTS(dev, GDK_TYPE_EXTENSION_MODE, "GDK_");
234
+
235
+ }
@@ -0,0 +1,634 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgdkdisplay.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 14:27:08 $
8
+
9
+ Copyright (C) 2002-2005 Ruby-GNOME2 Project Team
10
+ ************************************************/
11
+
12
+ #include "global.h"
13
+
14
+ #if GTK_CHECK_VERSION(2,2,0)
15
+ #define _SELF(i) GDK_DISPLAY_OBJECT(RVAL2GOBJ(i))
16
+
17
+
18
+ static VALUE
19
+ gdkdisplay_close(self)
20
+ VALUE self;
21
+ {
22
+ gdk_display_close(_SELF(self));
23
+ return self;
24
+ }
25
+
26
+ static VALUE
27
+ gdkdisplay_s_open(self, display_name)
28
+ VALUE self, display_name;
29
+ {
30
+ GdkDisplay* gdisplay = gdk_display_open(RVAL2CSTR(display_name));
31
+ if (! gdisplay) {
32
+ rb_raise(rb_eRuntimeError, "The display `%s' could not be opened.",
33
+ RVAL2CSTR(display_name));
34
+ } else {
35
+ VALUE display;
36
+ g_object_ref(gdisplay);
37
+ display = GOBJ2RVAL(gdisplay);
38
+
39
+ if (rb_block_given_p()) {
40
+ rb_ensure(rb_yield, display, gdkdisplay_close, display);
41
+ return Qnil;
42
+ } else {
43
+ return display;
44
+ }
45
+ }
46
+ }
47
+
48
+ static VALUE
49
+ gdkdisplay_s_get_default(self)
50
+ VALUE self;
51
+ {
52
+ GdkDisplay* gdisplay = gdk_display_get_default();
53
+ if (! gdisplay)
54
+ rb_raise(rb_eRuntimeError, "No default display is found.");
55
+
56
+ return GOBJ2RVAL(gdisplay);
57
+ }
58
+
59
+
60
+ static VALUE
61
+ gdkdisplay_name(self)
62
+ VALUE self;
63
+ {
64
+ return CSTR2RVAL(gdk_display_get_name(_SELF(self)));
65
+ }
66
+
67
+ static VALUE
68
+ gdkdisplay_n_screens(self)
69
+ VALUE self;
70
+ {
71
+ return INT2NUM(gdk_display_get_n_screens(_SELF(self)));
72
+ }
73
+
74
+ static VALUE
75
+ gdkdisplay_get_screen(self, num)
76
+ VALUE self, num;
77
+ {
78
+ return GOBJ2RVAL(gdk_display_get_screen(_SELF(self), NUM2INT(num)));
79
+ }
80
+
81
+ static VALUE
82
+ gdkdisplay_default_screen(self)
83
+ VALUE self;
84
+ {
85
+ return GOBJ2RVAL(gdk_display_get_default_screen(_SELF(self)));
86
+ }
87
+
88
+ static VALUE
89
+ gdkdisplay_pointer_ungrab(self, time)
90
+ VALUE self, time;
91
+ {
92
+ gdk_display_pointer_ungrab(_SELF(self), NUM2ULONG(time));
93
+ return self;
94
+ }
95
+
96
+ static VALUE
97
+ gdkdisplay_keyboard_ungrab(self, time)
98
+ VALUE self, time;
99
+ {
100
+ gdk_display_keyboard_ungrab(_SELF(self), NUM2ULONG(time));
101
+ return self;
102
+ }
103
+
104
+ static VALUE
105
+ gdkdisplay_pointer_grabbed(self)
106
+ VALUE self;
107
+ {
108
+ return CBOOL2RVAL(gdk_display_pointer_is_grabbed(_SELF(self)));
109
+ }
110
+
111
+ static VALUE
112
+ gdkdisplay_beep(self)
113
+ VALUE self;
114
+ {
115
+ gdk_display_beep(_SELF(self));
116
+ return self;
117
+ }
118
+
119
+ static VALUE
120
+ gdkdisplay_sync(self)
121
+ VALUE self;
122
+ {
123
+ gdk_display_sync(_SELF(self));
124
+ return self;
125
+ }
126
+
127
+ #if GTK_CHECK_VERSION(2,4,0)
128
+ static VALUE
129
+ gdkdisplay_flush(self)
130
+ VALUE self;
131
+ {
132
+ gdk_display_flush(_SELF(self));
133
+ return self;
134
+ }
135
+ #endif
136
+
137
+ static VALUE
138
+ gdkdisplay_list_devices(self)
139
+ VALUE self;
140
+ {
141
+ return rbgutil_glist2ary(gdk_display_list_devices(_SELF(self)));
142
+ }
143
+
144
+ static VALUE
145
+ gdkdisplay_get_event(self)
146
+ VALUE self;
147
+ {
148
+ return GEV2RVAL(gdk_display_get_event(_SELF(self)));
149
+ }
150
+
151
+ static VALUE
152
+ gdkdisplay_peek_event(self)
153
+ VALUE self;
154
+ {
155
+ return GEV2RVAL(gdk_display_peek_event(_SELF(self)));
156
+ }
157
+
158
+ static VALUE
159
+ gdkdisplay_put_event(self, event)
160
+ VALUE self, event;
161
+ {
162
+ gdk_display_put_event(_SELF(self), RVAL2GEV(event));
163
+ return self;
164
+ }
165
+
166
+ /* Don't implement this.
167
+ static GdkFilterReturn
168
+ filter_func(xevent, event, func)
169
+ GdkXEvent xevent;
170
+ GdkEvent event;
171
+ gpointer func;
172
+ {
173
+ return GENUM2RVAL(rb_funcall((VALUE)func, id_call, 2,
174
+ ????, GEV2RVAL(event)),
175
+ GDK_TYPE_FILTER_RETURN);
176
+ }
177
+
178
+ static VALUE
179
+ gdkdisplay_add_client_message_filter(self, message_type)
180
+ VALUE self, message_type;
181
+ {
182
+ VALUE func = RB_BLOCK_PROC();
183
+ G_RELATIVE(self, func);
184
+ gdk_display_add_client_message_filter(_SELF(self), RVAL2ATOM(message_type),
185
+ filter_func, func);
186
+ return self;
187
+ }
188
+ */
189
+
190
+ static VALUE
191
+ gdkdisplay_set_double_click_time(self, msec)
192
+ VALUE self, msec;
193
+ {
194
+ gdk_display_set_double_click_time(_SELF(self), NUM2UINT(msec));
195
+ return self;
196
+ }
197
+
198
+ static VALUE
199
+ gdkdisplay_get_double_click_time(self)
200
+ VALUE self;
201
+ {
202
+ return UINT2NUM(_SELF(self)->double_click_time);
203
+ }
204
+
205
+ static VALUE
206
+ gdkdisplay_get_button_click_time(self)
207
+ VALUE self;
208
+ {
209
+ return rb_ary_new3(2,
210
+ UINT2NUM(_SELF(self)->button_click_time[0]),
211
+ UINT2NUM(_SELF(self)->button_click_time[1]));
212
+ }
213
+
214
+ static VALUE
215
+ gdkdisplay_get_button_window(self)
216
+ VALUE self;
217
+ {
218
+ return rb_ary_new3(2,
219
+ GOBJ2RVAL(_SELF(self)->button_window[0]),
220
+ GOBJ2RVAL(_SELF(self)->button_window[1]));
221
+ }
222
+
223
+ static VALUE
224
+ gdkdisplay_get_button_number(self)
225
+ VALUE self;
226
+ {
227
+ return rb_ary_new3(2,
228
+ INT2NUM(_SELF(self)->button_number[0]),
229
+ INT2NUM(_SELF(self)->button_number[1]));
230
+ }
231
+
232
+ static VALUE
233
+ gdkdisplay_get_closed(self)
234
+ VALUE self;
235
+ {
236
+ return CBOOL2RVAL(_SELF(self)->closed);
237
+ }
238
+
239
+ #if GTK_CHECK_VERSION(2,4,0)
240
+ static VALUE
241
+ gdkdisplay_get_button_x(self)
242
+ VALUE self;
243
+ {
244
+ return rb_ary_new3(2,
245
+ INT2NUM(_SELF(self)->button_x[0]),
246
+ INT2NUM(_SELF(self)->button_x[1]));
247
+ }
248
+
249
+ static VALUE
250
+ gdkdisplay_get_button_y(self)
251
+ VALUE self;
252
+ {
253
+ return rb_ary_new3(2,
254
+ INT2NUM(_SELF(self)->button_y[0]),
255
+ INT2NUM(_SELF(self)->button_y[1]));
256
+ }
257
+
258
+ static VALUE
259
+ gdkdisplay_set_double_click_distance(self, distance)
260
+ VALUE self, distance;
261
+ {
262
+ gdk_display_set_double_click_distance(_SELF(self), NUM2UINT(distance));
263
+ return self;
264
+ }
265
+
266
+ static VALUE
267
+ gdkdisplay_get_double_click_distance(self, distance)
268
+ VALUE self;
269
+ {
270
+ return UINT2NUM(_SELF(self)->double_click_distance);
271
+ }
272
+ #endif
273
+
274
+ static VALUE
275
+ gdkdisplay_get_pointer(self)
276
+ VALUE self;
277
+ {
278
+ GdkScreen *screen;
279
+ int x,y;
280
+ GdkModifierType mask;
281
+
282
+ gdk_display_get_pointer(_SELF(self), &screen, &x, &y, &mask);
283
+
284
+ return rb_ary_new3(4, GOBJ2RVAL(screen), INT2NUM(x), INT2NUM(y), INT2NUM(mask));
285
+ }
286
+ static VALUE
287
+ gdkdisplay_get_window_at_pointer(self)
288
+ VALUE self;
289
+ {
290
+ GdkWindow *window;
291
+ int x,y;
292
+
293
+ window = gdk_display_get_window_at_pointer(_SELF(self), &x, &y);
294
+
295
+ return rb_ary_new3(3, GOBJ2RVAL(window), INT2NUM(x), INT2NUM(y));
296
+ }
297
+
298
+ /* Don't implement this.
299
+ GdkDisplayPointerHooks* gdk_display_set_pointer_hooks
300
+ (GdkDisplay *display,
301
+ const GdkDisplayPointerHooks *new_hooks);
302
+ */
303
+
304
+ #if GTK_CHECK_VERSION(2,4,0)
305
+ static VALUE
306
+ gdkdisplay_supports_cursor_color(self)
307
+ VALUE self;
308
+ {
309
+ return CBOOL2RVAL(gdk_display_supports_cursor_color(_SELF(self)));
310
+ }
311
+
312
+ static VALUE
313
+ gdkdisplay_supports_cursor_alpha(self)
314
+ VALUE self;
315
+ {
316
+ return CBOOL2RVAL(gdk_display_supports_cursor_alpha(_SELF(self)));
317
+ }
318
+
319
+ static VALUE
320
+ gdkdisplay_get_default_cursor_size(self)
321
+ VALUE self;
322
+ {
323
+ return UINT2NUM(gdk_display_get_default_cursor_size(_SELF(self)));
324
+ }
325
+
326
+ static VALUE
327
+ gdkdisplay_get_maximal_cursor_size(self)
328
+ VALUE self;
329
+ {
330
+ guint width, height;
331
+ gdk_display_get_maximal_cursor_size(_SELF(self), &width, &height);
332
+ return rb_assoc_new(UINT2NUM(width), UINT2NUM(height));
333
+ }
334
+
335
+ static VALUE
336
+ gdkdisplay_get_default_group(self)
337
+ VALUE self;
338
+ {
339
+ return GOBJ2RVAL(gdk_display_get_default_group(_SELF(self)));
340
+ }
341
+ #endif
342
+
343
+ #if GTK_CHECK_VERSION(2,6,0)
344
+ static VALUE
345
+ gdkdisplay_supports_selection_notification(self)
346
+ VALUE self;
347
+ {
348
+ return CBOOL2RVAL(gdk_display_supports_selection_notification(_SELF(self)));
349
+ }
350
+
351
+ static VALUE
352
+ gdkdisplay_request_selection_notification(self, selection)
353
+ VALUE self, selection;
354
+ {
355
+ return CBOOL2RVAL(gdk_display_request_selection_notification(_SELF(self),
356
+ RVAL2ATOM(selection)));
357
+ }
358
+
359
+ static VALUE
360
+ gdkdisplay_supports_clipboard_persistence(self)
361
+ VALUE self;
362
+ {
363
+ return CBOOL2RVAL(gdk_display_supports_clipboard_persistence(_SELF(self)));
364
+ }
365
+
366
+ static VALUE
367
+ gdkdisplay_store_clipboard(self, clipboard_window, time_, targets)
368
+ VALUE self, clipboard_window, time_, targets;
369
+ {
370
+ gint i;
371
+ gint n_targets = RARRAY_LEN(targets);
372
+ GdkAtom* gtargets = g_new(GdkAtom, n_targets);
373
+
374
+ for (i = 0; i < n_targets; i++){
375
+ gtargets[i] = RVAL2ATOM(RARRAY_PTR(targets)[i]);
376
+ }
377
+
378
+ gdk_display_store_clipboard(_SELF(self), GDK_WINDOW(RVAL2GOBJ(clipboard_window)),
379
+ NUM2UINT(time_), gtargets, n_targets);
380
+ return self;
381
+ }
382
+ #endif
383
+
384
+ static VALUE
385
+ gdkdisplay_get_core_pointer(self)
386
+ VALUE self;
387
+ {
388
+ return GOBJ2RVAL(gdk_display_get_core_pointer(_SELF(self)));
389
+ }
390
+
391
+ #if GTK_CHECK_VERSION(2,8,0)
392
+ static VALUE
393
+ gdkdisplay_warp_pointer(self, screen, x, y)
394
+ VALUE self, screen, x, y;
395
+ {
396
+ gdk_display_warp_pointer(_SELF(self), RVAL2GOBJ(screen), NUM2INT(x), NUM2INT(y));
397
+ return self;
398
+ }
399
+ #endif
400
+
401
+ #ifdef GDK_WINDOWING_X11
402
+ static VALUE
403
+ gdkdisplay_grab(self)
404
+ VALUE self;
405
+ {
406
+ gdk_x11_display_grab(_SELF(self));
407
+ return self;
408
+ }
409
+ static VALUE
410
+ gdkdisplay_ungrab(self)
411
+ VALUE self;
412
+ {
413
+ gdk_x11_display_ungrab(_SELF(self));
414
+ return self;
415
+ }
416
+ #if GTK_CHECK_VERSION(2,4,0)
417
+ static VALUE
418
+ gdkdisplay_register_standard_event_type(self, event_base, n_events)
419
+ VALUE self, event_base, n_events;
420
+ {
421
+ gdk_x11_register_standard_event_type(_SELF(self),
422
+ NUM2INT(event_base), NUM2INT(n_events));
423
+ return self;
424
+ }
425
+ #endif
426
+ #if GTK_CHECK_VERSION(2,8,0)
427
+ static VALUE
428
+ gdkdisplay_get_user_time(self)
429
+ VALUE self;
430
+ {
431
+ return UINT2NUM(gdk_x11_display_get_user_time(_SELF(self)));
432
+ }
433
+
434
+ static VALUE
435
+ gdkdisplay_set_cursor_theme(self, theme, size)
436
+ VALUE self, theme, size;
437
+ {
438
+ gdk_x11_display_set_cursor_theme(_SELF(self), RVAL2CSTR(theme), NUM2INT(size));
439
+ return self;
440
+ }
441
+ #endif
442
+
443
+ # if GTK_CHECK_VERSION(2, 12, 0)
444
+ /*
445
+ *** need gdk_x11_display_broadcast_startup_messagev() ***
446
+
447
+ typedef struct _StartupMessageParameterData {
448
+ gchar **parameters;
449
+ guint i;
450
+ } StartupMessageParameterData;
451
+
452
+ static int
453
+ collect_parameter(VALUE key, VALUE value, VALUE data)
454
+ {
455
+ StartupMessageParameterData *parameter_data;
456
+ parameter_data = (StartupMessageParameterData *)data;
457
+
458
+ parameter_data->parameters[parameter_data->i] = RVAL2CSTR(key);
459
+ parameter_data->i++;
460
+ parameter_data->parameters[parameter_data->i] = RVAL2CSTR(value);
461
+ parameter_data->i++;
462
+
463
+ return ST_CONTINUE;
464
+ }
465
+
466
+ static VALUE
467
+ gdkdisplay_broadcast_startup_message(int argc, VALUE *argv, VALUE self)
468
+ {
469
+ VALUE rb_message_type, rb_parameters;
470
+ char *message_type;
471
+ guint n_parameters;
472
+ gchar **parameters;
473
+
474
+ rb_scan_args(argc, argv, "11", &rb_message_type, &rb_parameters);
475
+
476
+ message_type = RVAL2CSTR(rb_message_type);
477
+ if (NIL_P(rb_parameters)) {
478
+ n_parameters = 0;
479
+ parameters = NULL;
480
+ }
481
+ else {
482
+ StartupMessageParameterData data;
483
+
484
+ Check_Type(rb_parameters, T_HASH);
485
+ n_parameters = NUM2UINT(rb_funcall(rb_parameters, rb_intern("size"), 0));
486
+ parameters = ALLOCA_N(gchar *, n_parameters * 2);
487
+ data.i = 0;
488
+ data.parameters = parameters;
489
+ rb_hash_foreach(rb_parameters, collect_parameter, (VALUE)&data);
490
+ }
491
+
492
+ gdk_x11_display_broadcast_startup_messagev(_SELF(self),
493
+ message_type,
494
+ n_parameters,
495
+ parameters);
496
+
497
+ return self;
498
+ }
499
+ */
500
+
501
+ static VALUE
502
+ gdkdisplay_get_startup_notification_id(VALUE self)
503
+ {
504
+ return CSTR2RVAL(gdk_x11_display_get_startup_notification_id(_SELF(self)));
505
+ }
506
+ # endif
507
+
508
+ #endif
509
+ #endif
510
+
511
+ #if GTK_CHECK_VERSION(2,10,0)
512
+ static VALUE
513
+ gdkdisplay_supports_shapes(self)
514
+ VALUE self;
515
+ {
516
+ return CBOOL2RVAL(gdk_display_supports_shapes(_SELF(self)));
517
+ }
518
+
519
+ static VALUE
520
+ gdkdisplay_supports_input_shapes(self)
521
+ VALUE self;
522
+ {
523
+ return CBOOL2RVAL(gdk_display_supports_input_shapes(_SELF(self)));
524
+ }
525
+ #endif
526
+
527
+ #if GTK_CHECK_VERSION(2, 12, 0)
528
+ static VALUE
529
+ gdkdisplay_supports_composite(VALUE self)
530
+ {
531
+ return CBOOL2RVAL(gdk_display_supports_composite(_SELF(self)));
532
+ }
533
+
534
+ static VALUE
535
+ gdkdisplay_trigger_tooltip_query(VALUE self)
536
+ {
537
+ gtk_tooltip_trigger_tooltip_query(_SELF(self));
538
+ return self;
539
+ }
540
+ #endif
541
+
542
+ void
543
+ Init_gtk_gdk_display()
544
+ {
545
+ #if GTK_CHECK_VERSION(2,2,0)
546
+ VALUE gdkDisplay = G_DEF_CLASS(GDK_TYPE_DISPLAY, "Display", mGdk);
547
+
548
+ rb_define_singleton_method(gdkDisplay, "open", gdkdisplay_s_open, 1);
549
+ rb_define_singleton_method(gdkDisplay, "default", gdkdisplay_s_get_default, 0);
550
+ rb_define_method(gdkDisplay, "name", gdkdisplay_name, 0);
551
+ rb_define_method(gdkDisplay, "n_screens", gdkdisplay_n_screens, 0);
552
+ rb_define_method(gdkDisplay, "get_screen", gdkdisplay_get_screen, 1);
553
+ rb_define_alias(gdkDisplay, "[]", "get_screen");
554
+ rb_define_method(gdkDisplay, "default_screen", gdkdisplay_default_screen, 0);
555
+
556
+ rb_define_method(gdkDisplay, "pointer_ungrab", gdkdisplay_pointer_ungrab, 1);
557
+ rb_define_method(gdkDisplay, "keyboard_ungrab", gdkdisplay_keyboard_ungrab, 1);
558
+ rb_define_method(gdkDisplay, "pointer_grabbed?", gdkdisplay_pointer_grabbed, 0);
559
+
560
+ rb_define_method(gdkDisplay, "beep", gdkdisplay_beep, 0);
561
+ rb_define_method(gdkDisplay, "sync", gdkdisplay_sync, 0);
562
+ #if GTK_CHECK_VERSION(2,4,0)
563
+ rb_define_method(gdkDisplay, "flush", gdkdisplay_flush, 0);
564
+ #endif
565
+ rb_define_method(gdkDisplay, "close", gdkdisplay_close, 0);
566
+
567
+ rb_define_method(gdkDisplay, "devices", gdkdisplay_list_devices, 0);
568
+ rb_define_method(gdkDisplay, "event", gdkdisplay_get_event, 0);
569
+ rb_define_method(gdkDisplay, "peek_event", gdkdisplay_peek_event, 0);
570
+ rb_define_method(gdkDisplay, "put_event", gdkdisplay_put_event, 1);
571
+ rb_define_method(gdkDisplay, "set_double_click_time", gdkdisplay_set_double_click_time, 1);
572
+ rb_define_method(gdkDisplay, "double_click_time", gdkdisplay_get_double_click_time, 0);
573
+ rb_define_method(gdkDisplay, "button_click_time", gdkdisplay_get_button_click_time, 0);
574
+ rb_define_method(gdkDisplay, "button_window", gdkdisplay_get_button_window, 0);
575
+ rb_define_method(gdkDisplay, "button_number", gdkdisplay_get_button_number, 0);
576
+ rb_define_method(gdkDisplay, "closed?", gdkdisplay_get_closed, 0);
577
+ #if GTK_CHECK_VERSION(2,4,0)
578
+ rb_define_method(gdkDisplay, "button_x", gdkdisplay_get_button_x, 0);
579
+ rb_define_method(gdkDisplay, "button_y", gdkdisplay_get_button_y, 0);
580
+ rb_define_method(gdkDisplay, "set_double_click_distance", gdkdisplay_set_double_click_distance, 1);
581
+ rb_define_method(gdkDisplay, "double_click_distance", gdkdisplay_get_double_click_distance, 0);
582
+ #endif
583
+ rb_define_method(gdkDisplay, "pointer", gdkdisplay_get_pointer, 0);
584
+ rb_define_method(gdkDisplay, "window_at_pointer", gdkdisplay_get_window_at_pointer, 0);
585
+ #if GTK_CHECK_VERSION(2,4,0)
586
+ rb_define_method(gdkDisplay, "supports_cursor_color?", gdkdisplay_supports_cursor_color, 0);
587
+ rb_define_method(gdkDisplay, "supports_cursor_alpha?", gdkdisplay_supports_cursor_alpha, 0);
588
+ rb_define_method(gdkDisplay, "default_cursor_size", gdkdisplay_get_default_cursor_size, 0);
589
+ rb_define_method(gdkDisplay, "maximal_cursor_size", gdkdisplay_get_maximal_cursor_size, 0);
590
+ rb_define_method(gdkDisplay, "default_group", gdkdisplay_get_default_group, 0);
591
+ #endif
592
+ #if GTK_CHECK_VERSION(2,6,0)
593
+ rb_define_method(gdkDisplay, "supports_selection_notification?", gdkdisplay_supports_selection_notification, 0);
594
+ rb_define_method(gdkDisplay, "request_selection_notification?", gdkdisplay_request_selection_notification, 1);
595
+ rb_define_method(gdkDisplay, "supports_clipboard_persistence?", gdkdisplay_supports_clipboard_persistence, 0);
596
+ rb_define_method(gdkDisplay, "store_clipboard", gdkdisplay_store_clipboard, 3);
597
+ #endif
598
+ rb_define_method(gdkDisplay, "core_pointer", gdkdisplay_get_core_pointer, 0);
599
+ #if GTK_CHECK_VERSION(2,8,0)
600
+ rb_define_method(gdkDisplay, "warp_pointer", gdkdisplay_warp_pointer, 3);
601
+ #endif
602
+
603
+ G_DEF_SETTERS(gdkDisplay);
604
+ #ifdef GDK_WINDOWING_X11
605
+ rb_define_method(gdkDisplay, "grab", gdkdisplay_grab, 0);
606
+ rb_define_method(gdkDisplay, "ungrab", gdkdisplay_ungrab, 0);
607
+ #if GTK_CHECK_VERSION(2,4,0)
608
+ rb_define_method(gdkDisplay, "register_standard_event_type", gdkdisplay_register_standard_event_type, 2);
609
+ #endif
610
+ #if GTK_CHECK_VERSION(2,8,0)
611
+ rb_define_method(gdkDisplay, "user_time", gdkdisplay_get_user_time, 0);
612
+ rb_define_method(gdkDisplay, "set_cursor_theme", gdkdisplay_set_cursor_theme, 2);
613
+ #endif
614
+ # if GTK_CHECK_VERSION(2, 12, 0)
615
+ /*
616
+ rb_define_method(gdkDisplay, "broadcast_startup_message",
617
+ gdkdisplay_broadcast_startup_message, -1);
618
+ */
619
+ rb_define_method(gdkDisplay, "startup_notification_id",
620
+ gdkdisplay_get_startup_notification_id, 0);
621
+ # endif
622
+ G_DEF_CLASS3("GdkDisplayX11", "DisplayX11", mGdk);
623
+ #endif
624
+ #endif
625
+
626
+ #if GTK_CHECK_VERSION(2,10,0)
627
+ rb_define_method(gdkDisplay, "supports_shapes?", gdkdisplay_supports_shapes, 0);
628
+ rb_define_method(gdkDisplay, "supports_input_shapes?", gdkdisplay_supports_input_shapes, 0);
629
+ #endif
630
+ #if GTK_CHECK_VERSION(2, 12, 0)
631
+ rb_define_method(gdkDisplay, "supports_composite?", gdkdisplay_supports_composite, 0);
632
+ rb_define_method(gdkDisplay, "trigger_tooltip_query", gdkdisplay_trigger_tooltip_query, 0);
633
+ #endif
634
+ }