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,1020 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgdkevent.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 16:07:31 $
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
+
17
+ #if GTK_CHECK_VERSION(2,8,0)
18
+ static VALUE gdkevents[36];
19
+ #elif GTK_CHECK_VERSION(2,6,0)
20
+ static VALUE gdkevents[35];
21
+ #else
22
+ static VALUE gdkevents[34];
23
+ #endif
24
+
25
+ /***********************************************/
26
+
27
+ VALUE
28
+ make_gdkevent(ev)
29
+ GdkEvent *ev;
30
+ {
31
+ VALUE obj;
32
+ if (ev == NULL) return Qnil;
33
+
34
+ obj = BOXED2RVAL(ev, GDK_TYPE_EVENT);
35
+ RBASIC(obj)->klass = gdkevents[ev->type]; /* hack */
36
+ return obj;
37
+ }
38
+
39
+ GdkEvent*
40
+ get_gdkevent(event)
41
+ VALUE event;
42
+ {
43
+ return NIL_P(event) ? NULL : RVAL2BOXED(event, GDK_TYPE_EVENT);
44
+ }
45
+
46
+ /***********************************************/
47
+ #define ATTR_STR(type, name)\
48
+ static VALUE \
49
+ gdkevent ## type ## _ ## name (self)\
50
+ VALUE self;\
51
+ {\
52
+ return CSTR2RVAL(get_gdkevent(self)->type.name);\
53
+ }\
54
+ static VALUE \
55
+ gdkevent ## type ## _set_ ## name (self, val)\
56
+ VALUE self, val;\
57
+ {\
58
+ get_gdkevent(self)->type.name = RVAL2CSTR(val);\
59
+ return self;\
60
+ }
61
+
62
+ #define ATTR_INT(type, name)\
63
+ static VALUE \
64
+ gdkevent ## type ## _ ## name (self)\
65
+ VALUE self;\
66
+ {\
67
+ return INT2NUM(get_gdkevent(self)->type.name);\
68
+ }\
69
+ static VALUE \
70
+ gdkevent ## type ## _set_ ## name (self, val)\
71
+ VALUE self, val;\
72
+ {\
73
+ get_gdkevent(self)->type.name = NUM2INT(val);\
74
+ return self;\
75
+ }
76
+
77
+ #define ATTR_UINT(type, name)\
78
+ static VALUE \
79
+ gdkevent ## type ## _ ## name (self)\
80
+ VALUE self;\
81
+ {\
82
+ return UINT2NUM(get_gdkevent(self)->type.name);\
83
+ }\
84
+ static VALUE \
85
+ gdkevent ## type ## _set_ ## name (self, val)\
86
+ VALUE self, val;\
87
+ {\
88
+ get_gdkevent(self)->type.name = NUM2UINT(val);\
89
+ return self;\
90
+ }
91
+
92
+ #define ATTR_FLOAT(type, name)\
93
+ static VALUE \
94
+ gdkevent ## type ## _ ## name (self)\
95
+ VALUE self;\
96
+ {\
97
+ return rb_float_new(get_gdkevent(self)->type.name);\
98
+ }\
99
+ static VALUE \
100
+ gdkevent ## type ## _set_ ## name (self, val)\
101
+ VALUE self, val;\
102
+ {\
103
+ get_gdkevent(self)->type.name = NUM2DBL(val);\
104
+ return self;\
105
+ }
106
+
107
+ #define ATTR_GOBJ(type, name)\
108
+ static VALUE \
109
+ gdkevent ## type ## _ ## name (self)\
110
+ VALUE self;\
111
+ {\
112
+ return GOBJ2RVAL(get_gdkevent(self)->type.name);\
113
+ }\
114
+ static VALUE \
115
+ gdkevent ## type ## _set_ ## name (self, val)\
116
+ VALUE self, val;\
117
+ {\
118
+ GdkEvent *event;\
119
+ event = get_gdkevent(self);\
120
+ if (event->type.name)\
121
+ g_object_unref(event->type.name);\
122
+ event->type.name = RVAL2GOBJ(val);\
123
+ if (event->type.name)\
124
+ g_object_ref(event->type.name);\
125
+ return self;\
126
+ }
127
+
128
+ #define ATTR_BOOL(type, name)\
129
+ static VALUE \
130
+ gdkevent ## type ## _ ## name (self)\
131
+ VALUE self;\
132
+ {\
133
+ return CBOOL2RVAL(get_gdkevent(self)->type.name);\
134
+ }\
135
+ static VALUE \
136
+ gdkevent ## type ## _set_ ## name (self, val)\
137
+ VALUE self, val;\
138
+ {\
139
+ get_gdkevent(self)->type.name = RVAL2CBOOL(val);\
140
+ return self;\
141
+ }
142
+
143
+ #define ATTR_ATOM(type, name)\
144
+ static VALUE \
145
+ gdkevent ## type ## _ ## name (self)\
146
+ VALUE self;\
147
+ {\
148
+ GdkAtom atom = get_gdkevent(self)->type.name;\
149
+ return BOXED2RVAL(atom, GDK_TYPE_ATOM);\
150
+ }\
151
+ static VALUE \
152
+ gdkevent ## type ## _set_ ## name (self, val)\
153
+ VALUE self, val;\
154
+ {\
155
+ get_gdkevent(self)->type.name = RVAL2ATOM(val);\
156
+ return self;\
157
+ }
158
+
159
+ #define ATTR_FLAGS(type, name, gtype)\
160
+ static VALUE \
161
+ gdkevent ## type ## _ ## name (self)\
162
+ VALUE self;\
163
+ {\
164
+ return GFLAGS2RVAL(get_gdkevent(self)->type.name, gtype);\
165
+ }\
166
+ static VALUE \
167
+ gdkevent ## type ## _set_ ## name (self, val)\
168
+ VALUE self, val;\
169
+ {\
170
+ get_gdkevent(self)->type.name = RVAL2GFLAGS(val, gtype);\
171
+ return self;\
172
+ }
173
+
174
+ #define ATTR_ENUM(type, name, gtype)\
175
+ static VALUE \
176
+ gdkevent ## type ## _ ## name (self)\
177
+ VALUE self;\
178
+ {\
179
+ return GENUM2RVAL(get_gdkevent(self)->type.name, gtype);\
180
+ }\
181
+ static VALUE \
182
+ gdkevent ## type ## _set_ ## name (self, val)\
183
+ VALUE self, val;\
184
+ {\
185
+ get_gdkevent(self)->type.name = RVAL2GENUM(val, gtype);\
186
+ return self;\
187
+ }
188
+
189
+ #define ATTR_AXES(type, gdkklass) \
190
+ static VALUE \
191
+ gdkevent ##type ## _axes(self)\
192
+ VALUE self;\
193
+ {\
194
+ gdkklass type = get_gdkevent(self)->type;\
195
+ return type.axes ? rb_ary_new3(2, \
196
+ rb_float_new(type.axes[0]),\
197
+ rb_float_new(type.axes[1])) : Qnil;\
198
+ } \
199
+ static VALUE \
200
+ gdkevent ## type ## _set_axes(self, x, y)\
201
+ VALUE self, x, y;\
202
+ {\
203
+ gdkklass val = get_gdkevent(self)->type;\
204
+ val.axes[0] = NUM2DBL(x);\
205
+ val.axes[1] = NUM2DBL(y);\
206
+ return self;\
207
+ }
208
+
209
+ #define DEFINE_ACCESSOR(event, type, name) \
210
+ rb_define_method(event, G_STRINGIFY(name), gdkevent ## type ## _## name, 0);\
211
+ rb_define_method(event, G_STRINGIFY(set_ ## name), gdkevent ## type ## _set_## name, 1);
212
+
213
+
214
+ /* initialize */
215
+ #if GTK_CHECK_VERSION(2,2,0)
216
+ #define GDKEVENT_INIT(type, default_gtype) \
217
+ static VALUE \
218
+ gdkevent ## type ## _initialize(argc, argv, self)\
219
+ int argc;\
220
+ VALUE *argv;\
221
+ VALUE self;\
222
+ {\
223
+ VALUE type;\
224
+ GdkEventType gtype;\
225
+ \
226
+ rb_scan_args(argc, argv, "01", &type);\
227
+ if (NIL_P(type)){\
228
+ gtype = default_gtype;\
229
+ } else {\
230
+ gtype = RVAL2GENUM(type, GDK_TYPE_EVENT_TYPE);\
231
+ }\
232
+ \
233
+ G_INITIALIZE(self, gdk_event_new(gtype));\
234
+ return Qnil;\
235
+ }
236
+ #else
237
+ #define GDKEVENT_INIT(type, default_gtype) \
238
+ static VALUE \
239
+ gdkevent ## type ## _initialize(argc, argv, self)\
240
+ int argc;\
241
+ VALUE *argv;\
242
+ VALUE self;\
243
+ {\
244
+ rb_raise(rb_eRuntimeError, "Gdk::Event.new is not supported in this environment.");\
245
+ return Qnil;\
246
+ }
247
+ #endif
248
+
249
+ #define DEFINE_INIT(event, type) \
250
+ rb_define_method(event, "initialize", gdkevent ## type ## _initialize, -1);
251
+
252
+ /***********************************************/
253
+
254
+ /* GdkEvent Singleton Methods */
255
+ static VALUE
256
+ gdkevent_s_events_pending(self)
257
+ VALUE self;
258
+ {
259
+ return CBOOL2RVAL(gdk_events_pending());
260
+ }
261
+
262
+ static VALUE
263
+ gdkevent_s_peek(self)
264
+ VALUE self;
265
+ {
266
+ return make_gdkevent(gdk_event_peek());
267
+ }
268
+
269
+ static VALUE
270
+ gdkevent_s_get(self)
271
+ VALUE self;
272
+ {
273
+ return make_gdkevent(gdk_event_get());
274
+ }
275
+
276
+ static VALUE
277
+ gdkevent_s_get_graphics_expose(self, window)
278
+ VALUE self, window;
279
+ {
280
+ return make_gdkevent(gdk_event_get_graphics_expose(GDK_WINDOW(RVAL2GOBJ(window))));
281
+ }
282
+
283
+ /* GdkEvent */
284
+ #if GTK_CHECK_VERSION(2,2,0)
285
+ static VALUE
286
+ gdkevent_initialize(self, type)
287
+ VALUE self, type;
288
+ {
289
+ GdkEventType gtype = RVAL2GENUM(type, GDK_TYPE_EVENT_TYPE);
290
+ if (RBASIC(self)->klass != gdkevents[gtype])
291
+ rb_raise(rb_eArgError, "Wrong event type for this class.");
292
+
293
+ G_INITIALIZE(self, gdk_event_new(gtype));
294
+ return Qnil;
295
+ }
296
+ #endif
297
+
298
+ static VALUE
299
+ gdkevent_type(self)
300
+ VALUE self;
301
+ {
302
+ return GENUM2RVAL(get_gdkevent(self)->type, GDK_TYPE_EVENT_TYPE);
303
+ }
304
+
305
+ static VALUE
306
+ gdkevent_put(self)
307
+ VALUE self;
308
+ {
309
+ gdk_event_put(get_gdkevent(self));
310
+ return self;
311
+ }
312
+
313
+ /* We don't need this.
314
+ gdk_event_get_time();
315
+ gboolean gdk_event_get_state (GdkEvent *event,
316
+ GdkModifierType *state);
317
+ */
318
+
319
+ static VALUE
320
+ gdkevent_get_axis(self, axis_use)
321
+ VALUE self, axis_use;
322
+ {
323
+ gdouble value;
324
+ gboolean ret = gdk_event_get_axis(get_gdkevent(self),
325
+ RVAL2GENUM(axis_use, GDK_TYPE_AXIS_USE), &value);
326
+ return ret ? rb_float_new(value) : Qnil;
327
+ }
328
+
329
+ static VALUE
330
+ gdkevent_get_coords(self)
331
+ VALUE self;
332
+ {
333
+ gdouble x_win, y_win;
334
+ gboolean ret = gdk_event_get_coords(get_gdkevent(self), &x_win, &y_win);
335
+
336
+ return ret ? rb_ary_new3(2, rb_float_new(x_win), rb_float_new(y_win)) : Qnil;
337
+ }
338
+
339
+ static VALUE
340
+ gdkevent_get_root_coords(self)
341
+ VALUE self;
342
+ {
343
+ gdouble x_root, y_root;
344
+ gboolean ret = gdk_event_get_root_coords(get_gdkevent(self), &x_root, &y_root);
345
+
346
+ return ret ? rb_ary_new3(2, rb_float_new(x_root), rb_float_new(y_root)) : Qnil;
347
+ }
348
+
349
+ static void
350
+ handler_func(event, func)
351
+ GdkEvent* event;
352
+ gpointer func;
353
+ {
354
+ rb_funcall((VALUE)func, id_call, 1, make_gdkevent(event));
355
+ }
356
+
357
+ static VALUE
358
+ gdkevent_s_handler_set(self)
359
+ VALUE self;
360
+ {
361
+ volatile VALUE func = rb_block_proc();
362
+ G_RELATIVE(self, func);
363
+
364
+ gdk_event_handler_set((GdkEventFunc)handler_func, (gpointer)func, NULL);
365
+ return self;
366
+ }
367
+
368
+ static VALUE
369
+ gdkevent_s_get_show_events(self)
370
+ VALUE self;
371
+ {
372
+ return CBOOL2RVAL(gdk_get_show_events());
373
+ }
374
+
375
+ static VALUE
376
+ gdkevent_s_set_show_events(self, show_events)
377
+ VALUE self, show_events;
378
+ {
379
+ gdk_set_show_events(RVAL2CBOOL(show_events));
380
+ return self;
381
+ }
382
+ #if GTK_CHECK_VERSION(2,2,0)
383
+ static VALUE
384
+ gdkevent_set_screen(self, screen)
385
+ VALUE self, screen;
386
+ {
387
+ gdk_event_set_screen(get_gdkevent(self), GDK_SCREEN(RVAL2GOBJ(screen)));
388
+ return self;
389
+ }
390
+
391
+ static VALUE
392
+ gdkevent_screen(self)
393
+ VALUE self;
394
+ {
395
+ return GOBJ2RVAL(gdk_event_get_screen(get_gdkevent(self)));
396
+ }
397
+ #endif
398
+
399
+ /*
400
+ type: String, Integer, Gdk::Color.
401
+ */
402
+ static VALUE
403
+ gdkevent_s_setting_get(argc, argv, self)
404
+ int argc;
405
+ VALUE* argv;
406
+ VALUE self;
407
+ {
408
+ VALUE name, type;
409
+ GType gtype;
410
+ GValue val = {0,};
411
+ gboolean ret;
412
+ VALUE value;
413
+
414
+ rb_scan_args(argc, argv, "11", &name, &type);
415
+ if NIL_P(type)
416
+ gtype = G_TYPE_STRING;
417
+ else
418
+ gtype = CLASS2GTYPE(type);
419
+
420
+ g_value_init(&val, gtype);
421
+ ret = gdk_setting_get(RVAL2CSTR(name), &val);
422
+
423
+ value = ret ? GVAL2RVAL(&val) : Qnil;
424
+ g_value_unset(&val);
425
+ return value;
426
+ }
427
+
428
+ /* GdkEventAny */
429
+ ATTR_GOBJ(any, window);
430
+ ATTR_BOOL(any, send_event);
431
+
432
+ /* GdkEventKey */
433
+ ATTR_UINT(key, time);
434
+ ATTR_FLAGS(key, state, GDK_TYPE_MODIFIER_TYPE);
435
+ ATTR_INT(key, keyval);
436
+ ATTR_UINT(key, hardware_keycode);
437
+ ATTR_UINT(key, group);
438
+
439
+ /* GdkEventButton */
440
+ ATTR_UINT(button, time);
441
+ ATTR_FLOAT(button, x);
442
+ ATTR_FLOAT(button, y);
443
+ ATTR_AXES(button, GdkEventButton);
444
+ ATTR_INT(button, button);
445
+ ATTR_FLAGS(button, state, GDK_TYPE_MODIFIER_TYPE);
446
+ ATTR_GOBJ(button, device);
447
+ ATTR_FLOAT(button, x_root);
448
+ ATTR_FLOAT(button, y_root);
449
+
450
+ /* GdkEventScroll */
451
+ ATTR_UINT(scroll, time);
452
+ ATTR_FLOAT(scroll, x);
453
+ ATTR_FLOAT(scroll, y);
454
+ ATTR_FLAGS(scroll, state, GDK_TYPE_MODIFIER_TYPE);
455
+ ATTR_ENUM(scroll, direction, GDK_TYPE_SCROLL_DIRECTION);
456
+ ATTR_GOBJ(scroll, device);
457
+ ATTR_FLOAT(scroll, x_root);
458
+ ATTR_FLOAT(scroll, y_root);
459
+ GDKEVENT_INIT(scroll, GDK_SCROLL);
460
+
461
+ /* GdkEventMotion */
462
+ ATTR_UINT(motion, time);
463
+ ATTR_FLOAT(motion, x);
464
+ ATTR_FLOAT(motion, y);
465
+ ATTR_AXES(motion, GdkEventMotion);
466
+ ATTR_FLOAT(motion, x_root);
467
+ ATTR_FLOAT(motion, y_root);
468
+ ATTR_FLAGS(motion, state, GDK_TYPE_MODIFIER_TYPE);
469
+ ATTR_BOOL(motion, is_hint);
470
+ ATTR_GOBJ(motion, device);
471
+ GDKEVENT_INIT(motion, GDK_MOTION_NOTIFY);
472
+
473
+ #if GTK_CHECK_VERSION(2, 12, 0)
474
+ static VALUE
475
+ gdkeventmotion_request_motions(VALUE self)
476
+ {
477
+ gdk_event_request_motions(&(get_gdkevent(self)->motion));
478
+ return self;
479
+ }
480
+ #endif
481
+
482
+ /* GdkEventExpose */
483
+ static VALUE
484
+ gdkeventexpose_area(self)
485
+ VALUE self;
486
+ {
487
+ return BOXED2RVAL(&get_gdkevent(self)->expose.area, GDK_TYPE_RECTANGLE);
488
+ }
489
+
490
+ static VALUE
491
+ gdkeventexpose_set_area(self, rect)
492
+ VALUE self, rect;
493
+ {
494
+ GdkRectangle* grect = (GdkRectangle*)RVAL2BOXED(rect, GDK_TYPE_RECTANGLE);
495
+ GdkEventExpose event = get_gdkevent(self)->expose;
496
+ event.area.x = grect->x;
497
+ event.area.y = grect->y;
498
+ event.area.width = grect->width;
499
+ event.area.height = grect->height;
500
+ return self;
501
+ }
502
+
503
+ static VALUE
504
+ gdkeventexpose_region(self)
505
+ VALUE self;
506
+ {
507
+ return BOXED2RVAL(get_gdkevent(self)->expose.region, GDK_TYPE_REGION);
508
+ }
509
+ static VALUE
510
+ gdkeventexpose_set_region(self, region)
511
+ VALUE self, region;
512
+ {
513
+ get_gdkevent(self)->expose.region = RVAL2BOXED(region, GDK_TYPE_REGION);
514
+ return self;
515
+ }
516
+
517
+ ATTR_INT(expose, count);
518
+ GDKEVENT_INIT(expose, GDK_EXPOSE);
519
+
520
+ /* GdkEventVisibility */
521
+ ATTR_ENUM(visibility, state, GDK_TYPE_VISIBILITY_STATE);
522
+ GDKEVENT_INIT(visibility, GDK_VISIBILITY_NOTIFY);
523
+
524
+ /* GdkEventCrossing */
525
+ ATTR_GOBJ(crossing, subwindow);
526
+ ATTR_UINT(crossing, time);
527
+ ATTR_INT(crossing, x);
528
+ ATTR_INT(crossing, y);
529
+ ATTR_FLOAT(crossing, x_root);
530
+ ATTR_FLOAT(crossing, y_root);
531
+ ATTR_ENUM(crossing, mode, GDK_TYPE_CROSSING_MODE);
532
+ ATTR_ENUM(crossing, detail, GDK_TYPE_NOTIFY_TYPE);
533
+ ATTR_BOOL(crossing, focus);
534
+ ATTR_FLAGS(crossing, state, GDK_TYPE_MODIFIER_TYPE);
535
+
536
+ /* GdkEventFocus */
537
+ ATTR_BOOL(focus_change, in);
538
+ GDKEVENT_INIT(focus_change, GDK_FOCUS_CHANGE);
539
+
540
+ /* GdkEventConfigure */
541
+ ATTR_INT(configure, x);
542
+ ATTR_INT(configure, y);
543
+ ATTR_INT(configure, width);
544
+ ATTR_INT(configure, height);
545
+ GDKEVENT_INIT(configure, GDK_CONFIGURE);
546
+
547
+ /* GdkEventProperty */
548
+ ATTR_ATOM(property, atom);
549
+ ATTR_UINT(property, time);
550
+ ATTR_ENUM(property, state, GDK_TYPE_PROPERTY_STATE);
551
+ GDKEVENT_INIT(property, GDK_PROPERTY_NOTIFY);
552
+
553
+ /* GdkEventSelection */
554
+ ATTR_ATOM(selection, selection);
555
+ ATTR_ATOM(selection, target);
556
+ ATTR_ATOM(selection, property);
557
+ ATTR_UINT(selection, requestor);
558
+ ATTR_INT(selection, time);
559
+
560
+ /* GdkEventDND */
561
+ ATTR_GOBJ(dnd, context);
562
+ ATTR_UINT(dnd, time);
563
+ ATTR_INT(dnd, x_root);
564
+ ATTR_INT(dnd, y_root);
565
+
566
+ /* GdkEventProximity */
567
+ ATTR_UINT(proximity, time);
568
+ ATTR_GOBJ(proximity, device);
569
+
570
+ /* GdkEventClient */
571
+ ATTR_ATOM(client, message_type);
572
+ GDKEVENT_INIT(client, GDK_CLIENT_EVENT);
573
+
574
+ static VALUE
575
+ gdkeventclient_data_format(self)
576
+ VALUE self;
577
+ {
578
+ return INT2NUM(get_gdkevent(self)->client.data_format);
579
+ }
580
+
581
+ static VALUE
582
+ gdkeventclient_data(self)
583
+ VALUE self;
584
+ {
585
+ int i;
586
+ VALUE ary = Qnil;
587
+ gushort format = get_gdkevent(self)->client.data_format;
588
+
589
+ if (format == 8) {
590
+ ary = rb_ary_new2(20);
591
+ for (i = 0; i < 20; i++)
592
+ rb_ary_push(ary, INT2FIX(get_gdkevent(self)->client.data.b[i]));
593
+ } else if (format == 16) {
594
+ ary = rb_ary_new2(10);
595
+ for (i = 0; i<10; i++)
596
+ rb_ary_push(ary, INT2FIX(get_gdkevent(self)->client.data.s[i]));
597
+ } else if (format == 32){
598
+ ary = rb_ary_new2(5);
599
+ for (i = 0; i < 5; i++)
600
+ rb_ary_push(ary, INT2NUM(get_gdkevent(self)->client.data.l[i]));
601
+ } else {
602
+ rb_warn("The format is not supported.");
603
+ }
604
+ return ary;
605
+ }
606
+
607
+ static VALUE
608
+ gdkeventclient_send_client_message(argc, argv, self)
609
+ int argc;
610
+ VALUE *argv;
611
+ VALUE self;
612
+ {
613
+ VALUE xid, display;
614
+ rb_scan_args(argc, argv, "11", &xid, &display);
615
+ if (NIL_P(display)){
616
+ return CBOOL2RVAL(gdk_event_send_client_message(
617
+ get_gdkevent(self), NUM2INT(xid)));
618
+ } else {
619
+ #if GTK_CHECK_VERSION(2,2,0)
620
+ return CBOOL2RVAL(gdk_event_send_client_message_for_display(
621
+ GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)),
622
+ get_gdkevent(self),
623
+ NUM2UINT(xid)));
624
+ #else
625
+ rb_warn("this arguments number has been supported since 2.2");
626
+ return Qfalse;
627
+ #endif
628
+ }
629
+ }
630
+
631
+ static VALUE
632
+ gdkeventclient_send_clientmessage_toall(self)
633
+ VALUE self;
634
+ {
635
+ gdk_event_send_clientmessage_toall(get_gdkevent(self));
636
+ return self;
637
+ }
638
+
639
+ static GdkFilterReturn
640
+ filter_func(xevent, event, func)
641
+ GdkXEvent* xevent;
642
+ GdkEvent* event;
643
+ gpointer func;
644
+ {
645
+ VALUE ret = rb_funcall((VALUE)func, id_call, 2, LONG2NUM((glong)xevent), make_gdkevent(event));
646
+ return RVAL2GENUM(ret, GDK_TYPE_FILTER_RETURN);
647
+ }
648
+
649
+ static VALUE
650
+ gdkevent_s_add_client_message_filter(self, message_type)
651
+ VALUE self, message_type;
652
+ {
653
+ volatile VALUE func = rb_block_proc();
654
+ G_RELATIVE(self, func);
655
+ gdk_add_client_message_filter(RVAL2ATOM(message_type),
656
+ (GdkFilterFunc)filter_func, (gpointer)func);
657
+ return self;
658
+ }
659
+
660
+ /* GdkEventNoExpose */
661
+ GDKEVENT_INIT(noexpose, GDK_NO_EXPOSE);
662
+
663
+ /* GdkEventWindowState */
664
+ ATTR_FLAGS(window_state, changed_mask, GDK_TYPE_WINDOW_STATE);
665
+ ATTR_FLAGS(window_state, new_window_state, GDK_TYPE_WINDOW_STATE);
666
+ GDKEVENT_INIT(window_state, GDK_WINDOW_STATE);
667
+
668
+ /* GdkEventSetting */
669
+ ATTR_ENUM(setting, action, GDK_TYPE_SETTING_ACTION);
670
+ ATTR_STR(setting, name);
671
+ GDKEVENT_INIT(setting, GDK_SETTING);
672
+
673
+ /* GdkEventOwnerChange */
674
+ #if GTK_CHECK_VERSION(2,6,0)
675
+ ATTR_UINT(owner_change, owner);
676
+ ATTR_ENUM(owner_change, reason, GDK_TYPE_OWNER_CHANGE);
677
+ ATTR_ATOM(owner_change, selection);
678
+ ATTR_UINT(owner_change, time);
679
+ ATTR_UINT(owner_change, selection_time);
680
+ GDKEVENT_INIT(owner_change, GDK_OWNER_CHANGE);
681
+ #endif
682
+
683
+ /* GdkEventGrabBroken */
684
+ #if GTK_CHECK_VERSION(2,8,0)
685
+ ATTR_BOOL(grab_broken, keyboard);
686
+ ATTR_BOOL(grab_broken, implicit);
687
+ ATTR_GOBJ(grab_broken, grab_window);
688
+ GDKEVENT_INIT(grab_broken, GDK_GRAB_BROKEN);
689
+ #endif
690
+
691
+ /* MISC */
692
+ static VALUE
693
+ gdkevent_g2r(const GValue *values)
694
+ {
695
+ return make_gdkevent(g_value_get_boxed(&values[0]));
696
+ }
697
+
698
+ void
699
+ Init_gtk_gdk_event()
700
+ {
701
+ VALUE ev;
702
+ VALUE gdkEvent;
703
+ VALUE gdkEventAny;
704
+
705
+ gdkEvent = G_DEF_CLASS(GDK_TYPE_EVENT, "Event", mGdk);
706
+ gdkEventAny = rb_define_class_under(mGdk, "EventAny", gdkEvent);
707
+
708
+ gdkevents[GDK_DELETE] = gdkEventAny;
709
+ gdkevents[GDK_DESTROY] = gdkEventAny;
710
+ gdkevents[GDK_EXPOSE] = rb_define_class_under(mGdk, "EventExpose", gdkEventAny);
711
+ gdkevents[GDK_MOTION_NOTIFY] = rb_define_class_under(mGdk, "EventMotion", gdkEventAny);
712
+ gdkevents[GDK_BUTTON_PRESS] = rb_define_class_under(mGdk, "EventButton", gdkEventAny);
713
+ gdkevents[GDK_2BUTTON_PRESS] = gdkevents[GDK_BUTTON_PRESS];
714
+ gdkevents[GDK_3BUTTON_PRESS] = gdkevents[GDK_BUTTON_PRESS];
715
+ gdkevents[GDK_BUTTON_RELEASE]= gdkevents[GDK_BUTTON_PRESS];
716
+ gdkevents[GDK_KEY_PRESS] = rb_define_class_under(mGdk, "EventKey", gdkEventAny);
717
+ gdkevents[GDK_KEY_RELEASE] = gdkevents[GDK_KEY_PRESS];
718
+ gdkevents[GDK_ENTER_NOTIFY] = rb_define_class_under(mGdk, "EventCrossing", gdkEventAny);
719
+ gdkevents[GDK_LEAVE_NOTIFY] = gdkevents[GDK_ENTER_NOTIFY];
720
+ gdkevents[GDK_FOCUS_CHANGE] = rb_define_class_under(mGdk, "EventFocus", gdkEventAny);
721
+ gdkevents[GDK_CONFIGURE] = rb_define_class_under(mGdk, "EventConfigure", gdkEventAny);
722
+ gdkevents[GDK_MAP] = gdkEventAny;
723
+ gdkevents[GDK_UNMAP] = gdkEventAny;
724
+ gdkevents[GDK_PROPERTY_NOTIFY]= rb_define_class_under(mGdk, "EventProperty", gdkEventAny);
725
+ gdkevents[GDK_SELECTION_CLEAR]= rb_define_class_under(mGdk, "EventSelection", gdkEventAny);
726
+ gdkevents[GDK_SELECTION_REQUEST]= gdkevents[GDK_SELECTION_CLEAR];
727
+ gdkevents[GDK_SELECTION_NOTIFY] = gdkevents[GDK_SELECTION_CLEAR];
728
+ gdkevents[GDK_PROXIMITY_IN] = rb_define_class_under(mGdk, "EventProximity", gdkEventAny);
729
+ gdkevents[GDK_PROXIMITY_OUT] = gdkevents[GDK_PROXIMITY_IN];
730
+ gdkevents[GDK_DRAG_ENTER] = rb_define_class_under(mGdk, "EventDND", gdkEventAny);
731
+ gdkevents[GDK_DRAG_LEAVE] = gdkevents[GDK_DRAG_ENTER];
732
+ gdkevents[GDK_DRAG_MOTION] = gdkevents[GDK_DRAG_ENTER];
733
+ gdkevents[GDK_DRAG_STATUS] = gdkevents[GDK_DRAG_ENTER];
734
+ gdkevents[GDK_DROP_START] = gdkevents[GDK_DRAG_ENTER];
735
+ gdkevents[GDK_DROP_FINISHED] = gdkevents[GDK_DRAG_ENTER];
736
+ gdkevents[GDK_CLIENT_EVENT] = rb_define_class_under(mGdk, "EventClient", gdkEventAny);
737
+ gdkevents[GDK_VISIBILITY_NOTIFY] = rb_define_class_under(mGdk, "EventVisibility", gdkEventAny);
738
+ gdkevents[GDK_NO_EXPOSE] = rb_define_class_under(mGdk, "EventNoExpose", gdkEventAny);
739
+ gdkevents[GDK_SCROLL] = rb_define_class_under(mGdk, "EventScroll", gdkEventAny);
740
+ gdkevents[GDK_WINDOW_STATE] = rb_define_class_under(mGdk, "EventWindowState", gdkEventAny);
741
+ gdkevents[GDK_SETTING] = rb_define_class_under(mGdk, "EventSetting", gdkEventAny);
742
+ #if GTK_CHECK_VERSION(2,6,0)
743
+ gdkevents[GDK_OWNER_CHANGE] = rb_define_class_under(mGdk, "EventOwnerChange", gdkEventAny);
744
+ #endif
745
+ #if GTK_CHECK_VERSION(2,8,0)
746
+ gdkevents[GDK_GRAB_BROKEN] = rb_define_class_under(mGdk, "EventGrabBroken", gdkEventAny);
747
+ #endif
748
+
749
+ /* GdkEvent */
750
+ #if GTK_CHECK_VERSION(2,2,0)
751
+ rb_define_method(gdkEvent, "initialize", gdkevent_initialize, 1);
752
+ #endif
753
+ rb_define_method(gdkEvent, "event_type", gdkevent_type, 0);
754
+
755
+ rb_define_singleton_method(gdkEvent, "events_pending?", gdkevent_s_events_pending, 0);
756
+ rb_define_singleton_method(gdkEvent, "peek", gdkevent_s_peek, 0);
757
+ rb_define_singleton_method(gdkEvent, "get", gdkevent_s_get, 0);
758
+ rb_define_method(gdkEvent, "put", gdkevent_put, 0);
759
+ rb_define_method(gdkEvent, "get_axis", gdkevent_get_axis, 1);
760
+ rb_define_method(gdkEvent, "coords", gdkevent_get_coords, 0);
761
+ rb_define_method(gdkEvent, "root_coords", gdkevent_get_root_coords, 0);
762
+
763
+ rb_define_singleton_method(gdkEvent, "handler_set", gdkevent_s_handler_set, 0);
764
+ rb_define_singleton_method(gdkEvent, "show_events?", gdkevent_s_get_show_events, 0);
765
+ rb_define_singleton_method(gdkEvent, "set_show_events", gdkevent_s_set_show_events, 1);
766
+ rb_define_singleton_method(gdkEvent, "setting_get", gdkevent_s_setting_get, -1);
767
+ rb_define_singleton_method(gdkEvent, "add_client_message_filter", gdkevent_s_add_client_message_filter, 1);
768
+ #if GTK_CHECK_VERSION(2,2,0)
769
+ rb_define_method(gdkEvent, "screen", gdkevent_screen, 0);
770
+ rb_define_method(gdkEvent, "set_screen", gdkevent_set_screen, 1);
771
+ #endif
772
+ G_DEF_SETTERS(gdkEvent);
773
+
774
+ /* GdkEventAny */
775
+ DEFINE_ACCESSOR(gdkEventAny, any, window);
776
+ rb_define_method(gdkEventAny, "send_event?", gdkeventany_send_event, 0);
777
+ rb_define_method(gdkEventAny, "set_send_event", gdkeventany_set_send_event, 1);
778
+ G_DEF_SETTERS(gdkEventAny);
779
+
780
+ /* GdkEventKey */
781
+ ev = gdkevents[GDK_KEY_PRESS];
782
+ DEFINE_ACCESSOR(ev, key, time);
783
+ DEFINE_ACCESSOR(ev, key, state);
784
+ DEFINE_ACCESSOR(ev, key, keyval);
785
+ DEFINE_ACCESSOR(ev, key, hardware_keycode);
786
+ DEFINE_ACCESSOR(ev, key, group);
787
+ G_DEF_SETTERS(ev);
788
+
789
+ /* GdkEventButton */
790
+ ev = gdkevents[GDK_BUTTON_PRESS];
791
+ DEFINE_ACCESSOR(ev, button, time);
792
+ DEFINE_ACCESSOR(ev, button, x);
793
+ DEFINE_ACCESSOR(ev, button, y);
794
+ rb_define_method(ev, "axes", gdkeventbutton_axes, 0);
795
+ rb_define_method(ev, "set_axes", gdkeventbutton_set_axes, 2);
796
+ DEFINE_ACCESSOR(ev, button, state);
797
+ DEFINE_ACCESSOR(ev, button, button);
798
+ DEFINE_ACCESSOR(ev, button, device);
799
+ DEFINE_ACCESSOR(ev, button, x_root);
800
+ DEFINE_ACCESSOR(ev, button, y_root);
801
+ G_DEF_SETTERS(ev);
802
+
803
+ /* GdkEventScroll */
804
+ ev = gdkevents[GDK_SCROLL];
805
+ DEFINE_ACCESSOR(ev, scroll, time);
806
+ DEFINE_ACCESSOR(ev, scroll, x);
807
+ DEFINE_ACCESSOR(ev, scroll, y);
808
+ DEFINE_ACCESSOR(ev, scroll, state);
809
+ DEFINE_ACCESSOR(ev, scroll, direction);
810
+ DEFINE_ACCESSOR(ev, scroll, device);
811
+ DEFINE_ACCESSOR(ev, scroll, x_root);
812
+ DEFINE_ACCESSOR(ev, scroll, y_root);
813
+ DEFINE_INIT(ev, scroll);
814
+ G_DEF_SETTERS(ev);
815
+
816
+ /* GdkScrollDirection */
817
+ G_DEF_CLASS(GDK_TYPE_SCROLL_DIRECTION, "Direction", ev);
818
+ G_DEF_CONSTANTS(ev, GDK_TYPE_SCROLL_DIRECTION, "GDK_SCROLL_");
819
+
820
+ /* GdkEventMotion */
821
+ ev = gdkevents[GDK_MOTION_NOTIFY];
822
+ DEFINE_ACCESSOR(ev, motion, time);
823
+ DEFINE_ACCESSOR(ev, motion, x);
824
+ DEFINE_ACCESSOR(ev, motion, y);
825
+ rb_define_method(ev, "axes", gdkeventmotion_axes, 0);
826
+ rb_define_method(ev, "set_axes", gdkeventmotion_set_axes, 1);
827
+ DEFINE_ACCESSOR(ev, motion, state);
828
+ rb_define_method(ev, "hint?", gdkeventmotion_is_hint, 0);
829
+ rb_define_method(ev, "set_hint", gdkeventmotion_set_is_hint, 1);
830
+ DEFINE_ACCESSOR(ev, motion, device);
831
+ DEFINE_ACCESSOR(ev, motion, x_root);
832
+ DEFINE_ACCESSOR(ev, motion, y_root);
833
+ DEFINE_INIT(ev, motion);
834
+ #if GTK_CHECK_VERSION(2, 12, 0)
835
+ rb_define_method(ev, "request", gdkeventmotion_request_motions, 0);
836
+ #endif
837
+ G_DEF_SETTERS(ev);
838
+
839
+ /* GdkEventExpose */
840
+ ev = gdkevents[GDK_EXPOSE];
841
+ DEFINE_ACCESSOR(ev, expose, area);
842
+ DEFINE_ACCESSOR(ev, expose, region);
843
+ DEFINE_ACCESSOR(ev, expose, count);
844
+ DEFINE_INIT(ev, expose);
845
+ rb_define_singleton_method(ev, "get_graphics_expose",
846
+ gdkevent_s_get_graphics_expose, 1);
847
+ G_DEF_SETTERS(ev);
848
+
849
+ /* GdkEventVisibility */
850
+ ev = gdkevents[GDK_VISIBILITY_NOTIFY];
851
+ DEFINE_ACCESSOR(ev, visibility, state);
852
+ DEFINE_INIT(ev, visibility);
853
+ G_DEF_SETTERS(ev);
854
+
855
+ /* GdkVisibilityState */
856
+ G_DEF_CLASS(GDK_TYPE_VISIBILITY_STATE, "State", ev);
857
+ G_DEF_CONSTANTS(ev, GDK_TYPE_VISIBILITY_STATE, "GDK_VISIBILITY_");
858
+
859
+ /* GdkEventCrossing */
860
+ ev = gdkevents[GDK_ENTER_NOTIFY];
861
+ DEFINE_ACCESSOR(ev, crossing, subwindow);
862
+ DEFINE_ACCESSOR(ev, crossing, time);
863
+ DEFINE_ACCESSOR(ev, crossing, x);
864
+ DEFINE_ACCESSOR(ev, crossing, y);
865
+ DEFINE_ACCESSOR(ev, crossing, x_root);
866
+ DEFINE_ACCESSOR(ev, crossing, y_root);
867
+ DEFINE_ACCESSOR(ev, crossing, mode);
868
+ DEFINE_ACCESSOR(ev, crossing, detail);
869
+ rb_define_method(ev, "focus?", gdkeventcrossing_focus, 0);
870
+ rb_define_method(ev, "set_focus", gdkeventcrossing_set_focus, 1);
871
+ DEFINE_ACCESSOR(ev, crossing, state);
872
+ G_DEF_SETTERS(ev);
873
+
874
+ /* GdkCrossingMode */
875
+ G_DEF_CLASS(GDK_TYPE_CROSSING_MODE, "Mode", ev);
876
+ G_DEF_CONSTANTS(ev, GDK_TYPE_CROSSING_MODE, "GDK_CROSSING_");
877
+ /* GdkNotifyType */
878
+ G_DEF_CLASS(GDK_TYPE_NOTIFY_TYPE, "NotifyType", ev);
879
+ G_DEF_CONSTANTS(ev, GDK_TYPE_NOTIFY_TYPE, "GDK_");
880
+
881
+ /* GdkEventFocus */
882
+ ev = gdkevents[GDK_FOCUS_CHANGE];
883
+ rb_define_method(ev, "in?", gdkeventfocus_change_in, 0);
884
+ rb_define_method(ev, "set_in", gdkeventfocus_change_set_in, 1);
885
+ DEFINE_INIT(ev, focus_change);
886
+ G_DEF_SETTERS(ev);
887
+
888
+ /* GdkEventConfigure */
889
+ ev = gdkevents[GDK_CONFIGURE];
890
+ DEFINE_ACCESSOR(ev, configure, x);
891
+ DEFINE_ACCESSOR(ev, configure, y);
892
+ DEFINE_ACCESSOR(ev, configure, width);
893
+ DEFINE_ACCESSOR(ev, configure, height);
894
+ DEFINE_INIT(ev, configure);
895
+ G_DEF_SETTERS(ev);
896
+
897
+ /* GdkEventProperty */
898
+ ev = gdkevents[GDK_PROPERTY_NOTIFY];
899
+ DEFINE_ACCESSOR(ev, property, atom);
900
+ DEFINE_ACCESSOR(ev, property, time);
901
+ DEFINE_ACCESSOR(ev, property, state);
902
+ DEFINE_INIT(ev, property);
903
+ G_DEF_SETTERS(ev);
904
+
905
+ /* GdkPropertyState */
906
+ G_DEF_CLASS(GDK_TYPE_PROPERTY_STATE, "State", ev);
907
+ G_DEF_CONSTANTS(ev, GDK_TYPE_PROPERTY_STATE, "GDK_");
908
+
909
+ /* GdkEventSelection */
910
+ ev = gdkevents[GDK_SELECTION_CLEAR];
911
+ DEFINE_ACCESSOR(ev, selection, selection);
912
+ DEFINE_ACCESSOR(ev, selection, target);
913
+ DEFINE_ACCESSOR(ev, selection, property);
914
+ DEFINE_ACCESSOR(ev, selection, requestor);
915
+ DEFINE_ACCESSOR(ev, selection, time);
916
+ G_DEF_SETTERS(ev);
917
+
918
+ /* GdkEventDND */
919
+ ev = gdkevents[GDK_DRAG_ENTER];
920
+ DEFINE_ACCESSOR(ev, dnd, context);
921
+ DEFINE_ACCESSOR(ev, dnd, time);
922
+ DEFINE_ACCESSOR(ev, dnd, x_root);
923
+ DEFINE_ACCESSOR(ev, dnd, y_root);
924
+ G_DEF_SETTERS(ev);
925
+
926
+ /* GdkEventProximity */
927
+ ev = gdkevents[GDK_PROXIMITY_IN];
928
+ DEFINE_ACCESSOR(ev, proximity, time);
929
+ DEFINE_ACCESSOR(ev, proximity, device);
930
+ G_DEF_SETTERS(ev);
931
+
932
+ /* GdkEventClient */
933
+ ev = gdkevents[GDK_CLIENT_EVENT];
934
+ DEFINE_ACCESSOR(ev, client, message_type);
935
+ rb_define_method(ev, "data_format", gdkeventclient_data_format, 0);
936
+ rb_define_method(ev, "data", gdkeventclient_data, 0);
937
+ rb_define_method(ev, "send_client_message",
938
+ gdkeventclient_send_client_message, -1);
939
+ rb_define_method(ev, "send_clientmessage_toall",
940
+ gdkeventclient_send_clientmessage_toall, 0);
941
+ DEFINE_INIT(ev, client);
942
+ G_DEF_SETTERS(ev);
943
+
944
+ /* GdkEventNoExpose */
945
+ ev = gdkevents[GDK_NO_EXPOSE];
946
+ DEFINE_INIT(ev, noexpose);
947
+
948
+ /* GdkEventWindowState */
949
+ ev = gdkevents[GDK_WINDOW_STATE];
950
+ DEFINE_ACCESSOR(ev, window_state, changed_mask);
951
+ DEFINE_ACCESSOR(ev, window_state, new_window_state);
952
+ DEFINE_INIT(ev, window_state);
953
+ G_DEF_SETTERS(ev);
954
+
955
+ /* GdkWindowState */
956
+ G_DEF_CLASS(GDK_TYPE_WINDOW_STATE, "WindowState", ev);
957
+ G_DEF_CONSTANTS(ev, GDK_TYPE_WINDOW_STATE, "GDK_WINDOW_STATE_");
958
+
959
+ /* GdkEventSetting */
960
+ ev = gdkevents[GDK_SETTING];
961
+ DEFINE_ACCESSOR(ev, setting, action);
962
+ DEFINE_ACCESSOR(ev, setting, name);
963
+ DEFINE_INIT(ev, setting);
964
+ G_DEF_SETTERS(ev);
965
+
966
+ /* GdkSettingAction */
967
+ G_DEF_CLASS(GDK_TYPE_SETTING_ACTION, "Action", ev);
968
+ G_DEF_CONSTANTS(ev, GDK_TYPE_SETTING_ACTION, "GDK_SETTING_");
969
+
970
+ #if GTK_CHECK_VERSION(2,6,0)
971
+ /* GdkEventOwnerChange */
972
+ ev = gdkevents[GDK_OWNER_CHANGE];
973
+ DEFINE_ACCESSOR(ev, owner_change, owner);
974
+ DEFINE_ACCESSOR(ev, owner_change, reason);
975
+ DEFINE_ACCESSOR(ev, owner_change, selection);
976
+ DEFINE_ACCESSOR(ev, owner_change, time);
977
+ DEFINE_ACCESSOR(ev, owner_change, selection_time);
978
+ G_DEF_SETTERS(ev);
979
+ DEFINE_INIT(ev, owner_change);
980
+
981
+ /* GdkOwnerChange */
982
+ G_DEF_CLASS(GDK_TYPE_OWNER_CHANGE, "OwnerChange", ev);
983
+ G_DEF_CONSTANTS(ev, GDK_TYPE_OWNER_CHANGE, "GDK_OWNER_CHANGE_");
984
+ #endif
985
+
986
+ #if GTK_CHECK_VERSION(2,8,0)
987
+ /* GdkEventGrabBroken */
988
+ ev = gdkevents[GDK_GRAB_BROKEN];
989
+ rb_define_method(ev, "keyboard?", gdkeventgrab_broken_keyboard, 0);
990
+ rb_define_method(ev, "set_keyboard", gdkeventgrab_broken_set_keyboard, 1);
991
+ rb_define_method(ev, "implicit?", gdkeventgrab_broken_implicit, 0);
992
+ rb_define_method(ev, "set_implicit", gdkeventgrab_broken_set_implicit, 1);
993
+ DEFINE_ACCESSOR(ev, grab_broken, grab_window);
994
+ DEFINE_INIT(ev, grab_broken);
995
+ G_DEF_SETTERS(ev);
996
+ #endif
997
+
998
+ rbgobj_register_g2r_func(GDK_TYPE_EVENT, &gdkevent_g2r);
999
+
1000
+ /*
1001
+ * GdkEvent's Constants
1002
+ */
1003
+ rb_define_const(gdkEvent, "CURRENT_TIME", INT2FIX(GDK_CURRENT_TIME));
1004
+ rb_define_const(gdkEvent, "PRIORITY_EVENTS", INT2FIX(GDK_PRIORITY_EVENTS));
1005
+ rb_define_const(gdkEvent, "PRIORITY_REDRAW", INT2FIX(GDK_PRIORITY_REDRAW));
1006
+
1007
+ /* GdkEventType */
1008
+ /* XXX */
1009
+ G_RENAME_CONSTANT("2BUTTON_PRESS","BUTTON2_PRESS");
1010
+ G_RENAME_CONSTANT("3BUTTON_PRESS","BUTTON3_PRESS");
1011
+ G_DEF_CLASS(GDK_TYPE_EVENT_TYPE, "Type", gdkEvent);
1012
+ G_RENAME_CONSTANT("2BUTTON_PRESS","BUTTON2_PRESS");
1013
+ G_RENAME_CONSTANT("3BUTTON_PRESS","BUTTON3_PRESS");
1014
+ G_DEF_CONSTANTS(gdkEvent, GDK_TYPE_EVENT_TYPE, "GDK_");
1015
+
1016
+ /* GdkEventMask */
1017
+ G_DEF_CLASS(GDK_TYPE_EVENT_MASK, "Mask", gdkEvent);
1018
+ G_DEF_CONSTANTS(gdkEvent, GDK_TYPE_EVENT_MASK, "GDK_");
1019
+
1020
+ }