gtk2 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6664 -0
- data/README +33 -0
- data/Rakefile +71 -0
- data/extconf.rb +116 -0
- data/src/global.h +33 -0
- data/src/init.c +39 -0
- data/src/lib/gtk2.rb +13 -0
- data/src/lib/gtk2/base.rb +95 -0
- data/src/makeinits.rb +57 -0
- data/src/makekeysyms.rb +5 -0
- data/src/rbgdk.c +395 -0
- data/src/rbgdk.h +50 -0
- data/src/rbgdkatom.c +122 -0
- data/src/rbgdkcairo.c +100 -0
- data/src/rbgdkcolor.c +151 -0
- data/src/rbgdkcolormap.c +142 -0
- data/src/rbgdkconst.c +29 -0
- data/src/rbgdkconversions.h +18 -0
- data/src/rbgdkcursor.c +115 -0
- data/src/rbgdkdevice.c +235 -0
- data/src/rbgdkdisplay.c +634 -0
- data/src/rbgdkdisplaymanager.c +50 -0
- data/src/rbgdkdragcontext.c +280 -0
- data/src/rbgdkdraw.c +487 -0
- data/src/rbgdkevent.c +1020 -0
- data/src/rbgdkgc.c +456 -0
- data/src/rbgdkgeometry.c +272 -0
- data/src/rbgdkimage.c +155 -0
- data/src/rbgdkinput.c +70 -0
- data/src/rbgdkkeymap.c +153 -0
- data/src/rbgdkkeysyms.h +2174 -0
- data/src/rbgdkkeyval.c +105 -0
- data/src/rbgdkpango.c +171 -0
- data/src/rbgdkpangorenderer.c +132 -0
- data/src/rbgdkpixbuf.c +178 -0
- data/src/rbgdkpixmap.c +255 -0
- data/src/rbgdkproperty.c +342 -0
- data/src/rbgdkrectangle.c +146 -0
- data/src/rbgdkregion.c +242 -0
- data/src/rbgdkrgb.c +197 -0
- data/src/rbgdkscreen.c +535 -0
- data/src/rbgdkselection.c +161 -0
- data/src/rbgdkthreads.c +68 -0
- data/src/rbgdktimecoord.c +118 -0
- data/src/rbgdkvisual.c +273 -0
- data/src/rbgdkwindow.c +1302 -0
- data/src/rbgdkwindowattr.c +213 -0
- data/src/rbgdkx11.c +256 -0
- data/src/rbgtk.c +93 -0
- data/src/rbgtk.h +121 -0
- data/src/rbgtkaboutdialog.c +195 -0
- data/src/rbgtkaccelerator.c +78 -0
- data/src/rbgtkaccelgroup.c +216 -0
- data/src/rbgtkaccelgroupentry.c +85 -0
- data/src/rbgtkaccelkey.c +116 -0
- data/src/rbgtkaccellabel.c +46 -0
- data/src/rbgtkaccelmap.c +162 -0
- data/src/rbgtkaccessible.c +29 -0
- data/src/rbgtkaction.c +277 -0
- data/src/rbgtkactiongroup.c +377 -0
- data/src/rbgtkadjustment.c +153 -0
- data/src/rbgtkalignment.c +71 -0
- data/src/rbgtkallocation.c +171 -0
- data/src/rbgtkarrow.c +47 -0
- data/src/rbgtkaspectframe.c +46 -0
- data/src/rbgtkassistant.c +230 -0
- data/src/rbgtkbbox.c +47 -0
- data/src/rbgtkbin.c +31 -0
- data/src/rbgtkbindingset.c +192 -0
- data/src/rbgtkborder.c +80 -0
- data/src/rbgtkbox.c +142 -0
- data/src/rbgtkbuildable.c +115 -0
- data/src/rbgtkbuilder.c +154 -0
- data/src/rbgtkbutton.c +151 -0
- data/src/rbgtkcalendar.c +159 -0
- data/src/rbgtkcelleditable.c +49 -0
- data/src/rbgtkcelllayout.c +144 -0
- data/src/rbgtkcellrenderer.c +139 -0
- data/src/rbgtkcellrendereraccel.c +42 -0
- data/src/rbgtkcellrenderercombo.c +37 -0
- data/src/rbgtkcellrendererpixbuf.c +33 -0
- data/src/rbgtkcellrendererprogress.c +37 -0
- data/src/rbgtkcellrendererspin.c +38 -0
- data/src/rbgtkcellrenderertext.c +45 -0
- data/src/rbgtkcellrenderertoggle.c +32 -0
- data/src/rbgtkcellview.c +134 -0
- data/src/rbgtkcheckbutton.c +55 -0
- data/src/rbgtkcheckmenuitem.c +56 -0
- data/src/rbgtkclipboard.c +473 -0
- data/src/rbgtkcolorbutton.c +63 -0
- data/src/rbgtkcolorsel.c +175 -0
- data/src/rbgtkcolorselectiondialog.c +72 -0
- data/src/rbgtkcombo.c +117 -0
- data/src/rbgtkcombobox.c +240 -0
- data/src/rbgtkcomboboxentry.c +60 -0
- data/src/rbgtkconst.c +163 -0
- data/src/rbgtkcontainer.c +776 -0
- data/src/rbgtkconversions.h +26 -0
- data/src/rbgtkcurve.c +105 -0
- data/src/rbgtkdialog.c +244 -0
- data/src/rbgtkdrag.c +436 -0
- data/src/rbgtkdrawingarea.c +31 -0
- data/src/rbgtkeditable.c +152 -0
- data/src/rbgtkentry.c +161 -0
- data/src/rbgtkentrycompletion.c +167 -0
- data/src/rbgtkeventbox.c +31 -0
- data/src/rbgtkexpander.c +67 -0
- data/src/rbgtkfilechooser.c +403 -0
- data/src/rbgtkfilechooserbutton.c +72 -0
- data/src/rbgtkfilechooserdialog.c +58 -0
- data/src/rbgtkfilechooserwidget.c +50 -0
- data/src/rbgtkfilefilter.c +139 -0
- data/src/rbgtkfilesel.c +155 -0
- data/src/rbgtkfixed.c +72 -0
- data/src/rbgtkfontbutton.c +69 -0
- data/src/rbgtkfontselection.c +30 -0
- data/src/rbgtkfontselectiondialog.c +106 -0
- data/src/rbgtkframe.c +64 -0
- data/src/rbgtkgamma.c +47 -0
- data/src/rbgtkhandlebox.c +42 -0
- data/src/rbgtkhbbox.c +31 -0
- data/src/rbgtkhbox.c +38 -0
- data/src/rbgtkhpaned.c +31 -0
- data/src/rbgtkhruler.c +31 -0
- data/src/rbgtkhscale.c +45 -0
- data/src/rbgtkhscrollbar.c +38 -0
- data/src/rbgtkhseparator.c +30 -0
- data/src/rbgtkiconfactory.c +80 -0
- data/src/rbgtkiconinfo.c +118 -0
- data/src/rbgtkiconset.c +87 -0
- data/src/rbgtkiconsize.c +90 -0
- data/src/rbgtkiconsource.c +176 -0
- data/src/rbgtkicontheme.c +309 -0
- data/src/rbgtkiconview.c +351 -0
- data/src/rbgtkimage.c +152 -0
- data/src/rbgtkimagemenuitem.c +52 -0
- data/src/rbgtkimcontext.c +134 -0
- data/src/rbgtkimcontextsimple.c +48 -0
- data/src/rbgtkimmulticontext.c +38 -0
- data/src/rbgtkinits.c +473 -0
- data/src/rbgtkinputdialog.c +30 -0
- data/src/rbgtkinvisible.c +68 -0
- data/src/rbgtkitem.c +51 -0
- data/src/rbgtkitemfactory.c +312 -0
- data/src/rbgtklabel.c +168 -0
- data/src/rbgtklayout.c +91 -0
- data/src/rbgtklinkbutton.c +68 -0
- data/src/rbgtkliststore.c +412 -0
- data/src/rbgtkmacros.h +26 -0
- data/src/rbgtkmain.c +532 -0
- data/src/rbgtkmenu.c +272 -0
- data/src/rbgtkmenubar.c +48 -0
- data/src/rbgtkmenuitem.c +171 -0
- data/src/rbgtkmenushell.c +128 -0
- data/src/rbgtkmenutoolbutton.c +74 -0
- data/src/rbgtkmessagedialog.c +102 -0
- data/src/rbgtkmisc.c +63 -0
- data/src/rbgtknotebook.c +484 -0
- data/src/rbgtkobject.c +186 -0
- data/src/rbgtkoptionmenu.c +65 -0
- data/src/rbgtkpagesetup.c +196 -0
- data/src/rbgtkpagesetupunixdialog.c +80 -0
- data/src/rbgtkpaned.c +114 -0
- data/src/rbgtkpapersize.c +186 -0
- data/src/rbgtkplug.c +84 -0
- data/src/rbgtkprintcontext.c +124 -0
- data/src/rbgtkprinter.c +155 -0
- data/src/rbgtkprintjob.c +151 -0
- data/src/rbgtkprintoperation.c +152 -0
- data/src/rbgtkprintoperationpreview.c +54 -0
- data/src/rbgtkprintsettings.c +794 -0
- data/src/rbgtkprintunixdialog.c +98 -0
- data/src/rbgtkprogress.c +21 -0
- data/src/rbgtkprogressbar.c +72 -0
- data/src/rbgtkradioaction.c +102 -0
- data/src/rbgtkradiobutton.c +83 -0
- data/src/rbgtkradiomenuitem.c +115 -0
- data/src/rbgtkradiotoolbutton.c +99 -0
- data/src/rbgtkrange.c +98 -0
- data/src/rbgtkrc.c +228 -0
- data/src/rbgtkrcstyle.c +184 -0
- data/src/rbgtkrecentaction.c +52 -0
- data/src/rbgtkrecentchooser.c +276 -0
- data/src/rbgtkrecentchooserdialog.c +59 -0
- data/src/rbgtkrecentchoosermenu.c +55 -0
- data/src/rbgtkrecentchooserwidget.c +45 -0
- data/src/rbgtkrecentdata.c +152 -0
- data/src/rbgtkrecentfilter.c +180 -0
- data/src/rbgtkrecentfilterinfo.c +197 -0
- data/src/rbgtkrecentinfo.c +232 -0
- data/src/rbgtkrecentmanager.c +164 -0
- data/src/rbgtkruler.c +82 -0
- data/src/rbgtkscale.c +47 -0
- data/src/rbgtkscalebutton.c +115 -0
- data/src/rbgtkscrollbar.c +21 -0
- data/src/rbgtkscrolledwindow.c +160 -0
- data/src/rbgtkselection.c +171 -0
- data/src/rbgtkselectiondata.c +333 -0
- data/src/rbgtkseparator.c +21 -0
- data/src/rbgtkseparatormenuitem.c +28 -0
- data/src/rbgtkseparatortoolitem.c +40 -0
- data/src/rbgtksettings.c +225 -0
- data/src/rbgtksizegroup.c +74 -0
- data/src/rbgtksocket.c +72 -0
- data/src/rbgtkspinbutton.c +138 -0
- data/src/rbgtkstatusbar.c +90 -0
- data/src/rbgtkstatusicon.c +120 -0
- data/src/rbgtkstock.c +264 -0
- data/src/rbgtkstyle.c +722 -0
- data/src/rbgtktable.c +190 -0
- data/src/rbgtktargetlist.c +148 -0
- data/src/rbgtktearoffmenuitem.c +30 -0
- data/src/rbgtktextappearance.c +173 -0
- data/src/rbgtktextattributes.c +209 -0
- data/src/rbgtktextbuffer.c +993 -0
- data/src/rbgtktextchild.c +49 -0
- data/src/rbgtktextiter.c +553 -0
- data/src/rbgtktextmark.c +87 -0
- data/src/rbgtktexttag.c +66 -0
- data/src/rbgtktexttagtable.c +94 -0
- data/src/rbgtktextview.c +351 -0
- data/src/rbgtktoggleaction.c +76 -0
- data/src/rbgtktogglebutton.c +84 -0
- data/src/rbgtktoggletoolbutton.c +70 -0
- data/src/rbgtktoolbar.c +373 -0
- data/src/rbgtktoolbutton.c +75 -0
- data/src/rbgtktoolitem.c +184 -0
- data/src/rbgtktooltip.c +76 -0
- data/src/rbgtktooltips.c +107 -0
- data/src/rbgtktreedragdest.c +19 -0
- data/src/rbgtktreedragsource.c +19 -0
- data/src/rbgtktreeiter.c +259 -0
- data/src/rbgtktreemodel.c +256 -0
- data/src/rbgtktreemodelfilter.c +214 -0
- data/src/rbgtktreemodelsort.c +113 -0
- data/src/rbgtktreepath.c +195 -0
- data/src/rbgtktreerowreference.c +168 -0
- data/src/rbgtktreeselection.c +235 -0
- data/src/rbgtktreesortable.c +127 -0
- data/src/rbgtktreestore.c +379 -0
- data/src/rbgtktreeview.c +881 -0
- data/src/rbgtktreeviewcolumn.c +331 -0
- data/src/rbgtkuimanager.c +210 -0
- data/src/rbgtkvbbox.c +31 -0
- data/src/rbgtkvbox.c +38 -0
- data/src/rbgtkviewport.c +33 -0
- data/src/rbgtkvolumebutton.c +36 -0
- data/src/rbgtkvpaned.c +31 -0
- data/src/rbgtkvruler.c +30 -0
- data/src/rbgtkvscale.c +45 -0
- data/src/rbgtkvscrollbar.c +38 -0
- data/src/rbgtkvseparator.c +30 -0
- data/src/rbgtkwidget.c +1414 -0
- data/src/rbgtkwindow.c +822 -0
- data/src/rbgtkwindowgroup.c +48 -0
- data/test/gtk-test-utils.rb +15 -0
- data/test/run-test.rb +30 -0
- data/test/test_gc.rb +25 -0
- data/test/test_gdk.rb +18 -0
- data/test/test_gdk_color.rb +10 -0
- data/test/test_gdk_display.rb +37 -0
- data/test/test_gdk_event.rb +11 -0
- data/test/test_gdk_gc.rb +7 -0
- data/test/test_gdk_keymap.rb +8 -0
- data/test/test_gdk_pango.rb +9 -0
- data/test/test_gdk_selection_data.rb +17 -0
- data/test/test_gdk_window.rb +29 -0
- data/test/test_gdk_window_attribute.rb +9 -0
- data/test/test_gtk_about_dialog.rb +14 -0
- data/test/test_gtk_buildable.rb +66 -0
- data/test/test_gtk_builder.rb +188 -0
- data/test/test_gtk_entry.rb +18 -0
- data/test/test_gtk_icon_theme.rb +30 -0
- data/test/test_gtk_image.rb +8 -0
- data/test/test_gtk_list_store.rb +65 -0
- data/test/test_gtk_menu_item.rb +13 -0
- data/test/test_gtk_rc_style.rb +14 -0
- data/test/test_gtk_tree_path.rb +20 -0
- data/test/test_gtk_unix_print.rb +14 -0
- data/test/test_gtk_widget.rb +32 -0
- metadata +393 -0
@@ -0,0 +1,214 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/************************************************
|
3
|
+
|
4
|
+
rbgtktreemodelfilter.c -
|
5
|
+
|
6
|
+
$Author: ggc $
|
7
|
+
$Date: 2007/07/13 16:07:32 $
|
8
|
+
|
9
|
+
Copyright (C) 2004,2005 Masao Mutoh
|
10
|
+
************************************************/
|
11
|
+
|
12
|
+
#include "global.h"
|
13
|
+
|
14
|
+
#if GTK_CHECK_VERSION(2,4,0)
|
15
|
+
#define _SELF(s) (GTK_TREE_MODEL_FILTER(RVAL2GOBJ(s)))
|
16
|
+
|
17
|
+
static ID id_child_model;
|
18
|
+
static ID id_root;
|
19
|
+
|
20
|
+
static VALUE
|
21
|
+
treemodelfilter_initialize(argc, argv, self)
|
22
|
+
int argc;
|
23
|
+
VALUE* argv;
|
24
|
+
VALUE self;
|
25
|
+
{
|
26
|
+
VALUE child_model, root;
|
27
|
+
GtkTreeModel* widget;
|
28
|
+
|
29
|
+
rb_scan_args(argc, argv, "11", &child_model, &root);
|
30
|
+
|
31
|
+
G_CHILD_SET(self, id_child_model, child_model);
|
32
|
+
if (NIL_P(root)){
|
33
|
+
widget = gtk_tree_model_filter_new(GTK_TREE_MODEL(RVAL2GOBJ(child_model)),
|
34
|
+
(GtkTreePath*)NULL);
|
35
|
+
} else {
|
36
|
+
G_CHILD_SET(self, id_root, root);
|
37
|
+
widget = gtk_tree_model_filter_new(GTK_TREE_MODEL(RVAL2GOBJ(child_model)),
|
38
|
+
(GtkTreePath*)RVAL2GTKTREEPATH(root));
|
39
|
+
}
|
40
|
+
|
41
|
+
G_INITIALIZE(self, widget);
|
42
|
+
return Qnil;
|
43
|
+
}
|
44
|
+
|
45
|
+
static gboolean
|
46
|
+
visible_func(model, iter, func)
|
47
|
+
GtkTreeModel* model;
|
48
|
+
GtkTreeIter* iter;
|
49
|
+
gpointer func;
|
50
|
+
{
|
51
|
+
VALUE ret;
|
52
|
+
|
53
|
+
iter->user_data3 = model;
|
54
|
+
ret = rb_funcall((VALUE)func, id_call, 2, GOBJ2RVAL(model), GTKTREEITER2RVAL(iter));
|
55
|
+
return RVAL2CBOOL(ret);
|
56
|
+
}
|
57
|
+
|
58
|
+
static VALUE
|
59
|
+
treemodelfilter_set_visible_func(self)
|
60
|
+
VALUE self;
|
61
|
+
{
|
62
|
+
VALUE func = rb_block_proc();
|
63
|
+
G_RELATIVE(self, func);
|
64
|
+
gtk_tree_model_filter_set_visible_func(_SELF(self),
|
65
|
+
(GtkTreeModelFilterVisibleFunc)visible_func,
|
66
|
+
(gpointer)func, NULL);
|
67
|
+
return self;
|
68
|
+
}
|
69
|
+
|
70
|
+
static void
|
71
|
+
modify_func(model, iter, value, column, func)
|
72
|
+
GtkTreeModel* model;
|
73
|
+
GtkTreeIter* iter;
|
74
|
+
GValue* value;
|
75
|
+
gint column;
|
76
|
+
gpointer func;
|
77
|
+
{
|
78
|
+
VALUE ret;
|
79
|
+
iter->user_data3 = model;
|
80
|
+
ret = rb_funcall((VALUE)func, id_call, 3, GOBJ2RVAL(model), GTKTREEITER2RVAL(iter),
|
81
|
+
INT2NUM(column));
|
82
|
+
rbgobj_rvalue_to_gvalue(ret, value);
|
83
|
+
}
|
84
|
+
|
85
|
+
/*
|
86
|
+
* Should return value
|
87
|
+
*
|
88
|
+
* e.g.
|
89
|
+
* filter.set_modify_func(String) do |model, iter, column|
|
90
|
+
* "foo"
|
91
|
+
* end
|
92
|
+
*/
|
93
|
+
static VALUE
|
94
|
+
treemodelfilter_set_modify_func(argc, argv, self)
|
95
|
+
int argc;
|
96
|
+
VALUE* argv;
|
97
|
+
VALUE self;
|
98
|
+
{
|
99
|
+
VALUE func = rb_block_proc();
|
100
|
+
gint i;
|
101
|
+
GType* types;
|
102
|
+
|
103
|
+
if (argc == 0) rb_raise(rb_eArgError, "need more than 1 class type.");
|
104
|
+
|
105
|
+
types = ALLOCA_N(GType, argc);
|
106
|
+
|
107
|
+
G_RELATIVE(self, func);
|
108
|
+
|
109
|
+
for (i = 0; i < argc; i++){
|
110
|
+
types[i] = CLASS2GTYPE(argv[i]);
|
111
|
+
}
|
112
|
+
gtk_tree_model_filter_set_modify_func(_SELF(self),
|
113
|
+
argc, types,
|
114
|
+
(GtkTreeModelFilterModifyFunc)modify_func,
|
115
|
+
(gpointer)func, NULL);
|
116
|
+
return self;
|
117
|
+
}
|
118
|
+
|
119
|
+
static VALUE
|
120
|
+
treemodelfilter_set_visible_column(self, column)
|
121
|
+
VALUE self, column;
|
122
|
+
{
|
123
|
+
gtk_tree_model_filter_set_visible_column(_SELF(self), NUM2INT(column));
|
124
|
+
return self;
|
125
|
+
}
|
126
|
+
|
127
|
+
static VALUE
|
128
|
+
treemodelfilter_get_model(self)
|
129
|
+
VALUE self;
|
130
|
+
{
|
131
|
+
return GOBJ2RVAL(gtk_tree_model_filter_get_model(_SELF(self)));
|
132
|
+
}
|
133
|
+
|
134
|
+
static VALUE
|
135
|
+
treemodelfilter_convert_child_iter_to_iter(self, child_iter)
|
136
|
+
VALUE self, child_iter;
|
137
|
+
{
|
138
|
+
GtkTreeIter filter_iter;
|
139
|
+
GtkTreeModelFilter* modelfilter = _SELF(self);
|
140
|
+
gtk_tree_model_filter_convert_child_iter_to_iter(modelfilter, &filter_iter,
|
141
|
+
RVAL2GTKTREEITER(child_iter));
|
142
|
+
filter_iter.user_data3 = gtk_tree_model_filter_get_model(modelfilter);
|
143
|
+
return GTKTREEITER2RVAL(&filter_iter);
|
144
|
+
}
|
145
|
+
|
146
|
+
static VALUE
|
147
|
+
treemodelfilter_convert_iter_to_child_iter(self, filtered_iter)
|
148
|
+
VALUE self, filtered_iter;
|
149
|
+
{
|
150
|
+
GtkTreeIter child_iter;
|
151
|
+
GtkTreeModelFilter* modelfilter = _SELF(self);
|
152
|
+
gtk_tree_model_filter_convert_iter_to_child_iter(modelfilter, &child_iter,
|
153
|
+
RVAL2GTKTREEITER(filtered_iter));
|
154
|
+
child_iter.user_data3 = gtk_tree_model_filter_get_model(modelfilter);
|
155
|
+
return GTKTREEITER2RVAL(&child_iter);
|
156
|
+
}
|
157
|
+
|
158
|
+
static VALUE
|
159
|
+
treemodelfilter_convert_child_path_to_path(self, child_path)
|
160
|
+
VALUE self, child_path;
|
161
|
+
{
|
162
|
+
return GTKTREEPATH2RVAL(gtk_tree_model_filter_convert_child_path_to_path(
|
163
|
+
_SELF(self),
|
164
|
+
RVAL2GTKTREEPATH(child_path)));
|
165
|
+
}
|
166
|
+
static VALUE
|
167
|
+
treemodelfilter_convert_path_to_child_path(self, filter_path)
|
168
|
+
VALUE self, filter_path;
|
169
|
+
{
|
170
|
+
return GTKTREEPATH2RVAL(gtk_tree_model_filter_convert_path_to_child_path(
|
171
|
+
_SELF(self),
|
172
|
+
RVAL2GTKTREEPATH(filter_path)));
|
173
|
+
}
|
174
|
+
|
175
|
+
static VALUE
|
176
|
+
treemodelfilter_refilter(self)
|
177
|
+
VALUE self;
|
178
|
+
{
|
179
|
+
gtk_tree_model_filter_refilter(_SELF(self));
|
180
|
+
return self;
|
181
|
+
}
|
182
|
+
|
183
|
+
static VALUE
|
184
|
+
treemodelfilter_clear_cache(self)
|
185
|
+
VALUE self;
|
186
|
+
{
|
187
|
+
gtk_tree_model_filter_clear_cache(_SELF(self));
|
188
|
+
return self;
|
189
|
+
}
|
190
|
+
#endif
|
191
|
+
|
192
|
+
void
|
193
|
+
Init_gtk_treemodelfilter()
|
194
|
+
{
|
195
|
+
#if GTK_CHECK_VERSION(2,4,0)
|
196
|
+
VALUE tmf = G_DEF_CLASS(GTK_TYPE_TREE_MODEL_FILTER, "TreeModelFilter", mGtk);
|
197
|
+
|
198
|
+
id_child_model = rb_intern("child_model");
|
199
|
+
id_root = rb_intern("root");
|
200
|
+
|
201
|
+
rb_define_method(tmf, "initialize", treemodelfilter_initialize, -1);
|
202
|
+
rb_define_method(tmf, "set_visible_func", treemodelfilter_set_visible_func, 0);
|
203
|
+
rb_define_method(tmf, "set_modify_func", treemodelfilter_set_modify_func, -1);
|
204
|
+
rb_define_method(tmf, "set_visible_column", treemodelfilter_set_visible_column, 1);
|
205
|
+
rb_define_method(tmf, "model", treemodelfilter_get_model, 0);
|
206
|
+
rb_define_method(tmf, "convert_child_iter_to_iter", treemodelfilter_convert_child_iter_to_iter, 1);
|
207
|
+
rb_define_method(tmf, "convert_iter_to_child_iter", treemodelfilter_convert_iter_to_child_iter, 1);
|
208
|
+
rb_define_method(tmf, "convert_child_path_to_path", treemodelfilter_convert_child_path_to_path, 1);
|
209
|
+
rb_define_method(tmf, "convert_path_to_child_path", treemodelfilter_convert_path_to_child_path, 1);
|
210
|
+
rb_define_method(tmf, "refilter", treemodelfilter_refilter, 0);
|
211
|
+
rb_define_method(tmf, "clear_cache", treemodelfilter_clear_cache, 0);
|
212
|
+
G_DEF_SETTERS(tmf);
|
213
|
+
#endif
|
214
|
+
}
|
@@ -0,0 +1,113 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/************************************************
|
3
|
+
|
4
|
+
rbgtktreemodelsort.c -
|
5
|
+
|
6
|
+
$Author: mutoh $
|
7
|
+
$Date: 2005/11/06 04:44:24 $
|
8
|
+
|
9
|
+
Copyright (C) 2003-2005 Masao Mutoh
|
10
|
+
************************************************/
|
11
|
+
|
12
|
+
#include "global.h"
|
13
|
+
|
14
|
+
#define _SELF(s) (GTK_TREE_MODEL_SORT(RVAL2GOBJ(s)))
|
15
|
+
|
16
|
+
static ID id_model;
|
17
|
+
|
18
|
+
static VALUE
|
19
|
+
tmodelsort_initialize(self, model)
|
20
|
+
VALUE self, model;
|
21
|
+
{
|
22
|
+
G_CHILD_SET(self, id_model, model);
|
23
|
+
G_INITIALIZE(self,
|
24
|
+
gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(RVAL2GOBJ(model))));
|
25
|
+
return Qnil;
|
26
|
+
}
|
27
|
+
|
28
|
+
static VALUE
|
29
|
+
tmodelsort_convert_child_path_to_path(self, child_path)
|
30
|
+
VALUE self, child_path;
|
31
|
+
{
|
32
|
+
return GTKTREEPATH2RVAL(gtk_tree_model_sort_convert_child_path_to_path(
|
33
|
+
_SELF(self),
|
34
|
+
RVAL2GTKTREEPATH(child_path)));
|
35
|
+
}
|
36
|
+
|
37
|
+
static VALUE
|
38
|
+
tmodelsort_convert_child_iter_to_iter(self, child_iter)
|
39
|
+
VALUE self, child_iter;
|
40
|
+
{
|
41
|
+
GtkTreeIter sort_iter;
|
42
|
+
GtkTreeModelSort* modelsort = _SELF(self);
|
43
|
+
gtk_tree_model_sort_convert_child_iter_to_iter(modelsort, &sort_iter,
|
44
|
+
RVAL2GTKTREEITER(child_iter));
|
45
|
+
sort_iter.user_data3 = gtk_tree_model_sort_get_model(modelsort);
|
46
|
+
return GTKTREEITER2RVAL(&sort_iter);
|
47
|
+
}
|
48
|
+
|
49
|
+
static VALUE
|
50
|
+
tmodelsort_convert_path_to_child_path(self, sorted_path)
|
51
|
+
VALUE self, sorted_path;
|
52
|
+
{
|
53
|
+
return GTKTREEPATH2RVAL(gtk_tree_model_sort_convert_path_to_child_path(
|
54
|
+
_SELF(self),
|
55
|
+
RVAL2GTKTREEPATH(sorted_path)));
|
56
|
+
}
|
57
|
+
|
58
|
+
static VALUE
|
59
|
+
tmodelsort_convert_iter_to_child_iter(self, sorted_iter)
|
60
|
+
VALUE self, sorted_iter;
|
61
|
+
{
|
62
|
+
GtkTreeIter child_iter;
|
63
|
+
GtkTreeModelSort* modelsort = _SELF(self);
|
64
|
+
gtk_tree_model_sort_convert_iter_to_child_iter(modelsort, &child_iter,
|
65
|
+
RVAL2GTKTREEITER(sorted_iter));
|
66
|
+
child_iter.user_data3 = gtk_tree_model_sort_get_model(modelsort);
|
67
|
+
return GTKTREEITER2RVAL(&child_iter);
|
68
|
+
}
|
69
|
+
|
70
|
+
static VALUE
|
71
|
+
tmodelsort_reset_default_sort_func(self)
|
72
|
+
VALUE self;
|
73
|
+
{
|
74
|
+
gtk_tree_model_sort_reset_default_sort_func(_SELF(self));
|
75
|
+
return self;
|
76
|
+
}
|
77
|
+
|
78
|
+
static VALUE
|
79
|
+
tmodelsort_clear_cache(self)
|
80
|
+
VALUE self;
|
81
|
+
{
|
82
|
+
gtk_tree_model_sort_clear_cache(_SELF(self));
|
83
|
+
return self;
|
84
|
+
}
|
85
|
+
|
86
|
+
#if GTK_CHECK_VERSION(2,2,0)
|
87
|
+
static VALUE
|
88
|
+
tmodelsort_iter_is_valid(self, iter)
|
89
|
+
VALUE self, iter;
|
90
|
+
{
|
91
|
+
return CBOOL2RVAL(gtk_tree_model_sort_iter_is_valid(_SELF(self), RVAL2GTKTREEITER(iter)));
|
92
|
+
}
|
93
|
+
#endif
|
94
|
+
|
95
|
+
void
|
96
|
+
Init_gtk_tmodelsort()
|
97
|
+
{
|
98
|
+
VALUE gTMSort = G_DEF_CLASS(GTK_TYPE_TREE_MODEL_SORT, "TreeModelSort", mGtk);
|
99
|
+
|
100
|
+
id_model = rb_intern("model");
|
101
|
+
|
102
|
+
rb_define_method(gTMSort, "initialize", tmodelsort_initialize, 1);
|
103
|
+
rb_define_method(gTMSort, "convert_child_path_to_path", tmodelsort_convert_child_path_to_path, 1);
|
104
|
+
rb_define_method(gTMSort, "convert_child_iter_to_iter", tmodelsort_convert_child_iter_to_iter, 1);
|
105
|
+
rb_define_method(gTMSort, "convert_path_to_child_path", tmodelsort_convert_path_to_child_path, 1);
|
106
|
+
rb_define_method(gTMSort, "convert_iter_to_child_iter", tmodelsort_convert_iter_to_child_iter, 1);
|
107
|
+
rb_define_method(gTMSort, "reset_default_sort_func", tmodelsort_reset_default_sort_func, 0);
|
108
|
+
rb_define_method(gTMSort, "clear_cache", tmodelsort_clear_cache, 0);
|
109
|
+
#if GTK_CHECK_VERSION(2,2,0)
|
110
|
+
rb_define_method(gTMSort, "iter_is_valid?", tmodelsort_iter_is_valid, 1);
|
111
|
+
#endif
|
112
|
+
|
113
|
+
}
|
data/src/rbgtktreepath.c
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
+
/************************************************
|
3
|
+
|
4
|
+
rbgtktreepath.c -
|
5
|
+
|
6
|
+
$Author: ggc $
|
7
|
+
$Date: 2007/07/13 14:27:10 $
|
8
|
+
|
9
|
+
Copyright (C) 2002-2004 Ruby-GNOME2 Project Team
|
10
|
+
Copyright (C) 2003,2004 Masao Mutoh
|
11
|
+
************************************************/
|
12
|
+
|
13
|
+
#include "global.h"
|
14
|
+
|
15
|
+
#define _SELF(s) ((GtkTreePath*)RVAL2BOXED(s, GTK_TYPE_TREE_PATH))
|
16
|
+
|
17
|
+
static ID id_equal;
|
18
|
+
|
19
|
+
static VALUE
|
20
|
+
treepath_initialize(argc, argv, self)
|
21
|
+
int argc;
|
22
|
+
VALUE* argv;
|
23
|
+
VALUE self;
|
24
|
+
{
|
25
|
+
VALUE path;
|
26
|
+
GtkTreePath* widget;
|
27
|
+
|
28
|
+
if (argc == 1) {
|
29
|
+
path = argv[0];
|
30
|
+
if (TYPE(path) == T_STRING){
|
31
|
+
widget = gtk_tree_path_new_from_string(RVAL2CSTR(path));
|
32
|
+
} else {
|
33
|
+
widget = gtk_tree_path_new();
|
34
|
+
gtk_tree_path_append_index(widget, NUM2INT(path));
|
35
|
+
}
|
36
|
+
if (widget == NULL)
|
37
|
+
rb_raise(rb_eArgError, "Invalid path %s was passed.", RVAL2CSTR(path));
|
38
|
+
} else {
|
39
|
+
int i;
|
40
|
+
widget = gtk_tree_path_new();
|
41
|
+
for (i = 0; i < argc; i++)
|
42
|
+
gtk_tree_path_append_index(widget, NUM2INT(argv[i]));
|
43
|
+
}
|
44
|
+
|
45
|
+
G_INITIALIZE(self, widget);
|
46
|
+
return Qnil;
|
47
|
+
}
|
48
|
+
|
49
|
+
static VALUE
|
50
|
+
treepath_to_string(self)
|
51
|
+
VALUE self;
|
52
|
+
{
|
53
|
+
gchar* s = gtk_tree_path_to_string(_SELF(self));
|
54
|
+
VALUE result = CSTR2RVAL(s);
|
55
|
+
g_free(s);
|
56
|
+
return result;
|
57
|
+
}
|
58
|
+
|
59
|
+
/* Do we need this ?
|
60
|
+
GtkTreePath* gtk_tree_path_new_first (void);
|
61
|
+
|
62
|
+
Deprecated
|
63
|
+
#define gtk_tree_path_new_root ()
|
64
|
+
*/
|
65
|
+
|
66
|
+
static VALUE
|
67
|
+
treepath_append_index(self, index)
|
68
|
+
VALUE self, index;
|
69
|
+
{
|
70
|
+
gtk_tree_path_append_index(_SELF(self), NUM2INT(index));
|
71
|
+
return self;
|
72
|
+
}
|
73
|
+
|
74
|
+
static VALUE
|
75
|
+
treepath_prepend_index(self, index)
|
76
|
+
VALUE self, index;
|
77
|
+
{
|
78
|
+
gtk_tree_path_prepend_index(_SELF(self), NUM2INT(index));
|
79
|
+
return self;
|
80
|
+
}
|
81
|
+
|
82
|
+
static VALUE
|
83
|
+
treepath_get_depth(self)
|
84
|
+
VALUE self;
|
85
|
+
{
|
86
|
+
return INT2NUM(gtk_tree_path_get_depth(_SELF(self)));
|
87
|
+
}
|
88
|
+
|
89
|
+
static VALUE
|
90
|
+
treepath_get_indices(self)
|
91
|
+
VALUE self;
|
92
|
+
{
|
93
|
+
VALUE ary;
|
94
|
+
gint i, length;
|
95
|
+
gint* indices;
|
96
|
+
|
97
|
+
length = gtk_tree_path_get_depth(_SELF(self));
|
98
|
+
indices = gtk_tree_path_get_indices(_SELF(self));
|
99
|
+
|
100
|
+
if (indices != NULL) {
|
101
|
+
ary = rb_ary_new2(length);
|
102
|
+
for (i = 0; i < length; i++) {
|
103
|
+
rb_ary_push(ary, INT2NUM(indices[i]));
|
104
|
+
}
|
105
|
+
|
106
|
+
return ary;
|
107
|
+
} else {
|
108
|
+
return Qnil;
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
static VALUE
|
113
|
+
treepath_compare(self, other)
|
114
|
+
VALUE self, other;
|
115
|
+
{
|
116
|
+
return INT2NUM(gtk_tree_path_compare(_SELF(self), _SELF(other)));
|
117
|
+
}
|
118
|
+
|
119
|
+
static VALUE
|
120
|
+
treepath_equal(VALUE self, VALUE other)
|
121
|
+
{
|
122
|
+
if (!RVAL2CBOOL(rb_funcall(CLASS_OF(self), id_equal, 1, CLASS_OF(other)))) {
|
123
|
+
return Qfalse;
|
124
|
+
}
|
125
|
+
|
126
|
+
return CBOOL2RVAL(gtk_tree_path_compare(_SELF(self), _SELF(other)) == 0);
|
127
|
+
}
|
128
|
+
|
129
|
+
static VALUE
|
130
|
+
treepath_next(self)
|
131
|
+
VALUE self;
|
132
|
+
{
|
133
|
+
gtk_tree_path_next(_SELF(self));
|
134
|
+
return self;
|
135
|
+
}
|
136
|
+
|
137
|
+
static VALUE
|
138
|
+
treepath_prev(self)
|
139
|
+
VALUE self;
|
140
|
+
{
|
141
|
+
return CBOOL2RVAL(gtk_tree_path_prev(_SELF(self)));
|
142
|
+
}
|
143
|
+
|
144
|
+
static VALUE
|
145
|
+
treepath_up(self)
|
146
|
+
VALUE self;
|
147
|
+
{
|
148
|
+
return CBOOL2RVAL(gtk_tree_path_up(_SELF(self)));
|
149
|
+
}
|
150
|
+
|
151
|
+
static VALUE
|
152
|
+
treepath_down(self)
|
153
|
+
VALUE self;
|
154
|
+
{
|
155
|
+
gtk_tree_path_down(_SELF(self));
|
156
|
+
return Qtrue;
|
157
|
+
}
|
158
|
+
|
159
|
+
static VALUE
|
160
|
+
treepath_is_ancestor(self, descendant)
|
161
|
+
VALUE self, descendant;
|
162
|
+
{
|
163
|
+
return CBOOL2RVAL(gtk_tree_path_is_ancestor(_SELF(self), _SELF(descendant)));
|
164
|
+
}
|
165
|
+
|
166
|
+
static VALUE
|
167
|
+
treepath_is_descendant(self, ancestor)
|
168
|
+
VALUE self, ancestor;
|
169
|
+
{
|
170
|
+
return CBOOL2RVAL(gtk_tree_path_is_descendant(_SELF(self), _SELF(ancestor)));
|
171
|
+
}
|
172
|
+
|
173
|
+
void
|
174
|
+
Init_gtk_treepath()
|
175
|
+
{
|
176
|
+
VALUE gTreepath = G_DEF_CLASS(GTK_TYPE_TREE_PATH, "TreePath", mGtk);
|
177
|
+
|
178
|
+
id_equal = rb_intern("==");
|
179
|
+
|
180
|
+
rb_define_method(gTreepath, "initialize", treepath_initialize, -1);
|
181
|
+
rb_define_method(gTreepath, "to_str", treepath_to_string, 0);
|
182
|
+
rb_define_alias(gTreepath, "to_s", "to_str");
|
183
|
+
rb_define_method(gTreepath, "append_index", treepath_append_index, 1);
|
184
|
+
rb_define_method(gTreepath, "prepend_index", treepath_prepend_index, 1);
|
185
|
+
rb_define_method(gTreepath, "depth", treepath_get_depth, 0);
|
186
|
+
rb_define_method(gTreepath, "indices", treepath_get_indices, 0);
|
187
|
+
rb_define_method(gTreepath, "<=>", treepath_compare, 1);
|
188
|
+
rb_define_method(gTreepath, "==", treepath_equal, 1);
|
189
|
+
rb_define_method(gTreepath, "next!", treepath_next, 0);
|
190
|
+
rb_define_method(gTreepath, "prev!", treepath_prev, 0);
|
191
|
+
rb_define_method(gTreepath, "up!", treepath_up, 0);
|
192
|
+
rb_define_method(gTreepath, "down!", treepath_down, 0);
|
193
|
+
rb_define_method(gTreepath, "ancestor?", treepath_is_ancestor, 1);
|
194
|
+
rb_define_method(gTreepath, "descendant?", treepath_is_descendant, 1);
|
195
|
+
}
|