1 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #include <gtkmm/treemodelfilter.h>
4 #include <gtkmm/private/treemodelfilter_p.h>
9 /* Copyright 1998-2002 The gtkmm Development Team
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.
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.
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.
26 #include <gtk/gtktreemodelfilter.h>
31 // This Signal Proxy allows the C++ coder to specify
32 // a sigc::slot instead of a static function.
33 class SignalProxy_Visible
36 typedef Gtk::TreeModelFilter::SlotVisible SlotType;
38 SignalProxy_Visible(const SlotType& slot)
41 ~SignalProxy_Visible();
43 static gboolean gtk_callback(GtkTreeModel* model, GtkTreeIter* iter, gpointer data);
44 static void gtk_callback_destroy(void* data);
50 SignalProxy_Visible::~SignalProxy_Visible()
53 gboolean SignalProxy_Visible::gtk_callback(GtkTreeModel* model, GtkTreeIter* iter, gpointer data)
55 SignalProxy_Visible *const self = static_cast<SignalProxy_Visible*>(data);
59 return (self->slot_)( Gtk::TreeModel::const_iterator(model, iter) );
63 Glib::exception_handlers_invoke();
66 return FALSE; //An arbitary default, just to avoid the compiler warning.
69 void SignalProxy_Visible::gtk_callback_destroy(void* data)
71 delete static_cast<SignalProxy_Visible*>(data);
75 // This Signal Proxy allows the C++ coder to specify
76 // a sigc::slot instead of a static function.
77 class SignalProxy_Modify
80 typedef Gtk::TreeModelFilter::SlotModify SlotType;
82 SignalProxy_Modify(const SlotType& slot)
85 ~SignalProxy_Modify();
87 static void gtk_callback(GtkTreeModel* model, GtkTreeIter* iter, GValue* value, gint column, gpointer data);
88 static void gtk_callback_destroy(void* data);
94 SignalProxy_Modify::~SignalProxy_Modify()
97 void SignalProxy_Modify::gtk_callback(GtkTreeModel* model, GtkTreeIter* iter, GValue* value, gint column, gpointer data)
99 SignalProxy_Modify *const self = static_cast<SignalProxy_Modify*>(data);
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);
109 (self->slot_)( Gtk::TreeModel::const_iterator(model, iter), cppValue, column );
111 //GTK+ has already done this for us: g_value_init(value, column_type);
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 */);
119 Glib::exception_handlers_invoke();
123 void SignalProxy_Modify::gtk_callback_destroy(void* data)
125 delete static_cast<SignalProxy_Modify*>(data);
129 } // anonymous namespace
132 typedef Gtk::TreeModel::Path Path; //So that the generated method implemenations can use this a return type.
137 TreeModelFilter::TreeModelFilter(const Glib::RefPtr<TreeModel>& child_model)
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))
144 TreeModelFilter::TreeModelFilter(const Glib::RefPtr<TreeModel>& child_model, const TreeModel::Path& virtual_root)
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))
151 void TreeModelFilter::set_visible_func(const SlotVisible& slot)
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);
158 gtk_tree_model_filter_set_visible_func(gobj(),
159 &SignalProxy_Visible::gtk_callback, pSignalProxy,
160 &SignalProxy_Visible::gtk_callback_destroy);
164 TreeModel::iterator TreeModelFilter::convert_child_iter_to_iter(const iterator& child_iter) const
166 TreeIter filter_iter (const_cast<TreeModelFilter*>(this));
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()));
175 TreeModel::iterator TreeModelFilter::convert_iter_to_child_iter(const iterator& filter_iter) const
177 GtkTreeModel *const child_model = gtk_tree_model_filter_get_model(const_cast<GtkTreeModelFilter*>(gobj()));
179 TreeIter child_iter (dynamic_cast<TreeModel*>(Glib::wrap_auto((GObject*) child_model, false)));
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()));
188 void TreeModelFilter::set_modify_func(const TreeModelColumnRecord& columns, const SlotModify& slot)
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);
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);
201 void TreeModelFilter::set_value_impl(const iterator& /* row */, int /* column */, const Glib::ValueBase& /* value */)
203 g_warning("Attempt to set a value of a row in a TreeModelFilter instead of in the child model.");
212 } // anonymous namespace
218 Glib::RefPtr<Gtk::TreeModelFilter> wrap(GtkTreeModelFilter* object, bool take_copy)
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.
224 } /* namespace Glib */
231 /* The *_Class implementation: */
233 const Glib::Class& TreeModelFilter_Class::init()
235 if(!gtype_) // create the GType if necessary
237 // Glib::Class has to know the class init function to clone custom types.
238 class_init_func_ = &TreeModelFilter_Class::class_init_function;
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();
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());
247 // Add derived versions of interfaces, if the C type implements any interfaces:
248 TreeModel::add_interface(get_type());
254 void TreeModelFilter_Class::class_init_function(void* g_class, void* class_data)
256 BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
257 CppClassParent::class_init_function(klass, class_data);
262 Glib::ObjectBase* TreeModelFilter_Class::wrap_new(GObject* object)
264 return new TreeModelFilter((GtkTreeModelFilter*)object);
268 /* The implementation: */
270 GtkTreeModelFilter* TreeModelFilter::gobj_copy()
276 TreeModelFilter::TreeModelFilter(const Glib::ConstructParams& construct_params)
278 Glib::Object(construct_params)
281 TreeModelFilter::TreeModelFilter(GtkTreeModelFilter* castitem)
283 Glib::Object((GObject*)(castitem))
286 TreeModelFilter::~TreeModelFilter()
290 TreeModelFilter::CppClassType TreeModelFilter::treemodelfilter_class_; // initialize static member
292 GType TreeModelFilter::get_type()
294 return treemodelfilter_class_.init().get_type();
297 GType TreeModelFilter::get_base_type()
299 return gtk_tree_model_filter_get_type();
303 Glib::RefPtr<TreeModelFilter> TreeModelFilter::create(const Glib::RefPtr<TreeModel>& child_model)
305 return Glib::RefPtr<TreeModelFilter>( new TreeModelFilter(child_model) );
307 Glib::RefPtr<TreeModelFilter> TreeModelFilter::create(const Glib::RefPtr<TreeModel>& child_model, const TreeModel::Path& virtual_root)
309 return Glib::RefPtr<TreeModelFilter>( new TreeModelFilter(child_model, virtual_root) );
311 void TreeModelFilter::set_visible_column(const TreeModelColumnBase& column)
313 gtk_tree_model_filter_set_visible_column(gobj(), (column).index());
316 void TreeModelFilter::set_visible_column(int column)
318 gtk_tree_model_filter_set_visible_column(gobj(), column);
321 Glib::RefPtr<TreeModel> TreeModelFilter::get_model()
324 Glib::RefPtr<TreeModel> retvalue = Glib::wrap(gtk_tree_model_filter_get_model(gobj()));
327 retvalue->reference(); //The function does not do a ref for us.
331 Glib::RefPtr<const TreeModel> TreeModelFilter::get_model() const
334 Glib::RefPtr<const TreeModel> retvalue = Glib::wrap(gtk_tree_model_filter_get_model(const_cast<GtkTreeModelFilter*>(gobj())));
337 retvalue->reference(); //The function does not do a ref for us.
341 Path TreeModelFilter::convert_child_path_to_path(const Path& child_path)
343 return Gtk::TreePath(gtk_tree_model_filter_convert_child_path_to_path(gobj(), const_cast<GtkTreePath*>((child_path).gobj())), false);
346 Path TreeModelFilter::convert_path_to_child_path(const Path& filter_path)
348 return Gtk::TreePath(gtk_tree_model_filter_convert_path_to_child_path(gobj(), const_cast<GtkTreePath*>((filter_path).gobj())), false);
351 Path TreeModelFilter::convert_child_path_to_path(const Path& child_path) const
353 return Gtk::TreePath(gtk_tree_model_filter_convert_child_path_to_path(const_cast<GtkTreeModelFilter*>(gobj()), const_cast<GtkTreePath*>((child_path).gobj())), false);
356 Path TreeModelFilter::convert_path_to_child_path(const Path& filter_path) const
358 return Gtk::TreePath(gtk_tree_model_filter_convert_path_to_child_path(const_cast<GtkTreeModelFilter*>(gobj()), const_cast<GtkTreePath*>((filter_path).gobj())), false);
361 void TreeModelFilter::refilter()
363 gtk_tree_model_filter_refilter(gobj());
366 void TreeModelFilter::clear_cache()
368 gtk_tree_model_filter_clear_cache(gobj());