1 // Generated by gmmproc 2.60.0 -- DO NOT MODIFY!
2
3
4 #include <glibmm.h>
5
6 #include <gtkmm/treeselection.h>
7 #include <gtkmm/private/treeselection_p.h>
8
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 Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 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 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26
27 #include <glibmm/vectorutils.h>
28
29 #include <gtkmm/treeview.h>
30 #include <gtk/gtk.h>
31
32
proxy_foreach_selection_iter_callback(GtkTreeModel * model,GtkTreePath *,GtkTreeIter * iter,void * data)33 static void proxy_foreach_selection_iter_callback(GtkTreeModel* model, GtkTreePath*, GtkTreeIter* iter, void* data)
34 {
35 typedef Gtk::TreeSelection::SlotForeachIter SlotType;
36 auto& slot = *static_cast<SlotType*>(data);
37
38 try
39 {
40 slot(Gtk::TreeModel::iterator(model, iter));
41 }
42 catch(...)
43 {
44 Glib::exception_handlers_invoke();
45 }
46 }
47
proxy_foreach_selection_path_callback(GtkTreeModel *,GtkTreePath * path,GtkTreeIter *,void * data)48 static void proxy_foreach_selection_path_callback(GtkTreeModel*, GtkTreePath* path, GtkTreeIter*, void* data)
49 {
50 typedef Gtk::TreeSelection::SlotForeachPath SlotType;
51 auto& slot = *static_cast<SlotType*>(data);
52
53 try
54 {
55 slot(Gtk::TreeModel::Path(path, true));
56 }
57 catch(...)
58 {
59 Glib::exception_handlers_invoke();
60 }
61 }
62
proxy_foreach_selection_path_and_iter_callback(GtkTreeModel * model,GtkTreePath * path,GtkTreeIter * iter,void * data)63 static void proxy_foreach_selection_path_and_iter_callback(GtkTreeModel* model, GtkTreePath* path,
64 GtkTreeIter* iter, void* data)
65 {
66 typedef Gtk::TreeSelection::SlotForeachPathAndIter SlotType;
67 auto& slot = *static_cast<SlotType*>(data);
68
69 try
70 {
71 slot(Gtk::TreeModel::Path(path, true), Gtk::TreeModel::iterator(model, iter));
72 }
73 catch(...)
74 {
75 Glib::exception_handlers_invoke();
76 }
77 }
78
79
SignalProxy_Select_gtk_callback(GtkTreeSelection *,GtkTreeModel * model,GtkTreePath * path,gboolean path_currently_selected,void * data)80 static gboolean SignalProxy_Select_gtk_callback(GtkTreeSelection*, GtkTreeModel* model, GtkTreePath* path,
81 gboolean path_currently_selected, void* data)
82 {
83 const auto the_slot = static_cast<Gtk::TreeSelection::SlotSelect*>(data);
84
85 try
86 {
87 return (*the_slot)(Glib::wrap(model, true), // take copy
88 Gtk::TreePath(path, true), // take copy
89 path_currently_selected);
90 }
91 catch(...)
92 {
93 Glib::exception_handlers_invoke();
94 }
95
96 return 0;
97 }
98
SignalProxy_Select_gtk_callback_destroy(void * data)99 static void SignalProxy_Select_gtk_callback_destroy(void* data)
100 {
101 delete static_cast<Gtk::TreeSelection::SlotSelect*>(data);
102 }
103
104
105 namespace Gtk
106 {
107
set_select_function(const SlotSelect & slot)108 void TreeSelection::set_select_function(const SlotSelect& slot)
109 {
110 // Create a copy of the slot. A pointer to this will be passed
111 // through the callback's data parameter. It will be deleted
112 // when SignalProxy_Select_gtk_callback_destroy() is called.
113 auto slot_copy = new SlotSelect(slot);
114
115 gtk_tree_selection_set_select_function(gobj(),
116 &SignalProxy_Select_gtk_callback, slot_copy,
117 &SignalProxy_Select_gtk_callback_destroy);
118 }
119
get_model()120 Glib::RefPtr<TreeModel> TreeSelection::get_model()
121 {
122 const auto tree_view = gtk_tree_selection_get_tree_view(gobj());
123 return Glib::wrap(gtk_tree_view_get_model(tree_view), true);
124 }
125
get_model() const126 Glib::RefPtr<const TreeModel> TreeSelection::get_model() const
127 {
128 const auto tree_view = gtk_tree_selection_get_tree_view(const_cast<GtkTreeSelection*>(gobj()));
129 return Glib::wrap(gtk_tree_view_get_model(tree_view), true);
130 }
131
get_selected()132 TreeModel::iterator TreeSelection::get_selected()
133 {
134 TreeModel::iterator iter;
135 GtkTreeModel* model_gobject = nullptr;
136
137 gtk_tree_selection_get_selected(gobj(), &model_gobject, iter.gobj());
138
139 iter.set_model_gobject(model_gobject);
140 return iter;
141 }
142
get_selected(Glib::RefPtr<TreeModel> & model)143 TreeModel::iterator TreeSelection::get_selected(Glib::RefPtr<TreeModel>& model)
144 {
145 TreeModel::iterator iter;
146 GtkTreeModel* model_gobject = nullptr;
147
148 gtk_tree_selection_get_selected(gobj(), &model_gobject, iter.gobj());
149
150 model = Glib::wrap(model_gobject, true);
151
152 iter.set_model_refptr(model);
153 return iter;
154 }
155
selected_foreach_iter(const SlotForeachIter & slot) const156 void TreeSelection::selected_foreach_iter(const SlotForeachIter& slot) const
157 {
158 SlotForeachIter slot_copy (slot);
159 gtk_tree_selection_selected_foreach(const_cast<GtkTreeSelection*>(gobj()), &proxy_foreach_selection_iter_callback, &slot_copy);
160 }
161
selected_foreach_path(const SlotForeachPath & slot) const162 void TreeSelection::selected_foreach_path(const SlotForeachPath& slot) const
163 {
164 SlotForeachPath slot_copy (slot);
165 gtk_tree_selection_selected_foreach(const_cast<GtkTreeSelection*>(gobj()), &proxy_foreach_selection_path_callback, &slot_copy);
166 }
167
selected_foreach(const SlotForeachPathAndIter & slot) const168 void TreeSelection::selected_foreach(const SlotForeachPathAndIter& slot) const
169 {
170 SlotForeachPathAndIter slot_copy (slot);
171 gtk_tree_selection_selected_foreach(const_cast<GtkTreeSelection*>(gobj()), &proxy_foreach_selection_path_and_iter_callback, &slot_copy);
172 }
173
get_selected_rows() const174 std::vector<TreeModel::Path> TreeSelection::get_selected_rows() const
175 {
176 return Glib::ListHandler<TreeModel::Path, TreePathTraits>::list_to_vector(gtk_tree_selection_get_selected_rows(
177 const_cast<GtkTreeSelection*>(gobj()), nullptr), Glib::OWNERSHIP_DEEP);
178 }
179
get_selected_rows(Glib::RefPtr<TreeModel> & model)180 std::vector<TreeModel::Path> TreeSelection::get_selected_rows(Glib::RefPtr<TreeModel>& model)
181 {
182 GtkTreeModel* model_gobject = nullptr;
183
184 const std::vector<TreeModel::Path> result (Glib::ListHandler<TreeModel::Path, TreePathTraits>::list_to_vector(gtk_tree_selection_get_selected_rows(
185 const_cast<GtkTreeSelection*>(gobj()), &model_gobject), Glib::OWNERSHIP_DEEP));
186
187 model = Glib::wrap(model_gobject, true);
188 return result;
189 }
190
191 } // namespace Gtk
192
193 namespace
194 {
195
196
197 static const Glib::SignalProxyInfo TreeSelection_signal_changed_info =
198 {
199 "changed",
200 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
201 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
202 };
203
204
205 } // anonymous namespace
206
207
208 namespace Glib
209 {
210
wrap(GtkTreeSelection * object,bool take_copy)211 Glib::RefPtr<Gtk::TreeSelection> wrap(GtkTreeSelection* object, bool take_copy)
212 {
213 return Glib::RefPtr<Gtk::TreeSelection>( dynamic_cast<Gtk::TreeSelection*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
214 //We use dynamic_cast<> in case of multiple inheritance.
215 }
216
217 } /* namespace Glib */
218
219
220 namespace Gtk
221 {
222
223
224 /* The *_Class implementation: */
225
init()226 const Glib::Class& TreeSelection_Class::init()
227 {
228 if(!gtype_) // create the GType if necessary
229 {
230 // Glib::Class has to know the class init function to clone custom types.
231 class_init_func_ = &TreeSelection_Class::class_init_function;
232
233 // This is actually just optimized away, apparently with no harm.
234 // Make sure that the parent type has been created.
235 //CppClassParent::CppObjectType::get_type();
236
237 // Create the wrapper type, with the same class/instance size as the base type.
238 register_derived_type(gtk_tree_selection_get_type());
239
240 // Add derived versions of interfaces, if the C type implements any interfaces:
241
242 }
243
244 return *this;
245 }
246
247
class_init_function(void * g_class,void * class_data)248 void TreeSelection_Class::class_init_function(void* g_class, void* class_data)
249 {
250 const auto klass = static_cast<BaseClassType*>(g_class);
251 CppClassParent::class_init_function(klass, class_data);
252
253
254 klass->changed = &changed_callback;
255 }
256
257
changed_callback(GtkTreeSelection * self)258 void TreeSelection_Class::changed_callback(GtkTreeSelection* self)
259 {
260 const auto obj_base = static_cast<Glib::ObjectBase*>(
261 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
262
263 // Non-gtkmmproc-generated custom classes implicitly call the default
264 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
265 // generated classes can use this optimisation, which avoids the unnecessary
266 // parameter conversions if there is no possibility of the virtual function
267 // being overridden:
268 if(obj_base && obj_base->is_derived_())
269 {
270 const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
271 if(obj) // This can be NULL during destruction.
272 {
273 try // Trap C++ exceptions which would normally be lost because this is a C callback.
274 {
275 // Call the virtual member method, which derived classes might override.
276 obj->on_changed();
277 return;
278 }
279 catch(...)
280 {
281 Glib::exception_handlers_invoke();
282 }
283 }
284 }
285
286 const auto base = static_cast<BaseClassType*>(
287 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
288 );
289
290 // Call the original underlying C function:
291 if(base && base->changed)
292 (*base->changed)(self);
293 }
294
295
wrap_new(GObject * object)296 Glib::ObjectBase* TreeSelection_Class::wrap_new(GObject* object)
297 {
298 return new TreeSelection((GtkTreeSelection*)object);
299 }
300
301
302 /* The implementation: */
303
gobj_copy()304 GtkTreeSelection* TreeSelection::gobj_copy()
305 {
306 reference();
307 return gobj();
308 }
309
TreeSelection(const Glib::ConstructParams & construct_params)310 TreeSelection::TreeSelection(const Glib::ConstructParams& construct_params)
311 :
312 Glib::Object(construct_params)
313 {
314
315 }
316
TreeSelection(GtkTreeSelection * castitem)317 TreeSelection::TreeSelection(GtkTreeSelection* castitem)
318 :
319 Glib::Object((GObject*)(castitem))
320 {}
321
322
TreeSelection(TreeSelection && src)323 TreeSelection::TreeSelection(TreeSelection&& src) noexcept
324 : Glib::Object(std::move(src))
325 {}
326
operator =(TreeSelection && src)327 TreeSelection& TreeSelection::operator=(TreeSelection&& src) noexcept
328 {
329 Glib::Object::operator=(std::move(src));
330 return *this;
331 }
332
333
~TreeSelection()334 TreeSelection::~TreeSelection() noexcept
335 {}
336
337
338 TreeSelection::CppClassType TreeSelection::treeselection_class_; // initialize static member
339
get_type()340 GType TreeSelection::get_type()
341 {
342 return treeselection_class_.init().get_type();
343 }
344
345
get_base_type()346 GType TreeSelection::get_base_type()
347 {
348 return gtk_tree_selection_get_type();
349 }
350
351
set_mode(SelectionMode type)352 void TreeSelection::set_mode(SelectionMode type)
353 {
354 gtk_tree_selection_set_mode(gobj(), ((GtkSelectionMode)(type)));
355 }
356
get_mode() const357 SelectionMode TreeSelection::get_mode() const
358 {
359 return ((SelectionMode)(gtk_tree_selection_get_mode(const_cast<GtkTreeSelection*>(gobj()))));
360 }
361
get_tree_view()362 TreeView* TreeSelection::get_tree_view()
363 {
364 return Glib::wrap(gtk_tree_selection_get_tree_view(gobj()));
365 }
366
get_tree_view() const367 const TreeView* TreeSelection::get_tree_view() const
368 {
369 return const_cast<TreeSelection*>(this)->get_tree_view();
370 }
371
count_selected_rows() const372 int TreeSelection::count_selected_rows() const
373 {
374 return gtk_tree_selection_count_selected_rows(const_cast<GtkTreeSelection*>(gobj()));
375 }
376
select(const TreeModel::Path & path)377 void TreeSelection::select(const TreeModel::Path& path)
378 {
379 gtk_tree_selection_select_path(gobj(), const_cast<GtkTreePath*>((path).gobj()));
380 }
381
select(const TreeModel::iterator & iter)382 void TreeSelection::select(const TreeModel::iterator& iter)
383 {
384 gtk_tree_selection_select_iter(gobj(), const_cast<GtkTreeIter*>((iter).gobj()));
385 }
386
select(const TreeModel::Row & row)387 void TreeSelection::select(const TreeModel::Row& row)
388 {
389 gtk_tree_selection_select_iter(gobj(), const_cast<GtkTreeIter*>((row).gobj()));
390 }
391
select(const TreeModel::Path & start_path,const TreeModel::Path & end_path)392 void TreeSelection::select(const TreeModel::Path& start_path, const TreeModel::Path& end_path)
393 {
394 gtk_tree_selection_select_range(gobj(), const_cast<GtkTreePath*>((start_path).gobj()), const_cast<GtkTreePath*>((end_path).gobj()));
395 }
396
unselect(const TreeModel::Path & path)397 void TreeSelection::unselect(const TreeModel::Path& path)
398 {
399 gtk_tree_selection_unselect_path(gobj(), const_cast<GtkTreePath*>((path).gobj()));
400 }
401
unselect(const TreeModel::Path & start_path,const TreeModel::Path & end_path)402 void TreeSelection::unselect(const TreeModel::Path& start_path, const TreeModel::Path& end_path)
403 {
404 gtk_tree_selection_unselect_range(gobj(), const_cast<GtkTreePath*>((start_path).gobj()), const_cast<GtkTreePath*>((end_path).gobj()));
405 }
406
unselect(const TreeModel::iterator & iter)407 void TreeSelection::unselect(const TreeModel::iterator& iter)
408 {
409 gtk_tree_selection_unselect_iter(gobj(), const_cast<GtkTreeIter*>((iter).gobj()));
410 }
411
is_selected(const TreeModel::Path & path) const412 bool TreeSelection::is_selected(const TreeModel::Path& path) const
413 {
414 return gtk_tree_selection_path_is_selected(const_cast<GtkTreeSelection*>(gobj()), const_cast<GtkTreePath*>((path).gobj()));
415 }
416
is_selected(const TreeModel::iterator & iter) const417 bool TreeSelection::is_selected(const TreeModel::iterator& iter) const
418 {
419 return gtk_tree_selection_iter_is_selected(const_cast<GtkTreeSelection*>(gobj()), const_cast<GtkTreeIter*>((iter).gobj()));
420 }
421
select_all()422 void TreeSelection::select_all()
423 {
424 gtk_tree_selection_select_all(gobj());
425 }
426
unselect_all()427 void TreeSelection::unselect_all()
428 {
429 gtk_tree_selection_unselect_all(gobj());
430 }
431
432
signal_changed()433 Glib::SignalProxy< void > TreeSelection::signal_changed()
434 {
435 return Glib::SignalProxy< void >(this, &TreeSelection_signal_changed_info);
436 }
437
438
property_mode()439 Glib::PropertyProxy< SelectionMode > TreeSelection::property_mode()
440 {
441 return Glib::PropertyProxy< SelectionMode >(this, "mode");
442 }
443
property_mode() const444 Glib::PropertyProxy_ReadOnly< SelectionMode > TreeSelection::property_mode() const
445 {
446 return Glib::PropertyProxy_ReadOnly< SelectionMode >(this, "mode");
447 }
448
449
on_changed()450 void Gtk::TreeSelection::on_changed()
451 {
452 const auto base = static_cast<BaseClassType*>(
453 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
454 );
455
456 if(base && base->changed)
457 (*base->changed)(gobj());
458 }
459
460
461 } // namespace Gtk
462
463
464