1
// Generated by gtkmmproc -- DO NOT MODIFY!
3
#include <gtkmm/treeselection.h>
4
#include <gtkmm/private/treeselection_p.h>
9
/* Copyright 1998-2002 The gtkmm Development Team
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.
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.
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.
26
#include <gtkmm/treeview.h>
27
#include <gtk/gtktreeselection.h>
33
void proxy_foreach_selection_iter_callback(GtkTreeModel* model, GtkTreePath*, GtkTreeIter* iter, void* data)
35
typedef Gtk::TreeSelection::SlotForeachIter SlotType;
36
SlotType& slot = *static_cast<SlotType*>(data);
40
slot(Gtk::TreeModel::iterator(model, iter));
44
Glib::exception_handlers_invoke();
48
void proxy_foreach_selection_path_callback(GtkTreeModel*, GtkTreePath* path, GtkTreeIter*, void* data)
50
typedef Gtk::TreeSelection::SlotForeachPath SlotType;
51
SlotType& slot = *static_cast<SlotType*>(data);
55
slot(Gtk::TreeModel::Path(path, true));
59
Glib::exception_handlers_invoke();
63
void proxy_foreach_selection_path_and_iter_callback(GtkTreeModel* model, GtkTreePath* path,
64
GtkTreeIter* iter, void* data)
66
typedef Gtk::TreeSelection::SlotForeachPathAndIter SlotType;
67
SlotType& slot = *static_cast<SlotType*>(data);
71
slot(Gtk::TreeModel::Path(path, true), Gtk::TreeModel::iterator(model, iter));
75
Glib::exception_handlers_invoke();
80
// This Signal Proxy allows the C++ coder to specify
81
// a sigc::slot instead of a static function.
82
class SignalProxy_Select
85
typedef Gtk::TreeSelection::SlotSelect SlotType;
87
SignalProxy_Select(const SlotType& slot) : slot_(slot) {}
88
~SignalProxy_Select();
90
static gboolean gtk_callback(GtkTreeSelection*, GtkTreeModel* model, GtkTreePath* path,
91
gboolean path_currently_selected, void* data);
93
static void gtk_callback_destroy(void* data);
99
SignalProxy_Select::~SignalProxy_Select()
102
gboolean SignalProxy_Select::gtk_callback(GtkTreeSelection*, GtkTreeModel* model, GtkTreePath* path,
103
gboolean path_currently_selected, void* data)
105
SignalProxy_Select *const self = static_cast<SignalProxy_Select*>(data);
109
return (self->slot_)(Glib::wrap(model, true), // take copy
110
Gtk::TreePath(path, true), // take copy
111
path_currently_selected);
115
Glib::exception_handlers_invoke();
121
void SignalProxy_Select::gtk_callback_destroy(void* data)
123
delete static_cast<SignalProxy_Select*>(data);
126
} // anonymous namespace
132
void TreeSelection::set_select_function(const SlotSelect& slot)
134
// Create a signal proxy. A pointer to this will be passed
135
// through the callback's data parameter. It will be deleted
136
// when SignalProxy_Select::gtk_callback_destroy() is called.
137
SignalProxy_Select *const pSignalProxy = new SignalProxy_Select(slot);
139
gtk_tree_selection_set_select_function(gobj(),
140
&SignalProxy_Select::gtk_callback, pSignalProxy,
141
&SignalProxy_Select::gtk_callback_destroy);
144
Glib::RefPtr<TreeModel> TreeSelection::get_model()
146
GtkTreeView *const tree_view = gtk_tree_selection_get_tree_view(gobj());
147
return Glib::wrap(gtk_tree_view_get_model(tree_view), true);
150
Glib::RefPtr<const TreeModel> TreeSelection::get_model() const
152
GtkTreeView *const tree_view = gtk_tree_selection_get_tree_view(const_cast<GtkTreeSelection*>(gobj()));
153
return Glib::wrap(gtk_tree_view_get_model(tree_view), true);
156
TreeModel::iterator TreeSelection::get_selected()
158
TreeModel::iterator iter;
159
GtkTreeModel* model_gobject = 0;
161
gtk_tree_selection_get_selected(gobj(), &model_gobject, iter.gobj());
163
iter.set_model_gobject(model_gobject);
167
TreeModel::iterator TreeSelection::get_selected(Glib::RefPtr<TreeModel>& model)
169
TreeModel::iterator iter;
170
GtkTreeModel* model_gobject = 0;
172
gtk_tree_selection_get_selected(gobj(), &model_gobject, iter.gobj());
174
model = Glib::wrap(model_gobject, true);
176
iter.set_model_refptr(model);
180
void TreeSelection::selected_foreach_iter(const SlotForeachIter& slot) const
182
SlotForeachIter slot_copy (slot);
183
gtk_tree_selection_selected_foreach(const_cast<GtkTreeSelection*>(gobj()), &proxy_foreach_selection_iter_callback, &slot_copy);
186
void TreeSelection::selected_foreach_path(const SlotForeachPath& slot) const
188
SlotForeachPath slot_copy (slot);
189
gtk_tree_selection_selected_foreach(const_cast<GtkTreeSelection*>(gobj()), &proxy_foreach_selection_path_callback, &slot_copy);
192
void TreeSelection::selected_foreach(const SlotForeachPathAndIter& slot) const
194
SlotForeachPathAndIter slot_copy (slot);
195
gtk_tree_selection_selected_foreach(const_cast<GtkTreeSelection*>(gobj()), &proxy_foreach_selection_path_and_iter_callback, &slot_copy);
198
TreeSelection::ListHandle_Path TreeSelection::get_selected_rows() const
200
return ListHandle_Path(gtk_tree_selection_get_selected_rows(
201
const_cast<GtkTreeSelection*>(gobj()), 0), Glib::OWNERSHIP_DEEP);
204
TreeSelection::ListHandle_Path TreeSelection::get_selected_rows(Glib::RefPtr<TreeModel>& model)
206
GtkTreeModel* model_gobject = 0;
208
const ListHandle_Path result (gtk_tree_selection_get_selected_rows(
209
const_cast<GtkTreeSelection*>(gobj()), &model_gobject), Glib::OWNERSHIP_DEEP);
211
model = Glib::wrap(model_gobject, true);
221
const Glib::SignalProxyInfo TreeSelection_signal_changed_info =
224
(GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
225
(GCallback) &Glib::SignalProxyNormal::slot0_void_callback
228
} // anonymous namespace
234
Glib::RefPtr<Gtk::TreeSelection> wrap(GtkTreeSelection* object, bool take_copy)
236
return Glib::RefPtr<Gtk::TreeSelection>( dynamic_cast<Gtk::TreeSelection*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
237
//We use dynamic_cast<> in case of multiple inheritance.
240
} /* namespace Glib */
247
/* The *_Class implementation: */
249
const Glib::Class& TreeSelection_Class::init()
251
if(!gtype_) // create the GType if necessary
253
// Glib::Class has to know the class init function to clone custom types.
254
class_init_func_ = &TreeSelection_Class::class_init_function;
256
// This is actually just optimized away, apparently with no harm.
257
// Make sure that the parent type has been created.
258
//CppClassParent::CppObjectType::get_type();
260
// Create the wrapper type, with the same class/instance size as the base type.
261
register_derived_type(gtk_tree_selection_get_type());
263
// Add derived versions of interfaces, if the C type implements any interfaces:
269
void TreeSelection_Class::class_init_function(void* g_class, void* class_data)
271
BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
272
CppClassParent::class_init_function(klass, class_data);
274
klass->changed = &changed_callback;
278
void TreeSelection_Class::changed_callback(GtkTreeSelection* self)
280
CppObjectType *const obj = dynamic_cast<CppObjectType*>(
281
Glib::ObjectBase::_get_current_wrapper((GObject*)self));
283
// Non-gtkmmproc-generated custom classes implicitly call the default
284
// Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
285
// generated classes can use this optimisation, which avoids the unnecessary
286
// parameter conversions if there is no possibility of the virtual function
288
if(obj && obj->is_derived_())
290
try // Trap C++ exceptions which would normally be lost because this is a C callback.
292
// Call the virtual member method, which derived classes might override.
297
Glib::exception_handlers_invoke();
302
BaseClassType *const base = static_cast<BaseClassType*>(
303
g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
306
// Call the original underlying C function:
307
if(base && base->changed)
308
(*base->changed)(self);
313
Glib::ObjectBase* TreeSelection_Class::wrap_new(GObject* object)
315
return new TreeSelection((GtkTreeSelection*)object);
319
/* The implementation: */
321
GtkTreeSelection* TreeSelection::gobj_copy()
327
TreeSelection::TreeSelection(const Glib::ConstructParams& construct_params)
329
Glib::Object(construct_params)
332
TreeSelection::TreeSelection(GtkTreeSelection* castitem)
334
Glib::Object((GObject*)(castitem))
337
TreeSelection::~TreeSelection()
341
TreeSelection::CppClassType TreeSelection::treeselection_class_; // initialize static member
343
GType TreeSelection::get_type()
345
return treeselection_class_.init().get_type();
348
GType TreeSelection::get_base_type()
350
return gtk_tree_selection_get_type();
354
void TreeSelection::set_mode(SelectionMode type)
356
gtk_tree_selection_set_mode(gobj(), ((GtkSelectionMode)(type)));
359
SelectionMode TreeSelection::get_mode() const
361
return ((SelectionMode)(gtk_tree_selection_get_mode(const_cast<GtkTreeSelection*>(gobj()))));
364
TreeView* TreeSelection::get_tree_view()
366
return Glib::wrap(gtk_tree_selection_get_tree_view(gobj()));
369
const TreeView* TreeSelection::get_tree_view() const
371
return Glib::wrap(gtk_tree_selection_get_tree_view(const_cast<GtkTreeSelection*>(gobj())));
374
int TreeSelection::count_selected_rows() const
376
return gtk_tree_selection_count_selected_rows(const_cast<GtkTreeSelection*>(gobj()));
379
void TreeSelection::select(const TreeModel::Path& path)
381
gtk_tree_selection_select_path(gobj(), const_cast<GtkTreePath*>((path).gobj()));
384
void TreeSelection::select(const TreeModel::iterator& iter)
386
gtk_tree_selection_select_iter(gobj(), const_cast<GtkTreeIter*>((iter).gobj()));
389
void TreeSelection::select(const TreeModel::Row& row)
391
gtk_tree_selection_select_iter(gobj(), const_cast<GtkTreeIter*>((row).gobj()));
394
void TreeSelection::select(const TreeModel::Path& start_path, const TreeModel::Path& end_path)
396
gtk_tree_selection_select_range(gobj(), const_cast<GtkTreePath*>((start_path).gobj()), const_cast<GtkTreePath*>((end_path).gobj()));
399
void TreeSelection::unselect(const TreeModel::Path& path)
401
gtk_tree_selection_unselect_path(gobj(), const_cast<GtkTreePath*>((path).gobj()));
404
void TreeSelection::unselect(const TreeModel::Path& start_path, const TreeModel::Path& end_path)
406
gtk_tree_selection_unselect_range(gobj(), const_cast<GtkTreePath*>((start_path).gobj()), const_cast<GtkTreePath*>((end_path).gobj()));
409
void TreeSelection::unselect(const TreeModel::iterator& iter)
411
gtk_tree_selection_unselect_iter(gobj(), const_cast<GtkTreeIter*>((iter).gobj()));
414
bool TreeSelection::is_selected(const TreeModel::Path& path) const
416
return gtk_tree_selection_path_is_selected(const_cast<GtkTreeSelection*>(gobj()), const_cast<GtkTreePath*>((path).gobj()));
419
bool TreeSelection::is_selected(const TreeModel::iterator& iter) const
421
return gtk_tree_selection_iter_is_selected(const_cast<GtkTreeSelection*>(gobj()), const_cast<GtkTreeIter*>((iter).gobj()));
424
void TreeSelection::select_all()
426
gtk_tree_selection_select_all(gobj());
429
void TreeSelection::unselect_all()
431
gtk_tree_selection_unselect_all(gobj());
435
Glib::SignalProxy0< void > TreeSelection::signal_changed()
437
return Glib::SignalProxy0< void >(this, &TreeSelection_signal_changed_info);
441
void Gtk::TreeSelection::on_changed()
443
BaseClassType *const base = static_cast<BaseClassType*>(
444
g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
447
if(base && base->changed)
448
(*base->changed)(gobj());