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,351 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgtkiconview.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 16:07:31 $
8
+
9
+ Copyright (C) 2005 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "global.h"
13
+
14
+ #if GTK_CHECK_VERSION(2,6,0)
15
+
16
+ #define _SELF(s) (GTK_ICON_VIEW(RVAL2GOBJ(s)))
17
+
18
+ static ID id_model;
19
+ static ID id_select_path;
20
+
21
+ static VALUE
22
+ iview_initialize(argc, argv, self)
23
+ int argc;
24
+ VALUE *argv;
25
+ VALUE self;
26
+ {
27
+ VALUE model;
28
+ rb_scan_args(argc, argv, "01", &model);
29
+ if (NIL_P(model)){
30
+ RBGTK_INITIALIZE(self, gtk_icon_view_new());
31
+ } else {
32
+ G_CHILD_SET(self, id_model, model);
33
+ RBGTK_INITIALIZE(self,
34
+ gtk_icon_view_new_with_model(GTK_TREE_MODEL(RVAL2GOBJ(model))));
35
+ }
36
+ return Qnil;
37
+ }
38
+
39
+ /* Defined as Properties
40
+ void gtk_icon_view_set_model (GtkIconView *icon_view,
41
+ GtkTreeModel *model);
42
+ GtkTreeModel* gtk_icon_view_get_model (GtkIconView *icon_view);
43
+ void gtk_icon_view_set_text_column (GtkIconView *icon_view,
44
+ gint column);
45
+ gint gtk_icon_view_get_text_column (GtkIconView *icon_view);
46
+ void gtk_icon_view_set_markup_column (GtkIconView *icon_view,
47
+ gint column);
48
+ gint gtk_icon_view_get_markup_column (GtkIconView *icon_view);
49
+ void gtk_icon_view_set_pixbuf_column (GtkIconView *icon_view,
50
+ gint column);
51
+ gint gtk_icon_view_get_pixbuf_column (GtkIconView *icon_view);
52
+ */
53
+
54
+ static VALUE
55
+ iview_get_path_at_pos(VALUE self, VALUE x, VALUE y)
56
+ {
57
+ return GTKTREEPATH2RVAL(gtk_icon_view_get_path_at_pos(_SELF(self), NUM2INT(x), NUM2INT(y)));
58
+ }
59
+
60
+ static void
61
+ iview_foreach_func(iview, path, func)
62
+ GtkIconView* iview;
63
+ GtkTreePath* path;
64
+ gpointer* func;
65
+ {
66
+ rb_funcall((VALUE)func, id_call, 2, GOBJ2RVAL(iview), GTKTREEPATH2RVAL(path));
67
+ }
68
+
69
+ static VALUE
70
+ iview_selected_foreach(self)
71
+ VALUE self;
72
+ {
73
+ VALUE func = rb_block_proc();
74
+ G_RELATIVE(self, func);
75
+ gtk_icon_view_selected_foreach(_SELF(self),
76
+ (GtkIconViewForeachFunc)iview_foreach_func,
77
+ (gpointer)func);
78
+ return self;
79
+ }
80
+
81
+ /* Defined as Properties
82
+ void gtk_icon_view_set_selection_mode
83
+ (GtkIconView *icon_view,
84
+ GtkSelectionMode mode);
85
+ GtkSelectionMode gtk_icon_view_get_selection_mode
86
+ (GtkIconView *icon_view);
87
+ void gtk_icon_view_set_orientation (GtkIconView *icon_view,
88
+ GtkOrientation orientation);
89
+ GtkOrientation gtk_icon_view_get_orientation
90
+ (GtkIconView *icon_view);
91
+ void gtk_icon_view_set_columns (GtkIconView *icon_view,
92
+ gint columns);
93
+ gint gtk_icon_view_get_columns (GtkIconView *icon_view);
94
+ void gtk_icon_view_set_item_width (GtkIconView *icon_view,
95
+ gint item_width);
96
+ gint gtk_icon_view_get_item_width (GtkIconView *icon_view);
97
+ void gtk_icon_view_set_spacing (GtkIconView *icon_view,
98
+ gint spacing);
99
+ gint gtk_icon_view_get_spacing (GtkIconView *icon_view);
100
+ void gtk_icon_view_set_row_spacing (GtkIconView *icon_view,
101
+ gint row_spacing);
102
+ gint gtk_icon_view_get_row_spacing (GtkIconView *icon_view);
103
+ void gtk_icon_view_set_column_spacing
104
+ (GtkIconView *icon_view,
105
+ gint column_spacing);
106
+ gint gtk_icon_view_get_column_spacing
107
+ (GtkIconView *icon_view);
108
+ void gtk_icon_view_set_margin (GtkIconView *icon_view,
109
+ gint margin);
110
+ gint gtk_icon_view_get_margin (GtkIconView *icon_view);
111
+ void gtk_icon_view_set_reorderable (GtkIconView *icon_view,
112
+ gboolean reorderable);
113
+ gboolean gtk_icon_view_get_reorderable (GtkIconView *icon_view);
114
+ */
115
+
116
+ static VALUE
117
+ iview_select_path(self, path)
118
+ VALUE self, path;
119
+ {
120
+ G_CHILD_SET(self, id_select_path, path);
121
+ gtk_icon_view_select_path(_SELF(self), RVAL2GTKTREEPATH(path));
122
+ return self;
123
+ }
124
+
125
+ static VALUE
126
+ iview_unselect_path(self, path)
127
+ VALUE self, path;
128
+ {
129
+ G_CHILD_UNSET(self, id_select_path);
130
+ gtk_icon_view_unselect_path(_SELF(self), RVAL2GTKTREEPATH(path));
131
+ return self;
132
+ }
133
+
134
+ static VALUE
135
+ iview_path_is_selected(self, path)
136
+ VALUE self, path;
137
+ {
138
+ return CBOOL2RVAL(gtk_icon_view_path_is_selected(_SELF(self), RVAL2GTKTREEPATH(path)));
139
+ }
140
+
141
+ static VALUE
142
+ iview_get_selected_items(self)
143
+ VALUE self;
144
+ {
145
+ GList* list = gtk_icon_view_get_selected_items(_SELF(self));
146
+ VALUE ret = GLIST2ARY2(list, GTK_TYPE_TREE_PATH);
147
+ g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL);
148
+ g_list_free(list);
149
+ return ret;
150
+ }
151
+
152
+ static VALUE
153
+ iview_select_all(self)
154
+ VALUE self;
155
+ {
156
+ gtk_icon_view_select_all(_SELF(self));
157
+ return self;
158
+ }
159
+
160
+ static VALUE
161
+ iview_unselect_all(self)
162
+ VALUE self;
163
+ {
164
+ gtk_icon_view_unselect_all(_SELF(self));
165
+ return self;
166
+ }
167
+
168
+ static VALUE
169
+ iview_item_activated(self, path)
170
+ VALUE self, path;
171
+ {
172
+ gtk_icon_view_item_activated(_SELF(self), RVAL2GTKTREEPATH(path));
173
+ return self;
174
+ }
175
+ #endif
176
+
177
+ #if GTK_CHECK_VERSION(2,8,0)
178
+ static VALUE
179
+ iview_create_drag_icon(self, path)
180
+ VALUE self, path;
181
+ {
182
+ return GOBJ2RVAL(gtk_icon_view_create_drag_icon(_SELF(self), RVAL2GTKTREEPATH(path)));
183
+ }
184
+
185
+ static VALUE
186
+ iview_enable_model_drag_dest(self, targets, actions)
187
+ VALUE self, targets, actions;
188
+ {
189
+ gtk_icon_view_enable_model_drag_dest(_SELF(self),
190
+ rbgtk_get_target_entry(targets),
191
+ RARRAY_LEN(targets),
192
+ RVAL2GFLAGS(actions, GDK_TYPE_DRAG_ACTION));
193
+ return self;
194
+ }
195
+
196
+ static VALUE
197
+ iview_enable_model_drag_source(self, flags, targets, actions)
198
+ VALUE self, flags, targets, actions;
199
+ {
200
+ gtk_icon_view_enable_model_drag_source(_SELF(self),
201
+ RVAL2GFLAGS(flags, GDK_TYPE_MODIFIER_TYPE),
202
+ rbgtk_get_target_entry(targets),
203
+ RARRAY_LEN(targets),
204
+ RVAL2GFLAGS(actions, GDK_TYPE_DRAG_ACTION));
205
+ return self;
206
+ }
207
+
208
+ static VALUE
209
+ iview_cursor(self)
210
+ VALUE self;
211
+ {
212
+ GtkTreePath* path;
213
+ GtkCellRenderer* cell;
214
+ gboolean cursor_set = gtk_icon_view_get_cursor(_SELF(self), &path, &cell);
215
+ return cursor_set ? rb_assoc_new(GTKTREEPATH2RVAL(path), GOBJ2RVAL(cell)) : Qnil;
216
+ }
217
+
218
+ static VALUE
219
+ iview_get_dest_item_at_pos(self, drag_x, drag_y)
220
+ VALUE self, drag_x, drag_y;
221
+ {
222
+ GtkTreePath* path;
223
+ GtkIconViewDropPosition pos;
224
+ gboolean item_at_pos = gtk_icon_view_get_dest_item_at_pos(_SELF(self), NUM2INT(drag_x), NUM2INT(drag_y), &path, &pos);
225
+ return item_at_pos ? rb_assoc_new(GTKTREEPATH2RVAL(path),
226
+ GENUM2RVAL(pos, GTK_TYPE_ICON_VIEW_DROP_POSITION)) : Qnil;
227
+ }
228
+
229
+ static VALUE
230
+ iview_drag_dest_item(self)
231
+ VALUE self;
232
+ {
233
+ GtkTreePath* path;
234
+ GtkIconViewDropPosition pos;
235
+ gtk_icon_view_get_drag_dest_item(_SELF(self), &path, &pos);
236
+ return rb_assoc_new(GTKTREEPATH2RVAL(path),
237
+ GENUM2RVAL(pos, GTK_TYPE_ICON_VIEW_DROP_POSITION));
238
+ }
239
+
240
+ static VALUE
241
+ iview_get_item_at_pos(self, x, y)
242
+ VALUE self, x, y;
243
+ {
244
+ GtkTreePath* path;
245
+ GtkCellRenderer* cell;
246
+ gboolean item_at_pos = gtk_icon_view_get_item_at_pos(_SELF(self), NUM2INT(x), NUM2INT(y), &path, &cell);
247
+ return item_at_pos ? rb_assoc_new(GTKTREEPATH2RVAL(path), GOBJ2RVAL(cell)) : Qnil;
248
+ }
249
+
250
+ static VALUE
251
+ iview_visible_range(self)
252
+ VALUE self;
253
+ {
254
+ GtkTreePath* start_path;
255
+ GtkTreePath* end_path;
256
+
257
+ gboolean valid_paths = gtk_icon_view_get_visible_range(_SELF(self), &start_path, &end_path);
258
+
259
+ return valid_paths ? rb_assoc_new(GTKTREEPATH2RVAL(start_path),
260
+ GTKTREEPATH2RVAL(end_path)) : Qnil;
261
+ }
262
+
263
+ static VALUE
264
+ iview_scroll_to_path(self, path, use_align, row_align, col_align)
265
+ VALUE self, path, use_align, row_align, col_align;
266
+ {
267
+ gtk_icon_view_scroll_to_path(_SELF(self),
268
+ RVAL2GTKTREEPATH(path),
269
+ RVAL2CBOOL(use_align),
270
+ NUM2DBL(row_align),
271
+ NUM2DBL(col_align));
272
+ return self;
273
+ }
274
+
275
+ static VALUE
276
+ iview_set_cursor(self, path, cell, start_editing)
277
+ VALUE self, path, cell, start_editing;
278
+ {
279
+ gtk_icon_view_set_cursor(_SELF(self), RVAL2GTKTREEPATH(path),
280
+ NIL_P(cell) ? NULL : RVAL2GOBJ(cell), RVAL2CBOOL(start_editing));
281
+ return self;
282
+ }
283
+
284
+ static VALUE
285
+ iview_set_drag_dest_item(self, path, pos)
286
+ VALUE self, path, pos;
287
+ {
288
+ gtk_icon_view_set_drag_dest_item(_SELF(self),
289
+ NIL_P(path) ? NULL : RVAL2GTKTREEPATH(path),
290
+ RVAL2GENUM(pos, GTK_TYPE_ICON_VIEW_DROP_POSITION));
291
+ return self;
292
+ }
293
+
294
+ static VALUE
295
+ iview_unset_model_drag_dest(self)
296
+ VALUE self;
297
+ {
298
+ gtk_icon_view_unset_model_drag_dest(_SELF(self));
299
+ return self;
300
+ }
301
+
302
+ static VALUE
303
+ iview_unset_model_drag_source(self)
304
+ VALUE self;
305
+ {
306
+ gtk_icon_view_unset_model_drag_source(_SELF(self));
307
+ return self;
308
+ }
309
+ #endif
310
+
311
+ void
312
+ Init_gtk_iconview()
313
+ {
314
+ #if GTK_CHECK_VERSION(2,6,0)
315
+ VALUE iview = G_DEF_CLASS(GTK_TYPE_ICON_VIEW, "IconView", mGtk);
316
+
317
+ id_model = rb_intern("model");
318
+ id_select_path = rb_intern("select_path");
319
+
320
+ rb_define_method(iview, "initialize", iview_initialize, -1);
321
+ rb_define_method(iview, "get_path_at_pos", iview_get_path_at_pos, 2);
322
+ rb_define_alias(iview, "get_path", "get_path_at_pos");
323
+ rb_define_method(iview, "selected_each", iview_selected_foreach, 0);
324
+ rb_define_method(iview, "select_path", iview_select_path, 1);
325
+ rb_define_method(iview, "unselect_path", iview_unselect_path, 1);
326
+ rb_define_method(iview, "path_is_selected?", iview_path_is_selected, 1);
327
+ rb_define_method(iview, "selected_items", iview_get_selected_items, 0);
328
+ rb_define_method(iview, "select_all", iview_select_all, 0);
329
+ rb_define_method(iview, "unselect_all", iview_unselect_all, 0);
330
+ rb_define_method(iview, "item_activated", iview_item_activated, 1);
331
+ #endif
332
+ #if GTK_CHECK_VERSION(2,8,0)
333
+ rb_define_method(iview, "create_drag_icon", iview_create_drag_icon, 1);
334
+ rb_define_method(iview, "enable_model_drag_dest", iview_enable_model_drag_dest, 2);
335
+ rb_define_method(iview, "enable_model_drag_source", iview_enable_model_drag_source, 3);
336
+ rb_define_method(iview, "cursor", iview_cursor, 0);
337
+ rb_define_method(iview, "get_dest_item", iview_get_dest_item_at_pos, 2);
338
+ rb_define_method(iview, "drag_dest_item", iview_drag_dest_item, 0);
339
+ rb_define_method(iview, "get_item", iview_get_item_at_pos, 2);
340
+ rb_define_method(iview, "visible_range", iview_visible_range, 0);
341
+ rb_define_method(iview, "scroll_to_path", iview_scroll_to_path, 4);
342
+ rb_define_method(iview, "set_cursor", iview_set_cursor, 3);
343
+ rb_define_method(iview, "set_drag_dest_item", iview_set_drag_dest_item, 2);
344
+ rb_define_method(iview, "unset_model_drag_dest", iview_unset_model_drag_dest, 0);
345
+ rb_define_method(iview, "unset_model_drag_source", iview_unset_model_drag_source, 0);
346
+
347
+ /* GtkIconViewDropPosition */
348
+ G_DEF_CLASS(GTK_TYPE_ICON_VIEW_DROP_POSITION, "Type", iview);
349
+ G_DEF_CONSTANTS(iview, GTK_TYPE_ICON_VIEW_DROP_POSITION, "GTK_ICON_VIEW_");
350
+ #endif
351
+ }
@@ -0,0 +1,152 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgtkimage.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2005/09/23 22:02:07 $
8
+
9
+ Copyright (C) 2002-2005 Masao Mutoh
10
+ ************************************************/
11
+
12
+ #include "global.h"
13
+
14
+ #define _SELF(s) (GTK_IMAGE(RVAL2GOBJ(s)))
15
+ /*
16
+ Use properties instead.
17
+ void gtk_image_get_icon_set (GtkImage *image,
18
+ GtkIconSet **icon_set,
19
+ GtkIconSize *size);
20
+ void gtk_image_get_image (GtkImage *image,
21
+ GdkImage **gdk_image,
22
+ GdkBitmap **mask);
23
+ GtkImageType gtk_image_get_storage_type (GtkImage *image);
24
+ */
25
+
26
+ static VALUE
27
+ image_initialize(argc, argv, self)
28
+ int argc;
29
+ VALUE *argv;
30
+ VALUE self;
31
+ {
32
+ VALUE arg1, arg2;
33
+ GType gtype;
34
+ GtkWidget* widget = NULL;
35
+
36
+ rb_scan_args(argc, argv, "02", &arg1, &arg2);
37
+
38
+ if (NIL_P(arg1)){
39
+ widget = gtk_image_new();
40
+ } else if (TYPE(arg1) == T_STRING && argc == 1){
41
+ widget = gtk_image_new_from_file(RVAL2CSTR(arg1));
42
+ } else if (TYPE(arg1) == T_SYMBOL){
43
+ widget = gtk_image_new_from_stock(rb_id2name(SYM2ID(arg1)),
44
+ RVAL2GENUM(arg2, GTK_TYPE_ICON_SIZE));
45
+ #if GTK_CHECK_VERSION(2,6,0)
46
+ } else if (TYPE(arg1) == T_STRING){
47
+ widget = gtk_image_new_from_icon_name(RVAL2CSTR(arg1),
48
+ RVAL2GENUM(arg2, GTK_TYPE_ICON_SIZE));
49
+ #endif
50
+ } else {
51
+ gtype = RVAL2GTYPE(arg1);
52
+ if (gtype == GDK_TYPE_IMAGE){
53
+ widget = gtk_image_new_from_image(GDK_IMAGE(RVAL2GOBJ(arg1)),
54
+ GDK_BITMAP(RVAL2GOBJ(arg2)));
55
+ } else if (gtype == GDK_TYPE_PIXBUF){
56
+ widget = gtk_image_new_from_pixbuf(GDK_PIXBUF(RVAL2GOBJ(arg1)));
57
+ } else if (gtype == GDK_TYPE_PIXMAP){
58
+ widget = gtk_image_new_from_pixmap(GDK_PIXMAP(RVAL2GOBJ(arg1)),
59
+ GDK_BITMAP(RVAL2GOBJ(arg2)));
60
+ } else if (gtype == GTK_TYPE_ICON_SET){
61
+ widget = gtk_image_new_from_icon_set((GtkIconSet*)RVAL2BOXED(arg1, GTK_TYPE_ICON_SET), RVAL2GENUM(arg2, GTK_TYPE_ICON_SIZE));
62
+ } else if (g_type_is_a(gtype, GDK_TYPE_PIXBUF_ANIMATION)) {
63
+ widget = gtk_image_new_from_animation(GDK_PIXBUF_ANIMATION(RVAL2GOBJ(arg1)));
64
+ }
65
+ }
66
+ RBGTK_INITIALIZE(self, widget);
67
+ return Qnil;
68
+ }
69
+
70
+ static VALUE
71
+ image_set(argc, argv, self)
72
+ int argc;
73
+ VALUE *argv;
74
+ VALUE self;
75
+ {
76
+ VALUE arg1, arg2;
77
+ GType gtype;
78
+
79
+ rb_scan_args(argc, argv, "11", &arg1, &arg2);
80
+
81
+ if (TYPE(arg1) == T_STRING && argc == 1){
82
+ gtk_image_set_from_file(_SELF(self), RVAL2CSTR(arg1));
83
+ } else if (TYPE(arg1) == T_SYMBOL){
84
+ gtk_image_set_from_stock(_SELF(self), rb_id2name(SYM2ID(arg1)),
85
+ RVAL2GENUM(arg2, GTK_TYPE_ICON_SIZE));
86
+ #if GTK_CHECK_VERSION(2,6,0)
87
+ } else if (TYPE(arg1) == T_STRING){
88
+ gtk_image_set_from_icon_name(_SELF(self), RVAL2CSTR(arg1),
89
+ RVAL2GENUM(arg2, GTK_TYPE_ICON_SIZE));
90
+ #endif
91
+ } else {
92
+ gtype = RVAL2GTYPE(arg1);
93
+ if (gtype == GDK_TYPE_IMAGE){
94
+ gtk_image_set_from_image(_SELF(self), GDK_IMAGE(RVAL2GOBJ(arg1)),
95
+ GDK_BITMAP(RVAL2GOBJ(arg2)));
96
+ } else if (gtype == GDK_TYPE_PIXBUF){
97
+ gtk_image_set_from_pixbuf(_SELF(self), GDK_PIXBUF(RVAL2GOBJ(arg1)));
98
+
99
+ } else if (gtype == GDK_TYPE_PIXMAP){
100
+ gtk_image_set_from_pixmap(_SELF(self), GDK_PIXMAP(RVAL2GOBJ(arg1)),
101
+ GDK_BITMAP(RVAL2GOBJ(arg2)));
102
+ } else if (gtype == GTK_TYPE_ICON_SET){
103
+ gtk_image_set_from_icon_set(_SELF(self),
104
+ (GtkIconSet*)RVAL2BOXED(arg1, GTK_TYPE_ICON_SET),
105
+ RVAL2GENUM(arg2, GTK_TYPE_ICON_SIZE));
106
+ } else if (g_type_is_a(gtype, GDK_TYPE_PIXBUF_ANIMATION)) {
107
+ gtk_image_set_from_animation(_SELF(self), GDK_PIXBUF_ANIMATION(RVAL2GOBJ(arg1)));
108
+ } else {
109
+ rb_raise(rb_eArgError, "invalid argument: %s", rb_class2name(arg1));
110
+ }
111
+ }
112
+
113
+ return self;
114
+ }
115
+
116
+ /* Defined as property
117
+ void gtk_image_get_icon_name (GtkImage *image,
118
+ G_CONST_RETURN gchar **icon_name,
119
+ GtkIconSize *size);
120
+ void gtk_image_set_pixel_size (GtkImage *image,
121
+ gint pixel_size);
122
+ gint gtk_image_get_pixel_size (GtkImage *image);
123
+
124
+ */
125
+
126
+ #if GTK_CHECK_VERSION(2,8,0)
127
+ static VALUE
128
+ image_clear(self)
129
+ VALUE self;
130
+ {
131
+ gtk_image_clear(_SELF(self));
132
+ return self;
133
+ }
134
+ #endif
135
+
136
+ void
137
+ Init_gtk_image()
138
+ {
139
+ VALUE gImage = G_DEF_CLASS(GTK_TYPE_IMAGE, "Image", mGtk);
140
+ rb_define_method(gImage, "initialize", image_initialize, -1);
141
+ rb_define_method(gImage, "set", image_set, -1);
142
+ #if GTK_CHECK_VERSION(2,8,0)
143
+ rb_define_method(gImage, "clear", image_clear, 0);
144
+ #endif
145
+
146
+ /* GtkImageType */
147
+ G_DEF_CLASS(GTK_TYPE_IMAGE_TYPE, "Type", gImage);
148
+ G_DEF_CONSTANTS(gImage, GTK_TYPE_IMAGE_TYPE, "GTK_IMAGE_");
149
+
150
+ G_SET_SYMBOL_PROPERTY(GTK_TYPE_IMAGE, "stock");
151
+
152
+ }