2 /* $Id: celllayout.ccg,v 1.8 2006/05/11 11:40:24 murrayc Exp $ */
4 /* Copyright 2003 The gtkmm Development Team
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.
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.
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.
21 #include <gtk/gtkcelllayout.h>
24 static void SignalProxy_CellData_gtk_callback(GtkCellLayout* /* cell_layout */, GtkCellRenderer* /* cell */, GtkTreeModel* tree_model, GtkTreeIter* iter, gpointer data)
26 Gtk::CellLayout::SlotCellData* the_slot = static_cast<Gtk::CellLayout::SlotCellData*>(data);
28 #ifdef GLIBMM_EXCEPTIONS_ENABLED
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
39 Glib::exception_handlers_invoke();
41 #endif //GLIBMM_EXCEPTIONS_ENABLED
44 static void SignalProxy_CellData_gtk_callback_destroy(void* data)
46 delete static_cast<Gtk::CellLayout::SlotCellData*>(data);
52 #ifdef GLIBMM_PROPERTIES_ENABLED
53 void CellLayout::add_attribute(const Glib::PropertyProxy_Base& property, const TreeModelColumnBase& column)
55 gtk_cell_layout_add_attribute(gobj(),
56 (GtkCellRenderer*) property.get_object()->gobj(), property.get_name(), column.index());
58 #endif //GLIBMM_PROPERTIES_ENABLED
60 void CellLayout::add_attribute(CellRenderer& cell, const Glib::ustring& attribute, const TreeModelColumnBase& column)
62 gtk_cell_layout_add_attribute(gobj(),
63 (GtkCellRenderer*) cell.gobj(), attribute.c_str(), column.index());
66 void CellLayout::set_cell_data_func(CellRenderer& cell, const SlotCellData& slot)
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);
73 gtk_cell_layout_set_cell_data_func(gobj(), cell.gobj(),
74 &SignalProxy_CellData_gtk_callback, slot_copy,
75 &SignalProxy_CellData_gtk_callback_destroy);