gtk2 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (255) hide show
  1. data/Rakefile +66 -1
  2. data/ext/gtk2/extconf.rb +0 -96
  3. data/ext/gtk2/global.h +274 -13
  4. data/ext/gtk2/gtk2.def +5 -3
  5. data/ext/gtk2/init.c +263 -19
  6. data/ext/gtk2/rbgdk.c +245 -89
  7. data/ext/gtk2/rbgdk.h +32 -6
  8. data/ext/gtk2/rbgdkatom.c +38 -28
  9. data/ext/gtk2/rbgdkcairo.c +32 -42
  10. data/ext/gtk2/rbgdkcolor.c +52 -42
  11. data/ext/gtk2/rbgdkcolormap.c +42 -37
  12. data/ext/gtk2/rbgdkconst.c +23 -13
  13. data/ext/gtk2/rbgdkconversions.h +19 -6
  14. data/ext/gtk2/rbgdkcursor.c +37 -25
  15. data/ext/gtk2/rbgdkdevice.c +77 -67
  16. data/ext/gtk2/rbgdkdisplay.c +158 -150
  17. data/ext/gtk2/rbgdkdisplaymanager.c +27 -15
  18. data/ext/gtk2/rbgdkdragcontext.c +121 -70
  19. data/ext/gtk2/rbgdkdraw.c +252 -160
  20. data/ext/gtk2/rbgdkevent.c +30 -20
  21. data/ext/gtk2/rbgdkgc.c +123 -116
  22. data/ext/gtk2/rbgdkgeometry.c +77 -68
  23. data/ext/gtk2/rbgdkimage.c +58 -47
  24. data/ext/gtk2/rbgdkinput.c +33 -26
  25. data/ext/gtk2/rbgdkkeymap.c +38 -27
  26. data/ext/gtk2/rbgdkkeyval.c +44 -32
  27. data/ext/gtk2/rbgdkpango.c +66 -39
  28. data/ext/gtk2/rbgdkpangorenderer.c +63 -35
  29. data/ext/gtk2/rbgdkpixbuf.c +36 -25
  30. data/ext/gtk2/rbgdkpixmap.c +65 -49
  31. data/ext/gtk2/rbgdkproperty.c +66 -60
  32. data/ext/gtk2/rbgdkrectangle.c +54 -46
  33. data/ext/gtk2/rbgdkregion.c +144 -79
  34. data/ext/gtk2/rbgdkrgb.c +74 -58
  35. data/ext/gtk2/rbgdkscreen.c +103 -97
  36. data/ext/gtk2/rbgdkselection.c +49 -39
  37. data/ext/gtk2/rbgdkthreads.c +32 -19
  38. data/ext/gtk2/rbgdktimecoord.c +60 -38
  39. data/ext/gtk2/rbgdkvisual.c +79 -71
  40. data/ext/gtk2/rbgdkwindow.c +284 -305
  41. data/ext/gtk2/rbgdkwindowattr.c +69 -58
  42. data/ext/gtk2/rbgdkx11.c +41 -28
  43. data/ext/gtk2/rbgtk.c +498 -19
  44. data/ext/gtk2/rbgtk.h +35 -20
  45. data/ext/gtk2/rbgtkaboutdialog.c +33 -80
  46. data/ext/gtk2/rbgtkaccelerator.c +36 -23
  47. data/ext/gtk2/rbgtkaccelgroup.c +50 -40
  48. data/ext/gtk2/rbgtkaccelgroupentry.c +32 -20
  49. data/ext/gtk2/rbgtkaccelkey.c +40 -28
  50. data/ext/gtk2/rbgtkaccellabel.c +30 -18
  51. data/ext/gtk2/rbgtkaccelmap.c +55 -42
  52. data/ext/gtk2/rbgtkaccessible.c +25 -14
  53. data/ext/gtk2/rbgtkaction.c +68 -68
  54. data/ext/gtk2/rbgtkactiongroup.c +317 -195
  55. data/ext/gtk2/rbgtkadjustment.c +33 -46
  56. data/ext/gtk2/rbgtkalignment.c +36 -24
  57. data/ext/gtk2/rbgtkallocation.c +53 -42
  58. data/ext/gtk2/rbgtkarrow.c +34 -22
  59. data/ext/gtk2/rbgtkaspectframe.c +32 -20
  60. data/ext/gtk2/rbgtkassistant.c +81 -61
  61. data/ext/gtk2/rbgtkbbox.c +32 -20
  62. data/ext/gtk2/rbgtkbin.c +28 -16
  63. data/ext/gtk2/rbgtkbindingset.c +42 -35
  64. data/ext/gtk2/rbgtkborder.c +34 -23
  65. data/ext/gtk2/rbgtkbox.c +40 -29
  66. data/ext/gtk2/rbgtkbuildable.c +57 -45
  67. data/ext/gtk2/rbgtkbuilder.c +53 -38
  68. data/ext/gtk2/rbgtkbutton.c +41 -55
  69. data/ext/gtk2/rbgtkcalendar.c +51 -40
  70. data/ext/gtk2/rbgtkcelleditable.c +28 -17
  71. data/ext/gtk2/rbgtkcelllayout.c +41 -30
  72. data/ext/gtk2/rbgtkcellrenderer.c +43 -32
  73. data/ext/gtk2/rbgtkcellrendereraccel.c +26 -18
  74. data/ext/gtk2/rbgtkcellrenderercombo.c +25 -17
  75. data/ext/gtk2/rbgtkcellrendererpixbuf.c +24 -17
  76. data/ext/gtk2/rbgtkcellrendererprogress.c +25 -17
  77. data/ext/gtk2/rbgtkcellrendererspin.c +24 -16
  78. data/ext/gtk2/rbgtkcellrendererspinner.c +23 -11
  79. data/ext/gtk2/rbgtkcellrenderertext.c +28 -21
  80. data/ext/gtk2/rbgtkcellrenderertoggle.c +24 -16
  81. data/ext/gtk2/rbgtkcellview.c +34 -33
  82. data/ext/gtk2/rbgtkcheckbutton.c +28 -16
  83. data/ext/gtk2/rbgtkcheckmenuitem.c +31 -19
  84. data/ext/gtk2/rbgtkclipboard.c +123 -77
  85. data/ext/gtk2/rbgtkcolorbutton.c +26 -31
  86. data/ext/gtk2/rbgtkcolorsel.c +109 -55
  87. data/ext/gtk2/rbgtkcolorselectiondialog.c +28 -19
  88. data/ext/gtk2/rbgtkcombo.c +43 -32
  89. data/ext/gtk2/rbgtkcombobox.c +44 -83
  90. data/ext/gtk2/rbgtkcomboboxentry.c +26 -21
  91. data/ext/gtk2/rbgtkconst.c +23 -13
  92. data/ext/gtk2/rbgtkcontainer.c +153 -100
  93. data/ext/gtk2/rbgtkconversions.h +19 -6
  94. data/ext/gtk2/rbgtkcurve.c +46 -36
  95. data/ext/gtk2/rbgtkdialog.c +104 -70
  96. data/ext/gtk2/rbgtkdrag.c +173 -121
  97. data/ext/gtk2/rbgtkdrawingarea.c +28 -16
  98. data/ext/gtk2/rbgtkeditable.c +63 -51
  99. data/ext/gtk2/rbgtkentry.c +48 -85
  100. data/ext/gtk2/rbgtkentrycompletion.c +42 -55
  101. data/ext/gtk2/rbgtkeventbox.c +28 -16
  102. data/ext/gtk2/rbgtkexpander.c +26 -35
  103. data/ext/gtk2/rbgtkfilechooser.c +87 -143
  104. data/ext/gtk2/rbgtkfilechooserbutton.c +26 -32
  105. data/ext/gtk2/rbgtkfilechooserdialog.c +25 -15
  106. data/ext/gtk2/rbgtkfilechooserwidget.c +26 -15
  107. data/ext/gtk2/rbgtkfilefilter.c +45 -35
  108. data/ext/gtk2/rbgtkfilesel.c +54 -43
  109. data/ext/gtk2/rbgtkfilesystemerror.c +51 -0
  110. data/ext/gtk2/rbgtkfixed.c +36 -25
  111. data/ext/gtk2/rbgtkfontbutton.c +26 -37
  112. data/ext/gtk2/rbgtkfontselection.c +27 -15
  113. data/ext/gtk2/rbgtkfontselectiondialog.c +43 -32
  114. data/ext/gtk2/rbgtkframe.c +39 -28
  115. data/ext/gtk2/rbgtkgamma.c +32 -20
  116. data/ext/gtk2/rbgtkhandlebox.c +31 -19
  117. data/ext/gtk2/rbgtkhbbox.c +28 -16
  118. data/ext/gtk2/rbgtkhbox.c +29 -17
  119. data/ext/gtk2/rbgtkhpaned.c +28 -16
  120. data/ext/gtk2/rbgtkhruler.c +28 -16
  121. data/ext/gtk2/rbgtkhscale.c +28 -16
  122. data/ext/gtk2/rbgtkhscrollbar.c +28 -16
  123. data/ext/gtk2/rbgtkhseparator.c +28 -16
  124. data/ext/gtk2/rbgtkiconfactory.c +35 -23
  125. data/ext/gtk2/rbgtkiconinfo.c +42 -30
  126. data/ext/gtk2/rbgtkiconset.c +31 -19
  127. data/ext/gtk2/rbgtkiconsize.c +38 -25
  128. data/ext/gtk2/rbgtkiconsource.c +62 -50
  129. data/ext/gtk2/rbgtkicontheme.c +95 -95
  130. data/ext/gtk2/rbgtkiconview.c +87 -121
  131. data/ext/gtk2/rbgtkimage.c +31 -40
  132. data/ext/gtk2/rbgtkimagemenuitem.c +26 -14
  133. data/ext/gtk2/rbgtkimcontext.c +46 -34
  134. data/ext/gtk2/rbgtkimcontextsimple.c +47 -24
  135. data/ext/gtk2/rbgtkimmulticontext.c +26 -14
  136. data/ext/gtk2/rbgtkinputdialog.c +28 -16
  137. data/ext/gtk2/rbgtkinvisible.c +24 -18
  138. data/ext/gtk2/rbgtkitem.c +32 -20
  139. data/ext/gtk2/rbgtkitemfactory.c +65 -57
  140. data/ext/gtk2/rbgtklabel.c +46 -57
  141. data/ext/gtk2/rbgtklayout.c +40 -29
  142. data/ext/gtk2/rbgtklinkbutton.c +26 -15
  143. data/ext/gtk2/rbgtkliststore.c +145 -102
  144. data/ext/gtk2/rbgtkmacros.h +19 -6
  145. data/ext/gtk2/rbgtkmenu.c +47 -59
  146. data/ext/gtk2/rbgtkmenubar.c +30 -30
  147. data/ext/gtk2/rbgtkmenuitem.c +34 -41
  148. data/ext/gtk2/rbgtkmenushell.c +43 -42
  149. data/ext/gtk2/rbgtkmenutoolbutton.c +27 -16
  150. data/ext/gtk2/rbgtkmessagedialog.c +31 -25
  151. data/ext/gtk2/rbgtkmisc.c +33 -22
  152. data/ext/gtk2/rbgtknotebook.c +98 -134
  153. data/ext/gtk2/rbgtkobject.c +46 -81
  154. data/ext/gtk2/rbgtkoptionmenu.c +35 -23
  155. data/ext/gtk2/rbgtkpagesetup.c +64 -54
  156. data/ext/gtk2/rbgtkpagesetupunixdialog.c +34 -27
  157. data/ext/gtk2/rbgtkpaned.c +46 -36
  158. data/ext/gtk2/rbgtkpapersize.c +60 -54
  159. data/ext/gtk2/rbgtkplug.c +32 -20
  160. data/ext/gtk2/rbgtkprintcontext.c +43 -35
  161. data/ext/gtk2/rbgtkprinter.c +36 -37
  162. data/ext/gtk2/rbgtkprintjob.c +36 -37
  163. data/ext/gtk2/rbgtkprintoperation.c +44 -33
  164. data/ext/gtk2/rbgtkprintoperationpreview.c +30 -18
  165. data/ext/gtk2/rbgtkprintsettings.c +248 -192
  166. data/ext/gtk2/rbgtkprintunixdialog.c +33 -45
  167. data/ext/gtk2/rbgtkprogress.c +23 -13
  168. data/ext/gtk2/rbgtkprogressbar.c +47 -46
  169. data/ext/gtk2/rbgtkradioaction.c +84 -39
  170. data/ext/gtk2/rbgtkradiobutton.c +33 -21
  171. data/ext/gtk2/rbgtkradiomenuitem.c +86 -45
  172. data/ext/gtk2/rbgtkradiotoolbutton.c +99 -53
  173. data/ext/gtk2/rbgtkrange.c +36 -56
  174. data/ext/gtk2/rbgtkrc.c +61 -49
  175. data/ext/gtk2/rbgtkrcstyle.c +59 -48
  176. data/ext/gtk2/rbgtkrecentaction.c +28 -16
  177. data/ext/gtk2/rbgtkrecentchooser.c +58 -92
  178. data/ext/gtk2/rbgtkrecentchooserdialog.c +29 -18
  179. data/ext/gtk2/rbgtkrecentchoosermenu.c +25 -21
  180. data/ext/gtk2/rbgtkrecentchooserwidget.c +24 -13
  181. data/ext/gtk2/rbgtkrecentdata.c +47 -36
  182. data/ext/gtk2/rbgtkrecentfilter.c +55 -46
  183. data/ext/gtk2/rbgtkrecentfilterinfo.c +51 -40
  184. data/ext/gtk2/rbgtkrecentinfo.c +66 -56
  185. data/ext/gtk2/rbgtkrecentmanager.c +47 -43
  186. data/ext/gtk2/rbgtkruler.c +35 -30
  187. data/ext/gtk2/rbgtkscale.c +29 -18
  188. data/ext/gtk2/rbgtkscalebutton.c +27 -27
  189. data/ext/gtk2/rbgtkscrollbar.c +23 -13
  190. data/ext/gtk2/rbgtkscrolledwindow.c +44 -60
  191. data/ext/gtk2/rbgtkselection.c +87 -67
  192. data/ext/gtk2/rbgtkselectiondata.c +74 -65
  193. data/ext/gtk2/rbgtkseparator.c +23 -13
  194. data/ext/gtk2/rbgtkseparatormenuitem.c +25 -13
  195. data/ext/gtk2/rbgtkseparatortoolitem.c +26 -21
  196. data/ext/gtk2/rbgtksettings.c +123 -103
  197. data/ext/gtk2/rbgtksizegroup.c +33 -30
  198. data/ext/gtk2/rbgtksocket.c +32 -20
  199. data/ext/gtk2/rbgtkspinbutton.c +48 -38
  200. data/ext/gtk2/rbgtkspinner.c +27 -14
  201. data/ext/gtk2/rbgtkstatusbar.c +36 -31
  202. data/ext/gtk2/rbgtkstatusicon.c +31 -44
  203. data/ext/gtk2/rbgtkstock.c +137 -125
  204. data/ext/gtk2/rbgtkstyle.c +177 -161
  205. data/ext/gtk2/rbgtktable.c +58 -47
  206. data/ext/gtk2/rbgtktargetlist.c +56 -36
  207. data/ext/gtk2/rbgtktearoffmenuitem.c +28 -16
  208. data/ext/gtk2/rbgtktextappearance.c +44 -34
  209. data/ext/gtk2/rbgtktextattributes.c +54 -42
  210. data/ext/gtk2/rbgtktextbuffer.c +188 -191
  211. data/ext/gtk2/rbgtktextchild.c +29 -18
  212. data/ext/gtk2/rbgtktextiter.c +153 -145
  213. data/ext/gtk2/rbgtktextmark.c +33 -30
  214. data/ext/gtk2/rbgtktexttag.c +34 -22
  215. data/ext/gtk2/rbgtktexttagtable.c +36 -25
  216. data/ext/gtk2/rbgtktextview.c +85 -73
  217. data/ext/gtk2/rbgtktoggleaction.c +27 -22
  218. data/ext/gtk2/rbgtktogglebutton.c +37 -26
  219. data/ext/gtk2/rbgtktoggletoolbutton.c +26 -20
  220. data/ext/gtk2/rbgtktoolbar.c +66 -69
  221. data/ext/gtk2/rbgtktoolbutton.c +27 -40
  222. data/ext/gtk2/rbgtktoolitem.c +60 -62
  223. data/ext/gtk2/rbgtktooltip.c +36 -25
  224. data/ext/gtk2/rbgtktooltips.c +42 -34
  225. data/ext/gtk2/rbgtktreedragdest.c +20 -11
  226. data/ext/gtk2/rbgtktreedragsource.c +20 -11
  227. data/ext/gtk2/rbgtktreeiter.c +58 -47
  228. data/ext/gtk2/rbgtktreemodel.c +83 -65
  229. data/ext/gtk2/rbgtktreemodelfilter.c +47 -35
  230. data/ext/gtk2/rbgtktreemodelsort.c +38 -27
  231. data/ext/gtk2/rbgtktreepath.c +55 -44
  232. data/ext/gtk2/rbgtktreerowreference.c +60 -42
  233. data/ext/gtk2/rbgtktreeselection.c +61 -52
  234. data/ext/gtk2/rbgtktreesortable.c +52 -42
  235. data/ext/gtk2/rbgtktreestore.c +88 -67
  236. data/ext/gtk2/rbgtktreeview.c +157 -185
  237. data/ext/gtk2/rbgtktreeviewcolumn.c +57 -62
  238. data/ext/gtk2/rbgtkuimanager.c +61 -61
  239. data/ext/gtk2/rbgtkvbbox.c +28 -16
  240. data/ext/gtk2/rbgtkvbox.c +29 -17
  241. data/ext/gtk2/rbgtkviewport.c +28 -16
  242. data/ext/gtk2/rbgtkvolumebutton.c +28 -16
  243. data/ext/gtk2/rbgtkvpaned.c +28 -16
  244. data/ext/gtk2/rbgtkvruler.c +28 -16
  245. data/ext/gtk2/rbgtkvscale.c +28 -16
  246. data/ext/gtk2/rbgtkvscrollbar.c +28 -16
  247. data/ext/gtk2/rbgtkvseparator.c +28 -16
  248. data/ext/gtk2/rbgtkwidget.c +284 -296
  249. data/ext/gtk2/rbgtkwindow.c +156 -214
  250. data/ext/gtk2/rbgtkwindowgroup.c +35 -24
  251. data/sample/testgtk/labels.rb +1 -0
  252. data/sample/testgtk/testgtk.rb +2 -0
  253. metadata +16 -17
  254. data/ChangeLog +0 -6902
  255. data/ext/gtk2/rbgtkmain.c +0 -493
@@ -1,18 +1,30 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002,2003 Masao Mutoh
5
+ * Copyright (C) 1998-2000 Yukihiro Matsumoto,
6
+ * Daisuke Kanda,
7
+ * Hiroshi Igarashi
8
+ *
9
+ * This library is free software; you can redistribute it and/or
10
+ * modify it under the terms of the GNU Lesser General Public
11
+ * License as published by the Free Software Foundation; either
12
+ * version 2.1 of the License, or (at your option) any later version.
13
+ *
14
+ * This library is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ * Lesser General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU Lesser General Public
20
+ * License along with this library; if not, write to the Free Software
21
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22
+ * MA 02110-1301 USA
23
+ */
3
24
 
4
- rbgdkregion.c -
5
-
6
- $Author: ggc $
7
- $Date: 2007/07/13 16:07:31 $
8
-
9
- Copyright (C) 2002,2003 Masao Mutoh
10
- Copyright (C) 1998-2000 Yukihiro Matsumoto,
11
- Daisuke Kanda,
12
- Hiroshi Igarashi
13
- ************************************************/
14
25
  #include "global.h"
15
26
 
27
+ #define RG_TARGET_NAMESPACE cRegion
16
28
  #define _SELF(r) ((GdkRegion*)RVAL2BOXED(r, GDK_TYPE_REGION))
17
29
 
18
30
  /**********************************/
@@ -29,30 +41,23 @@ gdk_region_get_type(void)
29
41
  }
30
42
  /**********************************/
31
43
  static VALUE
32
- gdkregion_initialize(int argc, VALUE *argv, VALUE self)
44
+ rg_initialize(int argc, VALUE *argv, VALUE self)
33
45
  {
34
- VALUE points_or_rectangle, fill_rule;
35
- GdkRegion* region;
36
- GdkPoint *gpoints;
37
- int i;
46
+ VALUE points_or_rectangle, rbfill_rule;
47
+ GdkRegion *region;
38
48
 
39
- rb_scan_args(argc, argv, "02", &points_or_rectangle, &fill_rule);
40
- if (NIL_P(points_or_rectangle)){
49
+ rb_scan_args(argc, argv, "02", &points_or_rectangle, &rbfill_rule);
50
+ if (NIL_P(points_or_rectangle)) {
41
51
  region = gdk_region_new();
42
- } else if (TYPE(points_or_rectangle) == T_ARRAY){
43
- gpoints = ALLOCA_N(GdkPoint, RARRAY_LEN(points_or_rectangle));
44
-
45
- for (i = 0; i < RARRAY_LEN(points_or_rectangle); i++) {
46
- Check_Type(RARRAY_PTR(points_or_rectangle)[i], T_ARRAY);
47
- if (RARRAY_LEN(RARRAY_PTR(points_or_rectangle)[i]) < 2) {
48
- rb_raise(rb_eArgError, "point %d should be array of size 2", i);
49
- }
50
- gpoints[i].x = NUM2INT(RARRAY_PTR(RARRAY_PTR(points_or_rectangle)[i])[0]);
51
- gpoints[i].y = NUM2INT(RARRAY_PTR(RARRAY_PTR(points_or_rectangle)[i])[1]);
52
- }
53
- region = gdk_region_polygon(gpoints, RARRAY_LEN(points_or_rectangle),
54
- RVAL2GENUM(fill_rule, GDK_TYPE_FILL_RULE));
55
- } else if (RVAL2GTYPE(points_or_rectangle) == GDK_TYPE_RECTANGLE){
52
+ } else if (TYPE(points_or_rectangle) == T_ARRAY) {
53
+ GdkFillRule fill_rule = RVAL2GENUM(rbfill_rule, GDK_TYPE_FILL_RULE);
54
+ long n;
55
+ GdkPoint *points = RVAL2GDKPOINTS(points_or_rectangle, &n);
56
+
57
+ region = gdk_region_polygon(points, n, fill_rule);
58
+
59
+ g_free(points);
60
+ } else if (RVAL2GTYPE(points_or_rectangle) == GDK_TYPE_RECTANGLE) {
56
61
  region = gdk_region_rectangle((GdkRectangle*)RVAL2BOXED(points_or_rectangle,
57
62
  GDK_TYPE_RECTANGLE));
58
63
  } else {
@@ -62,11 +67,12 @@ gdkregion_initialize(int argc, VALUE *argv, VALUE self)
62
67
  }
63
68
 
64
69
  G_INITIALIZE(self, region);
70
+
65
71
  return Qnil;
66
72
  }
67
73
 
68
74
  static VALUE
69
- gdkregion_get_rectangles(VALUE self)
75
+ rg_rectangles(VALUE self)
70
76
  {
71
77
  GdkRectangle* rectangles;
72
78
  gint n_rect, i;
@@ -88,27 +94,87 @@ gdkregion_span_func(GdkSpan *span, gpointer func)
88
94
  INT2NUM(span->x), INT2NUM(span->y), INT2NUM(span->width));
89
95
  }
90
96
 
97
+ struct rbgdk_rval2gdkspans_args {
98
+ VALUE ary;
99
+ long n;
100
+ GdkSpan *result;
101
+ };
102
+
91
103
  static VALUE
92
- gdkregion_spans_intersect_foreach(VALUE self, VALUE spans, VALUE sorted)
104
+ rbgdk_rval2gdkspans_body(VALUE value)
93
105
  {
94
- int i;
95
- GdkSpan* gspans = ALLOCA_N(GdkSpan, RARRAY_LEN(spans));
96
- volatile VALUE func = rb_block_proc();
106
+ long i;
107
+ struct rbgdk_rval2gdkspans_args *args = (struct rbgdk_rval2gdkspans_args *)value;
97
108
 
98
- G_RELATIVE(self, func);
99
- for (i = 0; i < RARRAY_LEN(spans); i++) {
100
- gspans[i].x = NUM2INT(RARRAY_PTR(RARRAY_PTR(spans)[i])[0]);
101
- gspans[i].y = NUM2INT(RARRAY_PTR(RARRAY_PTR(spans)[i])[1]);
102
- gspans[i].width = NUM2INT(RARRAY_PTR(RARRAY_PTR(spans)[i])[2]);
109
+ for (i = 0; i < args->n; i++) {
110
+ VALUE points = rb_ary_to_ary(RARRAY_PTR(args->ary)[i]);
111
+
112
+ if (RARRAY_LEN(points) != 2)
113
+ rb_raise(rb_eArgError, "point %ld should be array of size 3", i);
114
+
115
+ args->result[i].x = NUM2INT(RARRAY_PTR(points)[0]);
116
+ args->result[i].y = NUM2INT(RARRAY_PTR(points)[1]);
117
+ args->result[i].width = NUM2INT(RARRAY_PTR(points)[1]);
103
118
  }
104
- gdk_region_spans_intersect_foreach(_SELF(self),
105
- gspans, RARRAY_LEN(spans), RVAL2CBOOL(sorted),
106
- (GdkSpanFunc)gdkregion_span_func, (gpointer)func);
119
+
120
+ return Qnil;
121
+ }
122
+
123
+ static G_GNUC_NORETURN VALUE
124
+ rbgdk_rval2gdkspans_rescue(VALUE value)
125
+ {
126
+ g_free(((struct rbgdk_rval2gdkspans_args *)value)->result);
127
+
128
+ rb_exc_raise(rb_errinfo());
129
+ }
130
+
131
+ static GdkSpan *
132
+ rbgdk_rval2gdkspans(VALUE value, long *n)
133
+ {
134
+ struct rbgdk_rval2gdkspans_args args;
135
+
136
+ args.ary = rb_ary_to_ary(value);
137
+ args.n = RARRAY_LEN(args.ary);
138
+ args.result = g_new(GdkSpan, args.n + 1);
139
+
140
+ rb_rescue(rbgdk_rval2gdkspans_body, (VALUE)&args,
141
+ rbgdk_rval2gdkspans_rescue, (VALUE)&args);
142
+
143
+ if (n != NULL)
144
+ *n = args.n;
145
+
146
+ return args.result;
147
+ }
148
+
149
+ #define RVAL2GDKSPANS(value, n) rbgdk_rval2gdkspans(value, n)
150
+
151
+ static VALUE
152
+ rg_spans_intersect_each(VALUE self, VALUE rbspans, VALUE rbsorted)
153
+ {
154
+ GdkRegion *region = _SELF(self);
155
+ gboolean sorted = RVAL2CBOOL(rbsorted);
156
+ VALUE func = rb_block_proc();
157
+ long n;
158
+ GdkSpan *spans;
159
+
160
+ G_RELATIVE(self, func);
161
+
162
+ spans = RVAL2GDKSPANS(rbspans, &n);
163
+
164
+ gdk_region_spans_intersect_foreach(region,
165
+ spans,
166
+ n,
167
+ sorted,
168
+ (GdkSpanFunc)gdkregion_span_func,
169
+ (gpointer)func);
170
+
171
+ g_free(spans);
172
+
107
173
  return self;
108
174
  }
109
175
 
110
176
  static VALUE
111
- gdkregion_get_clipbox(VALUE self)
177
+ rg_clipbox(VALUE self)
112
178
  {
113
179
  GdkRectangle rect;
114
180
  gdk_region_get_clipbox(_SELF(self), &rect);
@@ -116,13 +182,13 @@ gdkregion_get_clipbox(VALUE self)
116
182
  }
117
183
 
118
184
  static VALUE
119
- gdkregion_empty(VALUE self)
185
+ rg_empty_p(VALUE self)
120
186
  {
121
187
  return CBOOL2RVAL(gdk_region_empty(_SELF(self)));
122
188
  }
123
189
 
124
190
  static VALUE
125
- gdkregion_equal(VALUE self, VALUE obj)
191
+ rg_operator_equal(VALUE self, VALUE obj)
126
192
  {
127
193
  if (!rb_obj_is_instance_of(obj, GTYPE2CLASS(GDK_TYPE_REGION))) {
128
194
  return Qnil;
@@ -131,14 +197,14 @@ gdkregion_equal(VALUE self, VALUE obj)
131
197
  }
132
198
 
133
199
  static VALUE
134
- gdkregion_point_in(VALUE self, VALUE x, VALUE y)
200
+ rg_point_in_p(VALUE self, VALUE x, VALUE y)
135
201
  {
136
202
  return CBOOL2RVAL(gdk_region_point_in(_SELF(self), NUM2INT(x),
137
203
  NUM2INT(y)));
138
204
  }
139
205
 
140
206
  static VALUE
141
- gdkregion_rect_in(VALUE self, VALUE rect)
207
+ rg_rect_in(VALUE self, VALUE rect)
142
208
  {
143
209
  return GENUM2RVAL(gdk_region_rect_in(
144
210
  _SELF(self),
@@ -147,28 +213,28 @@ gdkregion_rect_in(VALUE self, VALUE rect)
147
213
  }
148
214
 
149
215
  static VALUE
150
- gdkregion_offset(VALUE self, VALUE dx, VALUE dy)
216
+ rg_offset(VALUE self, VALUE dx, VALUE dy)
151
217
  {
152
218
  gdk_region_offset(_SELF(self), NUM2INT(dx), NUM2INT(dy));
153
219
  return self;
154
220
  }
155
221
 
156
222
  static VALUE
157
- gdkregion_shrink(VALUE self, VALUE dx, VALUE dy)
223
+ rg_shrink(VALUE self, VALUE dx, VALUE dy)
158
224
  {
159
225
  gdk_region_shrink(_SELF(self), NUM2INT(dx), NUM2INT(dy));
160
226
  return self;
161
227
  }
162
228
 
163
229
  static VALUE
164
- gdkregion_intersect(VALUE self, VALUE region)
230
+ rg_intersect(VALUE self, VALUE region)
165
231
  {
166
232
  gdk_region_intersect(_SELF(self), _SELF(region));
167
233
  return self;
168
234
  }
169
235
 
170
236
  static VALUE
171
- gdkregion_union(VALUE self, VALUE other)
237
+ rg_union(VALUE self, VALUE other)
172
238
  {
173
239
  if (RVAL2GTYPE(other) == GDK_TYPE_RECTANGLE){
174
240
  gdk_region_union_with_rect(_SELF(self),
@@ -180,45 +246,44 @@ gdkregion_union(VALUE self, VALUE other)
180
246
  }
181
247
 
182
248
  static VALUE
183
- gdkregion_subtract(VALUE self, VALUE region)
249
+ rg_subtract(VALUE self, VALUE region)
184
250
  {
185
251
  gdk_region_subtract(_SELF(self), _SELF(region));
186
252
  return self;
187
253
  }
188
254
 
189
255
  static VALUE
190
- gdkregion_xor(VALUE self, VALUE region)
256
+ rg_xor(VALUE self, VALUE region)
191
257
  {
192
258
  gdk_region_xor(_SELF(self), _SELF(region));
193
259
  return self;
194
260
  }
195
261
 
196
-
197
262
  void
198
- Init_gtk_gdk_region()
199
- {
200
- VALUE gdkRegion = G_DEF_CLASS(GDK_TYPE_REGION, "Region", mGdk);
201
-
202
- rb_define_method(gdkRegion, "initialize", gdkregion_initialize, -1);
203
- rb_define_method(gdkRegion, "rectangles", gdkregion_get_rectangles, 0);
204
- rb_define_method(gdkRegion, "spans_intersect_each", gdkregion_spans_intersect_foreach, 2);
205
- rb_define_method(gdkRegion, "clipbox", gdkregion_get_clipbox, 0);
206
- rb_define_method(gdkRegion, "empty?", gdkregion_empty, 0);
207
- rb_define_method(gdkRegion, "==", gdkregion_equal, 1);
208
- rb_define_method(gdkRegion, "point_in?", gdkregion_point_in, 2);
209
- rb_define_method(gdkRegion, "rect_in", gdkregion_rect_in, 1);
210
- rb_define_method(gdkRegion, "offset", gdkregion_offset, 2);
211
- rb_define_method(gdkRegion, "shrink", gdkregion_shrink, 2);
212
- rb_define_method(gdkRegion, "intersect", gdkregion_intersect, 1);
213
- rb_define_method(gdkRegion, "union", gdkregion_union, 1);
214
- rb_define_method(gdkRegion, "subtract", gdkregion_subtract, 1);
215
- rb_define_method(gdkRegion, "xor", gdkregion_xor, 1);
263
+ Init_gtk_gdk_region(VALUE mGdk)
264
+ {
265
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_REGION, "Region", mGdk);
266
+
267
+ RG_DEF_METHOD(initialize, -1);
268
+ RG_DEF_METHOD(rectangles, 0);
269
+ RG_DEF_METHOD(spans_intersect_each, 2);
270
+ RG_DEF_METHOD(clipbox, 0);
271
+ RG_DEF_METHOD_P(empty, 0);
272
+ RG_DEF_METHOD_OPERATOR("==", equal, 1);
273
+ RG_DEF_METHOD_P(point_in, 2);
274
+ RG_DEF_METHOD(rect_in, 1);
275
+ RG_DEF_METHOD(offset, 2);
276
+ RG_DEF_METHOD(shrink, 2);
277
+ RG_DEF_METHOD(intersect, 1);
278
+ RG_DEF_METHOD(union, 1);
279
+ RG_DEF_METHOD(subtract, 1);
280
+ RG_DEF_METHOD(xor, 1);
216
281
 
217
282
  /* GdkOverlapType */
218
- G_DEF_CLASS(GDK_TYPE_OVERLAP_TYPE, "OverlapType", gdkRegion);
219
- G_DEF_CONSTANTS(gdkRegion, GDK_TYPE_OVERLAP_TYPE, "GDK_");
283
+ G_DEF_CLASS(GDK_TYPE_OVERLAP_TYPE, "OverlapType", RG_TARGET_NAMESPACE);
284
+ G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_OVERLAP_TYPE, "GDK_");
220
285
 
221
286
  /* GdkFillRule */
222
- G_DEF_CLASS(GDK_TYPE_FILL_RULE, "FillRule", gdkRegion);
223
- G_DEF_CONSTANTS(gdkRegion, GDK_TYPE_FILL_RULE, "GDK_");
287
+ G_DEF_CLASS(GDK_TYPE_FILL_RULE, "FillRule", RG_TARGET_NAMESPACE);
288
+ G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_FILL_RULE, "GDK_");
224
289
  }
@@ -1,24 +1,34 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
3
-
4
- rbgdkrgb.c -
5
-
6
- $Author: ggc $
7
- $Date: 2007/07/13 16:07:31 $
8
-
9
- Copyright (C) 2002,2003 Ruby-GNOME2 Project Team
10
- Copyright (C) 1998-2000 Yukihiro Matsumoto,
11
- Daisuke Kanda,
12
- Hiroshi Igarashi
13
- ************************************************/
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002,2003 Ruby-GNOME2 Project Team
5
+ * Copyright (C) 1998-2000 Yukihiro Matsumoto,
6
+ * Daisuke Kanda,
7
+ * Hiroshi Igarashi
8
+ *
9
+ * This library is free software; you can redistribute it and/or
10
+ * modify it under the terms of the GNU Lesser General Public
11
+ * License as published by the Free Software Foundation; either
12
+ * version 2.1 of the License, or (at your option) any later version.
13
+ *
14
+ * This library is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ * Lesser General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU Lesser General Public
20
+ * License along with this library; if not, write to the Free Software
21
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22
+ * MA 02110-1301 USA
23
+ */
14
24
 
15
25
  #include "global.h"
16
26
 
27
+ #define RG_TARGET_NAMESPACE mRGB
17
28
  #define RVAL2DRAW(s) GDK_DRAWABLE(RVAL2GOBJ(s))
18
29
 
19
-
20
30
  static VALUE
21
- rgb_draw_rgb_image(int argc, VALUE *argv, VALUE self)
31
+ rg_m_draw_rgb_image(int argc, VALUE *argv, VALUE self)
22
32
  {
23
33
  VALUE win, gc, x, y, w, h, dither, buf, rowstride, xdith, ydith;
24
34
 
@@ -46,36 +56,42 @@ rgb_draw_rgb_image(int argc, VALUE *argv, VALUE self)
46
56
  }
47
57
 
48
58
  static VALUE
49
- rgb_draw_indexed_image(VALUE self, VALUE win, VALUE gc, VALUE x, VALUE y, VALUE w, VALUE h, VALUE dither, VALUE buf, VALUE rowstride, VALUE colors)
59
+ rg_m_draw_indexed_image(VALUE self, VALUE win, VALUE rbgc, VALUE rbx, VALUE rby,
60
+ VALUE rbwidth, VALUE rbheight, VALUE rbdither,
61
+ VALUE rbbuf, VALUE rbrowstride, VALUE rbcolors)
50
62
  {
51
- GdkRgbCmap* cmap;
52
- guint32* gcolors;
53
- gint i, n_colors;
63
+ GdkDrawable *drawable = RVAL2DRAW(win);
64
+ GdkGC *gc = GDK_GC(RVAL2GOBJ(rbgc));
65
+ gint x = NUM2INT(rbx);
66
+ gint y = NUM2INT(rby);
67
+ gint width = NUM2INT(rbwidth);
68
+ gint height = NUM2INT(rbheight);
69
+ GdkRgbDither dither = RVAL2GENUM(rbdither, GDK_TYPE_RGB_DITHER);
70
+ const guchar *buf = (const guchar *)RVAL2CSTR(rbbuf);
71
+ gint rowstride = NUM2INT(rbrowstride);
72
+ long n;
73
+ guint32 *colors = RVAL2GUINT32S(rbcolors, n);
74
+ GdkRgbCmap *cmap;
75
+
76
+ if (n < 0 || n > 255) {
77
+ g_free(colors);
54
78
 
55
- n_colors = RARRAY_LEN(colors);
56
-
57
- if (n_colors > 255)
58
79
  rb_raise(rb_eArgError, "colors: out of range (0 - 255)");
59
-
60
- gcolors = g_new(guint32, n_colors);
61
- for (i = 0; i < n_colors; i++) {
62
- gcolors[i] = NUM2UINT(RARRAY_PTR(colors)[i]);
63
80
  }
64
81
 
65
- cmap = gdk_rgb_cmap_new(gcolors, n_colors);
66
-
67
- gdk_draw_indexed_image(RVAL2DRAW(win), GDK_GC(RVAL2GOBJ(gc)),
68
- NUM2INT(x), NUM2INT(y),
69
- NUM2INT(w), NUM2INT(h),
70
- RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER),
71
- (guchar*)RVAL2CSTR(buf),
72
- NUM2INT(rowstride), cmap);
82
+ cmap = gdk_rgb_cmap_new(colors, n);
83
+
84
+ g_free(colors);
85
+
86
+ gdk_draw_indexed_image(drawable, gc, x, y, width, height, dither, buf, rowstride, cmap);
87
+
73
88
  gdk_rgb_cmap_free(cmap);
89
+
74
90
  return self;
75
91
  }
76
92
 
77
93
  static VALUE
78
- rgb_draw_gray_image(VALUE self, VALUE win, VALUE gc, VALUE x, VALUE y, VALUE w, VALUE h, VALUE dither, VALUE buf, VALUE rowstride)
94
+ rg_m_draw_gray_image(VALUE self, VALUE win, VALUE gc, VALUE x, VALUE y, VALUE w, VALUE h, VALUE dither, VALUE buf, VALUE rowstride)
79
95
  {
80
96
  gdk_draw_gray_image(RVAL2DRAW(win), GDK_GC(RVAL2GOBJ(gc)),
81
97
  NUM2INT(x), NUM2INT(y),
@@ -87,7 +103,7 @@ rgb_draw_gray_image(VALUE self, VALUE win, VALUE gc, VALUE x, VALUE y, VALUE w,
87
103
  }
88
104
 
89
105
  static VALUE
90
- rgb_draw_rgb_32_image(int argc, VALUE *argv, VALUE self)
106
+ rg_m_draw_rgb_32_image(int argc, VALUE *argv, VALUE self)
91
107
  {
92
108
  VALUE win, gc, x, y, w, h, dither, buf, rowstride, xdith, ydith;
93
109
 
@@ -113,7 +129,7 @@ rgb_draw_rgb_32_image(int argc, VALUE *argv, VALUE self)
113
129
  }
114
130
 
115
131
  static VALUE
116
- rgb_find_color(VALUE self, VALUE colormap, VALUE color)
132
+ rg_m_find_color(VALUE self, VALUE colormap, VALUE color)
117
133
  {
118
134
  gdk_rgb_find_color(GDK_COLORMAP(RVAL2GOBJ(colormap)),
119
135
  RVAL2GDKCOLOR(color));
@@ -121,62 +137,62 @@ rgb_find_color(VALUE self, VALUE colormap, VALUE color)
121
137
  }
122
138
 
123
139
  static VALUE
124
- rgb_set_install(VALUE self, VALUE install)
140
+ rg_m_set_install(VALUE self, VALUE install)
125
141
  {
126
142
  gdk_rgb_set_install(RVAL2CBOOL(install));
127
143
  return self;
128
144
  }
129
145
 
130
146
  static VALUE
131
- rgb_set_min_colors(VALUE self, VALUE min_colors)
147
+ rg_m_set_min_colors(VALUE self, VALUE min_colors)
132
148
  {
133
149
  gdk_rgb_set_min_colors(NUM2INT(min_colors));
134
150
  return self;
135
151
  }
136
152
 
137
153
  static VALUE
138
- rgb_get_visual(VALUE self)
154
+ rg_m_visual(G_GNUC_UNUSED VALUE self)
139
155
  {
140
156
  return GOBJ2RVAL(gdk_rgb_get_visual());
141
157
  }
142
158
 
143
159
  static VALUE
144
- rgb_get_cmap(VALUE self)
160
+ rg_m_colormap(G_GNUC_UNUSED VALUE self)
145
161
  {
146
162
  return GOBJ2RVAL(gdk_rgb_get_colormap());
147
163
  }
148
164
 
149
165
  static VALUE
150
- rgb_ditherable(VALUE self)
166
+ rg_m_ditherable_p(G_GNUC_UNUSED VALUE self)
151
167
  {
152
168
  return CBOOL2RVAL(gdk_rgb_ditherable());
153
169
  }
154
170
 
155
171
  static VALUE
156
- rgb_set_verbose(VALUE self, VALUE verbose)
172
+ rg_m_set_verbose(VALUE self, VALUE verbose)
157
173
  {
158
174
  gdk_rgb_set_verbose(RVAL2CBOOL(verbose));
159
175
  return self;
160
176
  }
161
177
 
162
178
  void
163
- Init_gtk_gdk_rgb()
179
+ Init_gtk_gdk_rgb(VALUE mGdk)
164
180
  {
165
- VALUE mGdkRgb = rb_define_module_under(mGdk, "RGB");
166
-
167
- rb_define_module_function(mGdkRgb, "draw_rgb_image", rgb_draw_rgb_image, -1);
168
- rb_define_module_function(mGdkRgb, "draw_indexed_image", rgb_draw_indexed_image, 10);
169
- rb_define_module_function(mGdkRgb, "draw_gray_image", rgb_draw_gray_image, 9);
170
- rb_define_module_function(mGdkRgb, "draw_rgb_32_image", rgb_draw_rgb_32_image, -1);
171
- rb_define_module_function(mGdkRgb, "find_color", rgb_find_color, 2);
172
- rb_define_module_function(mGdkRgb, "set_install", rgb_set_install, 1);
173
- rb_define_module_function(mGdkRgb, "set_min_colors", rgb_set_min_colors, 0);
174
- rb_define_module_function(mGdkRgb, "visual", rgb_get_visual, 0);
175
- rb_define_module_function(mGdkRgb, "colormap", rgb_get_cmap, 0);
176
- rb_define_module_function(mGdkRgb, "ditherable?", rgb_ditherable, 0);
177
- rb_define_module_function(mGdkRgb, "set_verbose", rgb_set_verbose, 1);
181
+ VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGdk, "RGB");
182
+
183
+ RG_DEF_MODFUNC(draw_rgb_image, -1);
184
+ RG_DEF_MODFUNC(draw_indexed_image, 10);
185
+ RG_DEF_MODFUNC(draw_gray_image, 9);
186
+ RG_DEF_MODFUNC(draw_rgb_32_image, -1);
187
+ RG_DEF_MODFUNC(find_color, 2);
188
+ RG_DEF_MODFUNC(set_install, 1);
189
+ RG_DEF_MODFUNC(set_min_colors, 0);
190
+ RG_DEF_MODFUNC(visual, 0);
191
+ RG_DEF_MODFUNC(colormap, 0);
192
+ RG_DEF_MODFUNC_P(ditherable, 0);
193
+ RG_DEF_MODFUNC(set_verbose, 1);
178
194
 
179
195
  /* GdkRgbDither */
180
- G_DEF_CLASS(GDK_TYPE_RGB_DITHER, "Dither", mGdkRgb);
181
- G_DEF_CONSTANTS(mGdkRgb, GDK_TYPE_RGB_DITHER, "GDK_RGB_");
196
+ G_DEF_CLASS(GDK_TYPE_RGB_DITHER, "Dither", RG_TARGET_NAMESPACE);
197
+ G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_RGB_DITHER, "GDK_RGB_");
182
198
  }