Install ardour as a binary, a script and a set of shared
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / treemodel.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3 #include <gtkmm/treemodel.h>
4 #include <gtkmm/private/treemodel_p.h>
5
6 #include <gtk/gtktypebuiltins.h>
7 // -*- c++ -*-
8 /* $Id$ */
9
10 /* Copyright 1998-2002 The gtkmm Development Team
11  *
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.
16  *
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.
21  *
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.
25  */
26
27 #include <gtkmm/treeiter.h>
28 #include <gtkmm/treepath.h>
29 #include <gtk/gtktreestore.h>
30 #include <gtk/gtktreemodel.h>
31
32 namespace
33 {
34
35 gboolean proxy_foreach_iter_callback(GtkTreeModel* model, GtkTreePath*, GtkTreeIter* iter, void* data)
36 {
37   typedef Gtk::TreeModel::SlotForeachIter SlotType;
38   SlotType& slot = *static_cast<SlotType*>(data);
39
40   try
41   {
42     return slot(Gtk::TreeModel::iterator(model, iter));
43   }
44   catch(...)
45   {
46     Glib::exception_handlers_invoke();
47   }
48
49   return 1;
50 }
51
52 gboolean proxy_foreach_path_callback(GtkTreeModel*, GtkTreePath* path, GtkTreeIter*, void* data)
53 {
54   typedef Gtk::TreeModel::SlotForeachPath SlotType;
55   SlotType& slot = *static_cast<SlotType*>(data);
56
57   try
58   {
59     return slot(Gtk::TreeModel::Path(path, true));
60   }
61   catch(...)
62   {
63     Glib::exception_handlers_invoke();
64   }
65
66   return 1;
67 }
68
69 gboolean proxy_foreach_path_and_iter_callback(GtkTreeModel* model, GtkTreePath* path,
70                                               GtkTreeIter* iter, void* data)
71 {
72   typedef Gtk::TreeModel::SlotForeachPathAndIter SlotType;
73   SlotType& slot = *static_cast<SlotType*>(data);
74
75   try
76   {
77     return slot(Gtk::TreeModel::Path(path, true), Gtk::TreeModel::iterator(model, iter));
78   }
79   catch(...)
80   {
81     Glib::exception_handlers_invoke();
82   }
83
84   return 1;
85 }
86
87 } //anonymous namespace
88
89
90 //Help the code generator, so that it doesn't have to fully qualify this type:
91 typedef Gtk::TreeModel::iterator iterator;
92
93 namespace Gtk
94 {
95
96 TreeModel::iterator TreeModel::get_iter(const Path& path)
97 {
98   Gtk::TreeModel::iterator iter(this);
99   gtk_tree_model_get_iter(gobj(), iter.gobj(), const_cast<GtkTreePath*>(path.gobj()));
100   return iter;
101 }
102
103 TreeModel::iterator TreeModel::get_iter(const Glib::ustring& path_string)
104 {
105   Gtk::TreeModel::iterator iter (this);
106   gtk_tree_model_get_iter_from_string(gobj(), iter.gobj(), path_string.c_str());
107   return iter;
108 }
109
110 TreeModel::Children TreeModel::children()
111 {
112   return TreeNodeChildren(this);
113 }
114
115 TreeModel::Children TreeModel::children() const
116 {              
117   //TODO: Remove the const when we have a real const TreeNodeChildren, when we have a real const_iterator.
118   return TreeNodeChildren(const_cast<TreeModel*>(this));
119 }
120
121 void TreeModel::set_value_impl(const iterator&, int, const Glib::ValueBase&)
122 {
123   g_assert_not_reached();
124 }
125
126 void TreeModel::get_value_impl(const iterator& row, int column, Glib::ValueBase& value) const
127 {
128   gtk_tree_model_get_value(
129       const_cast<GtkTreeModel*>(gobj()),
130       const_cast<GtkTreeIter*>(row.gobj()),
131       column, value.gobj());
132 }
133
134 void TreeModel::foreach_iter(const SlotForeachIter& slot)
135 {
136   SlotForeachIter slot_copy (slot);
137   gtk_tree_model_foreach(gobj(), &proxy_foreach_iter_callback, &slot_copy);
138 }
139
140 void TreeModel::foreach_path(const SlotForeachPath& slot)
141 {
142   SlotForeachPath slot_copy (slot);
143   gtk_tree_model_foreach(gobj(), &proxy_foreach_path_callback, &slot_copy);
144 }
145
146 void TreeModel::foreach(const SlotForeachPathAndIter& slot)
147 {
148   SlotForeachPathAndIter slot_copy (slot);
149   gtk_tree_model_foreach(gobj(), &proxy_foreach_path_and_iter_callback, &slot_copy);
150 }
151
152 bool TreeModel::iter_is_valid(const iterator& iter) const
153 {
154   //This method is overriden in TreeStore and ListStore.
155   //This implementation will only be used as a default for custom derived TreeModels,
156   //and when we wrap a C GtkTreeModel with a Gtk::TreeModel instance, without knowing what derived C type it is.
157   
158   // This check is almost the same as the private VALID_ITER() macro in gtkliststore.c and
159   // gtktreestore.c.
160   return (!iter.is_end_ && iter.gobj()->stamp != 0);
161 }
162
163 // Custom vfunc callbacks, because the C++ vfuncs have different parameters and return types
164 // that can not be generated automatically:
165 gboolean TreeModel_Class::iter_next_vfunc_callback(GtkTreeModel* self, GtkTreeIter* iter)
166 {
167   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
168       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
169
170   // Non-gtkmmproc-generated custom classes implicitly call the default
171   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
172   // generated classes can use this optimisation, which avoids the unnecessary
173   // parameter conversions if there is no possibility of the virtual function
174   // being overridden:
175   if(obj && obj->is_derived_())
176   {
177     try // Trap C++ exceptions which would normally be lost because this is a C callback.
178     {
179       // Call the virtual member method, which derived classes might override.
180       TreeModel::iterator iter_input = TreeModel::iterator(self, iter);
181       TreeModel::iterator iter_next( self, iter ); //Copies iter by value.
182       gboolean test = obj->iter_next_vfunc(iter_input, iter_next);
183
184       //Copy the new iter value to the C output parameter:
185       if(test)
186         *iter = *(iter_next.gobj());
187
188       return test;
189     }
190     catch(...)
191     {
192       Glib::exception_handlers_invoke();
193     }
194   }
195   else
196   {
197     BaseClassType *const base = static_cast<BaseClassType*>(
198       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
199         g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
200       )
201     );
202
203     // Call the original underlying C function:
204     if(base && base->iter_next)
205       return (*base->iter_next)(self, iter);
206   }
207
208   typedef gboolean RType;
209   return RType();
210 }
211
212
213 bool TreeModel::iter_next_vfunc(const iterator& iter, iterator& iter_next) const
214 {
215   //Call the default C implementation:
216   
217   BaseClassType *const base = static_cast<BaseClassType*>(
218     g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
219       g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
220     )
221   );
222
223   if(base && base->iter_next)
224   {
225     TreeModel::iterator iter_copy = iter;
226     gboolean test = (*base->iter_next)(const_cast<GtkTreeModel*>(gobj()), iter_copy.gobj());
227     if(test)
228       iter_next = iter_copy;
229
230     return test;
231   }
232
233   return bool();
234 }
235
236 gboolean TreeModel_Class::get_iter_vfunc_callback(GtkTreeModel* self, GtkTreeIter* iter, GtkTreePath* path)
237 {
238   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
239       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
240
241   // Non-gtkmmproc-generated custom classes implicitly call the default
242   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
243   // generated classes can use this optimisation, which avoids the unnecessary
244   // parameter conversions if there is no possibility of the virtual function
245   // being overridden:
246   if(obj && obj->is_derived_())
247   {
248     try // Trap C++ exceptions which would normally be lost because this is a C callback.
249     {
250       // Call the virtual member method, which derived classes might override.
251       Gtk::TreeModel::iterator iter_out(self, iter); //copies the iter by value.
252       gboolean test = obj->get_iter_vfunc(Gtk::TreePath(path, true), iter_out);
253
254       //Copy the new iter value to the C output parameter:
255       if(test)
256         *iter = *(iter_out.gobj());
257
258       return test;
259     }
260     catch(...)
261     {
262       Glib::exception_handlers_invoke();
263     }
264   }
265   else
266   {
267     BaseClassType *const base = static_cast<BaseClassType*>(
268         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
269 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
270 )    );
271
272     // Call the original underlying C function:
273     if(base && base->get_iter)
274       return (*base->get_iter)(self, iter, const_cast<GtkTreePath*>(path));
275   }
276
277   typedef gboolean RType;
278   return RType();
279 }
280
281 bool TreeModel::get_iter_vfunc(const Path& path, iterator& iter) const
282 {
283   //Call the default C implementation:
284
285   BaseClassType *const base = static_cast<BaseClassType*>(
286     g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
287       g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
288     )
289   );
290
291   if(base && base->get_iter)
292   {
293     return (*base->get_iter)( const_cast<GtkTreeModel*>(gobj()), iter.gobj(), const_cast<GtkTreePath*>(path.gobj()) );
294   }
295
296   return bool();
297 }
298
299 gboolean TreeModel_Class::iter_children_vfunc_callback(GtkTreeModel* self, GtkTreeIter* iter, GtkTreeIter* parent)
300 {
301   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
302       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
303
304   // Non-gtkmmproc-generated custom classes implicitly call the default
305   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
306   // generated classes can use this optimisation, which avoids the unnecessary
307   // parameter conversions if there is no possibility of the virtual function
308   // being overridden:
309   if(obj && obj->is_derived_())
310   {
311     try // Trap C++ exceptions which would normally be lost because this is a C callback.
312     {
313       // Call the virtual member method, which derived classes might override.
314       Gtk::TreeModel::iterator iter_out(self, iter); //copies the iter by value.
315
316       gboolean test = false;
317       if(!parent)
318       {
319         //Deal with this case, which is documented in the C docs as:
320         //" If @parent is %NULL returns the first node, equivalent to
321         //  <literal>gtk_tree_model_get_iter_first (tree_model, iter);</literal> "
322         test = obj->iter_nth_root_child_vfunc(0, iter_out);
323       }
324       else
325       {
326         //Normal case: 
327          Gtk::TreeModel::iterator parent_cpp(self, parent);
328          test = obj->iter_children_vfunc(parent_cpp, iter_out);
329       }
330
331       //Copy the new iter value to the C output parameter:
332       if(test)
333         *iter = *(iter_out.gobj());
334         
335       return test;
336     }
337     catch(...)
338     {
339       Glib::exception_handlers_invoke();
340     }
341   }
342   else
343   {
344     BaseClassType *const base = static_cast<BaseClassType*>(
345         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
346 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
347 )    );
348
349     // Call the original underlying C function:
350     if(base && base->iter_children)
351       return (*base->iter_children)(self, iter, parent);
352   }
353
354   typedef gboolean RType;
355   return RType();
356 }
357
358 bool TreeModel::iter_children_vfunc(const iterator& parent, iterator& iter) const
359 {
360   //Call the default C implementation:
361
362   BaseClassType *const base = static_cast<BaseClassType*>(
363     g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
364       g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
365     )
366   );
367
368   if(base && base->iter_children)
369   {
370     return (*base->iter_children)( const_cast<GtkTreeModel*>(gobj()), iter.gobj(), const_cast<GtkTreeIter*>(parent.gobj()) );
371   }
372
373   return bool();
374 }
375
376 gboolean TreeModel_Class::iter_parent_vfunc_callback(GtkTreeModel* self, GtkTreeIter* iter, GtkTreeIter* child)
377 {
378   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
379       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
380
381   // Non-gtkmmproc-generated custom classes implicitly call the default
382   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
383   // generated classes can use this optimisation, which avoids the unnecessary
384   // parameter conversions if there is no possibility of the virtual function
385   // being overridden:
386   if(obj && obj->is_derived_())
387   {
388     try // Trap C++ exceptions which would normally be lost because this is a C callback.
389     {
390       // Call the virtual member method, which derived classes might override.
391       Gtk::TreeModel::iterator iter_out(self, iter);
392       Gtk::TreeModel::iterator child_cpp(self, child);
393       gboolean test = obj->iter_parent_vfunc(child_cpp, iter_out);
394
395       //Copy the new iter value to the C output parameter:
396       if(test)
397         *iter = *(iter_out.gobj());
398
399       return test;
400     }
401     catch(...)
402     {
403       Glib::exception_handlers_invoke();
404     }
405   }
406   else
407   {
408     BaseClassType *const base = static_cast<BaseClassType*>(
409         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
410 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
411 )    );
412
413     // Call the original underlying C function:
414     if(base && base->iter_parent)
415       return (*base->iter_parent)(self, iter, child);
416   }
417
418   typedef gboolean RType;
419   return RType();
420 }
421
422 bool TreeModel::iter_parent_vfunc(const iterator& child, iterator& iter) const
423 {
424   //Call the default C implementation:
425
426   BaseClassType *const base = static_cast<BaseClassType*>(
427     g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
428       g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
429     )
430   );
431
432   if(base && base->iter_parent)
433   {
434     return (*base->iter_parent)( const_cast<GtkTreeModel*>(gobj()), iter.gobj(), const_cast<GtkTreeIter*>(child.gobj()) );
435   }
436
437   return bool();
438 }
439
440 gboolean TreeModel_Class::iter_nth_child_vfunc_callback(GtkTreeModel* self, GtkTreeIter* iter, GtkTreeIter* parent, int n)
441 {
442   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
443       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
444
445   // Non-gtkmmproc-generated custom classes implicitly call the default
446   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
447   // generated classes can use this optimisation, which avoids the unnecessary
448   // parameter conversions if there is no possibility of the virtual function
449   // being overridden:
450   if(obj && obj->is_derived_())
451   {
452     try // Trap C++ exceptions which would normally be lost because this is a C callback.
453     {
454       // Call the virtual member method, which derived classes might override.
455       Gtk::TreeModel::iterator iter_out(self, iter);
456
457       gboolean test = false;
458       if(!parent)
459       {
460         // Deal with this special case, docuemnted in the C docs as:
461         // "As a special case, if @parent is %NULL, then the nth root node is set.":
462         test = obj->iter_nth_root_child_vfunc(n, iter_out);
463       }
464       else
465       {
466         //The normal case:
467         Gtk::TreeModel::iterator parent_cpp(self, parent);
468         test = obj->iter_nth_child_vfunc(parent_cpp, n, iter_out);
469       }
470
471       //Copy the new iter value to the C output parameter:
472       if(test)
473         *iter = *(iter_out.gobj());
474
475       return test;
476     }
477     catch(...)
478     {
479       Glib::exception_handlers_invoke();
480     }
481   }
482   else
483   {
484     BaseClassType *const base = static_cast<BaseClassType*>(
485         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
486 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
487 )    );
488
489     // Call the original underlying C function:
490     if(base && base->iter_nth_child)
491       return (*base->iter_nth_child)(self, iter, parent, n);
492   }
493
494   typedef gboolean RType;
495   return RType();
496 }
497
498 bool TreeModel::iter_nth_child_vfunc(const iterator& parent, int n, iterator& iter) const
499 {
500   //Call the default C implementation:
501
502   BaseClassType *const base = static_cast<BaseClassType*>(
503     g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
504       g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
505     )
506   );
507
508   if(base && base->iter_nth_child)
509   {
510     return (*base->iter_nth_child)( const_cast<GtkTreeModel*>(gobj()), iter.gobj(), const_cast<GtkTreeIter*>(parent.gobj()), n );
511   }
512
513   return bool();
514 }
515
516 //See the implementation of iter_children_vfunc_callback() and iter_nth_child_vfunc_callback()
517 //to find out why this virtual function exists:
518 bool TreeModel::iter_nth_root_child_vfunc(int n, iterator& iter) const
519 {
520   //Call the default C implementation:
521
522   BaseClassType *const base = static_cast<BaseClassType*>(
523     g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
524       g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
525     )
526   );
527
528   if(base && base->iter_nth_child)
529   {
530     //This means that iter_nth_child(0) might be called by iter_children_vfunc_callback(),
531     //but hopefully that's exactly the same thing. TODO: Ask why both vfuncs exist. murrayc. 
532     return (*base->iter_nth_child)( const_cast<GtkTreeModel*>(gobj()), iter.gobj(), 0 /* the null parent */, n );
533   }
534
535   return bool();
536 }
537
538 gboolean TreeModel_Class::iter_n_children_vfunc_callback(GtkTreeModel* self, GtkTreeIter* iter)
539 {
540   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
541       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
542
543   // Non-gtkmmproc-generated custom classes implicitly call the default
544   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
545   // generated classes can use this optimisation, which avoids the unnecessary
546   // parameter conversions if there is no possibility of the virtual function
547   // being overridden:
548   if(obj && obj->is_derived_())
549   {
550     try // Trap C++ exceptions which would normally be lost because this is a C callback.
551     {
552       // Call the virtual member method, which derived classes might override.
553
554       //Deal with the case that iter is null, as described in the C docs:
555       if(iter)
556         return obj->iter_n_children_vfunc( Gtk::TreeModel::iterator(self, iter) );
557       else
558         return obj->iter_n_root_children_vfunc();
559     }
560     catch(...)
561     {
562       Glib::exception_handlers_invoke();
563     }
564   }
565   else
566   {
567     BaseClassType *const base = static_cast<BaseClassType*>(
568         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
569 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
570 )    );
571
572     // Call the original underlying C function:
573     if(base && base->iter_n_children)
574       return (*base->iter_n_children)(self, iter);
575   }
576
577   typedef gboolean RType;
578   return RType();
579 }
580
581 int TreeModel::iter_n_children_vfunc(const iterator& iter) const
582 {
583   BaseClassType *const base = static_cast<BaseClassType*>(
584       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
585 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
586 )  );
587
588   if(base && base->iter_n_children)
589     return (*base->iter_n_children)(const_cast<GtkTreeModel*>(gobj()), const_cast<GtkTreeIter*>((iter).gobj()));
590
591   typedef int RType;
592   return RType();
593 }
594
595 int TreeModel::iter_n_root_children_vfunc() const
596 {
597   BaseClassType *const base = static_cast<BaseClassType*>(
598       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
599 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
600 )  );
601
602   if(base && base->iter_n_children)
603     return (*base->iter_n_children)(const_cast<GtkTreeModel*>(gobj()), 0 /* null iter to mean root node, as described in C docs */);
604
605   typedef int RType;
606   return RType();
607 }
608
609
610 void TreeModel::rows_reordered(const Path& path, const iterator& iter, const Glib::ArrayHandle<int>& new_order)
611 {
612   //The size of the array seems to be based on the known number of children. murrayc.
613   gtk_tree_model_rows_reordered(gobj(), const_cast<GtkTreePath*>((path).gobj()), const_cast<GtkTreeIter*>((iter).gobj()), const_cast<int*>(new_order.data()));
614 }
615  
616
617 } // namespace Gtk
618
619
620 namespace
621 {
622
623 void TreeModel_signal_row_changed_callback(GtkTreeModel* self, GtkTreePath* path,GtkTreeIter* iter,void* data)
624 {
625   using namespace Gtk;
626   typedef sigc::slot< void,const TreeModel::Path&,const TreeModel::iterator& > SlotType;
627
628   // Do not try to call a signal on a disassociated wrapper.
629   if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
630   {
631     try
632     {
633       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
634         (*static_cast<SlotType*>(slot))(Gtk::TreePath(path, true)
635 , Gtk::TreeModel::iterator(self, iter)
636 );
637     }
638     catch(...)
639     {
640       Glib::exception_handlers_invoke();
641     }
642   }
643 }
644
645 const Glib::SignalProxyInfo TreeModel_signal_row_changed_info =
646 {
647   "row_changed",
648   (GCallback) &TreeModel_signal_row_changed_callback,
649   (GCallback) &TreeModel_signal_row_changed_callback
650 };
651
652
653 void TreeModel_signal_row_inserted_callback(GtkTreeModel* self, GtkTreePath* path,GtkTreeIter* iter,void* data)
654 {
655   using namespace Gtk;
656   typedef sigc::slot< void,const TreeModel::Path&,const TreeModel::iterator& > SlotType;
657
658   // Do not try to call a signal on a disassociated wrapper.
659   if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
660   {
661     try
662     {
663       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
664         (*static_cast<SlotType*>(slot))(Gtk::TreePath(path, true)
665 , Gtk::TreeModel::iterator(self, iter)
666 );
667     }
668     catch(...)
669     {
670       Glib::exception_handlers_invoke();
671     }
672   }
673 }
674
675 const Glib::SignalProxyInfo TreeModel_signal_row_inserted_info =
676 {
677   "row_inserted",
678   (GCallback) &TreeModel_signal_row_inserted_callback,
679   (GCallback) &TreeModel_signal_row_inserted_callback
680 };
681
682
683 void TreeModel_signal_row_has_child_toggled_callback(GtkTreeModel* self, GtkTreePath* path,GtkTreeIter* iter,void* data)
684 {
685   using namespace Gtk;
686   typedef sigc::slot< void,const TreeModel::Path&,const TreeModel::iterator& > SlotType;
687
688   // Do not try to call a signal on a disassociated wrapper.
689   if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
690   {
691     try
692     {
693       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
694         (*static_cast<SlotType*>(slot))(Gtk::TreePath(path, true)
695 , Gtk::TreeModel::iterator(self, iter)
696 );
697     }
698     catch(...)
699     {
700       Glib::exception_handlers_invoke();
701     }
702   }
703 }
704
705 const Glib::SignalProxyInfo TreeModel_signal_row_has_child_toggled_info =
706 {
707   "row_has_child_toggled",
708   (GCallback) &TreeModel_signal_row_has_child_toggled_callback,
709   (GCallback) &TreeModel_signal_row_has_child_toggled_callback
710 };
711
712
713 void TreeModel_signal_row_deleted_callback(GtkTreeModel* self, GtkTreePath* path,void* data)
714 {
715   using namespace Gtk;
716   typedef sigc::slot< void,const TreeModel::Path& > SlotType;
717
718   // Do not try to call a signal on a disassociated wrapper.
719   if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
720   {
721     try
722     {
723       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
724         (*static_cast<SlotType*>(slot))(Gtk::TreePath(path, true)
725 );
726     }
727     catch(...)
728     {
729       Glib::exception_handlers_invoke();
730     }
731   }
732 }
733
734 const Glib::SignalProxyInfo TreeModel_signal_row_deleted_info =
735 {
736   "row_deleted",
737   (GCallback) &TreeModel_signal_row_deleted_callback,
738   (GCallback) &TreeModel_signal_row_deleted_callback
739 };
740
741
742 void TreeModel_signal_rows_reordered_callback(GtkTreeModel* self, GtkTreePath* path,GtkTreeIter* iter,gint* new_order,void* data)
743 {
744   using namespace Gtk;
745   typedef sigc::slot< void,const TreeModel::Path&,const TreeModel::iterator&,int* > SlotType;
746
747   // Do not try to call a signal on a disassociated wrapper.
748   if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
749   {
750     try
751     {
752       if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
753         (*static_cast<SlotType*>(slot))(Gtk::TreePath(path, true)
754 , Gtk::TreeModel::iterator(self, iter)
755 , new_order
756 );
757     }
758     catch(...)
759     {
760       Glib::exception_handlers_invoke();
761     }
762   }
763 }
764
765 const Glib::SignalProxyInfo TreeModel_signal_rows_reordered_info =
766 {
767   "rows_reordered",
768   (GCallback) &TreeModel_signal_rows_reordered_callback,
769   (GCallback) &TreeModel_signal_rows_reordered_callback
770 };
771
772 } // anonymous namespace
773
774 // static
775 GType Glib::Value<Gtk::TreeModelFlags>::value_type()
776 {
777   return gtk_tree_model_flags_get_type();
778 }
779
780
781 namespace Glib
782 {
783
784 Glib::RefPtr<Gtk::TreeModel> wrap(GtkTreeModel* object, bool take_copy)
785 {
786   return Glib::RefPtr<Gtk::TreeModel>( dynamic_cast<Gtk::TreeModel*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
787   //We use dynamic_cast<> in case of multiple inheritance.
788 }
789
790 } // namespace Glib
791
792
793 namespace Gtk
794 {
795
796
797 /* The *_Class implementation: */
798
799 const Glib::Interface_Class& TreeModel_Class::init()
800 {
801   if(!gtype_) // create the GType if necessary
802   {
803     // Glib::Interface_Class has to know the interface init function
804     // in order to add interfaces to implementing types.
805     class_init_func_ = &TreeModel_Class::iface_init_function;
806
807     // We can not derive from another interface, and it is not necessary anyway.
808     gtype_ = gtk_tree_model_get_type();
809   }
810
811   return *this;
812 }
813
814 void TreeModel_Class::iface_init_function(void* g_iface, void*)
815 {
816   BaseClassType *const klass = static_cast<BaseClassType*>(g_iface);
817
818   //This is just to avoid an "unused variable" warning when there are no vfuncs or signal handlers to connect.
819   //This is a temporary fix until I find out why I can not seem to derive a GtkFileChooser interface. murrayc
820   g_assert(klass != 0); 
821
822   klass->get_flags = &get_flags_vfunc_callback;
823   klass->get_n_columns = &get_n_columns_vfunc_callback;
824   klass->get_column_type = &get_column_type_vfunc_callback;
825     klass->iter_next = &iter_next_vfunc_callback;
826     klass->get_iter = &get_iter_vfunc_callback;
827     klass->iter_children = &iter_children_vfunc_callback;
828     klass->iter_parent = &iter_parent_vfunc_callback;
829     klass->iter_nth_child = &iter_nth_child_vfunc_callback;
830     klass->iter_n_children = &iter_n_children_vfunc_callback;
831     klass->iter_has_child = &iter_has_child_vfunc_callback;
832   klass->ref_node = &ref_node_vfunc_callback;
833   klass->unref_node = &unref_node_vfunc_callback;
834   klass->get_path = &get_path_vfunc_callback;
835   klass->get_value = &get_value_vfunc_callback;
836   klass->row_changed = &row_changed_callback;
837   klass->row_inserted = &row_inserted_callback;
838   klass->row_has_child_toggled = &row_has_child_toggled_callback;
839   klass->row_deleted = &row_deleted_callback;
840   klass->rows_reordered = &rows_reordered_callback;
841 }
842
843 GtkTreeModelFlags TreeModel_Class::get_flags_vfunc_callback(GtkTreeModel* self)
844 {
845   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
846       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
847
848   // Non-gtkmmproc-generated custom classes implicitly call the default
849   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
850   // generated classes can use this optimisation, which avoids the unnecessary
851   // parameter conversions if there is no possibility of the virtual function
852   // being overridden:
853   if(obj && obj->is_derived_())
854   {
855     try // Trap C++ exceptions which would normally be lost because this is a C callback.
856     {
857       // Call the virtual member method, which derived classes might override.
858       return ((GtkTreeModelFlags)(obj->get_flags_vfunc()));
859     }
860     catch(...)
861     {
862       Glib::exception_handlers_invoke();
863     }
864   }
865   else
866   {
867     BaseClassType *const base = static_cast<BaseClassType*>(
868         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
869 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
870 )    );
871
872     // Call the original underlying C function:
873     if(base && base->get_flags)
874       return (*base->get_flags)(self);
875   }
876
877   typedef GtkTreeModelFlags RType;
878   return RType();
879 }
880
881 gint TreeModel_Class::get_n_columns_vfunc_callback(GtkTreeModel* self)
882 {
883   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
884       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
885
886   // Non-gtkmmproc-generated custom classes implicitly call the default
887   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
888   // generated classes can use this optimisation, which avoids the unnecessary
889   // parameter conversions if there is no possibility of the virtual function
890   // being overridden:
891   if(obj && obj->is_derived_())
892   {
893     try // Trap C++ exceptions which would normally be lost because this is a C callback.
894     {
895       // Call the virtual member method, which derived classes might override.
896       return obj->get_n_columns_vfunc();
897     }
898     catch(...)
899     {
900       Glib::exception_handlers_invoke();
901     }
902   }
903   else
904   {
905     BaseClassType *const base = static_cast<BaseClassType*>(
906         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
907 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
908 )    );
909
910     // Call the original underlying C function:
911     if(base && base->get_n_columns)
912       return (*base->get_n_columns)(self);
913   }
914
915   typedef gint RType;
916   return RType();
917 }
918
919 GType TreeModel_Class::get_column_type_vfunc_callback(GtkTreeModel* self, gint index)
920 {
921   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
922       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
923
924   // Non-gtkmmproc-generated custom classes implicitly call the default
925   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
926   // generated classes can use this optimisation, which avoids the unnecessary
927   // parameter conversions if there is no possibility of the virtual function
928   // being overridden:
929   if(obj && obj->is_derived_())
930   {
931     try // Trap C++ exceptions which would normally be lost because this is a C callback.
932     {
933       // Call the virtual member method, which derived classes might override.
934       return obj->get_column_type_vfunc(index
935 );
936     }
937     catch(...)
938     {
939       Glib::exception_handlers_invoke();
940     }
941   }
942   else
943   {
944     BaseClassType *const base = static_cast<BaseClassType*>(
945         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
946 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
947 )    );
948
949     // Call the original underlying C function:
950     if(base && base->get_column_type)
951       return (*base->get_column_type)(self, index);
952   }
953
954   typedef GType RType;
955   return RType();
956 }
957
958 gboolean TreeModel_Class::iter_has_child_vfunc_callback(GtkTreeModel* self, GtkTreeIter* iter)
959 {
960   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
961       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
962
963   // Non-gtkmmproc-generated custom classes implicitly call the default
964   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
965   // generated classes can use this optimisation, which avoids the unnecessary
966   // parameter conversions if there is no possibility of the virtual function
967   // being overridden:
968   if(obj && obj->is_derived_())
969   {
970     try // Trap C++ exceptions which would normally be lost because this is a C callback.
971     {
972       // Call the virtual member method, which derived classes might override.
973       return static_cast<int>(obj->iter_has_child_vfunc(Gtk::TreeModel::iterator(self, iter)
974 ));
975     }
976     catch(...)
977     {
978       Glib::exception_handlers_invoke();
979     }
980   }
981   else
982   {
983     BaseClassType *const base = static_cast<BaseClassType*>(
984         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
985 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
986 )    );
987
988     // Call the original underlying C function:
989     if(base && base->iter_has_child)
990       return (*base->iter_has_child)(self, iter);
991   }
992
993   typedef gboolean RType;
994   return RType();
995 }
996
997 void TreeModel_Class::ref_node_vfunc_callback(GtkTreeModel* self, GtkTreeIter* iter)
998 {
999   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
1000       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
1001
1002   // Non-gtkmmproc-generated custom classes implicitly call the default
1003   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
1004   // generated classes can use this optimisation, which avoids the unnecessary
1005   // parameter conversions if there is no possibility of the virtual function
1006   // being overridden:
1007   if(obj && obj->is_derived_())
1008   {
1009     try // Trap C++ exceptions which would normally be lost because this is a C callback.
1010     {
1011       // Call the virtual member method, which derived classes might override.
1012       obj->ref_node_vfunc(Gtk::TreeModel::iterator(self, iter)
1013 );
1014     }
1015     catch(...)
1016     {
1017       Glib::exception_handlers_invoke();
1018     }
1019   }
1020   else
1021   {
1022     BaseClassType *const base = static_cast<BaseClassType*>(
1023         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1024 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
1025 )    );
1026
1027     // Call the original underlying C function:
1028     if(base && base->ref_node)
1029       (*base->ref_node)(self, iter);
1030   }
1031 }
1032
1033 void TreeModel_Class::unref_node_vfunc_callback(GtkTreeModel* self, GtkTreeIter* iter)
1034 {
1035   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
1036       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
1037
1038   // Non-gtkmmproc-generated custom classes implicitly call the default
1039   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
1040   // generated classes can use this optimisation, which avoids the unnecessary
1041   // parameter conversions if there is no possibility of the virtual function
1042   // being overridden:
1043   if(obj && obj->is_derived_())
1044   {
1045     try // Trap C++ exceptions which would normally be lost because this is a C callback.
1046     {
1047       // Call the virtual member method, which derived classes might override.
1048       obj->unref_node_vfunc(Gtk::TreeModel::iterator(self, iter)
1049 );
1050     }
1051     catch(...)
1052     {
1053       Glib::exception_handlers_invoke();
1054     }
1055   }
1056   else
1057   {
1058     BaseClassType *const base = static_cast<BaseClassType*>(
1059         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1060 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
1061 )    );
1062
1063     // Call the original underlying C function:
1064     if(base && base->unref_node)
1065       (*base->unref_node)(self, iter);
1066   }
1067 }
1068
1069 GtkTreePath* TreeModel_Class::get_path_vfunc_callback(GtkTreeModel* self, GtkTreeIter* iter)
1070 {
1071   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
1072       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
1073
1074   // Non-gtkmmproc-generated custom classes implicitly call the default
1075   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
1076   // generated classes can use this optimisation, which avoids the unnecessary
1077   // parameter conversions if there is no possibility of the virtual function
1078   // being overridden:
1079   if(obj && obj->is_derived_())
1080   {
1081     try // Trap C++ exceptions which would normally be lost because this is a C callback.
1082     {
1083       // Call the virtual member method, which derived classes might override.
1084       return (obj->get_path_vfunc(Gtk::TreeModel::iterator(self, iter)
1085 )).gobj_copy();
1086     }
1087     catch(...)
1088     {
1089       Glib::exception_handlers_invoke();
1090     }
1091   }
1092   else
1093   {
1094     BaseClassType *const base = static_cast<BaseClassType*>(
1095         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1096 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
1097 )    );
1098
1099     // Call the original underlying C function:
1100     if(base && base->get_path)
1101       return (*base->get_path)(self, iter);
1102   }
1103
1104   typedef GtkTreePath* RType;
1105   return RType();
1106 }
1107
1108 void TreeModel_Class::get_value_vfunc_callback(GtkTreeModel* self, GtkTreeIter* iter, gint column, GValue* value)
1109 {
1110   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
1111       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
1112
1113   // Non-gtkmmproc-generated custom classes implicitly call the default
1114   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
1115   // generated classes can use this optimisation, which avoids the unnecessary
1116   // parameter conversions if there is no possibility of the virtual function
1117   // being overridden:
1118   if(obj && obj->is_derived_())
1119   {
1120     try // Trap C++ exceptions which would normally be lost because this is a C callback.
1121     {
1122       // Call the virtual member method, which derived classes might override.
1123       obj->get_value_vfunc(Gtk::TreeModel::iterator(self, iter)
1124 , column
1125 , *reinterpret_cast<Glib::ValueBase*>(value)
1126 );
1127     }
1128     catch(...)
1129     {
1130       Glib::exception_handlers_invoke();
1131     }
1132   }
1133   else
1134   {
1135     BaseClassType *const base = static_cast<BaseClassType*>(
1136         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1137 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
1138 )    );
1139
1140     // Call the original underlying C function:
1141     if(base && base->get_value)
1142       (*base->get_value)(self, iter, column, value);
1143   }
1144 }
1145
1146
1147 void TreeModel_Class::row_changed_callback(GtkTreeModel* self, GtkTreePath* path, GtkTreeIter* iter)
1148 {
1149   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
1150       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
1151
1152   // Non-gtkmmproc-generated custom classes implicitly call the default
1153   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
1154   // generated classes can use this optimisation, which avoids the unnecessary
1155   // parameter conversions if there is no possibility of the virtual function
1156   // being overridden:
1157   if(obj && obj->is_derived_())
1158   {
1159     try // Trap C++ exceptions which would normally be lost because this is a C callback.
1160     {
1161       // Call the virtual member method, which derived classes might override.
1162       obj->on_row_changed(Gtk::TreePath(path, true)
1163 , Gtk::TreeModel::iterator(self, iter)
1164 );
1165     }
1166     catch(...)
1167     {
1168       Glib::exception_handlers_invoke();
1169     }
1170   }
1171   else
1172   {
1173     BaseClassType *const base = static_cast<BaseClassType*>(
1174         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1175 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
1176 )    );
1177
1178     // Call the original underlying C function:
1179     if(base && base->row_changed)
1180       (*base->row_changed)(self, path, iter);
1181   }
1182 }
1183
1184 void TreeModel_Class::row_inserted_callback(GtkTreeModel* self, GtkTreePath* path, GtkTreeIter* iter)
1185 {
1186   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
1187       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
1188
1189   // Non-gtkmmproc-generated custom classes implicitly call the default
1190   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
1191   // generated classes can use this optimisation, which avoids the unnecessary
1192   // parameter conversions if there is no possibility of the virtual function
1193   // being overridden:
1194   if(obj && obj->is_derived_())
1195   {
1196     try // Trap C++ exceptions which would normally be lost because this is a C callback.
1197     {
1198       // Call the virtual member method, which derived classes might override.
1199       obj->on_row_inserted(Gtk::TreePath(path, true)
1200 , Gtk::TreeModel::iterator(self, iter)
1201 );
1202     }
1203     catch(...)
1204     {
1205       Glib::exception_handlers_invoke();
1206     }
1207   }
1208   else
1209   {
1210     BaseClassType *const base = static_cast<BaseClassType*>(
1211         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1212 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
1213 )    );
1214
1215     // Call the original underlying C function:
1216     if(base && base->row_inserted)
1217       (*base->row_inserted)(self, path, iter);
1218   }
1219 }
1220
1221 void TreeModel_Class::row_has_child_toggled_callback(GtkTreeModel* self, GtkTreePath* path, GtkTreeIter* iter)
1222 {
1223   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
1224       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
1225
1226   // Non-gtkmmproc-generated custom classes implicitly call the default
1227   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
1228   // generated classes can use this optimisation, which avoids the unnecessary
1229   // parameter conversions if there is no possibility of the virtual function
1230   // being overridden:
1231   if(obj && obj->is_derived_())
1232   {
1233     try // Trap C++ exceptions which would normally be lost because this is a C callback.
1234     {
1235       // Call the virtual member method, which derived classes might override.
1236       obj->on_row_has_child_toggled(Gtk::TreePath(path, true)
1237 , Gtk::TreeModel::iterator(self, iter)
1238 );
1239     }
1240     catch(...)
1241     {
1242       Glib::exception_handlers_invoke();
1243     }
1244   }
1245   else
1246   {
1247     BaseClassType *const base = static_cast<BaseClassType*>(
1248         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1249 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
1250 )    );
1251
1252     // Call the original underlying C function:
1253     if(base && base->row_has_child_toggled)
1254       (*base->row_has_child_toggled)(self, path, iter);
1255   }
1256 }
1257
1258 void TreeModel_Class::row_deleted_callback(GtkTreeModel* self, GtkTreePath* path)
1259 {
1260   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
1261       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
1262
1263   // Non-gtkmmproc-generated custom classes implicitly call the default
1264   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
1265   // generated classes can use this optimisation, which avoids the unnecessary
1266   // parameter conversions if there is no possibility of the virtual function
1267   // being overridden:
1268   if(obj && obj->is_derived_())
1269   {
1270     try // Trap C++ exceptions which would normally be lost because this is a C callback.
1271     {
1272       // Call the virtual member method, which derived classes might override.
1273       obj->on_row_deleted(Gtk::TreePath(path, true)
1274 );
1275     }
1276     catch(...)
1277     {
1278       Glib::exception_handlers_invoke();
1279     }
1280   }
1281   else
1282   {
1283     BaseClassType *const base = static_cast<BaseClassType*>(
1284         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1285 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
1286 )    );
1287
1288     // Call the original underlying C function:
1289     if(base && base->row_deleted)
1290       (*base->row_deleted)(self, path);
1291   }
1292 }
1293
1294 void TreeModel_Class::rows_reordered_callback(GtkTreeModel* self, GtkTreePath* path, GtkTreeIter* iter, gint* new_order)
1295 {
1296   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
1297       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
1298
1299   // Non-gtkmmproc-generated custom classes implicitly call the default
1300   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
1301   // generated classes can use this optimisation, which avoids the unnecessary
1302   // parameter conversions if there is no possibility of the virtual function
1303   // being overridden:
1304   if(obj && obj->is_derived_())
1305   {
1306     try // Trap C++ exceptions which would normally be lost because this is a C callback.
1307     {
1308       // Call the virtual member method, which derived classes might override.
1309       obj->on_rows_reordered(Gtk::TreePath(path, true)
1310 , Gtk::TreeModel::iterator(self, iter)
1311 , new_order
1312 );
1313     }
1314     catch(...)
1315     {
1316       Glib::exception_handlers_invoke();
1317     }
1318   }
1319   else
1320   {
1321     BaseClassType *const base = static_cast<BaseClassType*>(
1322         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1323 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
1324 )    );
1325
1326     // Call the original underlying C function:
1327     if(base && base->rows_reordered)
1328       (*base->rows_reordered)(self, path, iter, new_order);
1329   }
1330 }
1331
1332
1333 Glib::ObjectBase* TreeModel_Class::wrap_new(GObject* object)
1334 {
1335   return new TreeModel((GtkTreeModel*)(object));
1336 }
1337
1338
1339 /* The implementation: */
1340
1341 TreeModel::TreeModel()
1342 :
1343   Glib::Interface(treemodel_class_.init())
1344 {}
1345
1346 TreeModel::TreeModel(GtkTreeModel* castitem)
1347 :
1348   Glib::Interface((GObject*)(castitem))
1349 {}
1350
1351 TreeModel::~TreeModel()
1352 {}
1353
1354 // static
1355 void TreeModel::add_interface(GType gtype_implementer)
1356 {
1357   treemodel_class_.init().add_interface(gtype_implementer);
1358 }
1359
1360 TreeModel::CppClassType TreeModel::treemodel_class_; // initialize static member
1361
1362 GType TreeModel::get_type()
1363 {
1364   return treemodel_class_.init().get_type();
1365 }
1366
1367 GType TreeModel::get_base_type()
1368 {
1369   return gtk_tree_model_get_type();
1370 }
1371
1372
1373 TreeModelFlags TreeModel::get_flags() const
1374 {
1375   return ((TreeModelFlags)(gtk_tree_model_get_flags(const_cast<GtkTreeModel*>(gobj()))));
1376 }
1377
1378 int TreeModel::get_n_columns() const
1379 {
1380   return gtk_tree_model_get_n_columns(const_cast<GtkTreeModel*>(gobj()));
1381 }
1382
1383 GType TreeModel::get_column_type(int index) const
1384 {
1385   return gtk_tree_model_get_column_type(const_cast<GtkTreeModel*>(gobj()), index);
1386 }
1387
1388 TreeModel::Path TreeModel::get_path(const iterator& iter) const
1389 {
1390   return Gtk::TreePath(gtk_tree_model_get_path(const_cast<GtkTreeModel*>(gobj()), const_cast<GtkTreeIter*>((iter).gobj())), false);
1391 }
1392
1393 void TreeModel::row_changed(const Path& path, const iterator& iter)
1394 {
1395   gtk_tree_model_row_changed(gobj(), const_cast<GtkTreePath*>((path).gobj()), const_cast<GtkTreeIter*>((iter).gobj()));
1396 }
1397
1398 void TreeModel::row_inserted(const Path& path, const iterator& iter)
1399 {
1400   gtk_tree_model_row_inserted(gobj(), const_cast<GtkTreePath*>((path).gobj()), const_cast<GtkTreeIter*>((iter).gobj()));
1401 }
1402
1403 void TreeModel::row_has_child_toggled(const Path& path, const iterator& iter)
1404 {
1405   gtk_tree_model_row_has_child_toggled(gobj(), const_cast<GtkTreePath*>((path).gobj()), const_cast<GtkTreeIter*>((iter).gobj()));
1406 }
1407
1408 void TreeModel::row_deleted(const Path& path)
1409 {
1410   gtk_tree_model_row_deleted(gobj(), const_cast<GtkTreePath*>((path).gobj()));
1411 }
1412
1413 void TreeModel::rows_reordered(const Path& path, const iterator& iter, int* new_order)
1414 {
1415   gtk_tree_model_rows_reordered(gobj(), const_cast<GtkTreePath*>((path).gobj()), const_cast<GtkTreeIter*>((iter).gobj()), new_order);
1416 }
1417
1418 Glib::ustring TreeModel::get_string(const iterator& iter) const
1419 {
1420   return Glib::convert_return_gchar_ptr_to_ustring(gtk_tree_model_get_string_from_iter(const_cast<GtkTreeModel*>(gobj()), const_cast<GtkTreeIter*>((iter).gobj())));
1421 }
1422
1423
1424 Glib::SignalProxy2< void,const TreeModel::Path&,const TreeModel::iterator& > TreeModel::signal_row_changed()
1425 {
1426   return Glib::SignalProxy2< void,const TreeModel::Path&,const TreeModel::iterator& >(this, &TreeModel_signal_row_changed_info);
1427 }
1428
1429 Glib::SignalProxy2< void,const TreeModel::Path&,const TreeModel::iterator& > TreeModel::signal_row_inserted()
1430 {
1431   return Glib::SignalProxy2< void,const TreeModel::Path&,const TreeModel::iterator& >(this, &TreeModel_signal_row_inserted_info);
1432 }
1433
1434 Glib::SignalProxy2< void,const TreeModel::Path&,const TreeModel::iterator& > TreeModel::signal_row_has_child_toggled()
1435 {
1436   return Glib::SignalProxy2< void,const TreeModel::Path&,const TreeModel::iterator& >(this, &TreeModel_signal_row_has_child_toggled_info);
1437 }
1438
1439 Glib::SignalProxy1< void,const TreeModel::Path& > TreeModel::signal_row_deleted()
1440 {
1441   return Glib::SignalProxy1< void,const TreeModel::Path& >(this, &TreeModel_signal_row_deleted_info);
1442 }
1443
1444 Glib::SignalProxy3< void,const TreeModel::Path&,const TreeModel::iterator&,int* > TreeModel::signal_rows_reordered()
1445 {
1446   return Glib::SignalProxy3< void,const TreeModel::Path&,const TreeModel::iterator&,int* >(this, &TreeModel_signal_rows_reordered_info);
1447 }
1448
1449
1450 void Gtk::TreeModel::on_row_changed(const TreeModel::Path& path, const TreeModel::iterator& iter)
1451 {
1452   BaseClassType *const base = static_cast<BaseClassType*>(
1453       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1454 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
1455 )  );
1456
1457   if(base && base->row_changed)
1458     (*base->row_changed)(gobj(),const_cast<GtkTreePath*>((path).gobj()),const_cast<GtkTreeIter*>((iter).gobj()));
1459 }
1460
1461 void Gtk::TreeModel::on_row_inserted(const TreeModel::Path& path, const TreeModel::iterator& iter)
1462 {
1463   BaseClassType *const base = static_cast<BaseClassType*>(
1464       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1465 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
1466 )  );
1467
1468   if(base && base->row_inserted)
1469     (*base->row_inserted)(gobj(),const_cast<GtkTreePath*>((path).gobj()),const_cast<GtkTreeIter*>((iter).gobj()));
1470 }
1471
1472 void Gtk::TreeModel::on_row_has_child_toggled(const TreeModel::Path& path, const TreeModel::iterator& iter)
1473 {
1474   BaseClassType *const base = static_cast<BaseClassType*>(
1475       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1476 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
1477 )  );
1478
1479   if(base && base->row_has_child_toggled)
1480     (*base->row_has_child_toggled)(gobj(),const_cast<GtkTreePath*>((path).gobj()),const_cast<GtkTreeIter*>((iter).gobj()));
1481 }
1482
1483 void Gtk::TreeModel::on_row_deleted(const TreeModel::Path& path)
1484 {
1485   BaseClassType *const base = static_cast<BaseClassType*>(
1486       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1487 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
1488 )  );
1489
1490   if(base && base->row_deleted)
1491     (*base->row_deleted)(gobj(),const_cast<GtkTreePath*>((path).gobj()));
1492 }
1493
1494 void Gtk::TreeModel::on_rows_reordered(const TreeModel::Path& path, const TreeModel::iterator& iter, int* new_order)
1495 {
1496   BaseClassType *const base = static_cast<BaseClassType*>(
1497       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1498 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
1499 )  );
1500
1501   if(base && base->rows_reordered)
1502     (*base->rows_reordered)(gobj(),const_cast<GtkTreePath*>((path).gobj()),const_cast<GtkTreeIter*>((iter).gobj()),new_order);
1503 }
1504
1505
1506 TreeModelFlags Gtk::TreeModel::get_flags_vfunc() const
1507 {
1508   BaseClassType *const base = static_cast<BaseClassType*>(
1509       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1510 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
1511 )  );
1512
1513   if(base && base->get_flags)
1514     return ((TreeModelFlags)((*base->get_flags)(const_cast<GtkTreeModel*>(gobj()))));
1515
1516   typedef TreeModelFlags RType;
1517   return RType();
1518 }
1519
1520 int Gtk::TreeModel::get_n_columns_vfunc() const
1521 {
1522   BaseClassType *const base = static_cast<BaseClassType*>(
1523       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1524 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
1525 )  );
1526
1527   if(base && base->get_n_columns)
1528     return (*base->get_n_columns)(const_cast<GtkTreeModel*>(gobj()));
1529
1530   typedef int RType;
1531   return RType();
1532 }
1533
1534 GType Gtk::TreeModel::get_column_type_vfunc(int index) const
1535 {
1536   BaseClassType *const base = static_cast<BaseClassType*>(
1537       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1538 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
1539 )  );
1540
1541   if(base && base->get_column_type)
1542     return (*base->get_column_type)(const_cast<GtkTreeModel*>(gobj()),index);
1543
1544   typedef GType RType;
1545   return RType();
1546 }
1547
1548 bool Gtk::TreeModel::iter_has_child_vfunc(const iterator& iter) const
1549 {
1550   BaseClassType *const base = static_cast<BaseClassType*>(
1551       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1552 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
1553 )  );
1554
1555   if(base && base->iter_has_child)
1556     return (*base->iter_has_child)(const_cast<GtkTreeModel*>(gobj()),const_cast<GtkTreeIter*>((iter).gobj()));
1557
1558   typedef bool RType;
1559   return RType();
1560 }
1561
1562 void Gtk::TreeModel::ref_node_vfunc(const iterator& iter) const
1563 {
1564   BaseClassType *const base = static_cast<BaseClassType*>(
1565       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1566 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
1567 )  );
1568
1569   if(base && base->ref_node)
1570     (*base->ref_node)(const_cast<GtkTreeModel*>(gobj()),const_cast<GtkTreeIter*>((iter).gobj()));
1571 }
1572
1573 void Gtk::TreeModel::unref_node_vfunc(const iterator& iter) const
1574 {
1575   BaseClassType *const base = static_cast<BaseClassType*>(
1576       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1577 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
1578 )  );
1579
1580   if(base && base->unref_node)
1581     (*base->unref_node)(const_cast<GtkTreeModel*>(gobj()),const_cast<GtkTreeIter*>((iter).gobj()));
1582 }
1583
1584 TreeModel::Path Gtk::TreeModel::get_path_vfunc(const iterator& iter) const
1585 {
1586   BaseClassType *const base = static_cast<BaseClassType*>(
1587       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1588 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
1589 )  );
1590
1591   if(base && base->get_path)
1592     return Gtk::TreePath((*base->get_path)(const_cast<GtkTreeModel*>(gobj()),const_cast<GtkTreeIter*>((iter).gobj())), false);
1593
1594   typedef TreeModel::Path RType;
1595   return RType();
1596 }
1597
1598 void Gtk::TreeModel::get_value_vfunc(const iterator& iter, int column, Glib::ValueBase& value) const
1599 {
1600   BaseClassType *const base = static_cast<BaseClassType*>(
1601       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
1602 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
1603 )  );
1604
1605   if(base && base->get_value)
1606     (*base->get_value)(const_cast<GtkTreeModel*>(gobj()),const_cast<GtkTreeIter*>((iter).gobj()),column,(value).gobj());
1607 }
1608
1609
1610 } // namespace Gtk
1611
1612