1 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #include <gtkmm/treesortable.h>
4 #include <gtkmm/private/treesortable_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.
29 // This Signal Proxy allows the C++ coder to specify a sigc::slot instead of a static function.
30 class SignalProxy_Compare
33 typedef Gtk::TreeSortable::SlotCompare SlotType;
35 explicit SignalProxy_Compare(const SlotType& slot);
36 ~SignalProxy_Compare();
38 static int gtk_callback(GtkTreeModel* model, GtkTreeIter* lhs, GtkTreeIter* rhs, void* data);
39 static void gtk_callback_destroy(void* data);
45 SignalProxy_Compare::SignalProxy_Compare(const SlotType& slot)
50 SignalProxy_Compare::~SignalProxy_Compare()
53 int SignalProxy_Compare::gtk_callback(GtkTreeModel* model, GtkTreeIter* lhs, GtkTreeIter* rhs, void* data)
55 SignalProxy_Compare *const self = static_cast<SignalProxy_Compare*>(data);
59 // use Slot::operator()
60 return (self->slot_)(Gtk::TreeIter(model, lhs), Gtk::TreeIter(model, rhs));
64 Glib::exception_handlers_invoke();
70 void SignalProxy_Compare::gtk_callback_destroy(void* data)
72 delete static_cast<SignalProxy_Compare*>(data);
75 } // anonymous namespace
81 void TreeSortable::set_sort_func(int sort_column_id, const SlotCompare& slot)
83 SignalProxy_Compare *const pSignalProxy = new SignalProxy_Compare(slot);
85 gtk_tree_sortable_set_sort_func(
86 gobj(), sort_column_id,
87 &SignalProxy_Compare::gtk_callback, pSignalProxy,
88 &SignalProxy_Compare::gtk_callback_destroy);
91 void TreeSortable::set_sort_func(const Gtk::TreeModelColumnBase& sort_column, const SlotCompare& slot)
93 set_sort_func(sort_column.index(), slot);
96 void TreeSortable::set_default_sort_func(const SlotCompare& slot)
98 SignalProxy_Compare *const pSignalProxy = new SignalProxy_Compare(slot);
100 gtk_tree_sortable_set_default_sort_func(
102 &SignalProxy_Compare::gtk_callback, pSignalProxy,
103 &SignalProxy_Compare::gtk_callback_destroy);
106 void TreeSortable::unset_default_sort_func()
108 gtk_tree_sortable_set_default_sort_func(
109 gobj(), 0, 0, 0); /* See GTK+ docs about the 0s. */
113 void TreeSortable::set_sort_column_id(const TreeModelColumnBase& sort_column, SortType order)
115 set_sort_column(sort_column, order);
119 void TreeSortable::set_sort_column_id(int sort_column_id, SortType order)
121 set_sort_column(sort_column_id, order);
130 const Glib::SignalProxyInfo TreeSortable_signal_sort_column_changed_info =
132 "sort_column_changed",
133 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
134 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
137 } // anonymous namespace
143 Glib::RefPtr<Gtk::TreeSortable> wrap(GtkTreeSortable* object, bool take_copy)
145 return Glib::RefPtr<Gtk::TreeSortable>( dynamic_cast<Gtk::TreeSortable*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
146 //We use dynamic_cast<> in case of multiple inheritance.
156 /* The *_Class implementation: */
158 const Glib::Interface_Class& TreeSortable_Class::init()
160 if(!gtype_) // create the GType if necessary
162 // Glib::Interface_Class has to know the interface init function
163 // in order to add interfaces to implementing types.
164 class_init_func_ = &TreeSortable_Class::iface_init_function;
166 // We can not derive from another interface, and it is not necessary anyway.
167 gtype_ = gtk_tree_sortable_get_type();
173 void TreeSortable_Class::iface_init_function(void* g_iface, void*)
175 BaseClassType *const klass = static_cast<BaseClassType*>(g_iface);
177 //This is just to avoid an "unused variable" warning when there are no vfuncs or signal handlers to connect.
178 //This is a temporary fix until I find out why I can not seem to derive a GtkFileChooser interface. murrayc
179 g_assert(klass != 0);
181 klass->get_sort_column_id = &get_sort_column_id_vfunc_callback;
182 klass->set_sort_column_id = &set_sort_column_id_vfunc_callback;
183 klass->set_sort_func = &set_sort_func_vfunc_callback;
184 klass->set_default_sort_func = &set_default_sort_func_vfunc_callback;
185 klass->has_default_sort_func = &has_default_sort_func_vfunc_callback;
186 klass->sort_column_changed = &sort_column_changed_vfunc_callback;
187 klass->sort_column_changed = &sort_column_changed_callback;
190 gboolean TreeSortable_Class::get_sort_column_id_vfunc_callback(GtkTreeSortable* self, int* sort_column_id, GtkSortType* order)
192 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
193 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
195 // Non-gtkmmproc-generated custom classes implicitly call the default
196 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
197 // generated classes can use this optimisation, which avoids the unnecessary
198 // parameter conversions if there is no possibility of the virtual function
200 if(obj && obj->is_derived_())
202 try // Trap C++ exceptions which would normally be lost because this is a C callback.
204 // Call the virtual member method, which derived classes might override.
205 return static_cast<int>(obj->get_sort_column_id_vfunc(sort_column_id, ((SortType*) (order))
210 Glib::exception_handlers_invoke();
215 BaseClassType *const base = static_cast<BaseClassType*>(
216 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
217 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
220 // Call the original underlying C function:
221 if(base && base->get_sort_column_id)
222 return (*base->get_sort_column_id)(self, sort_column_id, order);
225 typedef gboolean RType;
229 void TreeSortable_Class::set_sort_column_id_vfunc_callback(GtkTreeSortable* self, int sort_column_id, GtkSortType order)
231 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
232 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
234 // Non-gtkmmproc-generated custom classes implicitly call the default
235 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
236 // generated classes can use this optimisation, which avoids the unnecessary
237 // parameter conversions if there is no possibility of the virtual function
239 if(obj && obj->is_derived_())
241 try // Trap C++ exceptions which would normally be lost because this is a C callback.
243 // Call the virtual member method, which derived classes might override.
244 obj->set_sort_column_id_vfunc(sort_column_id, ((SortType)(order))
249 Glib::exception_handlers_invoke();
254 BaseClassType *const base = static_cast<BaseClassType*>(
255 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
256 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
259 // Call the original underlying C function:
260 if(base && base->set_sort_column_id)
261 (*base->set_sort_column_id)(self, sort_column_id, order);
265 void TreeSortable_Class::set_sort_func_vfunc_callback(GtkTreeSortable* self, int sort_column_id, GtkTreeIterCompareFunc func, gpointer data, GtkDestroyNotify destroy)
267 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
268 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
270 // Non-gtkmmproc-generated custom classes implicitly call the default
271 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
272 // generated classes can use this optimisation, which avoids the unnecessary
273 // parameter conversions if there is no possibility of the virtual function
275 if(obj && obj->is_derived_())
277 try // Trap C++ exceptions which would normally be lost because this is a C callback.
279 // Call the virtual member method, which derived classes might override.
280 obj->set_sort_func_vfunc(sort_column_id, func, data
285 Glib::exception_handlers_invoke();
290 BaseClassType *const base = static_cast<BaseClassType*>(
291 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
292 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
295 // Call the original underlying C function:
296 if(base && base->set_sort_func)
297 (*base->set_sort_func)(self, sort_column_id, func, data, destroy);
301 void TreeSortable_Class::set_default_sort_func_vfunc_callback(GtkTreeSortable* self, GtkTreeIterCompareFunc func, gpointer data, GtkDestroyNotify destroy)
303 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
304 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
306 // Non-gtkmmproc-generated custom classes implicitly call the default
307 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
308 // generated classes can use this optimisation, which avoids the unnecessary
309 // parameter conversions if there is no possibility of the virtual function
311 if(obj && obj->is_derived_())
313 try // Trap C++ exceptions which would normally be lost because this is a C callback.
315 // Call the virtual member method, which derived classes might override.
316 obj->set_default_sort_func_vfunc(func, data
321 Glib::exception_handlers_invoke();
326 BaseClassType *const base = static_cast<BaseClassType*>(
327 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
328 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
331 // Call the original underlying C function:
332 if(base && base->set_default_sort_func)
333 (*base->set_default_sort_func)(self, func, data, destroy);
337 gboolean TreeSortable_Class::has_default_sort_func_vfunc_callback(GtkTreeSortable* self)
339 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
340 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
342 // Non-gtkmmproc-generated custom classes implicitly call the default
343 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
344 // generated classes can use this optimisation, which avoids the unnecessary
345 // parameter conversions if there is no possibility of the virtual function
347 if(obj && obj->is_derived_())
349 try // Trap C++ exceptions which would normally be lost because this is a C callback.
351 // Call the virtual member method, which derived classes might override.
352 return static_cast<int>(obj->has_default_sort_func_vfunc());
356 Glib::exception_handlers_invoke();
361 BaseClassType *const base = static_cast<BaseClassType*>(
362 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
363 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
366 // Call the original underlying C function:
367 if(base && base->has_default_sort_func)
368 return (*base->has_default_sort_func)(self);
371 typedef gboolean RType;
375 void TreeSortable_Class::sort_column_changed_vfunc_callback(GtkTreeSortable* self)
377 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
378 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
380 // Non-gtkmmproc-generated custom classes implicitly call the default
381 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
382 // generated classes can use this optimisation, which avoids the unnecessary
383 // parameter conversions if there is no possibility of the virtual function
385 if(obj && obj->is_derived_())
387 try // Trap C++ exceptions which would normally be lost because this is a C callback.
389 // Call the virtual member method, which derived classes might override.
390 obj->sort_column_changed_vfunc();
394 Glib::exception_handlers_invoke();
399 BaseClassType *const base = static_cast<BaseClassType*>(
400 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
401 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
404 // Call the original underlying C function:
405 if(base && base->sort_column_changed)
406 (*base->sort_column_changed)(self);
411 void TreeSortable_Class::sort_column_changed_callback(GtkTreeSortable* self)
413 CppObjectType *const obj = dynamic_cast<CppObjectType*>(
414 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
416 // Non-gtkmmproc-generated custom classes implicitly call the default
417 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
418 // generated classes can use this optimisation, which avoids the unnecessary
419 // parameter conversions if there is no possibility of the virtual function
421 if(obj && obj->is_derived_())
423 try // Trap C++ exceptions which would normally be lost because this is a C callback.
425 // Call the virtual member method, which derived classes might override.
426 obj->on_sort_column_changed();
430 Glib::exception_handlers_invoke();
435 BaseClassType *const base = static_cast<BaseClassType*>(
436 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
437 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
440 // Call the original underlying C function:
441 if(base && base->sort_column_changed)
442 (*base->sort_column_changed)(self);
447 Glib::ObjectBase* TreeSortable_Class::wrap_new(GObject* object)
449 return new TreeSortable((GtkTreeSortable*)(object));
453 /* The implementation: */
455 TreeSortable::TreeSortable()
457 Glib::Interface(treesortable_class_.init())
460 TreeSortable::TreeSortable(GtkTreeSortable* castitem)
462 Glib::Interface((GObject*)(castitem))
465 TreeSortable::~TreeSortable()
469 void TreeSortable::add_interface(GType gtype_implementer)
471 treesortable_class_.init().add_interface(gtype_implementer);
474 TreeSortable::CppClassType TreeSortable::treesortable_class_; // initialize static member
476 GType TreeSortable::get_type()
478 return treesortable_class_.init().get_type();
481 GType TreeSortable::get_base_type()
483 return gtk_tree_sortable_get_type();
487 bool TreeSortable::get_sort_column_id(int& sort_column_id, SortType& order) const
489 return gtk_tree_sortable_get_sort_column_id(const_cast<GtkTreeSortable*>(gobj()), &sort_column_id, ((GtkSortType*) &(order)));
492 void TreeSortable::set_sort_column(const TreeModelColumnBase& sort_column_id, SortType order)
494 gtk_tree_sortable_set_sort_column_id(gobj(), (sort_column_id).index(), ((GtkSortType)(order)));
497 void TreeSortable::set_sort_column(int sort_column_id, SortType order)
499 gtk_tree_sortable_set_sort_column_id(gobj(), sort_column_id, ((GtkSortType)(order)));
502 bool TreeSortable::has_default_sort_func() const
504 return gtk_tree_sortable_has_default_sort_func(const_cast<GtkTreeSortable*>(gobj()));
507 void TreeSortable::sort_column_changed()
509 gtk_tree_sortable_sort_column_changed(gobj());
513 Glib::SignalProxy0< void > TreeSortable::signal_sort_column_changed()
515 return Glib::SignalProxy0< void >(this, &TreeSortable_signal_sort_column_changed_info);
519 void Gtk::TreeSortable::on_sort_column_changed()
521 BaseClassType *const base = static_cast<BaseClassType*>(
522 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
523 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
526 if(base && base->sort_column_changed)
527 (*base->sort_column_changed)(gobj());
531 bool Gtk::TreeSortable::get_sort_column_id_vfunc(int* sort_column_id, SortType* order) const
533 BaseClassType *const base = static_cast<BaseClassType*>(
534 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
535 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
538 if(base && base->get_sort_column_id)
539 return (*base->get_sort_column_id)(const_cast<GtkTreeSortable*>(gobj()),sort_column_id,((GtkSortType*) (order)));
545 void Gtk::TreeSortable::set_sort_column_id_vfunc(int sort_column_id, SortType order)
547 BaseClassType *const base = static_cast<BaseClassType*>(
548 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
549 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
552 if(base && base->set_sort_column_id)
553 (*base->set_sort_column_id)(gobj(),sort_column_id,((GtkSortType)(order)));
556 void Gtk::TreeSortable::set_sort_func_vfunc(int sort_column_id, GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy)
558 BaseClassType *const base = static_cast<BaseClassType*>(
559 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
560 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
563 if(base && base->set_sort_func)
564 (*base->set_sort_func)(gobj(),sort_column_id,func,data,destroy);
567 void Gtk::TreeSortable::set_default_sort_func_vfunc(GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy)
569 BaseClassType *const base = static_cast<BaseClassType*>(
570 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
571 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
574 if(base && base->set_default_sort_func)
575 (*base->set_default_sort_func)(gobj(),func,data,destroy);
578 bool Gtk::TreeSortable::has_default_sort_func_vfunc() const
580 BaseClassType *const base = static_cast<BaseClassType*>(
581 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
582 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
585 if(base && base->has_default_sort_func)
586 return (*base->has_default_sort_func)(const_cast<GtkTreeSortable*>(gobj()));
592 void Gtk::TreeSortable::sort_column_changed_vfunc() const
594 BaseClassType *const base = static_cast<BaseClassType*>(
595 g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
596 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
599 if(base && base->sort_column_changed)
600 (*base->sort_column_changed)(const_cast<GtkTreeSortable*>(gobj()));