Install ardour as a binary, a script and a set of shared
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / treesortable.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3 #include <gtkmm/treesortable.h>
4 #include <gtkmm/private/treesortable_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 namespace
27 {
28
29 // This Signal Proxy allows the C++ coder to specify a sigc::slot instead of a static function.
30 class SignalProxy_Compare
31 {
32 public:
33   typedef Gtk::TreeSortable::SlotCompare SlotType;
34
35   explicit SignalProxy_Compare(const SlotType& slot);
36   ~SignalProxy_Compare();
37
38   static int  gtk_callback(GtkTreeModel* model, GtkTreeIter* lhs, GtkTreeIter* rhs, void* data);
39   static void gtk_callback_destroy(void* data);
40
41 private:
42   SlotType slot_;
43 };
44
45 SignalProxy_Compare::SignalProxy_Compare(const SlotType& slot)
46 :
47   slot_ (slot)
48 {}
49
50 SignalProxy_Compare::~SignalProxy_Compare()
51 {}
52
53 int SignalProxy_Compare::gtk_callback(GtkTreeModel* model, GtkTreeIter* lhs, GtkTreeIter* rhs, void* data)
54 {
55   SignalProxy_Compare *const self = static_cast<SignalProxy_Compare*>(data);
56
57   try
58   {
59     // use Slot::operator()
60     return (self->slot_)(Gtk::TreeIter(model, lhs), Gtk::TreeIter(model, rhs));
61   }
62   catch(...)
63   {
64     Glib::exception_handlers_invoke();
65   }
66
67   return 0;
68 }
69
70 void SignalProxy_Compare::gtk_callback_destroy(void* data)
71 {
72   delete static_cast<SignalProxy_Compare*>(data);
73 }
74
75 } // anonymous namespace
76
77
78 namespace Gtk
79 {
80
81 void TreeSortable::set_sort_func(int sort_column_id, const SlotCompare& slot)
82 {
83   SignalProxy_Compare *const pSignalProxy = new SignalProxy_Compare(slot);
84
85   gtk_tree_sortable_set_sort_func(
86       gobj(), sort_column_id,
87       &SignalProxy_Compare::gtk_callback, pSignalProxy,
88       &SignalProxy_Compare::gtk_callback_destroy);
89 }
90
91 void TreeSortable::set_sort_func(const Gtk::TreeModelColumnBase& sort_column, const SlotCompare& slot)
92 {
93   set_sort_func(sort_column.index(), slot);
94 }
95
96 void TreeSortable::set_default_sort_func(const SlotCompare& slot)
97 {
98   SignalProxy_Compare *const pSignalProxy = new SignalProxy_Compare(slot);
99
100   gtk_tree_sortable_set_default_sort_func(
101       gobj(),
102       &SignalProxy_Compare::gtk_callback, pSignalProxy,
103       &SignalProxy_Compare::gtk_callback_destroy);
104 }
105
106 void TreeSortable::unset_default_sort_func()
107 {
108   gtk_tree_sortable_set_default_sort_func(
109       gobj(), 0, 0, 0); /* See GTK+ docs about the 0s. */
110 }
111
112 //deprecated:
113 void TreeSortable::set_sort_column_id(const TreeModelColumnBase& sort_column, SortType order)
114 {
115   set_sort_column(sort_column, order);
116 }
117
118 //deprecated:
119 void TreeSortable::set_sort_column_id(int sort_column_id, SortType order)
120 {
121   set_sort_column(sort_column_id, order);
122 }  
123
124 } // namespace Gtk
125
126
127 namespace
128 {
129
130 const Glib::SignalProxyInfo TreeSortable_signal_sort_column_changed_info =
131 {
132   "sort_column_changed",
133   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
134   (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
135 };
136
137 } // anonymous namespace
138
139
140 namespace Glib
141 {
142
143 Glib::RefPtr<Gtk::TreeSortable> wrap(GtkTreeSortable* object, bool take_copy)
144 {
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.
147 }
148
149 } // namespace Glib
150
151
152 namespace Gtk
153 {
154
155
156 /* The *_Class implementation: */
157
158 const Glib::Interface_Class& TreeSortable_Class::init()
159 {
160   if(!gtype_) // create the GType if necessary
161   {
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;
165
166     // We can not derive from another interface, and it is not necessary anyway.
167     gtype_ = gtk_tree_sortable_get_type();
168   }
169
170   return *this;
171 }
172
173 void TreeSortable_Class::iface_init_function(void* g_iface, void*)
174 {
175   BaseClassType *const klass = static_cast<BaseClassType*>(g_iface);
176
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); 
180
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;
188 }
189
190 gboolean TreeSortable_Class::get_sort_column_id_vfunc_callback(GtkTreeSortable* self, int* sort_column_id, GtkSortType* order)
191 {
192   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
193       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
194
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
199   // being overridden:
200   if(obj && obj->is_derived_())
201   {
202     try // Trap C++ exceptions which would normally be lost because this is a C callback.
203     {
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))
206 ));
207     }
208     catch(...)
209     {
210       Glib::exception_handlers_invoke();
211     }
212   }
213   else
214   {
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.
218 )    );
219
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);
223   }
224
225   typedef gboolean RType;
226   return RType();
227 }
228
229 void TreeSortable_Class::set_sort_column_id_vfunc_callback(GtkTreeSortable* self, int sort_column_id, GtkSortType order)
230 {
231   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
232       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
233
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
238   // being overridden:
239   if(obj && obj->is_derived_())
240   {
241     try // Trap C++ exceptions which would normally be lost because this is a C callback.
242     {
243       // Call the virtual member method, which derived classes might override.
244       obj->set_sort_column_id_vfunc(sort_column_id, ((SortType)(order))
245 );
246     }
247     catch(...)
248     {
249       Glib::exception_handlers_invoke();
250     }
251   }
252   else
253   {
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.
257 )    );
258
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);
262   }
263 }
264
265 void TreeSortable_Class::set_sort_func_vfunc_callback(GtkTreeSortable* self, int sort_column_id, GtkTreeIterCompareFunc func, gpointer data, GtkDestroyNotify destroy)
266 {
267   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
268       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
269
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
274   // being overridden:
275   if(obj && obj->is_derived_())
276   {
277     try // Trap C++ exceptions which would normally be lost because this is a C callback.
278     {
279       // Call the virtual member method, which derived classes might override.
280       obj->set_sort_func_vfunc(sort_column_id, func, data
281 , destroy);
282     }
283     catch(...)
284     {
285       Glib::exception_handlers_invoke();
286     }
287   }
288   else
289   {
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.
293 )    );
294
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);
298   }
299 }
300
301 void TreeSortable_Class::set_default_sort_func_vfunc_callback(GtkTreeSortable* self, GtkTreeIterCompareFunc func, gpointer data, GtkDestroyNotify destroy)
302 {
303   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
304       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
305
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
310   // being overridden:
311   if(obj && obj->is_derived_())
312   {
313     try // Trap C++ exceptions which would normally be lost because this is a C callback.
314     {
315       // Call the virtual member method, which derived classes might override.
316       obj->set_default_sort_func_vfunc(func, data
317 , destroy);
318     }
319     catch(...)
320     {
321       Glib::exception_handlers_invoke();
322     }
323   }
324   else
325   {
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.
329 )    );
330
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);
334   }
335 }
336
337 gboolean TreeSortable_Class::has_default_sort_func_vfunc_callback(GtkTreeSortable* self)
338 {
339   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
340       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
341
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
346   // being overridden:
347   if(obj && obj->is_derived_())
348   {
349     try // Trap C++ exceptions which would normally be lost because this is a C callback.
350     {
351       // Call the virtual member method, which derived classes might override.
352       return static_cast<int>(obj->has_default_sort_func_vfunc());
353     }
354     catch(...)
355     {
356       Glib::exception_handlers_invoke();
357     }
358   }
359   else
360   {
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.
364 )    );
365
366     // Call the original underlying C function:
367     if(base && base->has_default_sort_func)
368       return (*base->has_default_sort_func)(self);
369   }
370
371   typedef gboolean RType;
372   return RType();
373 }
374
375 void TreeSortable_Class::sort_column_changed_vfunc_callback(GtkTreeSortable* self)
376 {
377   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
378       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
379
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
384   // being overridden:
385   if(obj && obj->is_derived_())
386   {
387     try // Trap C++ exceptions which would normally be lost because this is a C callback.
388     {
389       // Call the virtual member method, which derived classes might override.
390       obj->sort_column_changed_vfunc();
391     }
392     catch(...)
393     {
394       Glib::exception_handlers_invoke();
395     }
396   }
397   else
398   {
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.
402 )    );
403
404     // Call the original underlying C function:
405     if(base && base->sort_column_changed)
406       (*base->sort_column_changed)(self);
407   }
408 }
409
410
411 void TreeSortable_Class::sort_column_changed_callback(GtkTreeSortable* self)
412 {
413   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
414       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
415
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
420   // being overridden:
421   if(obj && obj->is_derived_())
422   {
423     try // Trap C++ exceptions which would normally be lost because this is a C callback.
424     {
425       // Call the virtual member method, which derived classes might override.
426       obj->on_sort_column_changed();
427     }
428     catch(...)
429     {
430       Glib::exception_handlers_invoke();
431     }
432   }
433   else
434   {
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.
438 )    );
439
440     // Call the original underlying C function:
441     if(base && base->sort_column_changed)
442       (*base->sort_column_changed)(self);
443   }
444 }
445
446
447 Glib::ObjectBase* TreeSortable_Class::wrap_new(GObject* object)
448 {
449   return new TreeSortable((GtkTreeSortable*)(object));
450 }
451
452
453 /* The implementation: */
454
455 TreeSortable::TreeSortable()
456 :
457   Glib::Interface(treesortable_class_.init())
458 {}
459
460 TreeSortable::TreeSortable(GtkTreeSortable* castitem)
461 :
462   Glib::Interface((GObject*)(castitem))
463 {}
464
465 TreeSortable::~TreeSortable()
466 {}
467
468 // static
469 void TreeSortable::add_interface(GType gtype_implementer)
470 {
471   treesortable_class_.init().add_interface(gtype_implementer);
472 }
473
474 TreeSortable::CppClassType TreeSortable::treesortable_class_; // initialize static member
475
476 GType TreeSortable::get_type()
477 {
478   return treesortable_class_.init().get_type();
479 }
480
481 GType TreeSortable::get_base_type()
482 {
483   return gtk_tree_sortable_get_type();
484 }
485
486
487 bool TreeSortable::get_sort_column_id(int& sort_column_id, SortType& order) const
488 {
489   return gtk_tree_sortable_get_sort_column_id(const_cast<GtkTreeSortable*>(gobj()), &sort_column_id, ((GtkSortType*) &(order)));
490 }
491
492 void TreeSortable::set_sort_column(const TreeModelColumnBase& sort_column_id, SortType order)
493 {
494   gtk_tree_sortable_set_sort_column_id(gobj(), (sort_column_id).index(), ((GtkSortType)(order)));
495 }
496
497 void TreeSortable::set_sort_column(int sort_column_id, SortType order)
498 {
499   gtk_tree_sortable_set_sort_column_id(gobj(), sort_column_id, ((GtkSortType)(order)));
500 }
501
502 bool TreeSortable::has_default_sort_func() const
503 {
504   return gtk_tree_sortable_has_default_sort_func(const_cast<GtkTreeSortable*>(gobj()));
505 }
506
507 void TreeSortable::sort_column_changed()
508 {
509   gtk_tree_sortable_sort_column_changed(gobj());
510 }
511
512
513 Glib::SignalProxy0< void > TreeSortable::signal_sort_column_changed()
514 {
515   return Glib::SignalProxy0< void >(this, &TreeSortable_signal_sort_column_changed_info);
516 }
517
518
519 void Gtk::TreeSortable::on_sort_column_changed()
520 {
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.
524 )  );
525
526   if(base && base->sort_column_changed)
527     (*base->sort_column_changed)(gobj());
528 }
529
530
531 bool Gtk::TreeSortable::get_sort_column_id_vfunc(int* sort_column_id, SortType* order) const
532 {
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.
536 )  );
537
538   if(base && base->get_sort_column_id)
539     return (*base->get_sort_column_id)(const_cast<GtkTreeSortable*>(gobj()),sort_column_id,((GtkSortType*) (order)));
540
541   typedef bool RType;
542   return RType();
543 }
544
545 void Gtk::TreeSortable::set_sort_column_id_vfunc(int sort_column_id, SortType order) 
546 {
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.
550 )  );
551
552   if(base && base->set_sort_column_id)
553     (*base->set_sort_column_id)(gobj(),sort_column_id,((GtkSortType)(order)));
554 }
555
556 void Gtk::TreeSortable::set_sort_func_vfunc(int sort_column_id, GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy) 
557 {
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.
561 )  );
562
563   if(base && base->set_sort_func)
564     (*base->set_sort_func)(gobj(),sort_column_id,func,data,destroy);
565 }
566
567 void Gtk::TreeSortable::set_default_sort_func_vfunc(GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy) 
568 {
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.
572 )  );
573
574   if(base && base->set_default_sort_func)
575     (*base->set_default_sort_func)(gobj(),func,data,destroy);
576 }
577
578 bool Gtk::TreeSortable::has_default_sort_func_vfunc() const
579 {
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.
583 )  );
584
585   if(base && base->has_default_sort_func)
586     return (*base->has_default_sort_func)(const_cast<GtkTreeSortable*>(gobj()));
587
588   typedef bool RType;
589   return RType();
590 }
591
592 void Gtk::TreeSortable::sort_column_changed_vfunc() const
593 {
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.
597 )  );
598
599   if(base && base->sort_column_changed)
600     (*base->sort_column_changed)(const_cast<GtkTreeSortable*>(gobj()));
601 }
602
603
604 } // namespace Gtk
605
606