rollback to 3428, before the mysterious removal of libs/* at 3431/3432
[ardour.git] / libs / gtkmm2 / gtk / src / celllayout.ccg
1 // -*- c++ -*-
2 /* $Id: celllayout.ccg,v 1.8 2006/05/11 11:40:24 murrayc Exp $ */
3
4 /* Copyright 2003 The gtkmm Development Team
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 #include <gtk/gtkcelllayout.h>
22
23
24 static void SignalProxy_CellData_gtk_callback(GtkCellLayout* /* cell_layout */, GtkCellRenderer* /* cell */, GtkTreeModel* tree_model, GtkTreeIter* iter, gpointer data)
25 {
26   Gtk::CellLayout::SlotCellData* the_slot = static_cast<Gtk::CellLayout::SlotCellData*>(data);
27
28   #ifdef GLIBMM_EXCEPTIONS_ENABLED
29   try
30   {
31   #endif //GLIBMM_EXCEPTIONS_ENABLED
32     //We ignore the cell, because that was given as an argument to the connecting method, so the caller should know which one it is already.
33     //And we ignore the tree_model because that can be obtained from the iter or from the CellLayout itself.
34     (*the_slot)(Gtk::TreeModel::const_iterator(tree_model, iter));
35   #ifdef GLIBMM_EXCEPTIONS_ENABLED
36   }
37   catch(...)
38   {
39     Glib::exception_handlers_invoke();
40   }
41   #endif //GLIBMM_EXCEPTIONS_ENABLED
42 }
43
44 static void SignalProxy_CellData_gtk_callback_destroy(void* data)
45 {
46   delete static_cast<Gtk::CellLayout::SlotCellData*>(data);
47 }
48
49 namespace Gtk
50 {
51
52 #ifdef GLIBMM_PROPERTIES_ENABLED
53 void CellLayout::add_attribute(const Glib::PropertyProxy_Base& property, const TreeModelColumnBase& column)
54 {
55   gtk_cell_layout_add_attribute(gobj(),
56       (GtkCellRenderer*) property.get_object()->gobj(), property.get_name(), column.index());
57 }
58 #endif //GLIBMM_PROPERTIES_ENABLED
59
60 void CellLayout::add_attribute(CellRenderer& cell, const Glib::ustring& attribute, const TreeModelColumnBase& column)
61 {
62   gtk_cell_layout_add_attribute(gobj(),
63       (GtkCellRenderer*) cell.gobj(), attribute.c_str(), column.index());
64 }
65
66 void CellLayout::set_cell_data_func(CellRenderer& cell, const SlotCellData& slot)
67 {
68   // Create a copy of the slot object.  A pointer to this will be passed
69   // through the callback's data parameter.  It will be deleted
70   // when SignalProxy_CellData_gtk_callback_destroy() is called.
71   SlotCellData* slot_copy = new SlotCellData(slot);
72
73   gtk_cell_layout_set_cell_data_func(gobj(), cell.gobj(),
74       &SignalProxy_CellData_gtk_callback, slot_copy,
75       &SignalProxy_CellData_gtk_callback_destroy);
76 }
77   
78
79 } //namespace Gtk
80
81