gtk3 0.0.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (425) hide show
  1. data/Rakefile +32 -0
  2. data/ext/gtk3/conversions.c +34 -0
  3. data/ext/gtk3/depend +11 -0
  4. data/ext/gtk3/extconf.rb +108 -0
  5. data/ext/gtk3/gtk3.def +10 -0
  6. data/ext/gtk3/init.c +38 -0
  7. data/ext/gtk3/rbgdkdisplay.c +39 -0
  8. data/ext/gtk3/rbgdkdragcontext.c +108 -0
  9. data/ext/gtk3/rbgdkevent.c +38 -0
  10. data/ext/gtk3/rbgdkscreen.c +61 -0
  11. data/ext/gtk3/rbgtk.c +625 -0
  12. data/ext/gtk3/rbgtk3.h +57 -0
  13. data/ext/gtk3/rbgtk3conversions.h +347 -0
  14. data/ext/gtk3/rbgtk3private.h +282 -0
  15. data/ext/gtk3/rbgtk3util.c +67 -0
  16. data/ext/gtk3/rbgtk3util.h +32 -0
  17. data/ext/gtk3/rbgtkaboutdialog.c +117 -0
  18. data/ext/gtk3/rbgtkaccelerator.c +78 -0
  19. data/ext/gtk3/rbgtkaccelgroup.c +199 -0
  20. data/ext/gtk3/rbgtkaccelgroupentry.c +93 -0
  21. data/ext/gtk3/rbgtkaccelkey.c +119 -0
  22. data/ext/gtk3/rbgtkaccellabel.c +55 -0
  23. data/ext/gtk3/rbgtkaccelmap.c +135 -0
  24. data/ext/gtk3/rbgtkaccessible.c +56 -0
  25. data/ext/gtk3/rbgtkaction.c +205 -0
  26. data/ext/gtk3/rbgtkactiongroup.c +466 -0
  27. data/ext/gtk3/rbgtkactivatable.c +30 -0
  28. data/ext/gtk3/rbgtkadjustment.c +98 -0
  29. data/ext/gtk3/rbgtkalignment.c +75 -0
  30. data/ext/gtk3/rbgtkallocation.c +166 -0
  31. data/ext/gtk3/rbgtkappchooser.c +47 -0
  32. data/ext/gtk3/rbgtkappchooserbutton.c +70 -0
  33. data/ext/gtk3/rbgtkappchooserdialog.c +68 -0
  34. data/ext/gtk3/rbgtkappchooserwidget.c +40 -0
  35. data/ext/gtk3/rbgtkapplication.c +69 -0
  36. data/ext/gtk3/rbgtkarrow.c +56 -0
  37. data/ext/gtk3/rbgtkaspectframe.c +56 -0
  38. data/ext/gtk3/rbgtkassistant.c +218 -0
  39. data/ext/gtk3/rbgtkbin.c +42 -0
  40. data/ext/gtk3/rbgtkbindingset.c +164 -0
  41. data/ext/gtk3/rbgtkborder.c +119 -0
  42. data/ext/gtk3/rbgtkbox.c +146 -0
  43. data/ext/gtk3/rbgtkbuildable.c +96 -0
  44. data/ext/gtk3/rbgtkbuilder.c +166 -0
  45. data/ext/gtk3/rbgtkbutton.c +93 -0
  46. data/ext/gtk3/rbgtkbuttonbox.c +87 -0
  47. data/ext/gtk3/rbgtkcalendar.c +118 -0
  48. data/ext/gtk3/rbgtkcelleditable.c +57 -0
  49. data/ext/gtk3/rbgtkcelllayout.c +144 -0
  50. data/ext/gtk3/rbgtkcellrenderer.c +116 -0
  51. data/ext/gtk3/rbgtkcellrendereraccel.c +41 -0
  52. data/ext/gtk3/rbgtkcellrenderercombo.c +38 -0
  53. data/ext/gtk3/rbgtkcellrendererpixbuf.c +41 -0
  54. data/ext/gtk3/rbgtkcellrendererprogress.c +38 -0
  55. data/ext/gtk3/rbgtkcellrendererspin.c +39 -0
  56. data/ext/gtk3/rbgtkcellrendererspinner.c +38 -0
  57. data/ext/gtk3/rbgtkcellrenderertext.c +48 -0
  58. data/ext/gtk3/rbgtkcellrenderertoggle.c +39 -0
  59. data/ext/gtk3/rbgtkcellview.c +109 -0
  60. data/ext/gtk3/rbgtkcheckbutton.c +64 -0
  61. data/ext/gtk3/rbgtkcheckmenuitem.c +64 -0
  62. data/ext/gtk3/rbgtkclipboard.c +389 -0
  63. data/ext/gtk3/rbgtkcolorbutton.c +49 -0
  64. data/ext/gtk3/rbgtkcolorselection.c +219 -0
  65. data/ext/gtk3/rbgtkcolorselectiondialog.c +56 -0
  66. data/ext/gtk3/rbgtkcombobox.c +147 -0
  67. data/ext/gtk3/rbgtkcomboboxtext.c +138 -0
  68. data/ext/gtk3/rbgtkconst.c +79 -0
  69. data/ext/gtk3/rbgtkcontainer.c +784 -0
  70. data/ext/gtk3/rbgtkcssprovider.c +110 -0
  71. data/ext/gtk3/rbgtkdialog.c +186 -0
  72. data/ext/gtk3/rbgtkdrag.c +93 -0
  73. data/ext/gtk3/rbgtkdrawingarea.c +42 -0
  74. data/ext/gtk3/rbgtkeditable.c +149 -0
  75. data/ext/gtk3/rbgtkentry.c +198 -0
  76. data/ext/gtk3/rbgtkentrybuffer.c +87 -0
  77. data/ext/gtk3/rbgtkentrycompletion.c +122 -0
  78. data/ext/gtk3/rbgtkeventbox.c +42 -0
  79. data/ext/gtk3/rbgtkexpander.c +49 -0
  80. data/ext/gtk3/rbgtkfilechooser.c +384 -0
  81. data/ext/gtk3/rbgtkfilechooserbutton.c +50 -0
  82. data/ext/gtk3/rbgtkfilechooserdialog.c +62 -0
  83. data/ext/gtk3/rbgtkfilechooserwidget.c +40 -0
  84. data/ext/gtk3/rbgtkfilefilter.c +128 -0
  85. data/ext/gtk3/rbgtkfilesystemerror.c +48 -0
  86. data/ext/gtk3/rbgtkfixed.c +61 -0
  87. data/ext/gtk3/rbgtkfontbutton.c +49 -0
  88. data/ext/gtk3/rbgtkfontchooser.c +78 -0
  89. data/ext/gtk3/rbgtkfontchooserdialog.c +56 -0
  90. data/ext/gtk3/rbgtkfontchooserwidget.c +45 -0
  91. data/ext/gtk3/rbgtkframe.c +69 -0
  92. data/ext/gtk3/rbgtkgrid.c +105 -0
  93. data/ext/gtk3/rbgtkhandlebox.c +45 -0
  94. data/ext/gtk3/rbgtkhsv.c +102 -0
  95. data/ext/gtk3/rbgtkiconfactory.c +85 -0
  96. data/ext/gtk3/rbgtkiconinfo.c +115 -0
  97. data/ext/gtk3/rbgtkiconset.c +84 -0
  98. data/ext/gtk3/rbgtkiconsize.c +91 -0
  99. data/ext/gtk3/rbgtkiconsource.c +184 -0
  100. data/ext/gtk3/rbgtkicontheme.c +268 -0
  101. data/ext/gtk3/rbgtkiconview.c +270 -0
  102. data/ext/gtk3/rbgtkimage.c +96 -0
  103. data/ext/gtk3/rbgtkimagemenuitem.c +67 -0
  104. data/ext/gtk3/rbgtkimcontext.c +133 -0
  105. data/ext/gtk3/rbgtkimcontextsimple.c +69 -0
  106. data/ext/gtk3/rbgtkimmulticontext.c +48 -0
  107. data/ext/gtk3/rbgtkinfobar.c +121 -0
  108. data/ext/gtk3/rbgtkinvisible.c +49 -0
  109. data/ext/gtk3/rbgtklabel.c +139 -0
  110. data/ext/gtk3/rbgtklayout.c +93 -0
  111. data/ext/gtk3/rbgtklinkbutton.c +55 -0
  112. data/ext/gtk3/rbgtkliststore.c +408 -0
  113. data/ext/gtk3/rbgtklockbutton.c +50 -0
  114. data/ext/gtk3/rbgtkmenu.c +168 -0
  115. data/ext/gtk3/rbgtkmenubar.c +43 -0
  116. data/ext/gtk3/rbgtkmenuitem.c +95 -0
  117. data/ext/gtk3/rbgtkmenushell.c +106 -0
  118. data/ext/gtk3/rbgtkmenutoolbutton.c +81 -0
  119. data/ext/gtk3/rbgtkmessagedialog.c +74 -0
  120. data/ext/gtk3/rbgtkmisc.c +70 -0
  121. data/ext/gtk3/rbgtknotebook.c +383 -0
  122. data/ext/gtk3/rbgtknumerableicon.c +50 -0
  123. data/ext/gtk3/rbgtkorientable.c +27 -0
  124. data/ext/gtk3/rbgtkoverlay.c +53 -0
  125. data/ext/gtk3/rbgtkpagesetup.c +195 -0
  126. data/ext/gtk3/rbgtkpagesetupunixdialog.c +94 -0
  127. data/ext/gtk3/rbgtkpaned.c +114 -0
  128. data/ext/gtk3/rbgtkpapersize.c +179 -0
  129. data/ext/gtk3/rbgtkplug.c +85 -0
  130. data/ext/gtk3/rbgtkprintcontext.c +125 -0
  131. data/ext/gtk3/rbgtkprinter.c +155 -0
  132. data/ext/gtk3/rbgtkprintjob.c +148 -0
  133. data/ext/gtk3/rbgtkprintoperation.c +149 -0
  134. data/ext/gtk3/rbgtkprintoperationpreview.c +59 -0
  135. data/ext/gtk3/rbgtkprintsettings.c +807 -0
  136. data/ext/gtk3/rbgtkprintunixdialog.c +90 -0
  137. data/ext/gtk3/rbgtkprogressbar.c +72 -0
  138. data/ext/gtk3/rbgtkradioaction.c +122 -0
  139. data/ext/gtk3/rbgtkradiobutton.c +89 -0
  140. data/ext/gtk3/rbgtkradiomenuitem.c +147 -0
  141. data/ext/gtk3/rbgtkradiotoolbutton.c +131 -0
  142. data/ext/gtk3/rbgtkrange.c +68 -0
  143. data/ext/gtk3/rbgtkrecentaction.c +64 -0
  144. data/ext/gtk3/rbgtkrecentchooser.c +198 -0
  145. data/ext/gtk3/rbgtkrecentchooserdialog.c +66 -0
  146. data/ext/gtk3/rbgtkrecentchoosermenu.c +50 -0
  147. data/ext/gtk3/rbgtkrecentchooserwidget.c +48 -0
  148. data/ext/gtk3/rbgtkrecentdata.c +187 -0
  149. data/ext/gtk3/rbgtkrecentfilter.c +169 -0
  150. data/ext/gtk3/rbgtkrecentfilterinfo.c +200 -0
  151. data/ext/gtk3/rbgtkrecentinfo.c +213 -0
  152. data/ext/gtk3/rbgtkrecentmanager.c +134 -0
  153. data/ext/gtk3/rbgtkscale.c +97 -0
  154. data/ext/gtk3/rbgtkscalebutton.c +84 -0
  155. data/ext/gtk3/rbgtkscrollable.c +31 -0
  156. data/ext/gtk3/rbgtkscrollbar.c +52 -0
  157. data/ext/gtk3/rbgtkscrolledwindow.c +122 -0
  158. data/ext/gtk3/rbgtkselection.c +168 -0
  159. data/ext/gtk3/rbgtkselectiondata.c +282 -0
  160. data/ext/gtk3/rbgtkseparator.c +44 -0
  161. data/ext/gtk3/rbgtkseparatormenuitem.c +39 -0
  162. data/ext/gtk3/rbgtkseparatortoolitem.c +38 -0
  163. data/ext/gtk3/rbgtksettings.c +229 -0
  164. data/ext/gtk3/rbgtksizegroup.c +66 -0
  165. data/ext/gtk3/rbgtksocket.c +82 -0
  166. data/ext/gtk3/rbgtkspinbutton.c +132 -0
  167. data/ext/gtk3/rbgtkspinner.c +55 -0
  168. data/ext/gtk3/rbgtkstatusbar.c +77 -0
  169. data/ext/gtk3/rbgtkstatusicon.c +122 -0
  170. data/ext/gtk3/rbgtkstock.c +213 -0
  171. data/ext/gtk3/rbgtkstylecontext.c +411 -0
  172. data/ext/gtk3/rbgtkstyleproperties.c +119 -0
  173. data/ext/gtk3/rbgtkstyleprovider.c +68 -0
  174. data/ext/gtk3/rbgtkswitch.c +40 -0
  175. data/ext/gtk3/rbgtktable.c +190 -0
  176. data/ext/gtk3/rbgtktargetlist.c +125 -0
  177. data/ext/gtk3/rbgtktearoffmenuitem.c +41 -0
  178. data/ext/gtk3/rbgtktextappearance.c +236 -0
  179. data/ext/gtk3/rbgtktextattributes.c +326 -0
  180. data/ext/gtk3/rbgtktextbuffer.c +899 -0
  181. data/ext/gtk3/rbgtktextchildanchor.c +56 -0
  182. data/ext/gtk3/rbgtktextiter.c +732 -0
  183. data/ext/gtk3/rbgtktextmark.c +71 -0
  184. data/ext/gtk3/rbgtktexttag.c +68 -0
  185. data/ext/gtk3/rbgtktexttagtable.c +96 -0
  186. data/ext/gtk3/rbgtktextview.c +336 -0
  187. data/ext/gtk3/rbgtkthemingengine.c +257 -0
  188. data/ext/gtk3/rbgtktoggleaction.c +61 -0
  189. data/ext/gtk3/rbgtktogglebutton.c +87 -0
  190. data/ext/gtk3/rbgtktoggletoolbutton.c +61 -0
  191. data/ext/gtk3/rbgtktoolbar.c +118 -0
  192. data/ext/gtk3/rbgtktoolbutton.c +66 -0
  193. data/ext/gtk3/rbgtktoolitem.c +200 -0
  194. data/ext/gtk3/rbgtktoolitemgroup.c +70 -0
  195. data/ext/gtk3/rbgtktoolshell.c +96 -0
  196. data/ext/gtk3/rbgtktooltip.c +100 -0
  197. data/ext/gtk3/rbgtktreedragdest.c +28 -0
  198. data/ext/gtk3/rbgtktreedragsource.c +28 -0
  199. data/ext/gtk3/rbgtktreeiter.c +258 -0
  200. data/ext/gtk3/rbgtktreemodel.c +236 -0
  201. data/ext/gtk3/rbgtktreemodelfilter.c +197 -0
  202. data/ext/gtk3/rbgtktreemodelsort.c +111 -0
  203. data/ext/gtk3/rbgtktreepath.c +191 -0
  204. data/ext/gtk3/rbgtktreerowreference.c +140 -0
  205. data/ext/gtk3/rbgtktreeselection.c +205 -0
  206. data/ext/gtk3/rbgtktreesortable.c +122 -0
  207. data/ext/gtk3/rbgtktreestore.c +330 -0
  208. data/ext/gtk3/rbgtktreeview.c +715 -0
  209. data/ext/gtk3/rbgtktreeviewcolumn.c +256 -0
  210. data/ext/gtk3/rbgtkuimanager.c +189 -0
  211. data/ext/gtk3/rbgtkviewport.c +44 -0
  212. data/ext/gtk3/rbgtkvolumebutton.c +41 -0
  213. data/ext/gtk3/rbgtkwidget.c +1564 -0
  214. data/ext/gtk3/rbgtkwidgetpath.c +229 -0
  215. data/ext/gtk3/rbgtkwindow.c +557 -0
  216. data/ext/gtk3/rbgtkwindowgroup.c +80 -0
  217. data/extconf.rb +49 -0
  218. data/lib/gtk3.rb +10 -0
  219. data/lib/gtk3/base.rb +67 -0
  220. data/lib/gtk3/deprecated.rb +1001 -0
  221. data/sample/gtk-demo/README +7 -0
  222. data/sample/gtk-demo/alphatest.png +0 -0
  223. data/sample/gtk-demo/apple-red.png +0 -0
  224. data/sample/gtk-demo/appwindow.rb +233 -0
  225. data/sample/gtk-demo/background.jpg +0 -0
  226. data/sample/gtk-demo/builder.rb +51 -0
  227. data/sample/gtk-demo/button_box.rb +84 -0
  228. data/sample/gtk-demo/cairo-arc-negative.rb +41 -0
  229. data/sample/gtk-demo/cairo-arc.rb +41 -0
  230. data/sample/gtk-demo/cairo-clip-image.rb +51 -0
  231. data/sample/gtk-demo/cairo-clip-rectangle.rb +35 -0
  232. data/sample/gtk-demo/cairo-clip.rb +35 -0
  233. data/sample/gtk-demo/cairo-curve-rectangle.rb +76 -0
  234. data/sample/gtk-demo/cairo-curve-to.rb +43 -0
  235. data/sample/gtk-demo/cairo-dash.rb +39 -0
  236. data/sample/gtk-demo/cairo-fill-and-stroke.rb +32 -0
  237. data/sample/gtk-demo/cairo-fill-and-stroke2.rb +38 -0
  238. data/sample/gtk-demo/cairo-gradient.rb +35 -0
  239. data/sample/gtk-demo/cairo-image-pattern.rb +39 -0
  240. data/sample/gtk-demo/cairo-image.rb +49 -0
  241. data/sample/gtk-demo/cairo-line-cap.rb +53 -0
  242. data/sample/gtk-demo/cairo-line-join.rb +41 -0
  243. data/sample/gtk-demo/cairo-long-lines.rb +41 -0
  244. data/sample/gtk-demo/cairo-operator.rb +83 -0
  245. data/sample/gtk-demo/cairo-path.rb +28 -0
  246. data/sample/gtk-demo/cairo-pattern-fill.rb +88 -0
  247. data/sample/gtk-demo/cairo-self-intersect.rb +32 -0
  248. data/sample/gtk-demo/cairo-text-align-center.rb +45 -0
  249. data/sample/gtk-demo/cairo-text-extents.rb +46 -0
  250. data/sample/gtk-demo/cairo-text.rb +43 -0
  251. data/sample/gtk-demo/changedisplay.rb +408 -0
  252. data/sample/gtk-demo/clipboard.rb +72 -0
  253. data/sample/gtk-demo/colorsel.rb +84 -0
  254. data/sample/gtk-demo/common.rb +88 -0
  255. data/sample/gtk-demo/demo.ui +258 -0
  256. data/sample/gtk-demo/dialog.rb +137 -0
  257. data/sample/gtk-demo/drawingarea.rb +226 -0
  258. data/sample/gtk-demo/editable_cells.rb +172 -0
  259. data/sample/gtk-demo/entry_completion.rb +63 -0
  260. data/sample/gtk-demo/expander.rb +40 -0
  261. data/sample/gtk-demo/floppybuddy.gif +0 -0
  262. data/sample/gtk-demo/gnome-applets.png +0 -0
  263. data/sample/gtk-demo/gnome-calendar.png +0 -0
  264. data/sample/gtk-demo/gnome-foot.png +0 -0
  265. data/sample/gtk-demo/gnome-fs-directory.png +0 -0
  266. data/sample/gtk-demo/gnome-fs-regular.png +0 -0
  267. data/sample/gtk-demo/gnome-gimp.png +0 -0
  268. data/sample/gtk-demo/gnome-gmush.png +0 -0
  269. data/sample/gtk-demo/gnome-gsame.png +0 -0
  270. data/sample/gtk-demo/gnu-keys.png +0 -0
  271. data/sample/gtk-demo/gtk-logo-rgb.gif +0 -0
  272. data/sample/gtk-demo/hypertext.rb +211 -0
  273. data/sample/gtk-demo/iconview.rb +109 -0
  274. data/sample/gtk-demo/images.rb +197 -0
  275. data/sample/gtk-demo/item_factory.rb +94 -0
  276. data/sample/gtk-demo/list_store.rb +138 -0
  277. data/sample/gtk-demo/main.rb +382 -0
  278. data/sample/gtk-demo/menus.rb +172 -0
  279. data/sample/gtk-demo/panes.rb +156 -0
  280. data/sample/gtk-demo/pixbufs.rb +176 -0
  281. data/sample/gtk-demo/printing.rb +128 -0
  282. data/sample/gtk-demo/rotated_text.rb +84 -0
  283. data/sample/gtk-demo/ruby-gnome2-logo.png +0 -0
  284. data/sample/gtk-demo/sizegroup.rb +118 -0
  285. data/sample/gtk-demo/stock_browser.rb +235 -0
  286. data/sample/gtk-demo/textview.rb +436 -0
  287. data/sample/gtk-demo/tree_store.rb +270 -0
  288. data/sample/misc/aboutdialog.rb +42 -0
  289. data/sample/misc/aboutdialog2.rb +42 -0
  290. data/sample/misc/alpha-demo.rb +70 -0
  291. data/sample/misc/assistant.rb +347 -0
  292. data/sample/misc/bindings.rb +107 -0
  293. data/sample/misc/button.rb +69 -0
  294. data/sample/misc/button2.rb +28 -0
  295. data/sample/misc/buttonbox.rb +93 -0
  296. data/sample/misc/cairo-pong.rb +215 -0
  297. data/sample/misc/calendar.rb +66 -0
  298. data/sample/misc/checkbutton.rb +46 -0
  299. data/sample/misc/colorselection.rb +25 -0
  300. data/sample/misc/combo_check.rb +71 -0
  301. data/sample/misc/combobox.rb +86 -0
  302. data/sample/misc/composited-windows.rb +113 -0
  303. data/sample/misc/cursor.rb +32 -0
  304. data/sample/misc/dialog.rb +44 -0
  305. data/sample/misc/dialog2.rb +39 -0
  306. data/sample/misc/dnd.rb +64 -0
  307. data/sample/misc/dndtreeview.rb +56 -0
  308. data/sample/misc/drag-move.rb +131 -0
  309. data/sample/misc/drawing.rb +90 -0
  310. data/sample/misc/entry.rb +34 -0
  311. data/sample/misc/entrycompletion.rb +33 -0
  312. data/sample/misc/expander.rb +27 -0
  313. data/sample/misc/filechooser.rb +41 -0
  314. data/sample/misc/frame.rb +69 -0
  315. data/sample/misc/gdkscreen.rb +32 -0
  316. data/sample/misc/gnome-logo-icon.png +0 -0
  317. data/sample/misc/helloworld.rb +35 -0
  318. data/sample/misc/iconview.rb +38 -0
  319. data/sample/misc/image.rb +42 -0
  320. data/sample/misc/itemfactory.rb +73 -0
  321. data/sample/misc/itemfactory2.rb +74 -0
  322. data/sample/misc/keyboard_grab.rb +29 -0
  323. data/sample/misc/label.rb +33 -0
  324. data/sample/misc/linkbutton.rb +42 -0
  325. data/sample/misc/listview.rb +92 -0
  326. data/sample/misc/menu.rb +81 -0
  327. data/sample/misc/misc_button.rb +49 -0
  328. data/sample/misc/mouse-gesture.rb +465 -0
  329. data/sample/misc/pangorenderer.rb +66 -0
  330. data/sample/misc/pointer_grab.rb +34 -0
  331. data/sample/misc/print.rb +247 -0
  332. data/sample/misc/properties.rb +85 -0
  333. data/sample/misc/radiobutton.rb +47 -0
  334. data/sample/misc/recentchooserdialog.rb +52 -0
  335. data/sample/misc/rgtk+cairo.rb +42 -0
  336. data/sample/misc/scalebutton.rb +19 -0
  337. data/sample/misc/settings.rb +41 -0
  338. data/sample/misc/statusicon.rb +123 -0
  339. data/sample/misc/stock.rb +36 -0
  340. data/sample/misc/style_property.rb +67 -0
  341. data/sample/misc/style_property.rc +19 -0
  342. data/sample/misc/t-gtkplug.rb +58 -0
  343. data/sample/misc/t-gtksocket.rb +65 -0
  344. data/sample/misc/test.xpm +92 -0
  345. data/sample/misc/textbuffer_serialize.rb +130 -0
  346. data/sample/misc/threads.rb +72 -0
  347. data/sample/misc/to_drawable.rb +42 -0
  348. data/sample/misc/togglebutton.rb +34 -0
  349. data/sample/misc/toolbar.rb +55 -0
  350. data/sample/misc/tooltips.rb +204 -0
  351. data/sample/misc/tree_combo.rb +79 -0
  352. data/sample/misc/tree_progress.rb +63 -0
  353. data/sample/misc/treemodelfilter.rb +49 -0
  354. data/sample/misc/treeview.rb +71 -0
  355. data/sample/misc/uimanager.rb +148 -0
  356. data/sample/misc/uimanager2.rb +91 -0
  357. data/sample/misc/uimanager2.xml +36 -0
  358. data/sample/misc/window.rb +24 -0
  359. data/sample/misc/xbm_cursor.rb +43 -0
  360. data/sample/testgtk/3DRings.xpm +116 -0
  361. data/sample/testgtk/FilesQueue.xpm +98 -0
  362. data/sample/testgtk/Modeller.xpm +117 -0
  363. data/sample/testgtk/README +14 -0
  364. data/sample/testgtk/button.rb +124 -0
  365. data/sample/testgtk/buttonbox.rb +100 -0
  366. data/sample/testgtk/check-n.xpm +21 -0
  367. data/sample/testgtk/check-y.xpm +21 -0
  368. data/sample/testgtk/checkbutton.rb +67 -0
  369. data/sample/testgtk/circles.xbm +46 -0
  370. data/sample/testgtk/colorselect.rb +33 -0
  371. data/sample/testgtk/dialog.rb +48 -0
  372. data/sample/testgtk/entry.rb +73 -0
  373. data/sample/testgtk/filesel.rb +65 -0
  374. data/sample/testgtk/fontselection.rb +56 -0
  375. data/sample/testgtk/labels.rb +74 -0
  376. data/sample/testgtk/layout.rb +108 -0
  377. data/sample/testgtk/marble.xpm +408 -0
  378. data/sample/testgtk/menu.rb +79 -0
  379. data/sample/testgtk/notebook.rb +280 -0
  380. data/sample/testgtk/pixmap.rb +58 -0
  381. data/sample/testgtk/progressbar.rb +173 -0
  382. data/sample/testgtk/radiobutton.rb +61 -0
  383. data/sample/testgtk/range.rb +65 -0
  384. data/sample/testgtk/reparent.rb +91 -0
  385. data/sample/testgtk/sample.rb +80 -0
  386. data/sample/testgtk/savedposition.rb +87 -0
  387. data/sample/testgtk/scrolledwindow.rb +67 -0
  388. data/sample/testgtk/shapedwindow.rb +99 -0
  389. data/sample/testgtk/spinbutton.rb +181 -0
  390. data/sample/testgtk/statusbar.rb +89 -0
  391. data/sample/testgtk/test.xpm +92 -0
  392. data/sample/testgtk/testgtk.rb +176 -0
  393. data/sample/testgtk/testgtkrc +146 -0
  394. data/sample/testgtk/testgtkrc2 +21 -0
  395. data/sample/testgtk/togglebutton.rb +53 -0
  396. data/sample/testgtk/toolbar.rb +82 -0
  397. data/sample/testgtk/tooltips.rb +41 -0
  398. data/sample/testgtk/wmhints.rb +40 -0
  399. data/test/gtk-test-utils.rb +15 -0
  400. data/test/run-test.rb +32 -0
  401. data/test/test_gc.rb +25 -0
  402. data/test/test_gdk.rb +18 -0
  403. data/test/test_gdk_color.rb +10 -0
  404. data/test/test_gdk_display.rb +37 -0
  405. data/test/test_gdk_event.rb +11 -0
  406. data/test/test_gdk_gc.rb +7 -0
  407. data/test/test_gdk_keymap.rb +8 -0
  408. data/test/test_gdk_pango.rb +9 -0
  409. data/test/test_gdk_selection_data.rb +17 -0
  410. data/test/test_gdk_window.rb +29 -0
  411. data/test/test_gdk_window_attribute.rb +9 -0
  412. data/test/test_gtk_about_dialog.rb +14 -0
  413. data/test/test_gtk_buildable.rb +66 -0
  414. data/test/test_gtk_builder.rb +188 -0
  415. data/test/test_gtk_entry.rb +18 -0
  416. data/test/test_gtk_icon_theme.rb +30 -0
  417. data/test/test_gtk_image.rb +8 -0
  418. data/test/test_gtk_list_store.rb +65 -0
  419. data/test/test_gtk_menu_item.rb +13 -0
  420. data/test/test_gtk_rc_style.rb +14 -0
  421. data/test/test_gtk_tree_path.rb +20 -0
  422. data/test/test_gtk_unix_print.rb +14 -0
  423. data/test/test_gtk_widget.rb +32 -0
  424. metadata +553 -94
  425. data/LICENSE +0 -19
@@ -0,0 +1,138 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
+ * MA 02110-1301 USA
19
+ */
20
+
21
+ #include "rbgtk3private.h"
22
+
23
+ #define RG_TARGET_NAMESPACE cComboBoxText
24
+ #define _SELF(self) (RVAL2GTKCOMBOBOXTEXT(self))
25
+
26
+ static VALUE
27
+ rg_initialize(int argc, VALUE *argv, VALUE self)
28
+ {
29
+ VALUE options, entry;
30
+ GtkWidget *widget = NULL;
31
+
32
+ rb_scan_args(argc, argv, "01", &options);
33
+ rbg_scan_options(options,
34
+ "entry", &entry,
35
+ NULL);
36
+
37
+ if (RVAL2CBOOL(entry))
38
+ widget = gtk_combo_box_text_new_with_entry();
39
+ else
40
+ widget = gtk_combo_box_text_new();
41
+ RBGTK_INITIALIZE(self, widget);
42
+
43
+ return Qnil;
44
+ }
45
+
46
+ static VALUE
47
+ rg_append(VALUE self, VALUE id, VALUE text)
48
+ {
49
+ gtk_combo_box_text_append(_SELF(self),
50
+ RVAL2CSTR_ACCEPT_NIL(id),
51
+ RVAL2CSTR(text));
52
+
53
+ return self;
54
+ }
55
+
56
+ static VALUE
57
+ rg_append_text(VALUE self, VALUE text)
58
+ {
59
+ gtk_combo_box_text_append_text(_SELF(self), RVAL2CSTR(text));
60
+
61
+ return self;
62
+ }
63
+
64
+ static VALUE
65
+ rg_active_text(VALUE self)
66
+ {
67
+ return CSTR2RVAL_FREE(gtk_combo_box_text_get_active_text(_SELF(self)));
68
+ }
69
+
70
+ static VALUE
71
+ rg_insert(VALUE self, VALUE position, VALUE id, VALUE text)
72
+ {
73
+ gtk_combo_box_text_insert(_SELF(self),
74
+ NUM2INT(position),
75
+ RVAL2CSTR_ACCEPT_NIL(id),
76
+ RVAL2CSTR(text));
77
+
78
+ return self;
79
+ }
80
+
81
+ static VALUE
82
+ rg_insert_text(VALUE self, VALUE position, VALUE text)
83
+ {
84
+ gtk_combo_box_text_insert_text(_SELF(self), NUM2INT(position), RVAL2CSTR(text));
85
+
86
+ return self;
87
+ }
88
+
89
+ static VALUE
90
+ rg_prepend(VALUE self, VALUE id, VALUE text)
91
+ {
92
+ gtk_combo_box_text_prepend(_SELF(self),
93
+ RVAL2CSTR_ACCEPT_NIL(id),
94
+ RVAL2CSTR(text));
95
+
96
+ return self;
97
+ }
98
+
99
+ static VALUE
100
+ rg_prepend_text(VALUE self, VALUE text)
101
+ {
102
+ gtk_combo_box_text_prepend_text(_SELF(self), RVAL2CSTR(text));
103
+
104
+ return self;
105
+ }
106
+
107
+ static VALUE
108
+ rg_remove(VALUE self, VALUE position)
109
+ {
110
+ gtk_combo_box_text_remove(_SELF(self), NUM2INT(position));
111
+
112
+ return self;
113
+ }
114
+
115
+ static VALUE
116
+ rg_remove_all(VALUE self)
117
+ {
118
+ gtk_combo_box_text_remove_all(_SELF(self));
119
+
120
+ return self;
121
+ }
122
+
123
+ void
124
+ Init_gtk_comboboxtext(VALUE mGtk)
125
+ {
126
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GTK_TYPE_COMBO_BOX_TEXT, "ComboBoxText", mGtk);
127
+
128
+ RG_DEF_METHOD(initialize, -1);
129
+ RG_DEF_METHOD(append, 2);
130
+ RG_DEF_METHOD(append_text, 1);
131
+ RG_DEF_METHOD(active_text, 0);
132
+ RG_DEF_METHOD(insert, 3);
133
+ RG_DEF_METHOD(insert_text, 2);
134
+ RG_DEF_METHOD(prepend, 2);
135
+ RG_DEF_METHOD(prepend_text, 1);
136
+ RG_DEF_METHOD(remove, 1);
137
+ RG_DEF_METHOD(remove_all, 0);
138
+ }
@@ -0,0 +1,79 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
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
+ */
24
+
25
+ #include "rbgtk3private.h"
26
+
27
+ void
28
+ Init_gtk_const(VALUE mGtk)
29
+ {
30
+ rb_define_const(mGtk, "BINDING_VERSION",
31
+ rb_ary_new3(3, INT2FIX(RBGTK_MAJOR_VERSION),
32
+ INT2FIX(RBGTK_MINOR_VERSION),
33
+ INT2FIX(RBGTK_MICRO_VERSION)));
34
+
35
+ rb_define_const(mGtk, "BUILD_VERSION",
36
+ rb_ary_new3(3, INT2FIX(GTK_MAJOR_VERSION),
37
+ INT2FIX(GTK_MINOR_VERSION),
38
+ INT2FIX(GTK_MICRO_VERSION)));
39
+
40
+ rb_define_const(mGtk, "VERSION",
41
+ rb_ary_new3(3, INT2FIX(gtk_major_version),
42
+ INT2FIX(gtk_minor_version),
43
+ INT2FIX(gtk_micro_version)));
44
+ rb_define_const(mGtk, "MAJOR_VERSION", INT2FIX(gtk_major_version));
45
+ rb_define_const(mGtk, "MINOR_VERSION", INT2FIX(gtk_minor_version));
46
+ rb_define_const(mGtk, "MICRO_VERSION", INT2FIX(gtk_micro_version));
47
+ rb_define_const(mGtk, "BINARY_AGE", INT2FIX(gtk_binary_age));
48
+ rb_define_const(mGtk, "INTERFACE_AGE", INT2FIX(gtk_interface_age));
49
+
50
+ G_DEF_CLASS(GTK_TYPE_ACCEL_FLAGS, "AccelFlags", mGtk);
51
+ G_DEF_CLASS(GTK_TYPE_ATTACH_OPTIONS, "AttachOptions", mGtk);
52
+ G_DEF_CLASS(GTK_TYPE_CORNER_TYPE, "CornerType", mGtk);
53
+ G_DEF_CLASS(GTK_TYPE_DELETE_TYPE, "DeleteType", mGtk);
54
+ G_DEF_CLASS(GTK_TYPE_DIRECTION_TYPE, "DirectionType", mGtk);
55
+ G_DEF_CLASS(GTK_TYPE_EXPANDER_STYLE, "ExpanderStyle", mGtk);
56
+ G_DEF_CLASS(GTK_TYPE_JUSTIFICATION, "Justification", mGtk);
57
+ G_DEF_CLASS(GTK_TYPE_MESSAGE_TYPE, "MessageType", mGtk);
58
+ G_DEF_CLASS(GTK_TYPE_MOVEMENT_STEP, "MovementStep", mGtk);
59
+ G_DEF_CLASS(GTK_TYPE_ORIENTATION, "Orientation", mGtk);
60
+ G_DEF_CLASS(GTK_TYPE_PACK_TYPE, "PackType", mGtk);
61
+ G_DEF_CLASS(GTK_TYPE_PATH_PRIORITY_TYPE, "PathPriorityType", mGtk);
62
+ G_DEF_CLASS(GTK_TYPE_PATH_TYPE, "PathType", mGtk);
63
+ G_DEF_CLASS(GTK_TYPE_POLICY_TYPE, "PolicyType", mGtk);
64
+ G_DEF_CLASS(GTK_TYPE_POSITION_TYPE, "PositionType", mGtk);
65
+ G_DEF_CLASS(GTK_TYPE_RELIEF_STYLE, "ReliefStyle", mGtk);
66
+ G_DEF_CLASS(GTK_TYPE_RESIZE_MODE, "ResizeMode", mGtk);
67
+ G_DEF_CLASS(GTK_TYPE_RESPONSE_TYPE, "ResponseType", mGtk);
68
+ G_DEF_CLASS(GTK_TYPE_SCROLL_STEP, "ScrollStep", mGtk);
69
+ G_DEF_CLASS(GTK_TYPE_SCROLL_TYPE, "ScrollType", mGtk);
70
+ G_DEF_CLASS(GTK_TYPE_SELECTION_MODE, "SelectionMode", mGtk);
71
+ G_DEF_CLASS(GTK_TYPE_SHADOW_TYPE, "ShadowType", mGtk);
72
+ G_DEF_CLASS(GTK_TYPE_STATE_FLAGS, "StateFlags", mGtk);
73
+ G_DEF_CLASS(GTK_TYPE_STATE_TYPE, "StateType", mGtk);
74
+ /* deprecated
75
+ G_DEF_CLASS(GTK_TYPE_SUBMENU_DIRECTION, "SubmenuDirection", mGtk);
76
+ G_DEF_CLASS(GTK_TYPE_SUBMENU_PLACEMENT, "SubmenuPlacement", mGtk);
77
+ */
78
+ G_DEF_CLASS(GTK_TYPE_SORT_TYPE, "SortType", mGtk);
79
+ }
@@ -0,0 +1,784 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002-2006 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
+ */
24
+
25
+ #include "rbgtk3private.h"
26
+
27
+ #define RG_TARGET_NAMESPACE cContainer
28
+ #define _SELF(self) (RVAL2GTKCONTAINER(self))
29
+
30
+ #define RubyGtkContainerHookModule "RubyGtkContainerHook__"
31
+
32
+ /*
33
+ We don't need this.
34
+ #define GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec)
35
+ */
36
+
37
+ static VALUE type_to_prop_setter_table;
38
+ static VALUE type_to_prop_getter_table;
39
+
40
+ static VALUE
41
+ rg_resize_container_p(VALUE self)
42
+ {
43
+ return CBOOL2RVAL(GTK_IS_RESIZE_CONTAINER(_SELF(self)));
44
+ }
45
+
46
+ static VALUE
47
+ rg_remove(VALUE self, VALUE other)
48
+ {
49
+ G_CHILD_REMOVE(self, other);
50
+ gtk_container_remove(_SELF(self), RVAL2GTKWIDGET(other));
51
+ return self;
52
+ }
53
+
54
+ static VALUE
55
+ rg_check_resize(VALUE self)
56
+ {
57
+ gtk_container_check_resize(_SELF(self));
58
+ return self;
59
+ }
60
+
61
+ static VALUE
62
+ rg_each(int argc, VALUE *argv, VALUE self)
63
+ {
64
+ VALUE callback;
65
+
66
+ rb_scan_args(argc, argv, "01", &callback);
67
+ if (NIL_P(callback)) {
68
+ callback = rb_block_proc();
69
+ }
70
+ gtk_container_foreach(_SELF(self), exec_callback, (gpointer)callback);
71
+ return self;
72
+ }
73
+
74
+ static VALUE
75
+ rg_each_forall(int argc, VALUE *argv, VALUE self)
76
+ {
77
+ VALUE callback;
78
+
79
+ rb_scan_args(argc, argv, "01", &callback);
80
+ if (NIL_P(callback)) {
81
+ callback = rb_block_proc();
82
+ }
83
+ gtk_container_forall(_SELF(self), exec_callback, (gpointer)callback);
84
+ return self;
85
+ }
86
+
87
+ static VALUE
88
+ rg_children(VALUE self)
89
+ {
90
+ return GOBJGLIST2RVAL_FREE(gtk_container_get_children(_SELF(self)),
91
+ g_list_free, NULL);
92
+ }
93
+
94
+ static VALUE
95
+ rg_set_reallocate_redraws(VALUE self, VALUE needs_redraws)
96
+ {
97
+ gtk_container_set_reallocate_redraws(_SELF(self), RVAL2CBOOL(needs_redraws));
98
+ return self;
99
+ }
100
+
101
+ static VALUE
102
+ rg_set_focus_child(VALUE self, VALUE child)
103
+ {
104
+ gtk_container_set_focus_child(_SELF(self), RVAL2GTKWIDGET(child));
105
+ return self;
106
+ }
107
+
108
+ static VALUE
109
+ rg_set_focus_vadjustment(VALUE self, VALUE adjustment)
110
+ {
111
+ gtk_container_set_focus_vadjustment(_SELF(self),
112
+ NIL_P(adjustment) ? NULL : RVAL2GTKADJUSTMENT(adjustment));
113
+ return self;
114
+ }
115
+
116
+ static VALUE
117
+ rg_set_focus_hadjustment(VALUE self, VALUE adjustment)
118
+ {
119
+ gtk_container_set_focus_hadjustment(_SELF(self),
120
+ NIL_P(adjustment) ? NULL : RVAL2GTKADJUSTMENT(adjustment));
121
+ return self;
122
+ }
123
+
124
+ static VALUE
125
+ rg_focus_vadjustment(VALUE self)
126
+ {
127
+ return GOBJ2RVAL(gtk_container_get_focus_vadjustment(_SELF(self)));
128
+ }
129
+
130
+ static VALUE
131
+ rg_focus_hadjustment(VALUE self)
132
+ {
133
+ return GOBJ2RVAL(gtk_container_get_focus_hadjustment(_SELF(self)));
134
+ }
135
+
136
+ static VALUE
137
+ rg_resize_children(VALUE self)
138
+ {
139
+ gtk_container_resize_children(_SELF(self));
140
+ return self;
141
+ }
142
+
143
+ static VALUE
144
+ rg_child_type(VALUE self)
145
+ {
146
+ return GTYPE2CLASS(gtk_container_child_type(_SELF(self)));
147
+ }
148
+
149
+ /*
150
+ void gtk_container_child_get (GtkContainer *container,
151
+ GtkWidget *child,
152
+ const gchar *first_prop_name,
153
+ ...);
154
+ void gtk_container_child_set (GtkContainer *container,
155
+ GtkWidget *child,
156
+ const gchar *first_prop_name,
157
+ ...);
158
+ */
159
+
160
+ static void
161
+ rbgtkcontainer_register_child_property_setter(GType gtype, const char *name, RValueToGValueFunc func)
162
+ {
163
+ GObjectClass* oclass;
164
+ GParamSpec* pspec;
165
+
166
+ VALUE table = rb_hash_aref(type_to_prop_setter_table, INT2FIX(gtype));
167
+ if (NIL_P(table)){
168
+ table = rb_hash_new();
169
+ rb_hash_aset(type_to_prop_setter_table, INT2FIX(gtype), table);
170
+ }
171
+
172
+ oclass = g_type_class_ref(gtype);
173
+ pspec = gtk_container_class_find_child_property(oclass, name);
174
+
175
+ rb_hash_aset(table, rb_intern(g_param_spec_get_name(pspec)),
176
+ Data_Wrap_Struct(rb_cData, NULL, NULL, func));
177
+
178
+ g_type_class_unref(oclass);
179
+ }
180
+
181
+ static void
182
+ rbgtkcontainer_register_child_property_getter(GType gtype, const char *name, GValueToRValueFunc func)
183
+ {
184
+ GObjectClass* oclass;
185
+ GParamSpec* pspec;
186
+
187
+ VALUE table = rb_hash_aref(type_to_prop_getter_table, INT2FIX(gtype));
188
+ if (NIL_P(table)){
189
+ table = rb_hash_new();
190
+ rb_hash_aset(type_to_prop_getter_table, INT2FIX(gtype), table);
191
+ }
192
+
193
+ oclass = g_type_class_ref(gtype);
194
+ pspec = gtk_container_class_find_child_property(oclass, name);
195
+
196
+ rb_hash_aset(table, rb_intern(g_param_spec_get_name(pspec)),
197
+ Data_Wrap_Struct(rb_cData, NULL, NULL, func));
198
+ }
199
+
200
+ static VALUE
201
+ rg_child_get_property(VALUE self, VALUE child, VALUE prop_name)
202
+ {
203
+ GParamSpec* pspec;
204
+ const char* name;
205
+
206
+ if (SYMBOL_P(prop_name)) {
207
+ name = rb_id2name(SYM2ID(prop_name));
208
+ } else {
209
+ name = RVAL2CSTR(prop_name);
210
+ }
211
+
212
+ pspec = gtk_container_class_find_child_property(
213
+ G_OBJECT_GET_CLASS(RVAL2GOBJ(self)), name);
214
+
215
+ if (!pspec)
216
+ rb_raise(rb_eArgError, "No such property: %s", name);
217
+ else {
218
+ GValueToRValueFunc getter = NULL;
219
+ GValue gval = G_VALUE_INIT;
220
+ VALUE ret;
221
+
222
+ {
223
+ VALUE table = rb_hash_aref(type_to_prop_getter_table,
224
+ INT2FIX(pspec->owner_type));
225
+ if (!NIL_P(table)){
226
+ VALUE obj = rb_hash_aref(table, rb_intern(g_param_spec_get_name(pspec)));
227
+ if (!NIL_P(obj))
228
+ Data_Get_Struct(obj, void, getter);
229
+ }
230
+ }
231
+ g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec));
232
+ gtk_container_child_get_property(RVAL2GTKCONTAINER(self),
233
+ RVAL2GTKWIDGET(child),
234
+ name , &gval);
235
+ ret = getter ? getter(&gval) : GVAL2RVAL(&gval);
236
+
237
+ G_CHILD_ADD(child, ret);
238
+
239
+ g_value_unset(&gval);
240
+ return ret;
241
+ }
242
+ }
243
+
244
+ static VALUE
245
+ rg_child_set_property(VALUE self, VALUE child, VALUE prop_name, VALUE val)
246
+ {
247
+ GParamSpec* pspec;
248
+ const char* name;
249
+
250
+ if (SYMBOL_P(prop_name)) {
251
+ name = rb_id2name(SYM2ID(prop_name));
252
+ } else {
253
+ name = RVAL2CSTR(prop_name);
254
+ }
255
+
256
+ pspec = gtk_container_class_find_child_property(
257
+ G_OBJECT_GET_CLASS(RVAL2GOBJ(self)), name);
258
+
259
+ if (!pspec)
260
+ rb_raise(rb_eArgError, "No such property: %s", name);
261
+ else {
262
+ RValueToGValueFunc setter = NULL;
263
+ GValue gval = G_VALUE_INIT;
264
+ g_value_init(&gval, G_PARAM_SPEC_VALUE_TYPE(pspec));
265
+
266
+ {
267
+ VALUE table = rb_hash_aref(type_to_prop_setter_table,
268
+ INT2FIX(pspec->owner_type));
269
+ if (!NIL_P(table)){
270
+ VALUE obj = rb_hash_aref(table, rb_intern(g_param_spec_get_name(pspec)));
271
+ if (!NIL_P(obj))
272
+ Data_Get_Struct(obj, void, setter);
273
+ }
274
+ }
275
+
276
+ if (setter)
277
+ setter(val, &gval);
278
+ else {
279
+ if (!NIL_P(val))
280
+ rbgobj_rvalue_to_gvalue(val, &gval);
281
+ }
282
+
283
+ G_CHILD_ADD(child, val);
284
+
285
+ gtk_container_child_set_property(RVAL2GTKCONTAINER(self),
286
+ RVAL2GTKWIDGET(child), name, &gval);
287
+
288
+ g_value_unset(&gval);
289
+ return self;
290
+ }
291
+ }
292
+
293
+ static VALUE
294
+ rg_add(int argc, VALUE *argv, VALUE self)
295
+ {
296
+ VALUE other, properties;
297
+ GtkWidget *child;
298
+
299
+ rb_scan_args(argc, argv, "11", &other, &properties);
300
+
301
+ child = RVAL2GTKWIDGET(other);
302
+ gtk_widget_freeze_child_notify(child);
303
+ gtk_container_add(_SELF(self), child);
304
+
305
+ G_CHILD_ADD(self, other);
306
+
307
+ if (gtk_widget_get_parent(child) && (! NIL_P(properties))){
308
+ int i;
309
+ VALUE ary;
310
+
311
+ Check_Type(properties, T_HASH);
312
+ ary = rb_funcall(properties, rb_intern("to_a"), 0);
313
+
314
+ for (i = 0; i < RARRAY_LEN(ary); i++) {
315
+ rg_child_set_property(self, other,
316
+ RARRAY_PTR(RARRAY_PTR(ary)[i])[0],
317
+ RARRAY_PTR(RARRAY_PTR(ary)[i])[1]);
318
+ }
319
+ }
320
+ gtk_widget_thaw_child_notify(child);
321
+ return self;
322
+ }
323
+
324
+ /*
325
+ void gtk_container_child_get_valist (GtkContainer *container,
326
+ GtkWidget *child,
327
+ const gchar *first_property_name,
328
+ va_list var_args);
329
+ void gtk_container_child_set_valist (GtkContainer *container,
330
+ GtkWidget *child,
331
+ const gchar *first_property_name,
332
+ va_list var_args);
333
+ */
334
+
335
+ /* deprecated
336
+ static VALUE
337
+ rg_propagate_expose(VALUE self, VALUE child, VALUE event)
338
+ {
339
+ gtk_container_propagate_expose(_SELF(self), RVAL2GTKWIDGET(child),
340
+ (GdkEventExpose *)RVAL2GEV(event));
341
+ return self;
342
+ }
343
+ */
344
+
345
+ static VALUE
346
+ rg_focus_chain(VALUE self)
347
+ {
348
+ gboolean ret;
349
+ GList *glist = NULL;
350
+ ret = gtk_container_get_focus_chain(_SELF(self), &glist);
351
+ return GOBJGLIST2RVAL_FREE(glist, g_list_free, NULL);
352
+ }
353
+
354
+ struct rval2gtkwidgetglist_args {
355
+ VALUE ary;
356
+ long n;
357
+ GList *result;
358
+ };
359
+
360
+ static VALUE
361
+ rbg_rval2gtkwidgetglist_body(VALUE value)
362
+ {
363
+ long i;
364
+ struct rval2gtkwidgetglist_args *args = (struct rval2gtkwidgetglist_args *)value;
365
+
366
+ for (i = 0; i < args->n; i++)
367
+ args->result = g_list_append(args->result, RVAL2GTKWIDGET(RARRAY_PTR(args->ary)[i]));
368
+
369
+ return Qnil;
370
+ }
371
+
372
+ static G_GNUC_NORETURN VALUE
373
+ rbg_rval2gtkwidgetglist_rescue(VALUE value)
374
+ {
375
+ g_list_free(((struct rval2gtkwidgetglist_args *)value)->result);
376
+
377
+ rb_exc_raise(rb_errinfo());
378
+ }
379
+
380
+ static GList *
381
+ rbg_rval2gtkwidgetglist(VALUE value)
382
+ {
383
+ struct rval2gtkwidgetglist_args args;
384
+
385
+ args.ary = rb_ary_to_ary(value);
386
+ args.n = RARRAY_LEN(args.ary);
387
+ args.result = NULL;
388
+
389
+ rb_rescue(rbg_rval2gtkwidgetglist_body, (VALUE)&args,
390
+ rbg_rval2gtkwidgetglist_rescue, (VALUE)&args);
391
+
392
+ return args.result;
393
+ }
394
+
395
+ #define RVAL2GTKWIDGETGLIST(value) rbg_rval2gtkwidgetglist(value)
396
+
397
+ static VALUE
398
+ rg_set_focus_chain(VALUE self, VALUE rbfocusable_widgets)
399
+ {
400
+ GtkContainer *container = _SELF(self);
401
+ GList *focusable_widgets = RVAL2GTKWIDGETGLIST(rbfocusable_widgets);
402
+
403
+ gtk_container_set_focus_chain(container, focusable_widgets);
404
+
405
+ g_list_free(focusable_widgets);
406
+
407
+ return self;
408
+ }
409
+
410
+ static VALUE
411
+ rg_unset_focus_chain(VALUE self)
412
+ {
413
+ gtk_container_unset_focus_chain(_SELF(self));
414
+ return self;
415
+ }
416
+
417
+ static VALUE
418
+ rg_s_child_property(VALUE self, VALUE property_name)
419
+ {
420
+ GObjectClass* oclass;
421
+ const char* name;
422
+ GParamSpec* prop;
423
+ VALUE result;
424
+
425
+ if (SYMBOL_P(property_name)) {
426
+ name = rb_id2name(SYM2ID(property_name));
427
+ } else {
428
+ name = RVAL2CSTR(property_name);
429
+ }
430
+
431
+ oclass = g_type_class_ref(CLASS2GTYPE(self));
432
+
433
+ prop = gtk_container_class_find_child_property(oclass, name);
434
+ if (!prop){
435
+ g_type_class_unref(oclass);
436
+ rb_raise(rb_eNameError, "no such property: %s", name);
437
+ }
438
+
439
+ result = GOBJ2RVAL(prop);
440
+ g_type_class_unref(oclass);
441
+ return result;
442
+ }
443
+
444
+ static VALUE
445
+ rg_s_install_child_property(int argc, VALUE *argv, VALUE self)
446
+ {
447
+ const RGObjClassInfo* cinfo = rbgobj_lookup_class(self);
448
+ GtkContainerClass* gclass;
449
+ VALUE spec, prop_id;
450
+ GParamSpec* pspec;
451
+
452
+ rb_scan_args(argc, argv, "11", &spec, &prop_id);
453
+
454
+ pspec = RVAL2GPARAMSPEC(spec);
455
+
456
+ if (cinfo->klass != self)
457
+ rb_raise(rb_eTypeError, "%s isn't registerd class",
458
+ rb_class2name(self));
459
+
460
+ gclass = GTK_CONTAINER_CLASS(g_type_class_ref(cinfo->gtype));
461
+ gtk_container_class_install_child_property(gclass,
462
+ NIL_P(prop_id) ? 1 : NUM2UINT(prop_id),
463
+ pspec);
464
+
465
+ return self;
466
+ }
467
+
468
+ static VALUE
469
+ rg_s_child_properties(int argc, VALUE *argv, VALUE self)
470
+ {
471
+ GObjectClass* oclass = g_type_class_ref(CLASS2GTYPE(self));
472
+ guint n_properties;
473
+ GParamSpec** props;
474
+ VALUE inherited_too;
475
+ VALUE ary;
476
+ guint i;
477
+
478
+ if (rb_scan_args(argc, argv, "01", &inherited_too) == 0)
479
+ inherited_too = Qtrue;
480
+
481
+ props = gtk_container_class_list_child_properties(oclass, &n_properties);
482
+
483
+ ary = rb_ary_new();
484
+ for (i = 0; i < n_properties; i++){
485
+ if (RVAL2CBOOL(inherited_too)
486
+ || GTYPE2CLASS(props[i]->owner_type) == self)
487
+ rb_ary_push(ary, CSTR2RVAL(props[i]->name));
488
+ }
489
+ g_free(props);
490
+ g_type_class_unref(oclass);
491
+ return ary;
492
+ }
493
+
494
+ /**********************************************************************/
495
+
496
+ static VALUE proc_mod_eval;
497
+ static GQuark q_ruby_setter;
498
+ static GQuark q_ruby_getter;
499
+
500
+ static VALUE
501
+ cont_initialize(int argc, VALUE *argv, VALUE self)
502
+ {
503
+ VALUE params_hash;
504
+ GObject* gobj;
505
+
506
+ rb_scan_args(argc, argv, "01", &params_hash);
507
+
508
+ if (!NIL_P(params_hash))
509
+ Check_Type(params_hash, T_HASH);
510
+
511
+ gobj = rbgobj_gobject_new(RVAL2GTYPE(self), params_hash);
512
+
513
+ RBGTK_INITIALIZE(self, gobj);
514
+ return Qnil;
515
+ }
516
+
517
+ // FIXME: use rb_protect
518
+ static void
519
+ get_prop_func(GObject* object,
520
+ G_GNUC_UNUSED guint property_id,
521
+ GValue* value,
522
+ GParamSpec* pspec)
523
+ {
524
+ ID ruby_getter = (ID)g_param_spec_get_qdata(pspec, q_ruby_getter);
525
+ if (!ruby_getter) {
526
+ gchar* name = g_strdup(g_param_spec_get_name(pspec));
527
+ gchar* p;
528
+ for (p = name; *p; p++) {
529
+ if (*p == '-')
530
+ *p = '_';
531
+ }
532
+ ruby_getter = rb_intern(name);
533
+ g_param_spec_set_qdata(pspec, q_ruby_getter, (gpointer)ruby_getter);
534
+ g_free(name);
535
+ }
536
+
537
+ {
538
+ VALUE ret = rb_funcall(GOBJ2RVAL(object), ruby_getter, 0);
539
+ rbgobj_rvalue_to_gvalue(ret, value);
540
+ }
541
+ }
542
+
543
+ // FIXME: use rb_protect
544
+ static void
545
+ set_prop_func(GObject* object,
546
+ G_GNUC_UNUSED guint property_id,
547
+ const GValue* value,
548
+ GParamSpec* pspec)
549
+ {
550
+ ID ruby_setter = (ID)g_param_spec_get_qdata(pspec, q_ruby_setter);
551
+ if (!ruby_setter) {
552
+ gchar* name = g_strconcat(g_param_spec_get_name(pspec), "=", NULL);
553
+ gchar* p;
554
+ for (p = name; *p; p++) {
555
+ if (*p == '-')
556
+ *p = '_';
557
+ }
558
+ ruby_setter = rb_intern(name);
559
+ g_param_spec_set_qdata(pspec, q_ruby_setter, (gpointer)ruby_setter);
560
+ g_free(name);
561
+ }
562
+
563
+ rb_funcall(GOBJ2RVAL(object), ruby_setter, 1, GVAL2RVAL(value));
564
+ }
565
+
566
+ // FIXME: use rb_protect
567
+ static void
568
+ get_child_prop_func(GtkContainer *container,
569
+ GtkWidget *child,
570
+ G_GNUC_UNUSED guint property_id,
571
+ GValue *value,
572
+ GParamSpec *pspec)
573
+ {
574
+ ID ruby_getter = (ID)g_param_spec_get_qdata(pspec, q_ruby_getter);
575
+ if (!ruby_getter) {
576
+ gchar* name = g_strconcat("get_", g_param_spec_get_name(pspec), NULL);
577
+ gchar* p;
578
+ for (p = name; *p; p++) {
579
+ if (*p == '-')
580
+ *p = '_';
581
+ }
582
+ ruby_getter = rb_intern(name);
583
+ g_param_spec_set_qdata(pspec, q_ruby_getter, (gpointer)ruby_getter);
584
+ g_free(name);
585
+ }
586
+
587
+ {
588
+ VALUE ret = rb_funcall(GOBJ2RVAL(container), ruby_getter, 1, GOBJ2RVAL(child));
589
+ rbgobj_rvalue_to_gvalue(ret, value);
590
+ }
591
+ }
592
+
593
+ // FIXME: use rb_protect
594
+ static void
595
+ set_child_prop_func(GtkContainer *container,
596
+ GtkWidget *child,
597
+ G_GNUC_UNUSED guint property_id,
598
+ const GValue *value,
599
+ GParamSpec *pspec)
600
+ {
601
+ ID ruby_setter = (ID)g_param_spec_get_qdata(pspec, q_ruby_setter);
602
+ if (!ruby_setter) {
603
+ gchar* name = g_strconcat("set_", g_param_spec_get_name(pspec), NULL);
604
+ gchar* p;
605
+ for (p = name; *p; p++) {
606
+ if (*p == '-')
607
+ *p = '_';
608
+ }
609
+ ruby_setter = rb_intern(name);
610
+ g_param_spec_set_qdata(pspec, q_ruby_setter, (gpointer)ruby_setter);
611
+ g_free(name);
612
+ }
613
+
614
+ rb_funcall(GOBJ2RVAL(container), ruby_setter, 2, GOBJ2RVAL(child), GVAL2RVAL(value));
615
+ }
616
+
617
+ // FIXME: use rb_protect
618
+ static void
619
+ class_init_func(gpointer g_class, G_GNUC_UNUSED gpointer class_data)
620
+ {
621
+ GObjectClass* g_class1 = G_OBJECT_CLASS(g_class);
622
+ GtkContainerClass* g_class2 = GTK_CONTAINER_CLASS(g_class);
623
+
624
+ g_class1->set_property = set_prop_func;
625
+ g_class1->get_property = get_prop_func;
626
+
627
+ g_class2->set_child_property = set_child_prop_func;
628
+ g_class2->get_child_property = get_child_prop_func;
629
+
630
+ #if 0
631
+ VALUE class_init_proc = (VALUE)class_data;
632
+ rb_funcall(proc_mod_eval, rb_intern("call"), 2,
633
+ GTYPE2CLASS(G_TYPE_FROM_CLASS(g_class)), class_init_proc);
634
+ #endif
635
+ }
636
+
637
+ static VALUE
638
+ rg_s_type_register(int argc, VALUE* argv, VALUE self)
639
+ {
640
+ VALUE type_name, flags;
641
+ volatile VALUE class_init_proc = Qnil;
642
+ GType parent_type;
643
+ GTypeInfo* info;
644
+
645
+ rb_scan_args(argc, argv, "03", &type_name, &info, &flags);
646
+
647
+ /* TODO: Replace this copy-paste job with the real thing in glib2. */
648
+ {
649
+ const RGObjClassInfo* cinfo = rbgobj_lookup_class(self);
650
+ if (cinfo->klass == self)
651
+ rb_raise(rb_eTypeError, "already registered");
652
+ }
653
+
654
+ {
655
+ VALUE superclass = rb_funcall(self, rb_intern("superclass"), 0);
656
+ const RGObjClassInfo* cinfo = CLASS2CINFO(superclass);
657
+ if (cinfo->klass != superclass)
658
+ rb_raise(rb_eTypeError, "super class must be registered to GLib");
659
+ parent_type = cinfo->gtype;
660
+ }
661
+
662
+ if (NIL_P(type_name)){
663
+ VALUE s = rb_funcall(self, rb_intern("name"), 0);
664
+
665
+ if (strlen(StringValuePtr(s)) == 0)
666
+ rb_raise(rb_eTypeError, "can't determine type name");
667
+
668
+ type_name = rb_funcall(
669
+ rb_eval_string("lambda{|x| x.gsub(/::/,'') }"),
670
+ rb_intern("call"), 1, s);
671
+ }
672
+
673
+ {
674
+ GTypeQuery query;
675
+ g_type_query(parent_type, &query);
676
+
677
+ /* TODO: This should not require a new GTypeInfo, as GLib doesn't
678
+ * retain a copy. */
679
+ info = g_new0(GTypeInfo, 1);
680
+ info->class_size = query.class_size;
681
+ info->base_init = NULL;
682
+ info->base_finalize = NULL;
683
+ info->class_init = class_init_func;
684
+ info->class_finalize = NULL;
685
+ info->class_data = (gpointer)class_init_proc;
686
+ info->instance_size = query.instance_size;
687
+ info->n_preallocs = 0;
688
+ info->instance_init = NULL;
689
+ info->value_table = NULL;
690
+ }
691
+
692
+ {
693
+ GType type = g_type_register_static(parent_type,
694
+ StringValuePtr(type_name),
695
+ info,
696
+ NIL_P(flags) ? 0 : NUM2INT(flags));
697
+ G_RELATIVE(self, class_init_proc);
698
+
699
+ rbgobj_register_class(self, type, TRUE, TRUE);
700
+
701
+ {
702
+ RGObjClassInfo* cinfo = (RGObjClassInfo*)rbgobj_lookup_class(self);
703
+ cinfo->flags |= RBGOBJ_DEFINED_BY_RUBY;
704
+ }
705
+
706
+ {
707
+ GType parent = g_type_parent(type);
708
+ const RGObjClassInfo* cinfo = GTYPE2CINFO(parent);
709
+ VALUE m = rb_define_module_under(self, RubyGtkContainerHookModule);
710
+
711
+ if (! (cinfo->flags & RBGOBJ_DEFINED_BY_RUBY)) {
712
+ rbg_define_method(m, "initialize", cont_initialize, -1);
713
+ }
714
+
715
+ rb_include_module(self, m);
716
+ }
717
+
718
+ return Qnil;
719
+ }
720
+ }
721
+ /**********************************************************************/
722
+
723
+ static void
724
+ cont_mark_callback(GtkWidget *w, G_GNUC_UNUSED gpointer data)
725
+ {
726
+ rbgobj_gc_mark_instance(w);
727
+ }
728
+
729
+ static void
730
+ cont_mark(void* p)
731
+ {
732
+ gtk_container_forall(GTK_CONTAINER(p), cont_mark_callback, NULL);
733
+ }
734
+
735
+ /**********************************************************************/
736
+
737
+ void
738
+ Init_gtk_container(VALUE mGtk)
739
+ {
740
+ VALUE RG_TARGET_NAMESPACE;
741
+
742
+ RG_TARGET_NAMESPACE = G_DEF_CLASS_WITH_GC_FUNC(GTK_TYPE_CONTAINER, "Container",
743
+ mGtk, cont_mark, NULL);
744
+ RG_DEF_METHOD_P(resize_container, 0);
745
+ RG_DEF_METHOD(add, -1);
746
+ RG_DEF_ALIAS("<<", "add");
747
+ RG_DEF_METHOD(remove, 1);
748
+ RG_DEF_METHOD(check_resize, 0);
749
+ RG_DEF_METHOD(each, -1);
750
+ RG_DEF_METHOD(each_forall, -1);
751
+ RG_DEF_METHOD(children, 0);
752
+ RG_DEF_METHOD(set_reallocate_redraws, 1);
753
+ RG_DEF_METHOD(set_focus_child, 1);
754
+ RG_DEF_METHOD(set_focus_vadjustment, 1);
755
+ RG_DEF_METHOD(set_focus_hadjustment, 1);
756
+ RG_DEF_METHOD(focus_vadjustment, 0);
757
+ RG_DEF_METHOD(focus_hadjustment, 0);
758
+ RG_DEF_METHOD(resize_children, 0);
759
+ RG_DEF_METHOD(child_type, 0);
760
+ RG_DEF_METHOD(child_get_property, 2);
761
+ RG_DEF_METHOD(child_set_property, 3);
762
+ /* deprecated
763
+ RG_DEF_METHOD(propagate_expose, 2);
764
+ */
765
+ RG_DEF_METHOD(focus_chain, 0);
766
+ RG_DEF_METHOD(set_focus_chain, 1);
767
+ RG_DEF_METHOD(unset_focus_chain, 0);
768
+ RG_DEF_SMETHOD(child_property, 1);
769
+ RG_DEF_SMETHOD(child_properties, -1);
770
+ RG_DEF_SMETHOD(install_child_property, -1);
771
+
772
+ q_ruby_getter = g_quark_from_static_string("__ruby_getter");
773
+ q_ruby_setter = g_quark_from_static_string("__ruby_setter");
774
+
775
+ RG_DEF_SMETHOD(type_register, -1);
776
+
777
+ rb_global_variable(&proc_mod_eval);
778
+ proc_mod_eval = rb_eval_string("lambda{|obj,proc| obj.module_eval(&proc)}");
779
+
780
+ rb_global_variable(&type_to_prop_setter_table);
781
+ rb_global_variable(&type_to_prop_getter_table);
782
+ type_to_prop_setter_table = rb_hash_new();
783
+ type_to_prop_getter_table = rb_hash_new();
784
+ }