1 // Generated by gtkmmproc -- DO NOT MODIFY!
4 #include <gtkmm/treeselection.h>
5 #include <gtkmm/private/treeselection_p.h>
10 /* Copyright 1998-2002 The gtkmm Development Team
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with this library; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <gtkmm/treeview.h>
28 #include <gtk/gtktreeselection.h>
31 static void proxy_foreach_selection_iter_callback(GtkTreeModel* model, GtkTreePath*, GtkTreeIter* iter, void* data)
33 typedef Gtk::TreeSelection::SlotForeachIter SlotType;
34 SlotType& slot = *static_cast<SlotType*>(data);
36 #ifdef GLIBMM_EXCEPTIONS_ENABLED
39 #endif //GLIBMM_EXCEPTIONS_ENABLED
40 slot(Gtk::TreeModel::iterator(model, iter));
41 #ifdef GLIBMM_EXCEPTIONS_ENABLED
45 Glib::exception_handlers_invoke();
47 #endif //GLIBMM_EXCEPTIONS_ENABLED
50 static void proxy_foreach_selection_path_callback(GtkTreeModel*, GtkTreePath* path, GtkTreeIter*, void* data)
52 typedef Gtk::TreeSelection::SlotForeachPath SlotType;
53 SlotType& slot = *static_cast<SlotType*>(data);
55 #ifdef GLIBMM_EXCEPTIONS_ENABLED
58 #endif //GLIBMM_EXCEPTIONS_ENABLED
59 slot(Gtk::TreeModel::Path(path, true));
60 #ifdef GLIBMM_EXCEPTIONS_ENABLED
64 Glib::exception_handlers_invoke();
66 #endif //GLIBMM_EXCEPTIONS_ENABLED
69 static void proxy_foreach_selection_path_and_iter_callback(GtkTreeModel* model, GtkTreePath* path,
70 GtkTreeIter* iter, void* data)
72 typedef Gtk::TreeSelection::SlotForeachPathAndIter SlotType;
73 SlotType& slot = *static_cast<SlotType*>(data);
75 #ifdef GLIBMM_EXCEPTIONS_ENABLED
78 #endif //GLIBMM_EXCEPTIONS_ENABLED
79 slot(Gtk::TreeModel::Path(path, true), Gtk::TreeModel::iterator(model, iter));
80 #ifdef GLIBMM_EXCEPTIONS_ENABLED
84 Glib::exception_handlers_invoke();
86 #endif //GLIBMM_EXCEPTIONS_ENABLED
90 static gboolean SignalProxy_Select_gtk_callback(GtkTreeSelection*, GtkTreeModel* model, GtkTreePath* path,
91 gboolean path_currently_selected, void* data)
93 const Gtk::TreeSelection::SlotSelect* the_slot = static_cast<Gtk::TreeSelection::SlotSelect*>(data);
95 #ifdef GLIBMM_EXCEPTIONS_ENABLED
98 #endif //GLIBMM_EXCEPTIONS_ENABLED
99 return (*the_slot)(Glib::wrap(model, true), // take copy
100 Gtk::TreePath(path, true), // take copy
101 path_currently_selected);
102 #ifdef GLIBMM_EXCEPTIONS_ENABLED
106 Glib::exception_handlers_invoke();
110 #endif //GLIBMM_EXCEPTIONS_ENABLED
113 static void SignalProxy_Select_gtk_callback_destroy(void* data)
115 delete static_cast<Gtk::TreeSelection::SlotSelect*>(data);
122 void TreeSelection::set_select_function(const SlotSelect& slot)
124 // Create a copy of the slot. A pointer to this will be passed
125 // through the callback's data parameter. It will be deleted
126 // when SignalProxy_Select_gtk_callback_destroy() is called.
127 SlotSelect* slot_copy = new SlotSelect(slot);
129 gtk_tree_selection_set_select_function(gobj(),
130 &SignalProxy_Select_gtk_callback, slot_copy,
131 &SignalProxy_Select_gtk_callback_destroy);
134 Glib::RefPtr<TreeModel> TreeSelection::get_model()
136 GtkTreeView *const tree_view = gtk_tree_selection_get_tree_view(gobj());
137 return Glib::wrap(gtk_tree_view_get_model(tree_view), true);
140 Glib::RefPtr<const TreeModel> TreeSelection::get_model() const
142 GtkTreeView *const tree_view = gtk_tree_selection_get_tree_view(const_cast<GtkTreeSelection*>(gobj()));
143 return Glib::wrap(gtk_tree_view_get_model(tree_view), true);
146 TreeModel::iterator TreeSelection::get_selected()
148 TreeModel::iterator iter;
149 GtkTreeModel* model_gobject = 0;
151 gtk_tree_selection_get_selected(gobj(), &model_gobject, iter.gobj());
153 iter.set_model_gobject(model_gobject);
157 TreeModel::iterator TreeSelection::get_selected(Glib::RefPtr<TreeModel>& model)
159 TreeModel::iterator iter;
160 GtkTreeModel* model_gobject = 0;
162 gtk_tree_selection_get_selected(gobj(), &model_gobject, iter.gobj());
164 model = Glib::wrap(model_gobject, true);
166 iter.set_model_refptr(model);
170 void TreeSelection::selected_foreach_iter(const SlotForeachIter& slot) const
172 SlotForeachIter slot_copy (slot);
173 gtk_tree_selection_selected_foreach(const_cast<GtkTreeSelection*>(gobj()), &proxy_foreach_selection_iter_callback, &slot_copy);
176 void TreeSelection::selected_foreach_path(const SlotForeachPath& slot) const
178 SlotForeachPath slot_copy (slot);
179 gtk_tree_selection_selected_foreach(const_cast<GtkTreeSelection*>(gobj()), &proxy_foreach_selection_path_callback, &slot_copy);
182 void TreeSelection::selected_foreach(const SlotForeachPathAndIter& slot) const
184 SlotForeachPathAndIter slot_copy (slot);
185 gtk_tree_selection_selected_foreach(const_cast<GtkTreeSelection*>(gobj()), &proxy_foreach_selection_path_and_iter_callback, &slot_copy);
188 TreeSelection::ListHandle_Path TreeSelection::get_selected_rows() const
190 return ListHandle_Path(gtk_tree_selection_get_selected_rows(
191 const_cast<GtkTreeSelection*>(gobj()), 0), Glib::OWNERSHIP_DEEP);
194 TreeSelection::ListHandle_Path TreeSelection::get_selected_rows(Glib::RefPtr<TreeModel>& model)
196 GtkTreeModel* model_gobject = 0;
198 const ListHandle_Path result (gtk_tree_selection_get_selected_rows(
199 const_cast<GtkTreeSelection*>(gobj()), &model_gobject), Glib::OWNERSHIP_DEEP);
201 model = Glib::wrap(model_gobject, true);
212 static const Glib::SignalProxyInfo TreeSelection_signal_changed_info =
215 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
216 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
220 } // anonymous namespace
226 Glib::RefPtr<Gtk::TreeSelection> wrap(GtkTreeSelection* object, bool take_copy)
228 return Glib::RefPtr<Gtk::TreeSelection>( dynamic_cast<Gtk::TreeSelection*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
229 //We use dynamic_cast<> in case of multiple inheritance.
232 } /* namespace Glib */
239 /* The *_Class implementation: */
241 const Glib::Class& TreeSelection_Class::init()
243 if(!gtype_) // create the GType if necessary
245 // Glib::Class has to know the class init function to clone custom types.
246 class_init_func_ = &TreeSelection_Class::class_init_function;
248 // This is actually just optimized away, apparently with no harm.
249 // Make sure that the parent type has been created.
250 //CppClassParent::CppObjectType::get_type();
252 // Create the wrapper type, with the same class/instance size as the base type.
253 register_derived_type(gtk_tree_selection_get_type());
255 // Add derived versions of interfaces, if the C type implements any interfaces:
261 void TreeSelection_Class::class_init_function(void* g_class, void* class_data)
263 BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
264 CppClassParent::class_init_function(klass, class_data);
266 #ifdef GLIBMM_VFUNCS_ENABLED
267 #endif //GLIBMM_VFUNCS_ENABLED
269 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
270 klass->changed = &changed_callback;
271 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
274 #ifdef GLIBMM_VFUNCS_ENABLED
275 #endif //GLIBMM_VFUNCS_ENABLED
277 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
278 void TreeSelection_Class::changed_callback(GtkTreeSelection* self)
280 Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
281 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
283 // Non-gtkmmproc-generated custom classes implicitly call the default
284 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
285 // generated classes can use this optimisation, which avoids the unnecessary
286 // parameter conversions if there is no possibility of the virtual function
288 if(obj_base && obj_base->is_derived_())
290 CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
291 if(obj) // This can be NULL during destruction.
293 #ifdef GLIBMM_EXCEPTIONS_ENABLED
294 try // Trap C++ exceptions which would normally be lost because this is a C callback.
296 #endif //GLIBMM_EXCEPTIONS_ENABLED
297 // Call the virtual member method, which derived classes might override.
300 #ifdef GLIBMM_EXCEPTIONS_ENABLED
304 Glib::exception_handlers_invoke();
306 #endif //GLIBMM_EXCEPTIONS_ENABLED
310 BaseClassType *const base = static_cast<BaseClassType*>(
311 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
314 // Call the original underlying C function:
315 if(base && base->changed)
316 (*base->changed)(self);
318 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
321 Glib::ObjectBase* TreeSelection_Class::wrap_new(GObject* object)
323 return new TreeSelection((GtkTreeSelection*)object);
327 /* The implementation: */
329 GtkTreeSelection* TreeSelection::gobj_copy()
335 TreeSelection::TreeSelection(const Glib::ConstructParams& construct_params)
337 Glib::Object(construct_params)
340 TreeSelection::TreeSelection(GtkTreeSelection* castitem)
342 Glib::Object((GObject*)(castitem))
345 TreeSelection::~TreeSelection()
349 TreeSelection::CppClassType TreeSelection::treeselection_class_; // initialize static member
351 GType TreeSelection::get_type()
353 return treeselection_class_.init().get_type();
356 GType TreeSelection::get_base_type()
358 return gtk_tree_selection_get_type();
362 void TreeSelection::set_mode(SelectionMode type)
364 gtk_tree_selection_set_mode(gobj(), ((GtkSelectionMode)(type)));
367 SelectionMode TreeSelection::get_mode() const
369 return ((SelectionMode)(gtk_tree_selection_get_mode(const_cast<GtkTreeSelection*>(gobj()))));
372 TreeView* TreeSelection::get_tree_view()
374 return Glib::wrap(gtk_tree_selection_get_tree_view(gobj()));
377 const TreeView* TreeSelection::get_tree_view() const
379 return const_cast<TreeSelection*>(this)->get_tree_view();
382 int TreeSelection::count_selected_rows() const
384 return gtk_tree_selection_count_selected_rows(const_cast<GtkTreeSelection*>(gobj()));
387 void TreeSelection::select(const TreeModel::Path& path)
389 gtk_tree_selection_select_path(gobj(), const_cast<GtkTreePath*>((path).gobj()));
392 void TreeSelection::select(const TreeModel::iterator& iter)
394 gtk_tree_selection_select_iter(gobj(), const_cast<GtkTreeIter*>((iter).gobj()));
397 void TreeSelection::select(const TreeModel::Row& row)
399 gtk_tree_selection_select_iter(gobj(), const_cast<GtkTreeIter*>((row).gobj()));
402 void TreeSelection::select(const TreeModel::Path& start_path, const TreeModel::Path& end_path)
404 gtk_tree_selection_select_range(gobj(), const_cast<GtkTreePath*>((start_path).gobj()), const_cast<GtkTreePath*>((end_path).gobj()));
407 void TreeSelection::unselect(const TreeModel::Path& path)
409 gtk_tree_selection_unselect_path(gobj(), const_cast<GtkTreePath*>((path).gobj()));
412 void TreeSelection::unselect(const TreeModel::Path& start_path, const TreeModel::Path& end_path)
414 gtk_tree_selection_unselect_range(gobj(), const_cast<GtkTreePath*>((start_path).gobj()), const_cast<GtkTreePath*>((end_path).gobj()));
417 void TreeSelection::unselect(const TreeModel::iterator& iter)
419 gtk_tree_selection_unselect_iter(gobj(), const_cast<GtkTreeIter*>((iter).gobj()));
422 bool TreeSelection::is_selected(const TreeModel::Path& path) const
424 return gtk_tree_selection_path_is_selected(const_cast<GtkTreeSelection*>(gobj()), const_cast<GtkTreePath*>((path).gobj()));
427 bool TreeSelection::is_selected(const TreeModel::iterator& iter) const
429 return gtk_tree_selection_iter_is_selected(const_cast<GtkTreeSelection*>(gobj()), const_cast<GtkTreeIter*>((iter).gobj()));
432 void TreeSelection::select_all()
434 gtk_tree_selection_select_all(gobj());
437 void TreeSelection::unselect_all()
439 gtk_tree_selection_unselect_all(gobj());
443 Glib::SignalProxy0< void > TreeSelection::signal_changed()
445 return Glib::SignalProxy0< void >(this, &TreeSelection_signal_changed_info);
449 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
450 void Gtk::TreeSelection::on_changed()
452 BaseClassType *const base = static_cast<BaseClassType*>(
453 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
456 if(base && base->changed)
457 (*base->changed)(gobj());
459 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
461 #ifdef GLIBMM_VFUNCS_ENABLED
462 #endif //GLIBMM_VFUNCS_ENABLED