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,49 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgtktextchild.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 14:27:10 $
8
+
9
+ Copyright (C) 2002,2003 Masahiro Sakai
10
+ Copyright (C) 2002-2006 Ruby-GNOME2 Project Team
11
+ ************************************************/
12
+
13
+ #include "global.h"
14
+
15
+ #define _SELF(self) GTK_TEXT_CHILD_ANCHOR(RVAL2GOBJ(self))
16
+
17
+ static VALUE
18
+ textchild_initialize(argc, argv, self)
19
+ int argc;
20
+ VALUE* argv;
21
+ VALUE self;
22
+ {
23
+ RBGTK_INITIALIZE(self, gtk_text_child_anchor_new());
24
+ return Qnil;
25
+ }
26
+
27
+ static VALUE
28
+ textchild_get_widgets(self)
29
+ VALUE self;
30
+ {
31
+ return GLIST2ARYF(gtk_text_child_anchor_get_widgets(_SELF(self)));
32
+ }
33
+
34
+ static VALUE
35
+ textchild_get_deleted(self)
36
+ VALUE self;
37
+ {
38
+ return CBOOL2RVAL(gtk_text_child_anchor_get_deleted(_SELF(self)));
39
+ }
40
+
41
+ void
42
+ Init_gtk_textchild()
43
+ {
44
+ VALUE gTextChildAnchor = G_DEF_CLASS(GTK_TYPE_TEXT_CHILD_ANCHOR, "TextChildAnchor", mGtk);
45
+
46
+ rb_define_method(gTextChildAnchor, "initialize", textchild_initialize, 0);
47
+ rb_define_method(gTextChildAnchor, "widgets", textchild_get_widgets, 0);
48
+ rb_define_method(gTextChildAnchor, "deleted?", textchild_get_deleted, 0);
49
+ }
@@ -0,0 +1,553 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /************************************************
3
+
4
+ rbgtktextiter.c -
5
+
6
+ $Author: ggc $
7
+ $Date: 2007/07/13 16:07:32 $
8
+
9
+ Copyright (C) 2002-2005 Ruby-GNOME2 Project Team
10
+ Copyright (C) 2002,2003 Masahiro Sakai
11
+ ************************************************/
12
+
13
+ #include "global.h"
14
+
15
+ #define _SELF(s) ((GtkTextIter*)RVAL2BOXED(s, GTK_TYPE_TEXT_ITER))
16
+ #define RVAL2TAG(t) (GTK_TEXT_TAG(RVAL2GOBJ(t)))
17
+ #define ITR2RVAL(i) (BOXED2RVAL(i, GTK_TYPE_TEXT_ITER))
18
+
19
+ static gboolean is_compat_240;
20
+ static ID id_pixbuf;
21
+
22
+ static VALUE
23
+ get_buffer(self)
24
+ VALUE self;
25
+ {
26
+ return GOBJ2RVAL(gtk_text_iter_get_buffer(_SELF(self)));
27
+ }
28
+
29
+ #define def_gint_getter(__name__) \
30
+ static VALUE \
31
+ get_##__name__(self) \
32
+ VALUE self; \
33
+ { \
34
+ return INT2NUM(gtk_text_iter_get_##__name__(_SELF(self))); \
35
+ }
36
+
37
+ def_gint_getter(offset)
38
+ def_gint_getter(line)
39
+ def_gint_getter(line_offset)
40
+ def_gint_getter(line_index)
41
+ def_gint_getter(visible_line_offset)
42
+ def_gint_getter(visible_line_index)
43
+
44
+ static VALUE
45
+ get_char(self)
46
+ VALUE self;
47
+ {
48
+ gchar buf[10];
49
+ gint len = g_unichar_to_utf8(gtk_text_iter_get_char(_SELF(self)), buf);
50
+ buf[len] = '\0';
51
+ return CSTR2RVAL(buf);
52
+ }
53
+
54
+ static VALUE
55
+ get_slice(self, rhs)
56
+ VALUE self, rhs;
57
+ {
58
+ return CSTR2RVAL(gtk_text_iter_get_slice(_SELF(self), _SELF(rhs)));
59
+ }
60
+
61
+ static VALUE
62
+ get_text(self, rhs)
63
+ VALUE self, rhs;
64
+ {
65
+ return CSTR2RVAL(gtk_text_iter_get_text(_SELF(self), _SELF(rhs)));
66
+ }
67
+
68
+ static VALUE
69
+ get_visible_slice(self, rhs)
70
+ VALUE self, rhs;
71
+ {
72
+ return CSTR2RVAL(gtk_text_iter_get_visible_slice(_SELF(self), _SELF(rhs)));
73
+ }
74
+
75
+ static VALUE
76
+ get_visible_text(self, rhs)
77
+ VALUE self, rhs;
78
+ {
79
+ return CSTR2RVAL(gtk_text_iter_get_visible_text(_SELF(self), _SELF(rhs)));
80
+ }
81
+
82
+ static VALUE
83
+ get_pixbuf(self)
84
+ VALUE self;
85
+ {
86
+ GdkPixbuf* pixbuf = gtk_text_iter_get_pixbuf(_SELF(self));
87
+ VALUE ret = Qnil;
88
+ if (pixbuf){
89
+ ret = GOBJ2RVAL(pixbuf);
90
+ G_CHILD_SET(self, id_pixbuf, ret);
91
+ }
92
+ return ret;
93
+ }
94
+
95
+ static VALUE
96
+ get_marks(self)
97
+ VALUE self;
98
+ {
99
+ return GSLIST2ARYF(gtk_text_iter_get_marks(_SELF(self)));
100
+ }
101
+
102
+ static VALUE
103
+ get_toggled_tags(self, toggled_on)
104
+ VALUE self, toggled_on;
105
+ {
106
+ return GSLIST2ARYF(gtk_text_iter_get_toggled_tags(_SELF(self), RVAL2CBOOL(toggled_on)));
107
+ }
108
+
109
+ static VALUE
110
+ get_child_anchor(self)
111
+ VALUE self;
112
+ {
113
+ GtkTextChildAnchor* anchor = gtk_text_iter_get_child_anchor(_SELF(self));
114
+ return anchor ? GOBJ2RVAL(anchor) : Qnil;
115
+ }
116
+
117
+ static VALUE
118
+ begins_tag(self, tag)
119
+ VALUE self, tag;
120
+ {
121
+ return CBOOL2RVAL(gtk_text_iter_begins_tag(_SELF(self), RVAL2TAG(tag)));
122
+ }
123
+
124
+ static VALUE
125
+ ends_tag(self, tag)
126
+ VALUE self, tag;
127
+ {
128
+ return CBOOL2RVAL(gtk_text_iter_ends_tag(_SELF(self), RVAL2TAG(tag)));
129
+ }
130
+
131
+ static VALUE
132
+ toggles_tag(self, tag)
133
+ VALUE self, tag;
134
+ {
135
+ return CBOOL2RVAL(gtk_text_iter_toggles_tag(_SELF(self), RVAL2TAG(tag)));
136
+ }
137
+
138
+ static VALUE
139
+ has_tag(self, tag)
140
+ VALUE self, tag;
141
+ {
142
+ return CBOOL2RVAL(gtk_text_iter_has_tag(_SELF(self), RVAL2TAG(tag)));
143
+ }
144
+
145
+ static VALUE
146
+ get_tags(self)
147
+ VALUE self;
148
+ {
149
+ return GSLIST2ARYF(gtk_text_iter_get_tags(_SELF(self)));
150
+ }
151
+
152
+ static VALUE
153
+ editable(self, default_setting)
154
+ VALUE self, default_setting;
155
+ {
156
+ return CBOOL2RVAL(gtk_text_iter_editable(_SELF(self), RVAL2CBOOL(default_setting)));
157
+ }
158
+
159
+ static VALUE
160
+ can_insert(self, default_setting)
161
+ VALUE self, default_setting;
162
+ {
163
+ return CBOOL2RVAL(gtk_text_iter_can_insert(_SELF(self), RVAL2CBOOL(default_setting)));
164
+ }
165
+
166
+
167
+ #define def_predicate(__name__) \
168
+ static VALUE \
169
+ __name__(self) \
170
+ VALUE self; \
171
+ { \
172
+ return CBOOL2RVAL(gtk_text_iter_##__name__(_SELF(self))); \
173
+ }
174
+
175
+ def_predicate(starts_word)
176
+ def_predicate(ends_word)
177
+ def_predicate(inside_word)
178
+ def_predicate(starts_sentence)
179
+ def_predicate(ends_sentence)
180
+ def_predicate(starts_line)
181
+ def_predicate(ends_line)
182
+ def_predicate(is_cursor_position)
183
+
184
+ def_gint_getter(chars_in_line)
185
+ def_gint_getter(bytes_in_line)
186
+
187
+ static VALUE
188
+ get_attributes(self)
189
+ VALUE self;
190
+ {
191
+ GtkTextAttributes attr;
192
+
193
+ if(gtk_text_iter_get_attributes(_SELF(self), &attr) == TRUE){
194
+ return BOXED2RVAL(&attr, GTK_TYPE_TEXT_ATTRIBUTES);
195
+ } else {
196
+ return Qnil;
197
+ }
198
+ }
199
+
200
+ static VALUE
201
+ get_language(self)
202
+ VALUE self;
203
+ {
204
+ return CSTR2RVAL(pango_language_to_string(gtk_text_iter_get_language(_SELF(self))));
205
+ }
206
+
207
+ def_predicate(is_end)
208
+ def_predicate(is_start)
209
+
210
+
211
+ #define def_move(__name__) \
212
+ static VALUE \
213
+ __name__(self) \
214
+ VALUE self; \
215
+ { \
216
+ return CBOOL2RVAL(gtk_text_iter_##__name__(_SELF(self))); \
217
+ }
218
+
219
+ #define def_move_gint(__name__) \
220
+ static VALUE \
221
+ __name__(self, i) \
222
+ VALUE self, i; \
223
+ { \
224
+ return CBOOL2RVAL(gtk_text_iter_##__name__(_SELF(self), NUM2INT(i))); \
225
+ }
226
+
227
+ def_move(forward_char)
228
+ def_move(backward_char)
229
+ def_move_gint(forward_chars)
230
+ def_move_gint(backward_chars)
231
+ def_move(forward_line)
232
+ def_move(backward_line)
233
+ def_move_gint(forward_lines)
234
+ def_move_gint(backward_lines)
235
+ def_move(forward_word_end)
236
+ def_move(backward_word_start)
237
+ def_move_gint(forward_word_ends)
238
+ def_move_gint(backward_word_starts)
239
+ def_move(forward_sentence_end)
240
+ def_move(backward_sentence_start)
241
+ def_move_gint(forward_sentence_ends)
242
+ def_move_gint(backward_sentence_starts)
243
+
244
+ #if GTK_CHECK_VERSION(2,4,0)
245
+ def_move_gint(forward_visible_word_ends)
246
+ def_move_gint(backward_visible_word_starts)
247
+ def_move(forward_visible_word_end)
248
+ def_move(backward_visible_word_start)
249
+ def_move(forward_visible_cursor_position)
250
+ def_move(backward_visible_cursor_position)
251
+ def_move_gint(forward_visible_cursor_positions)
252
+ def_move_gint(backward_visible_cursor_positions)
253
+ #endif
254
+ #if GTK_CHECK_VERSION(2,8,0)
255
+ def_move(forward_visible_line)
256
+ def_move(backward_visible_line)
257
+ def_move_gint(forward_visible_lines)
258
+ def_move_gint(backward_visible_lines)
259
+ #endif
260
+ def_move(forward_cursor_position)
261
+ def_move(backward_cursor_position)
262
+ def_move_gint(forward_cursor_positions)
263
+ def_move_gint(backward_cursor_positions)
264
+ def_move(forward_to_line_end)
265
+
266
+ static VALUE
267
+ forward_to_end(self)
268
+ VALUE self;
269
+ {
270
+ gtk_text_iter_forward_to_end(_SELF(self));
271
+ return self;
272
+ }
273
+
274
+ #define def_gint_setter(__name__) \
275
+ static VALUE \
276
+ set_##__name__(self, val) \
277
+ VALUE self, val; \
278
+ { \
279
+ gtk_text_iter_set_##__name__(_SELF(self), NUM2INT(val)); \
280
+ return val; \
281
+ }
282
+
283
+ def_gint_setter(offset)
284
+ def_gint_setter(line)
285
+ def_gint_setter(line_offset)
286
+ def_gint_setter(line_index)
287
+
288
+ def_gint_setter(visible_line_offset)
289
+ def_gint_setter(visible_line_index)
290
+
291
+ static VALUE
292
+ forward_to_tag_toggle(argc, argv, self)
293
+ int argc;
294
+ VALUE *argv;
295
+ VALUE self;
296
+ {
297
+ VALUE tag;
298
+
299
+ rb_scan_args(argc, argv, "01", &tag);
300
+ return CBOOL2RVAL(gtk_text_iter_forward_to_tag_toggle(_SELF(self),
301
+ NIL_P(tag) ? NULL : RVAL2TAG(tag)));
302
+ }
303
+
304
+ static VALUE
305
+ backward_to_tag_toggle(argc, argv, self)
306
+ int argc;
307
+ VALUE *argv;
308
+ VALUE self;
309
+ {
310
+ VALUE tag;
311
+
312
+ rb_scan_args(argc, argv, "01", &tag);
313
+ return CBOOL2RVAL(gtk_text_iter_backward_to_tag_toggle(_SELF(self),
314
+ NIL_P(tag) ? NULL : RVAL2TAG(tag)));
315
+ }
316
+
317
+ static gboolean
318
+ char_predicate_func(ch, func)
319
+ guint32 ch;
320
+ gpointer func;
321
+ {
322
+ return RVAL2CBOOL(rb_funcall((VALUE)func, id_call, 1, UINT2NUM(ch)));
323
+ }
324
+
325
+ static VALUE
326
+ forward_find_char(argc, argv, self)
327
+ int argc;
328
+ VALUE *argv;
329
+ VALUE self;
330
+ {
331
+ VALUE limit;
332
+ volatile VALUE func = rb_block_proc();
333
+
334
+ rb_scan_args(argc, argv, "01", &limit);
335
+ return CBOOL2RVAL(gtk_text_iter_forward_find_char(_SELF(self),
336
+ (GtkTextCharPredicate)char_predicate_func,
337
+ (gpointer)func,
338
+ NIL_P(limit) ? NULL : _SELF(limit)));
339
+ }
340
+
341
+ static VALUE
342
+ backward_find_char(argc, argv, self)
343
+ int argc;
344
+ VALUE *argv;
345
+ VALUE self;
346
+ {
347
+ VALUE limit;
348
+ volatile VALUE func = rb_block_proc();
349
+
350
+ rb_scan_args(argc, argv, "01", &limit);
351
+ return CBOOL2RVAL(gtk_text_iter_backward_find_char(_SELF(self),
352
+ (GtkTextCharPredicate)char_predicate_func,
353
+ (gpointer)func,
354
+ NIL_P(limit) ? NULL : _SELF(limit)));
355
+ }
356
+
357
+ static VALUE
358
+ forward_search(argc, argv, self)
359
+ int argc;
360
+ VALUE *argv;
361
+ VALUE self;
362
+ {
363
+ GtkTextIter m_start, m_end;
364
+ VALUE str, flags, limit;
365
+ gboolean ret;
366
+
367
+ rb_scan_args(argc, argv, "21", &str, &flags, &limit);
368
+
369
+ if (is_compat_240){
370
+ ret = gtk_text_iter_forward_search(_SELF(self), RVAL2CSTR(str),
371
+ RVAL2GFLAGS(flags, GTK_TYPE_TEXT_SEARCH_FLAGS),
372
+ &m_start, &m_end,
373
+ NIL_P(limit) ? NULL : _SELF(limit));
374
+ } else {
375
+ ret = gtk_text_iter_forward_search(_SELF(self), RVAL2CSTR(str),
376
+ RVAL2GENUM(flags, GTK_TYPE_TEXT_SEARCH_FLAGS),
377
+ &m_start, &m_end,
378
+ NIL_P(limit) ? NULL : _SELF(limit));
379
+ }
380
+ return ret ? rb_ary_new3(2, ITR2RVAL(&m_start), ITR2RVAL(&m_end)) : Qnil;
381
+ }
382
+
383
+ static VALUE
384
+ backward_search(argc, argv, self)
385
+ int argc;
386
+ VALUE *argv;
387
+ VALUE self;
388
+ {
389
+ GtkTextIter m_start, m_end;
390
+ VALUE str, flags, limit;
391
+ gboolean ret;
392
+
393
+ rb_scan_args(argc, argv, "21", &str, &flags, &limit);
394
+ if (is_compat_240){
395
+ ret = gtk_text_iter_backward_search(_SELF(self), RVAL2CSTR(str),
396
+ RVAL2GFLAGS(flags, GTK_TYPE_TEXT_SEARCH_FLAGS),
397
+ &m_start, &m_end,
398
+ NIL_P(limit) ? NULL : _SELF(limit));
399
+ } else {
400
+ ret = gtk_text_iter_backward_search(_SELF(self), RVAL2CSTR(str),
401
+ RVAL2GENUM(flags, GTK_TYPE_TEXT_SEARCH_FLAGS),
402
+ &m_start, &m_end,
403
+ NIL_P(limit) ? NULL : _SELF(limit));
404
+ }
405
+ return ret ? rb_ary_new3(2, ITR2RVAL(&m_start), ITR2RVAL(&m_end)) : Qnil;
406
+ }
407
+
408
+ static VALUE
409
+ equal(self, other)
410
+ VALUE self, other;
411
+ {
412
+ return CBOOL2RVAL(gtk_text_iter_equal(_SELF(self), _SELF(other)));
413
+ }
414
+
415
+ static VALUE
416
+ compare(self, rhs)
417
+ VALUE self, rhs;
418
+ {
419
+ return INT2NUM(gtk_text_iter_compare(_SELF(self), _SELF(rhs)));
420
+ }
421
+
422
+ /*
423
+ The following methods don't have to be implimented.
424
+ Including Comparable module is enough.
425
+
426
+ gboolean gtk_text_iter_in_range (const GtkTextIter *iter,
427
+ const GtkTextIter *start,
428
+ const GtkTextIter *end);
429
+ void gtk_text_iter_order (GtkTextIter *first,
430
+ GtkTextIter *second);
431
+ */
432
+
433
+ void
434
+ Init_gtk_textiter()
435
+ {
436
+ VALUE cTextIter = G_DEF_CLASS(GTK_TYPE_TEXT_ITER, "TextIter", mGtk);
437
+ rb_include_module(cTextIter, rb_mComparable);
438
+
439
+ is_compat_240 = gtk_check_version(2, 4, 0) ? FALSE : TRUE;
440
+
441
+ id_pixbuf = rb_intern("pixbuf");
442
+
443
+ rb_define_method(cTextIter, "buffer", get_buffer, 0);
444
+ rb_define_method(cTextIter, "offset", get_offset, 0);
445
+ rb_define_method(cTextIter, "line", get_line, 0);
446
+ rb_define_method(cTextIter, "line_offset", get_line_offset, 0);
447
+ rb_define_method(cTextIter, "line_index", get_line_index, 0);
448
+ rb_define_method(cTextIter, "visible_line_offset", get_visible_line_offset, 0);
449
+ rb_define_method(cTextIter, "visible_line_index", get_visible_line_index, 0);
450
+ rb_define_method(cTextIter, "char", get_char, 0);
451
+
452
+ rb_define_method(cTextIter, "get_slice", get_slice, 1);
453
+ rb_define_method(cTextIter, "get_text", get_text, 1);
454
+ rb_define_method(cTextIter, "get_visible_slice", get_visible_slice, 1);
455
+ rb_define_method(cTextIter, "get_visible_text", get_visible_text, 1);
456
+
457
+ rb_define_method(cTextIter, "pixbuf", get_pixbuf, 0);
458
+ rb_define_method(cTextIter, "marks", get_marks, 0);
459
+ rb_define_method(cTextIter, "child_anchor", get_child_anchor, 0);
460
+
461
+ rb_define_method(cTextIter, "toggled_tags", get_toggled_tags, 1);
462
+ rb_define_method(cTextIter, "begins_tag?", begins_tag, 1);
463
+ rb_define_method(cTextIter, "ends_tag?", ends_tag, 1);
464
+ rb_define_method(cTextIter, "toggles_tag?", toggles_tag, 1);
465
+ rb_define_method(cTextIter, "has_tag?", has_tag, 1);
466
+ rb_define_method(cTextIter, "tags", get_tags, 0);
467
+
468
+ rb_define_method(cTextIter, "editable?", editable, 1);
469
+ rb_define_method(cTextIter, "can_insert?", can_insert, 1);
470
+
471
+ rb_define_method(cTextIter, "starts_word?", starts_word, 0);
472
+ rb_define_method(cTextIter, "ends_word?", ends_word, 0);
473
+ rb_define_method(cTextIter, "inside_word?", inside_word, 0);
474
+ rb_define_method(cTextIter, "starts_sentence?", starts_sentence, 0);
475
+ rb_define_method(cTextIter, "ends_sentence?", ends_sentence, 0);
476
+ rb_define_method(cTextIter, "starts_line?", starts_line, 0);
477
+ rb_define_method(cTextIter, "ends_line?", ends_line, 0);
478
+ rb_define_method(cTextIter, "cursor_position?", is_cursor_position, 0);
479
+
480
+ rb_define_method(cTextIter, "chars_in_line", get_chars_in_line, 0);
481
+ rb_define_method(cTextIter, "bytes_in_line", get_bytes_in_line, 0);
482
+
483
+ rb_define_method(cTextIter, "attributes", get_attributes, 0);
484
+
485
+ rb_define_method(cTextIter, "language", get_language, 0);
486
+ rb_define_method(cTextIter, "end?", is_end, 0);
487
+ rb_define_method(cTextIter, "start?", is_start, 0);
488
+
489
+ rb_define_method(cTextIter, "forward_char", forward_char, 0);
490
+ rb_define_method(cTextIter, "backward_char", backward_char, 0);
491
+ rb_define_method(cTextIter, "forward_chars", forward_chars, 1);
492
+ rb_define_method(cTextIter, "backward_chars", backward_chars, 1);
493
+ rb_define_method(cTextIter, "forward_line", forward_line, 0);
494
+ rb_define_method(cTextIter, "backward_line", backward_line, 0);
495
+ rb_define_method(cTextIter, "forward_lines", forward_lines, 1);
496
+ rb_define_method(cTextIter, "backward_lines", backward_lines, 1);
497
+ rb_define_method(cTextIter, "forward_word_end", forward_word_end, 0);
498
+ rb_define_method(cTextIter, "backward_word_start", backward_word_start, 0);
499
+ rb_define_method(cTextIter, "forward_word_ends", forward_word_ends, 1);
500
+ rb_define_method(cTextIter, "backward_word_starts", backward_word_starts, 1);
501
+ rb_define_method(cTextIter, "forward_sentence_end", forward_sentence_end, 0);
502
+ rb_define_method(cTextIter, "backward_sentence_start", backward_sentence_start, 0);
503
+ rb_define_method(cTextIter, "forward_sentence_ends", forward_sentence_ends, 1);
504
+ rb_define_method(cTextIter, "backward_sentence_starts", backward_sentence_starts, 1);
505
+
506
+ #if GTK_CHECK_VERSION(2,4,0)
507
+ rb_define_method(cTextIter, "forward_visible_word_ends", forward_visible_word_ends, 1);
508
+ rb_define_method(cTextIter, "backward_visible_word_starts", backward_visible_word_starts, 1);
509
+ rb_define_method(cTextIter, "forward_visible_word_end", forward_visible_word_end, 0);
510
+ rb_define_method(cTextIter, "backword_visible_word_start", backward_visible_word_start, 0);
511
+ rb_define_method(cTextIter, "forward_visible_cursor_position", forward_visible_cursor_position, 0);
512
+ rb_define_method(cTextIter, "backward_visible_cursor_position", backward_visible_cursor_position, 0);
513
+ rb_define_method(cTextIter, "forward_visible_cursor_positions", forward_visible_cursor_positions, 1);
514
+ rb_define_method(cTextIter, "backward_visible_cursor_positions", backward_visible_cursor_positions, 1);
515
+ #endif
516
+ #if GTK_CHECK_VERSION(2,8,0)
517
+ rb_define_method(cTextIter, "forward_visible_line", forward_visible_line, 0);
518
+ rb_define_method(cTextIter, "backward_visible_line", backward_visible_line, 0);
519
+ rb_define_method(cTextIter, "forward_visible_lines", forward_visible_lines, 1);
520
+ rb_define_method(cTextIter, "backward_visible_lines", backward_visible_lines, 1);
521
+ #endif
522
+ rb_define_method(cTextIter, "forward_cursor_position", forward_cursor_position, 0);
523
+ rb_define_method(cTextIter, "backward_cursor_position", backward_cursor_position, 0);
524
+ rb_define_method(cTextIter, "forward_cursor_positions", forward_cursor_positions, 1);
525
+ rb_define_method(cTextIter, "backward_cursor_positions", backward_cursor_positions, 1);
526
+ rb_define_method(cTextIter, "forward_to_end", forward_to_end, 0);
527
+ rb_define_method(cTextIter, "forward_to_line_end", forward_to_line_end, 0);
528
+
529
+
530
+ rb_define_method(cTextIter, "set_offset", set_offset, 1);
531
+ rb_define_method(cTextIter, "set_line", set_line, 1);
532
+ rb_define_method(cTextIter, "set_line_offset", set_line_offset, 1);
533
+ rb_define_method(cTextIter, "set_line_index", set_line_index, 1);
534
+
535
+ rb_define_method(cTextIter, "set_visible_line_offset", set_visible_line_offset, 1);
536
+ rb_define_method(cTextIter, "set_visible_line_index", set_visible_line_index, 1);
537
+
538
+ rb_define_method(cTextIter, "forward_to_tag_toggle", forward_to_tag_toggle, -1);
539
+ rb_define_method(cTextIter, "backward_to_tag_toggle", backward_to_tag_toggle, -1);
540
+ rb_define_method(cTextIter, "forward_find_char", forward_find_char, -1);
541
+ rb_define_method(cTextIter, "backward_find_char", backward_find_char, -1);
542
+ rb_define_method(cTextIter, "forward_search", forward_search, -1);
543
+ rb_define_method(cTextIter, "backward_search", backward_search, -1);
544
+
545
+ rb_define_method(cTextIter, "==", equal, 1);
546
+ rb_define_method(cTextIter, "<=>", compare, 1);
547
+
548
+ G_DEF_SETTERS(cTextIter);
549
+
550
+ /* GtkTextSearchFlags */
551
+ G_DEF_CLASS(GTK_TYPE_TEXT_SEARCH_FLAGS, "SearchFlags", cTextIter);
552
+ G_DEF_CONSTANTS(cTextIter, GTK_TYPE_TEXT_SEARCH_FLAGS, "GTK_TEXT_");
553
+ }