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,19 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgtktreedragsource.c -
5
+
6
+ $Author: mutoh $
7
+
8
+ $Date: 2003/07/11 19:39:08 $
9
+
10
+ Copyright (C) 2003 Masao Mutoh
11
+ ************************************************/
12
+
13
+ #include "global.h"
14
+
15
+ void
16
+ Init_gtk_treedragsource()
17
+ {
18
+ G_DEF_INTERFACE(GTK_TYPE_TREE_DRAG_SOURCE, "TreeDragSource", mGtk);
19
+ }
@@ -0,0 +1,259 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgtktreeiter.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 14:27:10 $
8
+
9
+ Copyright (C) 2002-2004 Ruby-GNOME2 Project Team
10
+ Copyright (C) 2002,2003 Masao Mutoh
11
+ ************************************************/
12
+
13
+ #include "global.h"
14
+
15
+ #define _SELF(i) ((GtkTreeIter*)RVAL2BOXED(i, GTK_TYPE_TREE_ITER))
16
+
17
+ void
18
+ rbgtk_register_treeiter_set_value_func(gtype, func)
19
+ GType gtype;
20
+ rbgtkiter_set_value_func func;
21
+ {
22
+ rb_hash_aset(treeiter_set_value_table, INT2NUM(gtype),
23
+ Data_Wrap_Struct(rb_cData, NULL, NULL, func));
24
+ }
25
+
26
+ static VALUE
27
+ treeiter_first(self)
28
+ VALUE self;
29
+ {
30
+ GtkTreeIter* iter = _SELF(self);
31
+ GtkTreeModel* model = (GtkTreeModel*)iter->user_data3;
32
+ VALUE ret = CBOOL2RVAL(gtk_tree_model_get_iter_first(model, iter));
33
+ iter->user_data3 = model;
34
+ return ret;
35
+ }
36
+
37
+ static VALUE
38
+ treeiter_next(self)
39
+ VALUE self;
40
+ {
41
+ GtkTreeIter* iter = _SELF(self);
42
+ GtkTreeModel* model = (GtkTreeModel*)iter->user_data3;
43
+ gboolean ret = gtk_tree_model_iter_next(model, iter);
44
+ if (! ret){
45
+ gtk_tree_model_get_iter_first(model, iter);
46
+ }
47
+ iter->user_data3 = model;
48
+
49
+ return CBOOL2RVAL(ret);
50
+ }
51
+
52
+ static VALUE
53
+ treeiter_get_value(self, column)
54
+ VALUE self, column;
55
+ {
56
+ GValue value = {0, };
57
+ GtkTreeIter* iter = _SELF(self);
58
+ GtkTreeModel* model = (GtkTreeModel*)iter->user_data3;
59
+ VALUE ret = Qnil;
60
+
61
+ gtk_tree_model_get_value(model, iter, NUM2INT(column), &value);
62
+ if (G_VALUE_TYPE(&value) != G_TYPE_INVALID){
63
+ ret = GVAL2RVAL(&value);
64
+ g_value_unset(&value);
65
+ }
66
+ return ret;
67
+ }
68
+
69
+ static VALUE
70
+ treeiter_children(self)
71
+ VALUE self;
72
+ {
73
+ GtkTreeIter child;
74
+ GtkTreeIter* iter = _SELF(self);
75
+ GtkTreeModel* model = (GtkTreeModel*)iter->user_data3;
76
+ gboolean ret = gtk_tree_model_iter_children(model, &child, iter);
77
+ child.user_data3 = model;
78
+ return ret ? GTKTREEITER2RVAL(&child) : Qnil;
79
+ }
80
+
81
+ static VALUE
82
+ treeiter_get_path(self)
83
+ VALUE self;
84
+ {
85
+ VALUE retval = Qnil;
86
+ GtkTreeIter* iter = _SELF(self);
87
+ GtkTreeModel* model = (GtkTreeModel*)iter->user_data3;
88
+ GtkTreePath* path = gtk_tree_model_get_path(model, iter);
89
+ retval= GTKTREEPATH2RVAL(path);
90
+ gtk_tree_path_free(path);
91
+ return retval;
92
+ }
93
+
94
+ static VALUE
95
+ treeiter_has_child(self)
96
+ VALUE self;
97
+ {
98
+ GtkTreeIter* iter = _SELF(self);
99
+ GtkTreeModel* model = (GtkTreeModel*)iter->user_data3;
100
+ return CBOOL2RVAL(gtk_tree_model_iter_has_child(model, iter));
101
+ }
102
+
103
+ static VALUE
104
+ treeiter_n_children(self)
105
+ VALUE self;
106
+ {
107
+ GtkTreeIter* iter = _SELF(self);
108
+ GtkTreeModel* model = (GtkTreeModel*)iter->user_data3;
109
+ return INT2NUM(gtk_tree_model_iter_n_children(model, iter));
110
+ }
111
+
112
+ static VALUE
113
+ treeiter_nth_child(self, n)
114
+ VALUE self, n;
115
+ {
116
+ GtkTreeIter child;
117
+ GtkTreeIter* iter = _SELF(self);
118
+ GtkTreeModel* model = (GtkTreeModel*)iter->user_data3;
119
+ gboolean ret = gtk_tree_model_iter_nth_child(model, &child, iter, NUM2INT(n));
120
+ child.user_data3 = model;
121
+ return ret ? GTKTREEITER2RVAL(&child) : Qnil;
122
+ }
123
+
124
+ static VALUE
125
+ treeiter_parent(self)
126
+ VALUE self;
127
+ {
128
+ GtkTreeIter parent;
129
+ GtkTreeIter* iter = _SELF(self);
130
+ GtkTreeModel* model = (GtkTreeModel*)iter->user_data3;
131
+ gboolean ret = gtk_tree_model_iter_parent(model, &parent, iter);
132
+ parent.user_data3 = model;
133
+ return ret ? GTKTREEITER2RVAL(&parent) : Qnil;
134
+ }
135
+
136
+ static VALUE
137
+ treeiter_set_value(self, column, value)
138
+ VALUE self, column, value;
139
+ {
140
+ GtkTreeIter* iter = _SELF(self);
141
+ GtkTreeModel* model = (GtkTreeModel*)iter->user_data3;
142
+
143
+ VALUE obj = rb_hash_aref(treeiter_set_value_table, INT2NUM(G_TYPE_FROM_INSTANCE(model)));
144
+ rbgtkiter_set_value_func func;
145
+ GType gtype = gtk_tree_model_get_column_type(model, NUM2INT(column));
146
+ GValue gval = {0,};
147
+
148
+ if (NIL_P(obj))
149
+ rb_raise(rb_eTypeError, "Gtk::TreeModel is invalid.");
150
+
151
+ Data_Get_Struct(obj, void, func);
152
+
153
+ g_value_init(&gval, gtype);
154
+ rbgobj_rvalue_to_gvalue(value, &gval);
155
+ func(model, iter, NUM2INT(column), &gval);
156
+ g_value_unset(&gval);
157
+
158
+ return self;
159
+ }
160
+
161
+ static VALUE
162
+ treeiter_set_value_eql(self, column, value)
163
+ VALUE self, column, value;
164
+ {
165
+ treeiter_set_value(self, column, value);
166
+ return value;
167
+ }
168
+
169
+ static VALUE
170
+ treeiter_eql(self, other)
171
+ VALUE self, other;
172
+ {
173
+ gint i, num1, num2;
174
+ GtkTreeIter* iter1 = _SELF(self);
175
+ GtkTreeIter* iter2;
176
+ GtkTreeModel* model1;
177
+ GtkTreeModel* model2;
178
+ GtkTreePath* path1;
179
+ GtkTreePath* path2;
180
+
181
+ if (!rb_obj_is_kind_of(other, GTYPE2CLASS(GTK_TYPE_TREE_ITER)))
182
+ return Qfalse;
183
+
184
+ iter2 = _SELF(other);
185
+
186
+ model1 = (GtkTreeModel*)iter1->user_data3;
187
+ model2 = (GtkTreeModel*)iter2->user_data3;
188
+ if (model1 != model2) return Qfalse;
189
+
190
+ num1 = gtk_tree_model_get_n_columns(model1);
191
+ num2 = gtk_tree_model_get_n_columns(model2);
192
+ if (num1 != num2) return Qfalse;
193
+
194
+ path1 = gtk_tree_model_get_path(model1, iter1);
195
+ path2 = gtk_tree_model_get_path(model2, iter2);
196
+ if (gtk_tree_path_compare(path1, path2) != 0) {
197
+ gtk_tree_path_free(path1);
198
+ gtk_tree_path_free(path2);
199
+ return Qfalse;
200
+ } else {
201
+ gtk_tree_path_free(path1);
202
+ gtk_tree_path_free(path2);
203
+ }
204
+
205
+ for (i = 0; i < num1; i++){
206
+ GValue gval1 = {0,};
207
+ GValue gval2 = {0,};
208
+ VALUE ret1, ret2;
209
+ gtk_tree_model_get_value(model1, iter1, i, &gval1);
210
+ gtk_tree_model_get_value(model2, iter2, i, &gval2);
211
+
212
+ ret1 = GVAL2RVAL(&gval1);
213
+ ret2 = GVAL2RVAL(&gval2);
214
+ g_value_unset(&gval1);
215
+ g_value_unset(&gval2);
216
+ if (rb_equal(ret1, ret2) == Qfalse)
217
+ return Qfalse;
218
+ }
219
+ return Qtrue;
220
+ }
221
+
222
+ #if GTK_CHECK_VERSION(2,2,0)
223
+ static VALUE
224
+ treeiter_to_string(self)
225
+ VALUE self;
226
+ {
227
+ GtkTreeIter* iter = _SELF(self);
228
+ GtkTreeModel* model = (GtkTreeModel*)iter->user_data3;
229
+
230
+ gchar* s = gtk_tree_model_get_string_from_iter (model, iter);
231
+ VALUE result = CSTR2RVAL(s);
232
+ g_free(s);
233
+ return result;
234
+ }
235
+ #endif
236
+
237
+ void
238
+ Init_gtk_treeiter()
239
+ {
240
+ VALUE gTreeIter = G_DEF_CLASS(GTK_TYPE_TREE_ITER, "TreeIter", mGtk);
241
+
242
+ rb_define_method(gTreeIter, "first!", treeiter_first, 0);
243
+ rb_define_method(gTreeIter, "next!", treeiter_next, 0);
244
+ rb_define_method(gTreeIter, "get_value", treeiter_get_value, 1);
245
+ rb_define_alias(gTreeIter, "[]", "get_value");
246
+ rb_define_method(gTreeIter, "first_child", treeiter_children, 0);
247
+ rb_define_method(gTreeIter, "path", treeiter_get_path, 0);
248
+ rb_define_method(gTreeIter, "has_child?", treeiter_has_child, 0);
249
+ rb_define_method(gTreeIter, "n_children", treeiter_n_children, 0);
250
+ rb_define_method(gTreeIter, "nth_child", treeiter_nth_child, 1);
251
+ rb_define_method(gTreeIter, "parent", treeiter_parent, 0);
252
+ rb_define_method(gTreeIter, "set_value", treeiter_set_value, 2);
253
+ rb_define_method(gTreeIter, "[]=", treeiter_set_value_eql, 2);
254
+ rb_define_method(gTreeIter, "==", treeiter_eql, 1);
255
+ #if GTK_CHECK_VERSION(2,2,0)
256
+ rb_define_method(gTreeIter, "to_str", treeiter_to_string, 0);
257
+ rb_define_alias(gTreeIter, "to_s", "to_str");
258
+ #endif
259
+ }
@@ -0,0 +1,256 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgtktreemodel.c -
5
+
6
+ $Author: mutoh $
7
+ $Date: 2005/11/06 04:44:24 $
8
+
9
+ Copyright (C) 2002,2003 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "global.h"
13
+
14
+ #define _SELF(s) (GTK_TREE_MODEL(RVAL2GOBJ(s)))
15
+
16
+ static VALUE
17
+ treemodel_get_flags(self)
18
+ VALUE self;
19
+ {
20
+ return GFLAGS2RVAL(gtk_tree_model_get_flags(_SELF(self)), GTK_TYPE_TREE_MODEL_FLAGS);
21
+ }
22
+
23
+ static VALUE
24
+ treemodel_get_n_columns(self)
25
+ VALUE self;
26
+ {
27
+ return INT2NUM(gtk_tree_model_get_n_columns(_SELF(self)));
28
+ }
29
+
30
+ static VALUE
31
+ treemodel_get_column_type(self, index)
32
+ VALUE self;
33
+ {
34
+ return GTYPE2CLASS(gtk_tree_model_get_column_type(_SELF(self),
35
+ NUM2INT(index)));
36
+ }
37
+
38
+ static VALUE
39
+ treemodel_get_iter_first(self)
40
+ VALUE self;
41
+ {
42
+ VALUE val = Qnil;
43
+ GtkTreeIter iter;
44
+ GtkTreeModel* model = _SELF(self);
45
+ gboolean ret = (gtk_tree_model_get_iter_first(model, &iter));
46
+ iter.user_data3 = model;
47
+
48
+ if (ret) {
49
+ val = GTKTREEITER2RVAL(&iter);
50
+ G_CHILD_ADD(self, val);
51
+ }
52
+
53
+ return val;
54
+ }
55
+
56
+ static VALUE
57
+ treemodel_get_iter(self, path)
58
+ VALUE self, path;
59
+ {
60
+ VALUE val = Qnil;
61
+ GtkTreeIter iter;
62
+ gboolean ret;
63
+ GtkTreeModel* model = _SELF(self);
64
+
65
+ if (TYPE(path) == T_STRING){
66
+ ret = gtk_tree_model_get_iter_from_string(model, &iter,
67
+ RVAL2CSTR(path));
68
+ } else {
69
+ ret = gtk_tree_model_get_iter(model, &iter,
70
+ RVAL2GTKTREEPATH(path));
71
+ }
72
+ iter.user_data3 = model;
73
+
74
+ if (ret) {
75
+ val = GTKTREEITER2RVAL(&iter);
76
+ G_CHILD_ADD(self, val);
77
+ }
78
+
79
+ return val;
80
+ }
81
+
82
+ static VALUE
83
+ treemodel_get_value(self, iter, column)
84
+ VALUE self, iter, column;
85
+ {
86
+ GValue value = {0, };
87
+ VALUE ret = Qnil;
88
+ gtk_tree_model_get_value(_SELF(self), RVAL2GTKTREEITER(iter), NUM2INT(column), &value);
89
+ if (G_VALUE_TYPE(&value) != G_TYPE_INVALID){
90
+ ret = GVAL2RVAL(&value);
91
+ g_value_unset(&value);
92
+ }
93
+ return ret;
94
+ }
95
+
96
+ /* These methods may be neededless.
97
+ void gtk_tree_model_ref_node (GtkTreeModel *tree_model,
98
+ GtkTreeIter *iter);
99
+ void gtk_tree_model_unref_node (GtkTreeModel *tree_model,
100
+ GtkTreeIter *iter);
101
+ */
102
+
103
+ /* XXXX
104
+ void gtk_tree_model_get_valist (GtkTreeModel *tree_model,
105
+ GtkTreeIter *iter,
106
+ va_list var_args);
107
+ */
108
+
109
+ static gboolean
110
+ treemodel_foreach_func(model, path, iter, func)
111
+ GtkTreeModel* model;
112
+ GtkTreePath* path;
113
+ GtkTreeIter* iter;
114
+ gpointer func;
115
+ {
116
+ iter->user_data3 = model;
117
+ rb_yield(rb_ary_new3(3, GOBJ2RVAL(model), GTKTREEPATH2RVAL(path), GTKTREEITER2RVAL(iter)));
118
+ return FALSE;
119
+ }
120
+
121
+ static VALUE
122
+ treemodel_foreach(self)
123
+ VALUE self;
124
+ {
125
+ gtk_tree_model_foreach(_SELF(self),
126
+ (GtkTreeModelForeachFunc)treemodel_foreach_func,
127
+ (gpointer)NULL);
128
+ return self;
129
+ }
130
+
131
+ static VALUE
132
+ treemodel_row_changed(self, path, iter)
133
+ VALUE self, path, iter;
134
+ {
135
+ gtk_tree_model_row_changed(_SELF(self), RVAL2GTKTREEPATH(path), RVAL2GTKTREEITER(iter));
136
+ return self;
137
+ }
138
+
139
+ static VALUE
140
+ treemodel_row_inserted(self, path, iter)
141
+ VALUE self, path, iter;
142
+ {
143
+ gtk_tree_model_row_inserted(_SELF(self), RVAL2GTKTREEPATH(path), RVAL2GTKTREEITER(iter));
144
+ return self;
145
+ }
146
+
147
+ static VALUE
148
+ treemodel_row_has_child_toggled(self, path, iter)
149
+ VALUE self, path, iter;
150
+ {
151
+ gtk_tree_model_row_has_child_toggled(_SELF(self), RVAL2GTKTREEPATH(path), RVAL2GTKTREEITER(iter));
152
+ return self;
153
+ }
154
+
155
+ static VALUE
156
+ treemodel_row_deleted(self, path)
157
+ VALUE self, path;
158
+ {
159
+ gtk_tree_model_row_deleted(_SELF(self), RVAL2GTKTREEPATH(path));
160
+ return self;
161
+ }
162
+
163
+ static VALUE
164
+ treemodel_rows_reordered(self, path, iter, new_orders)
165
+ VALUE self, path, iter, new_orders;
166
+ {
167
+ gint i, len;
168
+ gint* orders;
169
+
170
+ Check_Type(new_orders, T_ARRAY);
171
+
172
+ len = RARRAY_LEN(new_orders);
173
+ orders = ALLOCA_N(gint, len);
174
+
175
+ for (i = 0; i < len; i++) {
176
+ orders[i] = RARRAY_PTR(new_orders)[i];
177
+ }
178
+
179
+ gtk_tree_model_rows_reordered(_SELF(self), RVAL2GTKTREEPATH(path), RVAL2GTKTREEITER(iter), orders);
180
+ return self;
181
+ }
182
+
183
+ static VALUE
184
+ treemodel_iter_is_valid(self, iter)
185
+ VALUE self, iter;
186
+ {
187
+ return Qtrue;
188
+ }
189
+
190
+ static VALUE
191
+ signal_func(num, values)
192
+ guint num;
193
+ const GValue* values;
194
+ {
195
+ GtkTreeModel* model = g_value_get_object(&values[0]);
196
+ GtkTreePath* path = g_value_get_boxed(&values[1]);
197
+ GtkTreeIter* iter = g_value_get_boxed(&values[2]);
198
+ iter->user_data3 = model;
199
+
200
+ return rb_ary_new3(3, GOBJ2RVAL(model), GTKTREEPATH2RVAL(path), GTKTREEITER2RVAL(iter));
201
+ }
202
+
203
+ static VALUE
204
+ signal_rows_reordered_func(num, values)
205
+ guint num;
206
+ const GValue* values;
207
+ {
208
+ GtkTreeModel* model = g_value_get_object(&values[0]);
209
+ GtkTreePath* path = g_value_get_boxed(&values[1]);
210
+ GtkTreeIter* iter = g_value_get_boxed(&values[2]);
211
+ gint* new_orders = (gint*)g_value_get_pointer(&values[3]);
212
+ gint len = gtk_tree_model_iter_n_children(model, iter);
213
+ VALUE orders = Qnil;
214
+ int i;
215
+
216
+ iter->user_data3 = model;
217
+
218
+ orders = rb_ary_new2(len);
219
+ for (i = 0; i < len; i++, new_orders++) {
220
+ rb_ary_push(orders, INT2NUM(*new_orders));
221
+ }
222
+ return rb_ary_new3(4, GOBJ2RVAL(model), GTKTREEPATH2RVAL(path), GTKTREEITER2RVAL(iter), orders);
223
+ }
224
+
225
+ void
226
+ Init_gtk_treemodel()
227
+ {
228
+ VALUE mTreeModel = G_DEF_INTERFACE(GTK_TYPE_TREE_MODEL, "TreeModel", mGtk);
229
+
230
+ rb_define_method(mTreeModel, "flags", treemodel_get_flags, 0);
231
+ rb_define_method(mTreeModel, "n_columns", treemodel_get_n_columns, 0);
232
+ rb_define_method(mTreeModel, "get_column_type", treemodel_get_column_type, 1);
233
+ rb_define_method(mTreeModel, "iter_first", treemodel_get_iter_first, 0);
234
+ rb_define_method(mTreeModel, "get_iter", treemodel_get_iter, 1);
235
+ rb_define_method(mTreeModel, "get_value", treemodel_get_value, 2);
236
+ rb_define_method(mTreeModel, "each", treemodel_foreach, 0);
237
+ rb_define_method(mTreeModel, "row_changed", treemodel_row_changed, 2);
238
+ rb_define_method(mTreeModel, "row_inserted", treemodel_row_inserted, 2);
239
+ rb_define_method(mTreeModel, "row_has_child_toggled", treemodel_row_has_child_toggled, 2);
240
+ rb_define_method(mTreeModel, "row_deleted", treemodel_row_deleted, 1);
241
+ rb_define_method(mTreeModel, "rows_reordered", treemodel_rows_reordered, 3);
242
+ rb_define_method(mTreeModel, "iter_is_valid?", treemodel_iter_is_valid, 1);
243
+
244
+ /* GtkTreeModelFlags */
245
+ G_DEF_CLASS(GTK_TYPE_TREE_MODEL_FLAGS, "Flags", mTreeModel);
246
+ G_DEF_CONSTANTS(mTreeModel, GTK_TYPE_TREE_MODEL_FLAGS, "GTK_TREE_MODEL_");
247
+
248
+ G_DEF_SIGNAL_FUNC(mTreeModel, "row_changed", (GValToRValSignalFunc)signal_func);
249
+ G_DEF_SIGNAL_FUNC(mTreeModel, "row_inserted", (GValToRValSignalFunc)signal_func);
250
+ G_DEF_SIGNAL_FUNC(mTreeModel, "row_has_child_toggled", (GValToRValSignalFunc)signal_func);
251
+ G_DEF_SIGNAL_FUNC(mTreeModel, "rows_reordered", (GValToRValSignalFunc)signal_rows_reordered_func);
252
+
253
+ G_DEF_SETTERS(mTreeModel);
254
+ }
255
+
256
+