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,105 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgdkkeyval.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 14:27:08 $
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
+ #include <gdk/gdkkeysyms.h>
17
+
18
+ static VALUE
19
+ keyval_to_name(self, keyval)
20
+ VALUE self, keyval;
21
+ {
22
+ gchar* name = gdk_keyval_name(NUM2UINT(keyval));
23
+ return name ? CSTR2RVAL(name) : Qnil;
24
+ }
25
+
26
+ static VALUE
27
+ keyval_from_name(self, keyval_name)
28
+ VALUE self, keyval_name;
29
+ {
30
+ return UINT2NUM(gdk_keyval_from_name(RVAL2CSTR(keyval_name)));
31
+ }
32
+
33
+ static VALUE
34
+ keyval_is_upper(self, keyval)
35
+ VALUE self, keyval;
36
+ {
37
+ return CBOOL2RVAL(gdk_keyval_is_upper(NUM2UINT(keyval)));
38
+ }
39
+
40
+ static VALUE
41
+ keyval_is_lower(self, keyval)
42
+ VALUE self, keyval;
43
+ {
44
+ return CBOOL2RVAL(gdk_keyval_is_lower(NUM2UINT(keyval)));
45
+ }
46
+
47
+ static VALUE
48
+ keyval_convert_case(self, symbol)
49
+ VALUE self, symbol;
50
+ {
51
+ guint upper, lower;
52
+ gdk_keyval_convert_case(NUM2UINT(symbol), &lower, &upper);
53
+ return rb_ary_new3(2, UINT2NUM(lower), UINT2NUM(upper));
54
+ }
55
+
56
+ static VALUE
57
+ keyval_to_upper(self, keyval)
58
+ VALUE self, keyval;
59
+ {
60
+ return INT2NUM(gdk_keyval_to_upper(NUM2UINT(keyval)));
61
+ }
62
+
63
+ static VALUE
64
+ keyval_to_lower(self, keyval)
65
+ VALUE self, keyval;
66
+ {
67
+ return INT2NUM(gdk_keyval_to_lower(NUM2UINT(keyval)));
68
+ }
69
+
70
+ static VALUE
71
+ keyval_to_unicode(self, keyval)
72
+ VALUE self, keyval;
73
+ {
74
+ return UINT2NUM(gdk_keyval_to_unicode(NUM2UINT(keyval)));
75
+ }
76
+
77
+ static VALUE
78
+ unicode_to_keyval(self, wc)
79
+ VALUE self, wc;
80
+ {
81
+ VALUE unicode;
82
+ if (TYPE(wc) == T_STRING) {
83
+ unicode = NUM2UINT(rb_funcall(wc, rb_intern("[]"), 1, INT2FIX(0)));
84
+ } else {
85
+ unicode = NUM2UINT(wc);
86
+ }
87
+ return UINT2NUM(gdk_unicode_to_keyval(unicode));
88
+ }
89
+
90
+ void
91
+ Init_gtk_gdk_keyval()
92
+ {
93
+ VALUE mGdkKeyval = rb_define_module_under(mGdk, "Keyval");
94
+ rb_define_module_function(mGdkKeyval, "to_name", keyval_to_name, 1);
95
+ rb_define_module_function(mGdkKeyval, "from_name", keyval_from_name, 1);
96
+ rb_define_module_function(mGdkKeyval, "upper?", keyval_is_upper, 1);
97
+ rb_define_module_function(mGdkKeyval, "lower?", keyval_is_lower, 1);
98
+ rb_define_module_function(mGdkKeyval, "convert_case", keyval_convert_case, 1);
99
+ rb_define_module_function(mGdkKeyval, "to_upper", keyval_to_upper, 1);
100
+ rb_define_module_function(mGdkKeyval, "to_lower", keyval_to_lower, 1);
101
+ rb_define_module_function(mGdkKeyval, "to_unicode", keyval_to_unicode, 1);
102
+ rb_define_module_function(mGdkKeyval, "from_unicode", unicode_to_keyval, 1);
103
+
104
+ #include "rbgdkkeysyms.h"
105
+ }
@@ -0,0 +1,171 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgdkpango.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 16:07:31 $
8
+
9
+ Copyright (C) 2003,2004 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "global.h"
13
+ #include "rbpango.h"
14
+
15
+ static VALUE
16
+ gdkpango_s_context_get(argc, argv, self)
17
+ int argc;
18
+ VALUE *argv;
19
+ VALUE self;
20
+ {
21
+ VALUE screen, ret;
22
+ rb_scan_args(argc, argv, "01", &screen);
23
+ if (NIL_P(screen)){
24
+ ret = GOBJ2RVAL(gdk_pango_context_get());
25
+ } else {
26
+ #if GTK_CHECK_VERSION(2,2,0)
27
+ ret = GOBJ2RVAL(gdk_pango_context_get_for_screen(GDK_SCREEN(RVAL2GOBJ(screen))));
28
+ #else
29
+ rb_warn("Gdk::Pango.context_get: Not supported arguments in GTK+-2.0.x.");
30
+ ret = GOBJ2RVAL(gdk_pango_context_get());
31
+ #endif
32
+ }
33
+ return ret;
34
+ }
35
+
36
+ static VALUE
37
+ gdkpango_context_set_colormap(self, colormap)
38
+ VALUE self, colormap;
39
+ {
40
+ gdk_pango_context_set_colormap(PANGO_CONTEXT(RVAL2GOBJ(self)),
41
+ GDK_COLORMAP(RVAL2GOBJ(self)));
42
+ return self;
43
+ }
44
+
45
+ static VALUE
46
+ gdkpango_attr_embossed_initialize(self, embossed)
47
+ VALUE self, embossed;
48
+ {
49
+ DATA_PTR(self) = gdk_pango_attr_embossed_new(RVAL2CBOOL(embossed));
50
+ return Qnil;
51
+ }
52
+
53
+ static VALUE
54
+ gdkpango_attr_embossed_value(self)
55
+ VALUE self;
56
+ {
57
+ return CBOOL2RVAL(((GdkPangoAttrEmbossed*)RVAL2ATTR(self))->embossed);
58
+ }
59
+
60
+ static VALUE
61
+ gdkpango_attr_stipple_initialize(self, stipple)
62
+ VALUE self, stipple;
63
+ {
64
+ DATA_PTR(self) = gdk_pango_attr_stipple_new(GDK_BITMAP(RVAL2GOBJ(stipple)));
65
+ return Qnil;
66
+ }
67
+
68
+ static VALUE
69
+ gdkpango_attr_stipple_value(self)
70
+ VALUE self;
71
+ {
72
+ return GOBJ2RVAL(((GdkPangoAttrStipple*)RVAL2ATTR(self))->stipple);
73
+ }
74
+
75
+ static VALUE
76
+ gdkpango_layout_get_clip_region(self, x_origin, y_origin, index_ranges)
77
+ VALUE self, x_origin, y_origin, index_ranges;
78
+ {
79
+ int i;
80
+ gint len = RARRAY_LEN(index_ranges);
81
+ gint* ranges = g_new(gint, len);
82
+
83
+ for (i = 0; i < len; i++) {
84
+ ranges[i] = RARRAY_PTR(index_ranges)[i];
85
+ }
86
+ return BOXED2RVAL(gdk_pango_layout_get_clip_region(PANGO_LAYOUT(RVAL2GOBJ(self)),
87
+ NUM2INT(x_origin),
88
+ NUM2INT(y_origin),
89
+ ranges, len), GDK_TYPE_REGION);
90
+ }
91
+
92
+ static VALUE
93
+ gdkpango_layout_line_get_clip_region(self, x_origin, y_origin, index_ranges)
94
+ VALUE self, x_origin, y_origin, index_ranges;
95
+ {
96
+ int i;
97
+ gint len = RARRAY_LEN(index_ranges);
98
+ gint* ranges = g_new(gint, len);
99
+
100
+ for (i = 0; i < len; i++) {
101
+ ranges[i] = RARRAY_PTR(index_ranges)[i];
102
+ }
103
+ return BOXED2RVAL(gdk_pango_layout_line_get_clip_region(
104
+ (PangoLayoutLine*)RVAL2BOXED(self, PANGO_TYPE_LAYOUT_LINE),
105
+ NUM2INT(x_origin),
106
+ NUM2INT(y_origin),
107
+ ranges, len), GDK_TYPE_REGION);
108
+ }
109
+
110
+ #if GTK_CHECK_VERSION(2, 12, 0)
111
+ static VALUE
112
+ gdkpango_attr_emboss_color_initialize(VALUE self, VALUE color)
113
+ {
114
+ DATA_PTR(self) = gdk_pango_attr_emboss_color_new(RVAL2GDKCOLOR(color));
115
+ return Qnil;
116
+ }
117
+
118
+ static VALUE
119
+ gdkpango_attr_emboss_color_value(VALUE self)
120
+ {
121
+ return BOXED2RVAL(&(((GdkPangoAttrEmbossColor *)RVAL2ATTR(self))->color),
122
+ PANGO_TYPE_COLOR);
123
+ }
124
+ #endif
125
+
126
+ void
127
+ Init_gtk_gdk_pango()
128
+ {
129
+ VALUE klass;
130
+ PangoAttribute* tmpattr;
131
+ GdkColor color;
132
+
133
+ VALUE mGdkPango = rb_define_module_under(mGdk, "Pango");
134
+ VALUE context = GTYPE2CLASS(PANGO_TYPE_CONTEXT);
135
+ VALUE layout = GTYPE2CLASS(PANGO_TYPE_LAYOUT);
136
+ VALUE layoutline = GTYPE2CLASS(PANGO_TYPE_LAYOUT_LINE);
137
+ VALUE pattr = ATTRTYPE2CLASS(CSTR2RVAL("Attribute"));
138
+ VALUE pattrbool = ATTRTYPE2CLASS(CSTR2RVAL("AttrBool"));
139
+ VALUE pattr_color = ATTRTYPE2CLASS(CSTR2RVAL("AttrColor"));
140
+
141
+ rb_define_module_function(mGdkPango, "context", gdkpango_s_context_get, -1);
142
+
143
+ rb_define_method(context, "set_colormap", gdkpango_context_set_colormap, 1);
144
+ G_DEF_SETTER(context, "colormap");
145
+ rb_define_method(layout, "get_clip_region", gdkpango_layout_get_clip_region, 3);
146
+ rb_define_method(layoutline, "get_clip_region", gdkpango_layout_line_get_clip_region, 3);
147
+
148
+ klass = rb_define_class_under(mGdk, "PangoAttrEmbossed", pattrbool);
149
+ rb_define_method(klass, "initialize", gdkpango_attr_embossed_initialize, 1);
150
+ tmpattr = gdk_pango_attr_embossed_new(TRUE);
151
+ rb_define_method(klass, "value", gdkpango_attr_embossed_value, 0);
152
+ RBPANGO_ADD_ATTRIBUTE(tmpattr->klass->type, klass);
153
+ pango_attribute_destroy(tmpattr);
154
+
155
+ klass = rb_define_class_under(mGdk, "PangoAttrStipple", pattr);
156
+ rb_define_method(klass, "initialize", gdkpango_attr_stipple_initialize, 1);
157
+ rb_define_method(klass, "value", gdkpango_attr_stipple_value, 0);
158
+ tmpattr = gdk_pango_attr_stipple_new(NULL);
159
+ RBPANGO_ADD_ATTRIBUTE(tmpattr->klass->type, klass);
160
+ pango_attribute_destroy(tmpattr);
161
+
162
+ #if GTK_CHECK_VERSION(2, 12, 0)
163
+ klass = rb_define_class_under(mGdk, "PangoAttrEmbossColor", pattr_color);
164
+ rb_define_method(klass, "initialize",
165
+ gdkpango_attr_emboss_color_initialize, 1);
166
+ rb_define_method(klass, "value", gdkpango_attr_emboss_color_value, 0);
167
+ tmpattr = gdk_pango_attr_emboss_color_new(&color);
168
+ RBPANGO_ADD_ATTRIBUTE(tmpattr->klass->type, klass);
169
+ pango_attribute_destroy(tmpattr);
170
+ #endif
171
+ }
@@ -0,0 +1,132 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgdkpangorenderer.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2005/02/12 16:03:46 $
8
+
9
+ Copyright (C) 2005 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "global.h"
13
+
14
+ #if GTK_CHECK_VERSION(2,6,0)
15
+
16
+ #define _SELF(s) (GDK_PANGO_RENDERER(RVAL2GOBJ(s)))
17
+
18
+ static VALUE
19
+ prenderer_initialize(argc, argv, self)
20
+ int argc;
21
+ VALUE *argv;
22
+ VALUE self;
23
+ {
24
+ VALUE screen;
25
+ GdkScreen* gscreen;
26
+
27
+ rb_scan_args(argc, argv, "01", &screen);
28
+
29
+ if (NIL_P(screen)){
30
+ gscreen = gdk_screen_get_default();
31
+ } else {
32
+ gscreen = GDK_SCREEN(RVAL2GOBJ(screen));
33
+ }
34
+
35
+ G_INITIALIZE(self, gdk_pango_renderer_new(gscreen));
36
+
37
+ return Qnil;
38
+ }
39
+
40
+ static VALUE
41
+ prenderer_s_get_default(argc, argv, self)
42
+ int argc;
43
+ VALUE *argv;
44
+ VALUE self;
45
+ {
46
+ VALUE screen;
47
+ GdkScreen* gscreen;
48
+
49
+ rb_scan_args(argc, argv, "01", &screen);
50
+
51
+ if (NIL_P(screen)){
52
+ gscreen = gdk_screen_get_default();
53
+ } else {
54
+ gscreen = GDK_SCREEN(RVAL2GOBJ(screen));
55
+ }
56
+ return GOBJ2RVAL(gdk_pango_renderer_get_default(gscreen));
57
+ }
58
+
59
+ static VALUE
60
+ prenderer_s_default(self)
61
+ VALUE self;
62
+ {
63
+ GdkScreen* gscreen = gdk_screen_get_default();
64
+ return GOBJ2RVAL(gdk_pango_renderer_get_default(gscreen));
65
+ }
66
+
67
+ static VALUE
68
+ prenderer_set_drawable(self, drawable)
69
+ VALUE self, drawable;
70
+ {
71
+ gdk_pango_renderer_set_drawable(_SELF(self),
72
+ GDK_DRAWABLE(RVAL2GOBJ(drawable)));
73
+ return self;
74
+ }
75
+
76
+ static VALUE
77
+ prenderer_set_gc(self, gc)
78
+ VALUE self, gc;
79
+ {
80
+ gdk_pango_renderer_set_gc(_SELF(self),
81
+ NIL_P(gc) ? NULL : GDK_GC(RVAL2GOBJ(gc)));
82
+ return self;
83
+ }
84
+
85
+ static VALUE
86
+ prenderer_set_stipple(self, part, stipple)
87
+ VALUE self, part, stipple;
88
+ {
89
+ #if HAVE_PANGO_RENDER_PART_GET_TYPE
90
+ gdk_pango_renderer_set_stipple(_SELF(self), RVAL2GENUM(part, PANGO_TYPE_RENDER_PART),
91
+ NIL_P(stipple) ? NULL : GDK_BITMAP(RVAL2GOBJ(stipple)));
92
+ #else
93
+ rb_warning("Gdk::PangoRender#set_tipple is not supported (Require pango-1.8.1 or later");
94
+ #endif
95
+ return self;
96
+ }
97
+
98
+ static VALUE
99
+ prenderer_set_override_color(self, part, color)
100
+ VALUE self, part, color;
101
+ {
102
+ #if HAVE_PANGO_RENDER_PART_GET_TYPE
103
+ gdk_pango_renderer_set_override_color(_SELF(self),
104
+ RVAL2GENUM(part, PANGO_TYPE_RENDER_PART),
105
+ RVAL2GDKCOLOR(color));
106
+ #else
107
+ rb_warning("Gdk::PangoRender#set_override_color is not supported (Require pango-1.8.1 or later");
108
+ #endif
109
+ return self;
110
+ }
111
+ #endif
112
+
113
+ void
114
+ Init_gtk_gdk_pangorenderer()
115
+ {
116
+ #if GTK_CHECK_VERSION(2,6,0)
117
+ VALUE renderer = G_DEF_CLASS(GDK_TYPE_PANGO_RENDERER, "PangoRenderer", mGdk);
118
+
119
+ rb_define_method(renderer, "initialize", prenderer_initialize, -1);
120
+ rb_define_method(renderer, "set_drawable", prenderer_set_drawable, 1);
121
+ rb_define_method(renderer, "set_gc", prenderer_set_gc, 1);
122
+ rb_define_method(renderer, "set_stipple", prenderer_set_stipple, 2);
123
+ rb_define_method(renderer, "set_override_color", prenderer_set_override_color, 2);
124
+
125
+ rb_define_singleton_method(renderer, "get_default", prenderer_s_get_default, -1);
126
+ rb_define_singleton_method(renderer, "default", prenderer_s_default, 0);
127
+
128
+ G_DEF_SETTERS(renderer);
129
+ #endif
130
+ }
131
+
132
+
@@ -0,0 +1,178 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgdkpixbuf.c -
5
+
6
+ $Author: ktou $
7
+ $Date: 2006/10/14 04:59:14 $
8
+
9
+ Copyright (C) 2002,2003 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "global.h"
13
+
14
+ #define _SELF(s) GDK_PIXBUF(RVAL2GOBJ(s))
15
+
16
+ static VALUE
17
+ pixbuf_render_threshold_alpha(self, bitmap, src_x, src_y, dest_x, dest_y,
18
+ width, height, alpha_threshold)
19
+ VALUE self, bitmap, src_x, src_y, dest_x, dest_y,
20
+ width, height, alpha_threshold;
21
+ {
22
+ gdk_pixbuf_render_threshold_alpha(_SELF(self), GDK_BITMAP(RVAL2GOBJ(bitmap)),
23
+ NUM2INT(src_x), NUM2INT(src_y),
24
+ NUM2INT(dest_x), NUM2INT(dest_y),
25
+ NUM2INT(width), NUM2INT(height),
26
+ NUM2INT(alpha_threshold));
27
+ return self;
28
+ }
29
+
30
+ static VALUE
31
+ pixbuf_render_to_drawable(argc, argv, self)
32
+ int argc;
33
+ VALUE *argv;
34
+ VALUE self;
35
+ {
36
+ VALUE gc, src_x, src_y, dest_x, dest_y, width, height,
37
+ dither, x_dither, y_dither;
38
+
39
+ #if GTK_CHECK_VERSION(2,2,0)
40
+ rb_warn("Gdk::Pixbuf#render_to_drawable is obsolete. Use Gdk::Drawable#draw_pixbuf instead.");
41
+ #endif
42
+
43
+ rb_scan_args(argc, argv, "73", &gc, &src_x, &src_y, &dest_x, &dest_y,
44
+ &width, &height, &dither, &x_dither, &y_dither);
45
+
46
+ if (NIL_P(gc))
47
+ rb_raise(rb_eArgError, "arguments 1 must be non nil");
48
+ if (NIL_P(src_x))
49
+ rb_raise(rb_eArgError, "arguments 2 must be non nil");
50
+ if (NIL_P(src_y))
51
+ rb_raise(rb_eArgError, "arguments 3 must be non nil");
52
+ if (NIL_P(dest_x))
53
+ rb_raise(rb_eArgError, "arguments 4 must be non nil");
54
+ if (NIL_P(dest_y))
55
+ rb_raise(rb_eArgError, "arguments 5 must be non nil");
56
+ if (NIL_P(width))
57
+ rb_raise(rb_eArgError, "arguments 6 must be non nil");
58
+ if (NIL_P(height))
59
+ rb_raise(rb_eArgError, "arguments 7 must be non nil");
60
+
61
+ gdk_pixbuf_render_to_drawable(_SELF(self),
62
+ GDK_DRAWABLE(RVAL2GOBJ(self)),
63
+ GDK_GC(RVAL2GOBJ(gc)),
64
+ NUM2INT(src_x), NUM2INT(src_y),
65
+ NUM2INT(dest_x), NUM2INT(dest_y),
66
+ NUM2INT(width), NUM2INT(height),
67
+ NIL_P(dither) ? GDK_RGB_DITHER_NONE : RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER),
68
+ NIL_P(x_dither) ? 0 : NUM2INT(x_dither),
69
+ NIL_P(y_dither) ? 0 : NUM2INT(y_dither));
70
+ return self;
71
+ }
72
+
73
+ static VALUE
74
+ pixbuf_render_pixmap_and_mask(argc, argv, self)
75
+ int argc;
76
+ VALUE *argv;
77
+ VALUE self;
78
+ {
79
+ VALUE colormap_or_alpha, alpha;
80
+ GdkPixmap *pixmap;
81
+ GdkBitmap *mask;
82
+
83
+ rb_scan_args(argc, argv, "11", &colormap_or_alpha, &alpha);
84
+
85
+ if (rb_obj_is_kind_of(colormap_or_alpha, GTYPE2CLASS(GDK_TYPE_COLORMAP))){
86
+ gdk_pixbuf_render_pixmap_and_mask_for_colormap(_SELF(self),
87
+ RVAL2GOBJ(colormap_or_alpha),
88
+ &pixmap,
89
+ &mask,
90
+ NIL_P(alpha)?0:NUM2INT(alpha));
91
+ } else {
92
+ gdk_pixbuf_render_pixmap_and_mask(_SELF(self),
93
+ &pixmap,
94
+ &mask,
95
+ NIL_P(colormap_or_alpha)?
96
+ 0:NUM2INT(colormap_or_alpha));
97
+ }
98
+
99
+ return rb_ary_new3(2,
100
+ pixmap ? GOBJ2RVAL(pixmap) : Qnil,
101
+ mask ? GOBJ2RVAL(mask) : Qnil);
102
+ }
103
+
104
+ static VALUE
105
+ pixbuf_s_from_drawable(argc, argv, self)
106
+ int argc;
107
+ VALUE *argv;
108
+ VALUE self;
109
+ {
110
+ VALUE cmap, src, src_x, src_y, width, height, dest, dest_x, dest_y;
111
+ GdkPixbuf* buf;
112
+
113
+ rb_scan_args(argc, argv, "63", &cmap, &src, &src_x, &src_y, &width, &height,
114
+ &dest, &dest_x, &dest_y);
115
+
116
+ buf = gdk_pixbuf_get_from_drawable(GDK_PIXBUF(RVAL2GOBJ(dest)),
117
+ GDK_DRAWABLE(RVAL2GOBJ(src)),
118
+ GDK_COLORMAP(RVAL2GOBJ(cmap)),
119
+ NUM2INT(src_x), NUM2INT(src_y),
120
+ NIL_P(dest_x) ? 0 : NUM2INT(dest_x),
121
+ NIL_P(dest_y) ? 0 : NUM2INT(dest_y),
122
+ NUM2INT(width), NUM2INT(height));
123
+ if (NIL_P(dest)) {
124
+ if (buf) {
125
+ return GOBJ2RVALU(buf);
126
+ } else {
127
+ return Qnil;
128
+ }
129
+ } else {
130
+ return dest;
131
+ }
132
+ }
133
+
134
+ static VALUE
135
+ pixbuf_s_from_image(argc, argv, self)
136
+ int argc;
137
+ VALUE *argv;
138
+ VALUE self;
139
+ {
140
+ VALUE cmap, src, src_x, src_y, width, height, dest, dest_x, dest_y;
141
+ GdkPixbuf* buf;
142
+
143
+ rb_scan_args(argc, argv, "63", &cmap, &src, &src_x, &src_y, &width, &height,
144
+ &dest, &dest_x, &dest_y);
145
+
146
+ buf = gdk_pixbuf_get_from_image(GDK_PIXBUF(RVAL2GOBJ(dest)),
147
+ GDK_IMAGE(RVAL2GOBJ(src)),
148
+ GDK_COLORMAP(RVAL2GOBJ(cmap)),
149
+ NUM2INT(src_x), NUM2INT(src_y),
150
+ NIL_P(dest_x) ? 0 : NUM2INT(dest_x),
151
+ NIL_P(dest_y) ? 0 : NUM2INT(dest_y),
152
+ NUM2INT(width), NUM2INT(height));
153
+ if (NIL_P(dest)) {
154
+ if (buf) {
155
+ return GOBJ2RVAL(buf);
156
+ } else {
157
+ return Qnil;
158
+ }
159
+ } else {
160
+ return dest;
161
+ }
162
+ }
163
+
164
+ void
165
+ Init_gtk_gdk_pixbuf()
166
+ {
167
+ /*
168
+ * This defines Gdk::Pixbuf methods of GDK side.
169
+ */
170
+ VALUE gdkPixbuf = GTYPE2CLASS(GDK_TYPE_PIXBUF);
171
+
172
+ rb_define_method(gdkPixbuf, "render_threshold_alpha", pixbuf_render_threshold_alpha, 8);
173
+ rb_define_method(gdkPixbuf, "render_to_drawable", pixbuf_render_to_drawable, -1);
174
+ rb_define_method(gdkPixbuf, "render_pixmap_and_mask", pixbuf_render_pixmap_and_mask, -1);
175
+
176
+ rb_define_singleton_method(gdkPixbuf, "from_drawable", pixbuf_s_from_drawable, -1);
177
+ rb_define_singleton_method(gdkPixbuf, "from_image", pixbuf_s_from_image, -1);
178
+ }