Install ardour as a binary, a script and a set of shared
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / treemodelfilter.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3 #include <gtkmm/treemodelfilter.h>
4 #include <gtkmm/private/treemodelfilter_p.h>
5
6 // -*- c++ -*-
7 /* $Id$ */
8
9 /* Copyright 1998-2002 The gtkmm Development Team
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Library General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Library General Public License for more details.
20  *
21  * You should have received a copy of the GNU Library General Public
22  * License along with this library; if not, write to the Free
23  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25
26 #include <gtk/gtktreemodelfilter.h>
27
28 namespace //anonymous
29 {
30
31 // This Signal Proxy allows the C++ coder to specify
32 // a sigc::slot instead of a static function.
33 class SignalProxy_Visible
34 {
35 public:
36   typedef Gtk::TreeModelFilter::SlotVisible SlotType;
37
38   SignalProxy_Visible(const SlotType& slot)
39   : slot_(slot) {}
40
41   ~SignalProxy_Visible();
42
43   static gboolean gtk_callback(GtkTreeModel* model, GtkTreeIter* iter, gpointer data);
44   static void gtk_callback_destroy(void* data);
45
46 private:
47   SlotType slot_;
48 };
49
50 SignalProxy_Visible::~SignalProxy_Visible()
51 {}
52
53 gboolean SignalProxy_Visible::gtk_callback(GtkTreeModel* model, GtkTreeIter* iter, gpointer data)
54 {
55   SignalProxy_Visible *const self = static_cast<SignalProxy_Visible*>(data);
56
57   try
58   {
59     return (self->slot_)( Gtk::TreeModel::const_iterator(model, iter) );
60   }
61   catch(...)
62   {
63     Glib::exception_handlers_invoke();
64   }
65
66   return FALSE; //An arbitary default, just to avoid the compiler warning.
67 }
68
69 void SignalProxy_Visible::gtk_callback_destroy(void* data)
70 {
71   delete static_cast<SignalProxy_Visible*>(data);
72 }
73
74
75 // This Signal Proxy allows the C++ coder to specify
76 // a sigc::slot instead of a static function.
77 class SignalProxy_Modify
78 {
79 public:
80   typedef Gtk::TreeModelFilter::SlotModify SlotType;
81
82   SignalProxy_Modify(const SlotType& slot)
83   : slot_(slot) {}
84
85   ~SignalProxy_Modify();
86
87   static void gtk_callback(GtkTreeModel* model, GtkTreeIter* iter, GValue* value, gint column, gpointer data);
88   static void gtk_callback_destroy(void* data);
89
90 private:
91   SlotType slot_;
92 };
93
94 SignalProxy_Modify::~SignalProxy_Modify()
95 {}
96
97 void SignalProxy_Modify::gtk_callback(GtkTreeModel* model, GtkTreeIter* iter, GValue* value, gint column, gpointer data)
98 {
99   SignalProxy_Modify *const self = static_cast<SignalProxy_Modify*>(data);
100
101   try
102   {
103     //Initialize the input parameter with the appropriate type for this column.
104     //Then the C++ handler can just use operator==() without calling init on the value output arg:
105     Glib::ValueBase cppValue;
106     GType column_type = gtk_tree_model_get_column_type(model, column);
107     cppValue.init(column_type);
108     
109     (self->slot_)( Gtk::TreeModel::const_iterator(model, iter), cppValue, column );
110
111     //GTK+ has already done this for us: g_value_init(value, column_type);
112
113     //If the C++ handler has inited value with an inappropriate GType, then this will fail,
114     //but they should not do that because it makes no sense.
115     g_value_copy(cppValue.gobj() /* source */, value /* destination */);  
116   }
117   catch(...)
118   {
119     Glib::exception_handlers_invoke();
120   }
121 }
122
123 void SignalProxy_Modify::gtk_callback_destroy(void* data)
124 {
125   delete static_cast<SignalProxy_Modify*>(data);
126 }
127
128
129 } // anonymous namespace
130
131
132 typedef Gtk::TreeModel::Path Path; //So that the generated method implemenations can use this a return type.
133
134 namespace Gtk
135 {
136
137 TreeModelFilter::TreeModelFilter(const Glib::RefPtr<TreeModel>& child_model)
138 :
139   Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
140   Glib::Object(Glib::ConstructParams(treemodelfilter_class_.init(), "child_model",child_model->gobj(), (char*) 0))
141 {
142 }
143
144 TreeModelFilter::TreeModelFilter(const Glib::RefPtr<TreeModel>& child_model, const TreeModel::Path& virtual_root)
145 :
146   Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
147   Glib::Object(Glib::ConstructParams(treemodelfilter_class_.init(), "child_model",child_model->gobj(),"virtual_root",(virtual_root.empty() ? 0 : const_cast<GtkTreePath*>((virtual_root).gobj())) , (char*) 0))
148 {
149 }
150
151 void TreeModelFilter::set_visible_func(const SlotVisible& slot)
152 {
153   // Create a signal proxy.  A pointer to this will be passed
154   // through the callback's data parameter.  It will be deleted
155   // when SignalProxy_Visible::gtk_callback_destroy() is called.
156   SignalProxy_Visible *const pSignalProxy = new SignalProxy_Visible(slot);
157
158   gtk_tree_model_filter_set_visible_func(gobj(),
159       &SignalProxy_Visible::gtk_callback, pSignalProxy,
160       &SignalProxy_Visible::gtk_callback_destroy);
161 }
162
163
164 TreeModel::iterator TreeModelFilter::convert_child_iter_to_iter(const iterator& child_iter) const
165 {
166   TreeIter filter_iter (const_cast<TreeModelFilter*>(this));
167
168   gtk_tree_model_filter_convert_child_iter_to_iter(
169       const_cast<GtkTreeModelFilter*>(gobj()), filter_iter.gobj(),
170       const_cast<GtkTreeIter*>(child_iter.gobj()));
171
172   return filter_iter;
173 }
174
175 TreeModel::iterator TreeModelFilter::convert_iter_to_child_iter(const iterator& filter_iter) const
176 {
177   GtkTreeModel *const child_model = gtk_tree_model_filter_get_model(const_cast<GtkTreeModelFilter*>(gobj()));
178
179   TreeIter child_iter (dynamic_cast<TreeModel*>(Glib::wrap_auto((GObject*) child_model, false)));
180
181   gtk_tree_model_filter_convert_iter_to_child_iter(
182       const_cast<GtkTreeModelFilter*>(gobj()), child_iter.gobj(),
183       const_cast<GtkTreeIter*>(filter_iter.gobj()));
184
185   return child_iter;
186 }
187
188 void TreeModelFilter::set_modify_func(const TreeModelColumnRecord& columns, const SlotModify& slot)
189 {
190   // Create a signal proxy.  A pointer to this will be passed
191   // through the callback's data parameter.  It will be deleted
192   // when SignalProxy_Modify::gtk_callback_destroy() is called.
193   SignalProxy_Modify *const pSignalProxy = new SignalProxy_Modify(slot);
194
195   gtk_tree_model_filter_set_modify_func(gobj(),
196     columns.size(), const_cast<GType*>(columns.types()),
197     &SignalProxy_Modify::gtk_callback, pSignalProxy,
198     &SignalProxy_Modify::gtk_callback_destroy);
199 }
200
201 void TreeModelFilter::set_value_impl(const iterator& /* row */, int /* column */, const Glib::ValueBase& /* value */)
202 {
203   g_warning("Attempt to set a value of a row in a TreeModelFilter instead of in the child model.");
204 }
205
206
207 } // namespace Gtk
208
209
210 namespace
211 {
212 } // anonymous namespace
213
214
215 namespace Glib
216 {
217
218 Glib::RefPtr<Gtk::TreeModelFilter> wrap(GtkTreeModelFilter* object, bool take_copy)
219 {
220   return Glib::RefPtr<Gtk::TreeModelFilter>( dynamic_cast<Gtk::TreeModelFilter*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
221   //We use dynamic_cast<> in case of multiple inheritance.
222 }
223
224 } /* namespace Glib */
225
226
227 namespace Gtk
228 {
229
230
231 /* The *_Class implementation: */
232
233 const Glib::Class& TreeModelFilter_Class::init()
234 {
235   if(!gtype_) // create the GType if necessary
236   {
237     // Glib::Class has to know the class init function to clone custom types.
238     class_init_func_ = &TreeModelFilter_Class::class_init_function;
239
240     // This is actually just optimized away, apparently with no harm.
241     // Make sure that the parent type has been created.
242     //CppClassParent::CppObjectType::get_type();
243
244     // Create the wrapper type, with the same class/instance size as the base type.
245     register_derived_type(gtk_tree_model_filter_get_type());
246
247     // Add derived versions of interfaces, if the C type implements any interfaces:
248   TreeModel::add_interface(get_type());
249   }
250
251   return *this;
252 }
253
254 void TreeModelFilter_Class::class_init_function(void* g_class, void* class_data)
255 {
256   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
257   CppClassParent::class_init_function(klass, class_data);
258
259 }
260
261
262 Glib::ObjectBase* TreeModelFilter_Class::wrap_new(GObject* object)
263 {
264   return new TreeModelFilter((GtkTreeModelFilter*)object);
265 }
266
267
268 /* The implementation: */
269
270 GtkTreeModelFilter* TreeModelFilter::gobj_copy()
271 {
272   reference();
273   return gobj();
274 }
275
276 TreeModelFilter::TreeModelFilter(const Glib::ConstructParams& construct_params)
277 :
278   Glib::Object(construct_params)
279 {}
280
281 TreeModelFilter::TreeModelFilter(GtkTreeModelFilter* castitem)
282 :
283   Glib::Object((GObject*)(castitem))
284 {}
285
286 TreeModelFilter::~TreeModelFilter()
287 {}
288
289
290 TreeModelFilter::CppClassType TreeModelFilter::treemodelfilter_class_; // initialize static member
291
292 GType TreeModelFilter::get_type()
293 {
294   return treemodelfilter_class_.init().get_type();
295 }
296
297 GType TreeModelFilter::get_base_type()
298 {
299   return gtk_tree_model_filter_get_type();
300 }
301
302
303 Glib::RefPtr<TreeModelFilter> TreeModelFilter::create(const Glib::RefPtr<TreeModel>& child_model)
304 {
305   return Glib::RefPtr<TreeModelFilter>( new TreeModelFilter(child_model) );
306 }
307 Glib::RefPtr<TreeModelFilter> TreeModelFilter::create(const Glib::RefPtr<TreeModel>& child_model, const TreeModel::Path& virtual_root)
308 {
309   return Glib::RefPtr<TreeModelFilter>( new TreeModelFilter(child_model, virtual_root) );
310 }
311 void TreeModelFilter::set_visible_column(const TreeModelColumnBase& column)
312 {
313   gtk_tree_model_filter_set_visible_column(gobj(), (column).index());
314 }
315
316 void TreeModelFilter::set_visible_column(int column)
317 {
318   gtk_tree_model_filter_set_visible_column(gobj(), column);
319 }
320
321 Glib::RefPtr<TreeModel> TreeModelFilter::get_model()
322 {
323
324   Glib::RefPtr<TreeModel> retvalue = Glib::wrap(gtk_tree_model_filter_get_model(gobj()));
325
326   if(retvalue)
327     retvalue->reference(); //The function does not do a ref for us.
328   return retvalue;
329 }
330
331 Glib::RefPtr<const TreeModel> TreeModelFilter::get_model() const
332 {
333
334   Glib::RefPtr<const TreeModel> retvalue = Glib::wrap(gtk_tree_model_filter_get_model(const_cast<GtkTreeModelFilter*>(gobj())));
335
336   if(retvalue)
337     retvalue->reference(); //The function does not do a ref for us.
338   return retvalue;
339 }
340
341 Path TreeModelFilter::convert_child_path_to_path(const Path& child_path)
342 {
343   return Gtk::TreePath(gtk_tree_model_filter_convert_child_path_to_path(gobj(), const_cast<GtkTreePath*>((child_path).gobj())), false);
344 }
345
346 Path TreeModelFilter::convert_path_to_child_path(const Path& filter_path)
347 {
348   return Gtk::TreePath(gtk_tree_model_filter_convert_path_to_child_path(gobj(), const_cast<GtkTreePath*>((filter_path).gobj())), false);
349 }
350
351 Path TreeModelFilter::convert_child_path_to_path(const Path& child_path) const
352 {
353   return Gtk::TreePath(gtk_tree_model_filter_convert_child_path_to_path(const_cast<GtkTreeModelFilter*>(gobj()), const_cast<GtkTreePath*>((child_path).gobj())), false);
354 }
355
356 Path TreeModelFilter::convert_path_to_child_path(const Path& filter_path) const
357 {
358   return Gtk::TreePath(gtk_tree_model_filter_convert_path_to_child_path(const_cast<GtkTreeModelFilter*>(gobj()), const_cast<GtkTreePath*>((filter_path).gobj())), false);
359 }
360
361 void TreeModelFilter::refilter()
362 {
363   gtk_tree_model_filter_refilter(gobj());
364 }
365
366 void TreeModelFilter::clear_cache()
367 {
368   gtk_tree_model_filter_clear_cache(gobj());
369 }
370
371
372 } // namespace Gtk
373
374