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,26 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgtkconversions.h -
5
+
6
+ Copyright (C) 2008 Ruby-GNOME2 Project Team
7
+ ************************************************/
8
+
9
+ #ifndef __RB_GTK_MACROS_H__
10
+ #define __RB_GTK_MACROS_H__
11
+
12
+ #define RBGTK_MAJOR_VERSION RBGLIB_MAJOR_VERSION
13
+ #define RBGTK_MINOR_VERSION RBGLIB_MINOR_VERSION
14
+ #define RBGTK_MICRO_VERSION RBGLIB_MICRO_VERSION
15
+
16
+ #if defined(G_PLATFORM_WIN32) && !defined(RUBY_GTK2_STATIC_COMPILATION)
17
+ # ifdef RUBY_GTK2_COMPILATION
18
+ # define RUBY_GTK2_VAR __declspec(dllexport)
19
+ # else
20
+ # define RUBY_GTK2_VAR extern __declspec(dllimport)
21
+ # endif
22
+ #else
23
+ # define RUBY_GTK2_VAR extern
24
+ #endif
25
+
26
+ #endif /* __RB_GTK_MACROS_H__ */
@@ -0,0 +1,532 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgtkmain.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 16:07:31 $
8
+
9
+ Copyright (C) 2002,2003, 2009 Ruby-GNOME2 Project Team
10
+ Copyright (C) 1998-2000 Yukihiro Matsumoto,
11
+ Daisuke Kanda,
12
+ Hiroshi Igarashi
13
+ ************************************************/
14
+ #include "global.h"
15
+ #include <locale.h>
16
+
17
+ static VALUE rbgtk_eGtkInitError;
18
+
19
+ static ID id__quit_callbacks__, id__timeout_callbacks__;
20
+ static ID id__idle_callbacks__, id__snooper_callbacks__;
21
+
22
+
23
+ typedef struct _callback_info_t
24
+ {
25
+ VALUE callback;
26
+ ID key;
27
+ guint id;
28
+ } callback_info_t;
29
+
30
+
31
+ static VALUE
32
+ gtk_m_function_body(data)
33
+ VALUE data;
34
+ {
35
+ callback_info_t *info = (callback_info_t *)data;
36
+ VALUE ret = rb_funcall(info->callback, id_call, 0);
37
+
38
+ if (info->key && !ret)
39
+ G_REMOVE_RELATIVE(mGtk, info->key, UINT2NUM(info->id));
40
+ return ret;
41
+ }
42
+
43
+ static gboolean
44
+ gtk_m_function(data)
45
+ gpointer data;
46
+ {
47
+ return RVAL2CBOOL(G_PROTECT_CALLBACK(gtk_m_function_body, data));
48
+ }
49
+
50
+ static VALUE
51
+ gtk_m_function2_body(gpointer proc)
52
+ {
53
+ rb_funcall((VALUE)proc, id_call, 0);
54
+ return Qnil;
55
+ }
56
+
57
+ static void
58
+ gtk_m_function2(gpointer proc)
59
+ {
60
+ G_PROTECT_CALLBACK(gtk_m_function2_body, proc);
61
+ }
62
+
63
+
64
+ static VALUE
65
+ gtk_m_set_locale(self)
66
+ VALUE self;
67
+ {
68
+ return CSTR2RVAL(gtk_set_locale());
69
+ }
70
+
71
+ static VALUE
72
+ gtk_m_disable_setlocale(self)
73
+ VALUE self;
74
+ {
75
+ gtk_disable_setlocale();
76
+ return Qnil;
77
+ }
78
+
79
+ static VALUE
80
+ gtk_m_get_default_language(self)
81
+ VALUE self;
82
+ {
83
+ return BOXED2RVAL(gtk_get_default_language(), PANGO_TYPE_LANGUAGE);
84
+ }
85
+
86
+ typedef void (*SignalFunc) (int);
87
+
88
+ static gboolean _initialized = FALSE;
89
+
90
+ static VALUE
91
+ gtk_m_init(int argc, VALUE *argv, VALUE self)
92
+ {
93
+ gint i, gargc;
94
+ VALUE argary;
95
+ gchar** gargv;
96
+ VALUE progname;
97
+
98
+ if (_initialized)
99
+ return self;
100
+ else
101
+ _initialized = TRUE;
102
+
103
+ rb_scan_args(argc, argv, "01", &argary);
104
+
105
+ if (NIL_P(argary)){
106
+ argary = rb_const_get(rb_cObject, rb_intern("ARGV"));
107
+ gargc = RARRAY_LEN(argary);
108
+ } else {
109
+ Check_Type(argary, T_ARRAY);
110
+ gargc = RARRAY_LEN(argary);
111
+ }
112
+
113
+ gargv = ALLOCA_N(char *, gargc + 1);
114
+ progname = rb_gv_get("$0");
115
+ gargv[0] = RVAL2CSTR(progname);
116
+
117
+ for (i = 0; i < gargc; i++) {
118
+ if (TYPE(RARRAY_PTR(argary)[i]) == T_STRING) {
119
+ gargv[i+1] = RVAL2CSTR(RARRAY_PTR(argary)[i]);
120
+ }
121
+ else {
122
+ gargv[i+1] = "";
123
+ }
124
+ }
125
+ gargc++;
126
+
127
+ {
128
+ gboolean is_initialized;
129
+ /* Gdk modifies sighandlers, sigh */
130
+ #ifdef NT
131
+ RETSIGTYPE (*sigfunc[3])();
132
+ #else
133
+ RETSIGTYPE (*sigfunc[7])();
134
+ #endif
135
+
136
+ #ifdef NT
137
+ sigfunc[0] = signal(SIGINT, SIG_IGN);
138
+ sigfunc[1] = signal(SIGSEGV, SIG_IGN);
139
+ sigfunc[2] = signal(SIGTERM, SIG_IGN);
140
+ #else
141
+ sigfunc[0] = signal(SIGHUP, SIG_IGN);
142
+ sigfunc[1] = signal(SIGINT, SIG_IGN);
143
+ sigfunc[2] = signal(SIGQUIT, SIG_IGN);
144
+ sigfunc[3] = signal(SIGBUS, SIG_IGN);
145
+ sigfunc[4] = signal(SIGSEGV, SIG_IGN);
146
+ sigfunc[5] = signal(SIGPIPE, SIG_IGN);
147
+ sigfunc[6] = signal(SIGTERM, SIG_IGN);
148
+ #endif
149
+
150
+ is_initialized = gtk_init_check(&gargc, &gargv);
151
+ if (! is_initialized) {
152
+ const char *display_name_arg = gdk_get_display_arg_name();
153
+ display_name_arg = display_name_arg ? display_name_arg : g_getenv("DISPLAY");
154
+ rb_raise(rbgtk_eGtkInitError, "Cannot open display: %s",
155
+ display_name_arg ? display_name_arg : " ");
156
+ }
157
+
158
+ setlocale(LC_NUMERIC, "C");
159
+
160
+ #ifdef NT
161
+ signal(SIGINT, (SignalFunc)sigfunc[0]);
162
+ signal(SIGSEGV, (SignalFunc)sigfunc[1]);
163
+ signal(SIGTERM, (SignalFunc)sigfunc[2]);
164
+ #else
165
+ signal(SIGHUP, sigfunc[0]);
166
+ signal(SIGINT, sigfunc[1]);
167
+ signal(SIGQUIT, sigfunc[2]);
168
+ signal(SIGBUS, sigfunc[3]);
169
+ signal(SIGSEGV, sigfunc[4]);
170
+ signal(SIGPIPE, sigfunc[5]);
171
+ signal(SIGTERM, sigfunc[6]);
172
+ #endif
173
+ }
174
+
175
+ return self;
176
+ }
177
+
178
+ /* We don't need them.
179
+ gtk_init()
180
+ gtk_exit()
181
+ */
182
+
183
+ static VALUE
184
+ gtk_m_main(self)
185
+ VALUE self;
186
+ {
187
+ gtk_main();
188
+ return Qnil;
189
+ }
190
+
191
+ static VALUE
192
+ gtk_m_main_level(self)
193
+ VALUE self;
194
+ {
195
+ return INT2FIX(gtk_main_level());
196
+ }
197
+
198
+ static VALUE
199
+ gtk_m_main_quit(self)
200
+ VALUE self;
201
+ {
202
+ gtk_main_quit();
203
+ return Qnil;
204
+ }
205
+
206
+ static VALUE
207
+ gtk_m_main_iteration(self)
208
+ VALUE self;
209
+ {
210
+ return CBOOL2RVAL(gtk_main_iteration());
211
+ }
212
+
213
+ static VALUE
214
+ gtk_m_main_iteration_do(self, blocking)
215
+ VALUE self, blocking;
216
+ {
217
+ return CBOOL2RVAL(gtk_main_iteration_do(RVAL2CBOOL(blocking)));
218
+ }
219
+
220
+ static VALUE
221
+ gtk_m_main_do_event(self, event)
222
+ VALUE self, event;
223
+ {
224
+ gtk_main_do_event(RVAL2GEV(event));
225
+ return event;
226
+ }
227
+
228
+ /* We don't need them.
229
+ gtk_true()
230
+ gtk_false()
231
+ */
232
+
233
+ static VALUE
234
+ gtk_m_grab_add(self, widget)
235
+ VALUE self, widget;
236
+ {
237
+ gtk_grab_add(GTK_WIDGET(RVAL2GOBJ(widget)));
238
+ return Qnil;
239
+ }
240
+
241
+ static VALUE
242
+ gtk_m_get_current(self)
243
+ VALUE self;
244
+ {
245
+ return GOBJ2RVAL(gtk_grab_get_current());
246
+ }
247
+
248
+ static VALUE
249
+ gtk_m_grab_remove(self, widget)
250
+ VALUE self, widget;
251
+ {
252
+ gtk_grab_remove(GTK_WIDGET(RVAL2GOBJ(widget)));
253
+ return Qnil;
254
+ }
255
+
256
+ static VALUE
257
+ gtk_m_init_add(self)
258
+ VALUE self;
259
+ {
260
+ volatile VALUE func = rb_block_proc();
261
+
262
+ gtk_init_add((GtkFunction)gtk_m_function2, (gpointer)func);
263
+ G_RELATIVE(self, func);
264
+ return Qnil;
265
+ }
266
+
267
+ static VALUE
268
+ gtk_m_quit_add(self, main_level)
269
+ VALUE self, main_level;
270
+ {
271
+ volatile VALUE func = rb_block_proc();
272
+ VALUE rb_id;
273
+ callback_info_t *info;
274
+ guint id;
275
+
276
+ info = ALLOC(callback_info_t);
277
+ info->callback = func;
278
+ info->key = id_relative_callbacks;
279
+ id = gtk_quit_add_full(NUM2UINT(main_level), (GtkFunction)gtk_m_function,
280
+ NULL, (gpointer)info, g_free);
281
+ info->id = id;
282
+ rb_id = UINT2NUM(id);
283
+ G_RELATIVE2(self, func, id__quit_callbacks__, rb_id);
284
+ return rb_id;
285
+ }
286
+
287
+ static VALUE
288
+ gtk_m_quit_remove(self, quit_handler_id)
289
+ VALUE self, quit_handler_id;
290
+ {
291
+ gtk_quit_remove(NUM2UINT(quit_handler_id));
292
+ G_REMOVE_RELATIVE(self, id__quit_callbacks__, quit_handler_id);
293
+ return quit_handler_id;
294
+ }
295
+
296
+ /* We don't need this.
297
+ gtk_quit_add_full ()
298
+ gtk_quit_add_destroy()
299
+ gtk_quit_remove_by_data()
300
+ gtk_timeout_add_full()
301
+ */
302
+
303
+ static VALUE
304
+ timeout_add(self, interval)
305
+ VALUE self, interval;
306
+ {
307
+ VALUE func, rb_id;
308
+ callback_info_t *info;
309
+ guint id;
310
+
311
+ func = rb_block_proc();
312
+ info = ALLOC(callback_info_t);
313
+ info->callback = func;
314
+ info->key = id__timeout_callbacks__;
315
+ id = gtk_timeout_add_full(NUM2UINT(interval), (GtkFunction)gtk_m_function,
316
+ NULL, (gpointer)info, g_free);
317
+ info->id = id;
318
+ rb_id = UINT2NUM(id);
319
+ G_RELATIVE2(self, func, id__timeout_callbacks__, rb_id);
320
+ return rb_id;
321
+ }
322
+
323
+ static VALUE
324
+ timeout_remove(self, id)
325
+ VALUE self, id;
326
+ {
327
+ gtk_timeout_remove(NUM2UINT(id));
328
+ G_REMOVE_RELATIVE(self, id__timeout_callbacks__, id);
329
+ return Qnil;
330
+ }
331
+
332
+ static VALUE
333
+ idle_add(self)
334
+ VALUE self;
335
+ {
336
+ VALUE func, rb_id;
337
+ callback_info_t *info;
338
+ guint id;
339
+
340
+ func = rb_block_proc();
341
+ info = ALLOC(callback_info_t);
342
+ info->callback = func;
343
+ info->key = id__idle_callbacks__;
344
+ id = gtk_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
345
+ (GtkFunction)gtk_m_function, NULL,
346
+ (gpointer)info, g_free);
347
+ info->id = id;
348
+ rb_id = UINT2NUM(id);
349
+ G_RELATIVE2(self, func, id__idle_callbacks__, rb_id);
350
+ return rb_id;
351
+ }
352
+
353
+ static VALUE
354
+ idle_add_priority(self, priority)
355
+ VALUE self;
356
+ {
357
+ VALUE func, rb_id;
358
+ callback_info_t *info;
359
+ guint id;
360
+
361
+ func = rb_block_proc();
362
+ info = ALLOC(callback_info_t);
363
+ info->callback = func;
364
+ info->key = id__idle_callbacks__;
365
+ id = gtk_idle_add_full(NUM2INT(priority), (GtkFunction)gtk_m_function,
366
+ NULL, (gpointer)info, g_free);
367
+ info->id = id;
368
+ rb_id = UINT2NUM(id);
369
+ G_RELATIVE2(self, func, id__idle_callbacks__, rb_id);
370
+ return rb_id;
371
+ }
372
+
373
+ static VALUE
374
+ idle_remove(self, id)
375
+ VALUE self, id;
376
+ {
377
+ gtk_idle_remove(NUM2UINT(id));
378
+ G_REMOVE_RELATIVE(self, id__idle_callbacks__, id);
379
+ return Qnil;
380
+ }
381
+
382
+ /* We don't need this.
383
+ gtk_idle_remove_by_data()
384
+ gtk_idle_add_full()
385
+
386
+ Use Gdk::Input.add, remove
387
+ gtk_input_add_full()
388
+ gtk_input_remove()
389
+ */
390
+
391
+ static gint
392
+ gtk_m_key_snoop_func(grab_widget, event, func)
393
+ GtkWidget* grab_widget;
394
+ GdkEventKey* event;
395
+ gpointer func;
396
+ {
397
+ VALUE ret = rb_funcall((VALUE)func, id_call, 2,
398
+ GOBJ2RVAL(grab_widget),
399
+ GEV2RVAL((GdkEvent*)event));
400
+ return RVAL2CBOOL(ret);
401
+ }
402
+
403
+ static VALUE
404
+ gtk_m_key_snooper_install(self)
405
+ VALUE self;
406
+ {
407
+ VALUE func = rb_block_proc();
408
+ VALUE id = INT2FIX(gtk_key_snooper_install(
409
+ (GtkKeySnoopFunc)gtk_m_key_snoop_func,
410
+ (gpointer)func));
411
+ G_RELATIVE2(self, func, id__snooper_callbacks__, id);
412
+ return id;
413
+ }
414
+
415
+ static VALUE
416
+ gtk_m_key_snooper_remove(self, id)
417
+ VALUE self, id;
418
+ {
419
+ gtk_key_snooper_remove(NUM2UINT(id));
420
+ G_REMOVE_RELATIVE(self, id__snooper_callbacks__, id);
421
+ return Qnil;
422
+ }
423
+
424
+ static VALUE
425
+ gtk_m_get_current_event(self)
426
+ VALUE self;
427
+ {
428
+ return GEV2RVAL(gtk_get_current_event());
429
+ }
430
+
431
+ static VALUE
432
+ gtk_m_get_current_event_time(self)
433
+ VALUE self;
434
+ {
435
+ return INT2NUM(gtk_get_current_event_time());
436
+ }
437
+
438
+ static VALUE
439
+ gtk_m_get_current_event_state(self)
440
+ VALUE self;
441
+ {
442
+ GdkModifierType state;
443
+ gboolean ret = gtk_get_current_event_state(&state);
444
+ return ret ? GFLAGS2RVAL(state, GDK_TYPE_MODIFIER_TYPE) : Qnil;
445
+ }
446
+
447
+ static VALUE
448
+ gtk_m_get_event_widget(argc, argv, self)
449
+ int argc;
450
+ VALUE* argv;
451
+ VALUE self;
452
+ {
453
+ VALUE event;
454
+ rb_scan_args(argc, argv, "01", &event);
455
+
456
+ return GOBJ2RVAL(gtk_get_event_widget(NIL_P(event) ? NULL :RVAL2GEV(event)));
457
+ }
458
+
459
+ static VALUE
460
+ gtk_m_propagate_event(self, widget, event)
461
+ VALUE self, widget, event;
462
+ {
463
+ gtk_propagate_event(GTK_WIDGET(RVAL2GOBJ(widget)), RVAL2GEV(event));
464
+ return Qnil;
465
+ }
466
+
467
+ /* From Version Information */
468
+ static VALUE
469
+ gtk_m_check_version(self, major, minor, micro)
470
+ VALUE self, major, minor, micro;
471
+ {
472
+ const gchar *ret;
473
+ ret = gtk_check_version(FIX2INT(major), FIX2INT(minor), FIX2INT(micro));
474
+ return ret ? CSTR2RVAL(ret) : Qnil;
475
+ }
476
+
477
+ static VALUE
478
+ gtk_m_check_version_q(self, major, minor, micro)
479
+ VALUE self, major, minor, micro;
480
+ {
481
+ const gchar *ret;
482
+ ret = gtk_check_version(FIX2INT(major), FIX2INT(minor), FIX2INT(micro));
483
+ return CBOOL2RVAL(ret == NULL);
484
+ }
485
+
486
+
487
+ void
488
+ Init_gtk_main()
489
+ {
490
+ id__quit_callbacks__ = rb_intern("__quit_callbacks__");
491
+ id__timeout_callbacks__ = rb_intern("__timeout_callbacks__");
492
+ id__idle_callbacks__ = rb_intern("__idle_callbacks__");
493
+ id__snooper_callbacks__ = rb_intern("__snooper_callbacks__");
494
+
495
+ rbgtk_eGtkInitError = rb_define_class_under(mGtk, "InitError",
496
+ rb_eRuntimeError);
497
+
498
+ rb_define_module_function(mGtk, "set_locale", gtk_m_set_locale, 0);
499
+ rb_define_module_function(mGtk, "disable_setlocale", gtk_m_disable_setlocale, 0);
500
+ rb_define_module_function(mGtk, "default_language", gtk_m_get_default_language, 0);
501
+ rb_define_module_function(mGtk, "init", gtk_m_init, -1);
502
+ rb_define_module_function(mGtk, "main", gtk_m_main, 0);
503
+ rb_define_module_function(mGtk, "main_level", gtk_m_main_level, 0);
504
+ rb_define_module_function(mGtk, "main_quit", gtk_m_main_quit, 0);
505
+ rb_define_module_function(mGtk, "main_iteration", gtk_m_main_iteration, 0);
506
+ rb_define_module_function(mGtk, "main_iteration_do", gtk_m_main_iteration_do, 1);
507
+ rb_define_module_function(mGtk, "main_do_event", gtk_m_main_do_event, 1);
508
+ rb_define_module_function(mGtk, "grab_add", gtk_m_grab_add, 1);
509
+ rb_define_module_function(mGtk, "current", gtk_m_get_current, 0);
510
+ rb_define_module_function(mGtk, "grab_remove", gtk_m_grab_remove, 1);
511
+ rb_define_module_function(mGtk, "init_add", gtk_m_init_add, 0);
512
+ rb_define_module_function(mGtk, "quit_add", gtk_m_quit_add, 1);
513
+ rb_define_module_function(mGtk, "quit_remove", gtk_m_quit_remove, 1);
514
+
515
+ rb_define_module_function(mGtk, "timeout_add", timeout_add, 1);
516
+ rb_define_module_function(mGtk, "timeout_remove", timeout_remove, 1);
517
+ rb_define_module_function(mGtk, "idle_add", idle_add, 0);
518
+ rb_define_module_function(mGtk, "idle_add_priority", idle_add_priority, 1);
519
+ rb_define_module_function(mGtk, "idle_remove", idle_remove, 1);
520
+ rb_define_module_function(mGtk, "key_snooper_install", gtk_m_key_snooper_install, 0);
521
+ rb_define_module_function(mGtk, "key_snooper_remove", gtk_m_key_snooper_remove, 1);
522
+ rb_define_module_function(mGtk, "current_event", gtk_m_get_current_event, 0);
523
+ rb_define_module_function(mGtk, "current_event_time", gtk_m_get_current_event_time, 0);
524
+ rb_define_module_function(mGtk, "current_event_state", gtk_m_get_current_event_state, 0);
525
+ rb_define_module_function(mGtk, "get_event_widget", gtk_m_get_event_widget, -1);
526
+ rb_define_module_function(mGtk, "propagate_event", gtk_m_propagate_event, 2);
527
+ rb_define_module_function(mGtk, "check_version", gtk_m_check_version, 3);
528
+ rb_define_module_function(mGtk, "check_version?", gtk_m_check_version_q, 3);
529
+
530
+ rb_define_const(mGtk, "PRIORITY_RESIZE", INT2FIX(GTK_PRIORITY_RESIZE));
531
+
532
+ }