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