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,24 +1,35 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
3
-
4
- rbgtklayout.c -
5
-
6
- $Author: mutoh $
7
- $Date: 2003/02/01 16:46:23 $
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 cLayout
17
28
  #define _SELF(self) (GTK_LAYOUT(RVAL2GOBJ(self)))
18
29
  #define RVAL2ADJ(a) (GTK_ADJUSTMENT(RVAL2GOBJ(a)))
19
30
 
20
31
  static VALUE
21
- layout_initialize(int argc, VALUE *argv, VALUE self)
32
+ rg_initialize(int argc, VALUE *argv, VALUE self)
22
33
  {
23
34
  VALUE hadjustment, vadjustment;
24
35
  GtkWidget* layout;
@@ -27,36 +38,36 @@ layout_initialize(int argc, VALUE *argv, VALUE self)
27
38
  layout = gtk_layout_new(
28
39
  NIL_P(hadjustment) ? 0 : RVAL2ADJ(hadjustment),
29
40
  NIL_P(vadjustment) ? 0 : RVAL2ADJ(vadjustment));
30
-
41
+
31
42
  RBGTK_INITIALIZE(self, layout);
32
43
  return Qnil;
33
44
  }
34
45
 
35
46
  static VALUE
36
- layout_put(VALUE self, VALUE widget, VALUE x, VALUE y)
47
+ rg_put(VALUE self, VALUE widget, VALUE x, VALUE y)
37
48
  {
38
49
  gtk_layout_put(_SELF(self), GTK_WIDGET(RVAL2GOBJ(widget)),
39
- NUM2INT(x), NUM2INT(y));
50
+ NUM2INT(x), NUM2INT(y));
40
51
  return self;
41
52
  }
42
53
 
43
54
  static VALUE
44
- layout_move(VALUE self, VALUE widget, VALUE x, VALUE y)
55
+ rg_move(VALUE self, VALUE widget, VALUE x, VALUE y)
45
56
  {
46
57
  gtk_layout_move(_SELF(self), GTK_WIDGET(RVAL2GOBJ(widget)),
47
- NUM2INT(x), NUM2INT(y));
58
+ NUM2INT(x), NUM2INT(y));
48
59
  return self;
49
60
  }
50
61
 
51
62
  static VALUE
52
- layout_set_size(VALUE self, VALUE width, VALUE height)
63
+ rg_set_size(VALUE self, VALUE width, VALUE height)
53
64
  {
54
65
  gtk_layout_set_size(_SELF(self), NUM2UINT(width), NUM2UINT(height));
55
66
  return self;
56
67
  }
57
68
 
58
69
  static VALUE
59
- layout_get_size(VALUE self)
70
+ rg_size(VALUE self)
60
71
  {
61
72
  guint width, height;
62
73
  gtk_layout_get_size(_SELF(self), &width, &height);
@@ -64,20 +75,20 @@ layout_get_size(VALUE self)
64
75
  }
65
76
 
66
77
  static VALUE
67
- layout_get_bin_window(VALUE self)
78
+ rg_bin_window(VALUE self)
68
79
  {
69
80
  return GOBJ2RVAL(_SELF(self)->bin_window);
70
81
  }
71
82
 
72
83
  void
73
- Init_gtk_layout()
84
+ Init_gtk_layout(VALUE mGtk)
74
85
  {
75
- VALUE gLayout = G_DEF_CLASS(GTK_TYPE_LAYOUT, "Layout", mGtk);
86
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_LAYOUT, "Layout", mGtk);
76
87
 
77
- rb_define_method(gLayout, "initialize", layout_initialize, -1);
78
- rb_define_method(gLayout, "put", layout_put, 3);
79
- rb_define_method(gLayout, "move", layout_move, 3);
80
- rb_define_method(gLayout, "set_size", layout_set_size, 2);
81
- rb_define_method(gLayout, "size", layout_get_size, 0);
82
- rb_define_method(gLayout, "bin_window", layout_get_bin_window, 0);
88
+ RG_DEF_METHOD(initialize, -1);
89
+ RG_DEF_METHOD(put, 3);
90
+ RG_DEF_METHOD(move, 3);
91
+ RG_DEF_METHOD(set_size, 2);
92
+ RG_DEF_METHOD(size, 0);
93
+ RG_DEF_METHOD(bin_window, 0);
83
94
  }
@@ -1,22 +1,33 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
3
-
4
- rbgtklinkbutton.c -
5
-
6
- $Author: sakai $
7
- $Date: 2007/07/08 03:00:49 $
8
-
9
- Copyright (C) 2006 Masao Mutoh
10
- ************************************************/
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2006 Masao Mutoh
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
11
21
 
12
22
  #include "global.h"
13
23
 
14
24
  #if GTK_CHECK_VERSION(2,10,0)
15
25
 
26
+ #define RG_TARGET_NAMESPACE cLinkButton
16
27
  #define _SELF(self) (GTK_LINK_BUTTON(RVAL2GOBJ(self)))
17
28
 
18
29
  static VALUE
19
- lb_initialize(int argc, VALUE *argv, VALUE self)
30
+ rg_initialize(int argc, VALUE *argv, VALUE self)
20
31
  {
21
32
  VALUE uri, label;
22
33
  GtkWidget *widget = NULL;
@@ -38,7 +49,7 @@ link_func(GtkLinkButton *button, const gchar *link, gpointer func)
38
49
  }
39
50
 
40
51
  static VALUE
41
- lb_set_uri_hook(VALUE self)
52
+ rg_s_set_uri_hook(VALUE self)
42
53
  {
43
54
  VALUE func = rb_block_proc();
44
55
  G_RELATIVE(self, func);
@@ -48,12 +59,12 @@ lb_set_uri_hook(VALUE self)
48
59
  #endif
49
60
 
50
61
  void
51
- Init_gtk_link_button()
62
+ Init_gtk_link_button(VALUE mGtk)
52
63
  {
53
64
  #if GTK_CHECK_VERSION(2,10,0)
54
- VALUE button = G_DEF_CLASS(GTK_TYPE_LINK_BUTTON, "LinkButton", mGtk);
65
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_LINK_BUTTON, "LinkButton", mGtk);
55
66
 
56
- rb_define_method(button, "initialize", lb_initialize, -1);
57
- rb_define_singleton_method(button, "set_uri_hook", lb_set_uri_hook, 0);
67
+ RG_DEF_METHOD(initialize, -1);
68
+ RG_DEF_SMETHOD(set_uri_hook, 0);
58
69
  #endif
59
70
  }
@@ -1,22 +1,33 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /************************************************
3
-
4
- rbgtkliststore.c -
5
-
6
- $Author: ggc $
7
- $Date: 2007/07/13 14:27:09 $
8
-
9
- Copyright (C) 2002-2005 Masao Mutoh
10
- ************************************************/
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002-2005 Masao Mutoh
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
11
21
 
12
22
  #include "global.h"
13
23
 
24
+ #define RG_TARGET_NAMESPACE cListStore
14
25
  #define _SELF(s) (GTK_LIST_STORE(RVAL2GOBJ(s)))
15
26
 
16
27
  static ID id_to_a, id_size;
17
28
 
18
29
  static VALUE
19
- lstore_initialize(int argc, VALUE *argv, VALUE self)
30
+ rg_initialize(int argc, VALUE *argv, VALUE self)
20
31
  {
21
32
  gint cnt;
22
33
  GtkListStore* store;
@@ -30,18 +41,18 @@ lstore_initialize(int argc, VALUE *argv, VALUE self)
30
41
  }
31
42
 
32
43
  store = gtk_list_store_newv(argc, buf);
33
-
44
+
34
45
  G_INITIALIZE(self, store);
35
46
 
36
47
  return Qnil;
37
48
  }
38
49
 
39
50
  static VALUE
40
- lstore_set_column_types(int argc, VALUE *argv, VALUE self)
51
+ rg_set_column_types(int argc, VALUE *argv, VALUE self)
41
52
  {
42
53
  gint cnt;
43
54
  GType* buf;
44
-
55
+
45
56
  if (argc == 0) rb_raise(rb_eArgError, "need more than 1 class type.");
46
57
  buf = ALLOCA_N(GType, argc);
47
58
  for (cnt = 0; cnt < argc; cnt++) {
@@ -54,17 +65,17 @@ lstore_set_column_types(int argc, VALUE *argv, VALUE self)
54
65
  }
55
66
 
56
67
  static VALUE
57
- lstore_set_value(VALUE self, VALUE iter, VALUE column, VALUE value)
68
+ rg_set_value(VALUE self, VALUE iter, VALUE column, VALUE value)
58
69
  {
59
70
  GType gtype = gtk_tree_model_get_column_type(GTK_TREE_MODEL(RVAL2GOBJ(self)), NUM2INT(column));
60
- GValue gval = {0,};
71
+ GValue gval = G_VALUE_INIT;
61
72
  g_value_init(&gval, gtype);
62
73
 
63
74
  rbgobj_rvalue_to_gvalue(value, &gval);
64
75
 
65
76
  G_CHILD_ADD(self, iter);
66
77
  G_CHILD_ADD(iter, value);
67
-
78
+
68
79
  gtk_list_store_set_value(_SELF(self), RVAL2GTKTREEITER(iter), NUM2INT(column), &gval);
69
80
 
70
81
  g_value_unset(&gval);
@@ -100,7 +111,7 @@ collect_value(VALUE key, VALUE value, ValuesInfo *info)
100
111
 
101
112
  static void
102
113
  hash_to_values(VALUE hash, VALUE iter, GtkTreeModel *model,
103
- gint *g_columns, GValue *g_values, gint length)
114
+ gint *g_columns, GValue *g_values, G_GNUC_UNUSED gint length)
104
115
  {
105
116
  ValuesInfo info;
106
117
 
@@ -114,12 +125,12 @@ hash_to_values(VALUE hash, VALUE iter, GtkTreeModel *model,
114
125
 
115
126
  static void
116
127
  array_to_values(VALUE array, VALUE iter, GtkTreeModel *model,
117
- gint *g_columns, GValue *g_values, gint length)
128
+ gint *g_columns, GValue *g_values, gint length)
118
129
  {
119
130
  gint i;
120
131
 
121
132
  for (i = 0; i < length; i++) {
122
- GType g_type;
133
+ GType g_type;
123
134
 
124
135
  g_columns[i] = i;
125
136
  g_type = gtk_tree_model_get_column_type(model, i);
@@ -130,7 +141,7 @@ array_to_values(VALUE array, VALUE iter, GtkTreeModel *model,
130
141
  }
131
142
 
132
143
  static VALUE
133
- lstore_set_valuesv(VALUE self, VALUE iter, VALUE values)
144
+ rg_set_values(VALUE self, VALUE iter, VALUE values)
134
145
  {
135
146
  GValue *g_values;
136
147
  GtkListStore *store;
@@ -151,17 +162,17 @@ lstore_set_valuesv(VALUE self, VALUE iter, VALUE values)
151
162
  store = _SELF(self);
152
163
  model = GTK_TREE_MODEL(store);
153
164
  if (RVAL2CBOOL(rb_obj_is_kind_of(values, rb_cHash))) {
154
- hash_to_values(values, iter, model, g_columns, g_values, length);
165
+ hash_to_values(values, iter, model, g_columns, g_values, length);
155
166
  }
156
167
  else if (RVAL2CBOOL(rb_obj_is_kind_of(values, rb_cArray))) {
157
- array_to_values(values, iter, model, g_columns, g_values, length);
168
+ array_to_values(values, iter, model, g_columns, g_values, length);
158
169
  }
159
170
  else {
160
- rb_raise(rb_eArgError, "must be array or hash of values");
171
+ rb_raise(rb_eArgError, "must be array or hash of values");
161
172
  }
162
173
 
163
174
  gtk_list_store_set_valuesv(store, RVAL2GTKTREEITER(iter),
164
- g_columns, g_values, length);
175
+ g_columns, g_values, length);
165
176
 
166
177
  for (i = 0; i < length; i++)
167
178
  g_value_unset(&g_values[i]);
@@ -179,9 +190,9 @@ lstore_set_valuesv(VALUE self, VALUE iter, VALUE values)
179
190
  GtkTreeIter *iter,
180
191
  va_list var_args);
181
192
  */
182
-
193
+
183
194
  static VALUE
184
- lstore_remove(VALUE self, VALUE iter)
195
+ rg_remove(VALUE self, VALUE iter)
185
196
  {
186
197
  G_CHILD_REMOVE(self, iter);
187
198
  #if GTK_CHECK_VERSION(2,2,0)
@@ -192,64 +203,98 @@ lstore_remove(VALUE self, VALUE iter)
192
203
  #endif
193
204
  }
194
205
 
206
+ struct lstore_insert_args {
207
+ GtkListStore *store;
208
+ GtkTreeIter iter;
209
+ gint position;
210
+ VALUE ary;
211
+ long i;
212
+ long n;
213
+ gint *columns;
214
+ GValue *values;
215
+ };
216
+
217
+ static VALUE
218
+ lstore_insert_body(VALUE value)
219
+ {
220
+ struct lstore_insert_args *args = (struct lstore_insert_args *)value;
221
+ GtkTreeModel *model = GTK_TREE_MODEL(args->store);
222
+
223
+ for (args->i = 0; args->i < args->n; args->i++) {
224
+ VALUE ary = rb_ary_to_ary(RARRAY_PTR(args->ary)[args->i]);
225
+
226
+ args->columns[args->i] = NUM2INT(RARRAY_PTR(ary)[1]);
227
+ g_value_init(&args->values[args->i],
228
+ gtk_tree_model_get_column_type(model, args->columns[args->i]));
229
+ rbgobj_rvalue_to_gvalue(RARRAY_PTR(ary)[0], &args->values[args->i]);
230
+ }
231
+
232
+ gtk_list_store_insert_with_valuesv(args->store,
233
+ &args->iter,
234
+ args->position,
235
+ args->columns,
236
+ args->values,
237
+ args->n);
238
+
239
+ return Qnil;
240
+ }
241
+
242
+ static VALUE
243
+ lstore_insert_ensure(VALUE value)
244
+ {
245
+ long i;
246
+ struct lstore_insert_args *args = (struct lstore_insert_args *)value;
247
+
248
+ for (i = 0; i < args->i; i++)
249
+ g_value_unset(&args->values[i]);
250
+
251
+ g_free(args->values);
252
+ g_free(args->columns);
253
+
254
+ return Qnil;
255
+ }
256
+
195
257
  /*
196
258
  Gtk::ListStore#insert(pos, val1 => 0, val2 => 2, ... )
197
259
  */
198
260
  static VALUE
199
- lstore_insert(int argc, VALUE *argv, VALUE self)
261
+ rg_insert(int argc, VALUE *argv, VALUE self)
200
262
  {
201
- VALUE position, values, ret;
202
- GtkTreeIter iter;
203
- GtkListStore* store = _SELF(self);
263
+ VALUE position, values, result;
264
+ struct lstore_insert_args args;
265
+ args.store = _SELF(self);
204
266
 
205
267
  rb_scan_args(argc, argv, "11", &position, &values);
268
+ args.position = NUM2INT(position);
206
269
 
207
270
  if (NIL_P(values)){
208
- gtk_list_store_insert(store, &iter, NUM2INT(position));
271
+ gtk_list_store_insert(args.store, &args.iter, args.position);
209
272
  } else {
210
273
  #if GTK_CHECK_VERSION(2,6,0)
211
- gint cnt, n_values;
212
- gint* columns;
213
- GType gtype;
214
- GValue* gvalues;
215
- VALUE ary = rb_funcall(values, id_to_a, 0);
216
-
217
- n_values = RARRAY_LEN(ary);
218
-
219
- gvalues = g_new(GValue, n_values);
220
- columns = g_new(gint, n_values);
221
-
222
- for (cnt = 0; cnt < n_values; cnt++) {
223
- Check_Type(RARRAY_PTR(ary)[cnt], T_ARRAY);
224
- columns[cnt] = NUM2INT(RARRAY_PTR(RARRAY_PTR(ary)[cnt])[1]);
225
- gtype = gtk_tree_model_get_column_type(GTK_TREE_MODEL(store), columns[cnt]);
226
- gvalues[cnt].g_type = 0;
227
- g_value_init(&gvalues[cnt], gtype);
228
- rbgobj_rvalue_to_gvalue(RARRAY_PTR(RARRAY_PTR(ary)[cnt])[0], &gvalues[cnt]);
229
- }
230
-
231
- gtk_list_store_insert_with_valuesv(store, &iter, NUM2INT(position),
232
- columns, gvalues, n_values);
233
-
234
- for (cnt = 0; cnt < n_values; cnt++) {
235
- g_value_unset(&gvalues[cnt]);
236
- }
237
- g_free(gvalues);
238
- g_free(columns);
274
+ args.ary = rb_funcall(values, id_to_a, 0);
275
+ args.n = RARRAY_LEN(args.ary);
276
+ args.columns = g_new(gint, args.n);
277
+ args.values = g_new0(GValue, args.n);
278
+
279
+ rb_ensure(lstore_insert_body, (VALUE)&args,
280
+ lstore_insert_ensure, (VALUE)&args);
239
281
  #else
240
- gtk_list_store_insert(store, &iter, NUM2INT(position));
241
- rb_warn("Ignored 2nd argument under this environment. Because it has been supported since GTK+-2.6. ");
282
+ gtk_list_store_insert(args.store, &args.iter, args.position);
283
+ rb_warn("Ignored 2nd argument under this environment, as it has been supported since GTK+-2.6.");
242
284
  #endif
243
285
  }
244
- iter.user_data3 = store;
245
286
 
246
- ret = GTKTREEITER2RVAL(&iter);
247
- G_CHILD_ADD(self, ret);
248
- return ret;
287
+ args.iter.user_data3 = args.store;
288
+
289
+ result = GTKTREEITER2RVAL(&args.iter);
290
+
291
+ G_CHILD_ADD(self, result);
292
+
293
+ return result;
249
294
  }
250
295
 
251
296
  static VALUE
252
- lstore_insert_before(VALUE self, VALUE sibling)
297
+ rg_insert_before(VALUE self, VALUE sibling)
253
298
  {
254
299
  VALUE ret;
255
300
  GtkTreeIter iter;
@@ -263,7 +308,7 @@ lstore_insert_before(VALUE self, VALUE sibling)
263
308
  }
264
309
 
265
310
  static VALUE
266
- lstore_insert_after(VALUE self, VALUE sibling)
311
+ rg_insert_after(VALUE self, VALUE sibling)
267
312
  {
268
313
  VALUE ret;
269
314
  GtkTreeIter iter;
@@ -277,7 +322,7 @@ lstore_insert_after(VALUE self, VALUE sibling)
277
322
  }
278
323
 
279
324
  static VALUE
280
- lstore_prepend(VALUE self)
325
+ rg_prepend(VALUE self)
281
326
  {
282
327
  VALUE ret;
283
328
  GtkTreeIter iter;
@@ -291,21 +336,21 @@ lstore_prepend(VALUE self)
291
336
  }
292
337
 
293
338
  static VALUE
294
- lstore_append(VALUE self)
339
+ rg_append(VALUE self)
295
340
  {
296
341
  VALUE ret;
297
342
  GtkTreeIter iter;
298
343
  GtkListStore* model = _SELF(self);
299
344
  gtk_list_store_append(model, &iter);
300
345
  iter.user_data3 = model;
301
-
346
+
302
347
  ret = GTKTREEITER2RVAL(&iter);
303
348
  G_CHILD_ADD(self, ret);
304
349
  return ret;
305
350
  }
306
351
 
307
352
  static VALUE
308
- lstore_clear(VALUE self)
353
+ rg_clear(VALUE self)
309
354
  {
310
355
  G_CHILD_REMOVE_ALL(self);
311
356
  gtk_list_store_clear(_SELF(self));
@@ -314,42 +359,40 @@ lstore_clear(VALUE self)
314
359
 
315
360
  #if GTK_CHECK_VERSION(2,2,0)
316
361
  static VALUE
317
- lstore_iter_is_valid(VALUE self, VALUE iter)
362
+ rg_iter_is_valid_p(VALUE self, VALUE iter)
318
363
  {
319
364
  return (NIL_P(iter)) ? Qfalse :
320
365
  CBOOL2RVAL(gtk_list_store_iter_is_valid(_SELF(self), RVAL2GTKTREEITER(iter)));
321
366
  }
322
367
 
323
368
  static VALUE
324
- lstore_reorder(VALUE self, VALUE new_order)
369
+ rg_reorder(VALUE self, VALUE rbnew_order)
325
370
  {
326
- gint i;
327
- gint len = RARRAY_LEN(new_order);
328
- gint* gnew_order = g_new(gint, len);
371
+ GtkListStore *store = _SELF(self);
372
+ long n;
373
+ gint *new_order = RVAL2GINTS(rbnew_order, n);
329
374
 
330
- for (i = 0; i < len; i++){
331
- gnew_order[i] = NUM2INT(RARRAY_PTR(new_order)[i]);
332
- }
375
+ gtk_list_store_reorder(store, new_order);
376
+
377
+ g_free(new_order);
333
378
 
334
- gtk_list_store_reorder(_SELF(self), gnew_order);
335
- g_free(gnew_order);
336
379
  return self;
337
380
  }
338
381
  static VALUE
339
- lstore_swap(VALUE self, VALUE iter1, VALUE iter2)
382
+ rg_swap(VALUE self, VALUE iter1, VALUE iter2)
340
383
  {
341
384
  gtk_list_store_swap(_SELF(self), RVAL2GTKTREEITER(iter1), RVAL2GTKTREEITER(iter2));
342
385
  return self;
343
386
  }
344
387
  static VALUE
345
- lstore_move_before(VALUE self, VALUE iter, VALUE position)
388
+ rg_move_before(VALUE self, VALUE iter, VALUE position)
346
389
  {
347
390
  gtk_list_store_move_before(_SELF(self), RVAL2GTKTREEITER(iter),
348
391
  NIL_P(position) ? NULL : RVAL2GTKTREEITER(position));
349
392
  return self;
350
393
  }
351
394
  static VALUE
352
- lstore_move_after(VALUE self, VALUE iter, VALUE position)
395
+ rg_move_after(VALUE self, VALUE iter, VALUE position)
353
396
  {
354
397
  gtk_list_store_move_after(_SELF(self), RVAL2GTKTREEITER(iter),
355
398
  NIL_P(position) ? NULL : RVAL2GTKTREEITER(position));
@@ -358,34 +401,34 @@ lstore_move_after(VALUE self, VALUE iter, VALUE position)
358
401
  #endif
359
402
 
360
403
  void
361
- Init_gtk_list_store()
404
+ Init_gtk_list_store(VALUE mGtk)
362
405
  {
363
- VALUE ls = G_DEF_CLASS(GTK_TYPE_LIST_STORE, "ListStore", mGtk);
406
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_LIST_STORE, "ListStore", mGtk);
364
407
 
365
408
  id_to_a = rb_intern("to_a");
366
409
  id_size = rb_intern("size");
367
410
 
368
411
  rbgtk_register_treeiter_set_value_func(GTK_TYPE_LIST_STORE,
369
412
  (rbgtkiter_set_value_func)&gtk_list_store_set_value);
370
- rb_define_method(ls, "initialize", lstore_initialize, -1);
371
- rb_define_method(ls, "set_column_types", lstore_set_column_types, -1);
372
- rb_define_method(ls, "set_value", lstore_set_value, 3);
373
- rb_define_method(ls, "remove", lstore_remove, 1);
374
- rb_define_method(ls, "insert", lstore_insert, -1);
375
- rb_define_method(ls, "insert_before", lstore_insert_before, 1);
376
- rb_define_method(ls, "insert_after", lstore_insert_after, 1);
377
- rb_define_method(ls, "prepend", lstore_prepend, 0);
378
- rb_define_method(ls, "append", lstore_append, 0);
379
- rb_define_method(ls, "clear", lstore_clear, 0);
413
+ RG_DEF_METHOD(initialize, -1);
414
+ RG_DEF_METHOD(set_column_types, -1);
415
+ RG_DEF_METHOD(set_value, 3);
416
+ RG_DEF_METHOD(remove, 1);
417
+ RG_DEF_METHOD(insert, -1);
418
+ RG_DEF_METHOD(insert_before, 1);
419
+ RG_DEF_METHOD(insert_after, 1);
420
+ RG_DEF_METHOD(prepend, 0);
421
+ RG_DEF_METHOD(append, 0);
422
+ RG_DEF_METHOD(clear, 0);
380
423
  #if GTK_CHECK_VERSION(2,2,0)
381
- rb_define_method(ls, "iter_is_valid?", lstore_iter_is_valid, 1);
382
- rb_define_method(ls, "reorder", lstore_reorder, 1);
383
- rb_define_method(ls, "swap", lstore_swap, 2);
384
- rb_define_method(ls, "move_before", lstore_move_before, 2);
385
- rb_define_method(ls, "move_after", lstore_move_after, 2);
424
+ RG_DEF_METHOD_P(iter_is_valid, 1);
425
+ RG_DEF_METHOD(reorder, 1);
426
+ RG_DEF_METHOD(swap, 2);
427
+ RG_DEF_METHOD(move_before, 2);
428
+ RG_DEF_METHOD(move_after, 2);
386
429
  #endif
387
430
  #if GTK_CHECK_VERSION(2, 12, 0)
388
- rb_define_method(ls, "set_values", lstore_set_valuesv, 2);
431
+ RG_DEF_METHOD(set_values, 2);
389
432
  #endif
390
433
 
391
434
  }