1 // Generated by gmmproc 2.60.0 -- DO NOT MODIFY!
2
3
4 #include <glibmm.h>
5
6 #include <gtkmm/menushell.h>
7 #include <gtkmm/private/menushell_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 <gtk/gtk.h>
28
29
30 namespace Gtk
31 {
32
33 // All ctors are manually implemented just to initialize accel_window_.
34
MenuShell()35 MenuShell::MenuShell()
36 :
37 // Mark this class as non-derived to allow C++ vfuncs to be skipped.
38 Glib::ObjectBase(nullptr),
39 Gtk::Container(Glib::ConstructParams(menushell_class_.init())),
40 accel_window_ (nullptr)
41 {}
42
MenuShell(const Glib::ConstructParams & construct_params)43 MenuShell::MenuShell(const Glib::ConstructParams& construct_params)
44 :
45 Glib::ObjectBase(nullptr),
46 Gtk::Container (construct_params),
47 accel_window_ (nullptr)
48 {}
49
MenuShell(GtkMenuShell * castitem)50 MenuShell::MenuShell(GtkMenuShell* castitem)
51 :
52 Gtk::Container((GtkContainer*) castitem),
53 accel_window_ (nullptr)
54 {}
55
56 // TODO: Why do we need a custom dtor?
~MenuShell()57 MenuShell::~MenuShell() noexcept
58 {}
59
accelerate(Window & window)60 void MenuShell::accelerate(Window& window)
61 {
62 // accel_window_ is used by menuitems that are added to the menushell
63 // after it has been accelerated.
64 accel_window_ = &window;
65
66 for(auto widget : get_children())
67 {
68 auto menuitem = dynamic_cast<MenuItem*>(widget);
69 if (menuitem)
70 {
71 menuitem->accelerate(window);
72 }
73 }
74 }
75
accelerate(Widget & parent)76 void MenuShell::accelerate(Widget& parent)
77 {
78 Gtk::Window* toplevel_window
79 = dynamic_cast<Gtk::Window*>(parent.get_toplevel());
80 if(toplevel_window)
81 accelerate(*toplevel_window);
82 }
83
insert_vfunc_callback(GtkMenuShell * self,GtkWidget * child,int position)84 void MenuShell_Class::insert_vfunc_callback(GtkMenuShell* self, GtkWidget* child, int position)
85 {
86 try
87 {
88 const auto obj = dynamic_cast<MenuShell*>(
89 Glib::ObjectBase::_get_current_wrapper((GObject*) self));
90
91 // If MenuShell is accelerated initialize accelerators of new MenuItem.
92 if(obj && obj->accel_window_ && GTK_IS_MENU_ITEM(child))
93 {
94 Glib::wrap((GtkMenuItem*) child)->accelerate(*obj->accel_window_);
95 }
96 }
97 catch(...)
98 {
99 Glib::exception_handlers_invoke();
100 }
101
102 const auto base = static_cast<GtkMenuShellClass*>(
103 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)));
104
105 if(base && base->insert)
106 (*base->insert)(self, child, position);
107 }
108
109 } // namespace Gtk
110
111
112 namespace
113 {
114
115
116 static const Glib::SignalProxyInfo MenuShell_signal_deactivate_info =
117 {
118 "deactivate",
119 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
120 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
121 };
122
123
124 static const Glib::SignalProxyInfo MenuShell_signal_selection_done_info =
125 {
126 "selection_done",
127 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
128 (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
129 };
130
131
MenuShell_signal_move_selected_callback(GtkMenuShell * self,gint p0,void * data)132 static gboolean MenuShell_signal_move_selected_callback(GtkMenuShell* self, gint p0,void* data)
133 {
134 using namespace Gtk;
135 using SlotType = sigc::slot< gboolean,int >;
136
137 auto obj = dynamic_cast<MenuShell*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
138 // Do not try to call a signal on a disassociated wrapper.
139 if(obj)
140 {
141 try
142 {
143 if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
144 return (*static_cast<SlotType*>(slot))(p0
145 );
146 }
147 catch(...)
148 {
149 Glib::exception_handlers_invoke();
150 }
151 }
152
153 using RType = gboolean;
154 return RType();
155 }
156
MenuShell_signal_move_selected_notify_callback(GtkMenuShell * self,gint p0,void * data)157 static gboolean MenuShell_signal_move_selected_notify_callback(GtkMenuShell* self, gint p0, void* data)
158 {
159 using namespace Gtk;
160 using SlotType = sigc::slot< void,int >;
161
162 auto obj = dynamic_cast<MenuShell*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
163 // Do not try to call a signal on a disassociated wrapper.
164 if(obj)
165 {
166 try
167 {
168 if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
169 (*static_cast<SlotType*>(slot))(p0
170 );
171 }
172 catch(...)
173 {
174 Glib::exception_handlers_invoke();
175 }
176 }
177
178 using RType = gboolean;
179 return RType();
180 }
181
182 static const Glib::SignalProxyInfo MenuShell_signal_move_selected_info =
183 {
184 "move-selected",
185 (GCallback) &MenuShell_signal_move_selected_callback,
186 (GCallback) &MenuShell_signal_move_selected_notify_callback
187 };
188
189
MenuShell_signal_insert_callback(GtkMenuShell * self,GtkWidget * p0,gint p1,void * data)190 static void MenuShell_signal_insert_callback(GtkMenuShell* self, GtkWidget* p0,gint p1,void* data)
191 {
192 using namespace Gtk;
193 using SlotType = sigc::slot< void,Widget*,int >;
194
195 auto obj = dynamic_cast<MenuShell*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
196 // Do not try to call a signal on a disassociated wrapper.
197 if(obj)
198 {
199 try
200 {
201 if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
202 (*static_cast<SlotType*>(slot))(Glib::wrap(p0)
203 , p1
204 );
205 }
206 catch(...)
207 {
208 Glib::exception_handlers_invoke();
209 }
210 }
211 }
212
213 static const Glib::SignalProxyInfo MenuShell_signal_insert_info =
214 {
215 "insert",
216 (GCallback) &MenuShell_signal_insert_callback,
217 (GCallback) &MenuShell_signal_insert_callback
218 };
219
220
221 } // anonymous namespace
222
223
224 namespace Glib
225 {
226
wrap(GtkMenuShell * object,bool take_copy)227 Gtk::MenuShell* wrap(GtkMenuShell* object, bool take_copy)
228 {
229 return dynamic_cast<Gtk::MenuShell *> (Glib::wrap_auto ((GObject*)(object), take_copy));
230 }
231
232 } /* namespace Glib */
233
234 namespace Gtk
235 {
236
237
238 /* The *_Class implementation: */
239
init()240 const Glib::Class& MenuShell_Class::init()
241 {
242 if(!gtype_) // create the GType if necessary
243 {
244 // Glib::Class has to know the class init function to clone custom types.
245 class_init_func_ = &MenuShell_Class::class_init_function;
246
247 // This is actually just optimized away, apparently with no harm.
248 // Make sure that the parent type has been created.
249 //CppClassParent::CppObjectType::get_type();
250
251 // Create the wrapper type, with the same class/instance size as the base type.
252 register_derived_type(gtk_menu_shell_get_type());
253
254 // Add derived versions of interfaces, if the C type implements any interfaces:
255
256 }
257
258 return *this;
259 }
260
261
class_init_function(void * g_class,void * class_data)262 void MenuShell_Class::class_init_function(void* g_class, void* class_data)
263 {
264 const auto klass = static_cast<BaseClassType*>(g_class);
265 CppClassParent::class_init_function(klass, class_data);
266
267 klass->insert = &insert_vfunc_callback;
268
269 klass->deactivate = &deactivate_callback;
270 klass->selection_done = &selection_done_callback;
271 klass->move_selected = &move_selected_callback;
272 }
273
274
deactivate_callback(GtkMenuShell * self)275 void MenuShell_Class::deactivate_callback(GtkMenuShell* self)
276 {
277 const auto obj_base = static_cast<Glib::ObjectBase*>(
278 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
279
280 // Non-gtkmmproc-generated custom classes implicitly call the default
281 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
282 // generated classes can use this optimisation, which avoids the unnecessary
283 // parameter conversions if there is no possibility of the virtual function
284 // being overridden:
285 if(obj_base && obj_base->is_derived_())
286 {
287 const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
288 if(obj) // This can be NULL during destruction.
289 {
290 try // Trap C++ exceptions which would normally be lost because this is a C callback.
291 {
292 // Call the virtual member method, which derived classes might override.
293 obj->on_deactivate();
294 return;
295 }
296 catch(...)
297 {
298 Glib::exception_handlers_invoke();
299 }
300 }
301 }
302
303 const auto base = static_cast<BaseClassType*>(
304 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
305 );
306
307 // Call the original underlying C function:
308 if(base && base->deactivate)
309 (*base->deactivate)(self);
310 }
selection_done_callback(GtkMenuShell * self)311 void MenuShell_Class::selection_done_callback(GtkMenuShell* self)
312 {
313 const auto obj_base = static_cast<Glib::ObjectBase*>(
314 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
315
316 // Non-gtkmmproc-generated custom classes implicitly call the default
317 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
318 // generated classes can use this optimisation, which avoids the unnecessary
319 // parameter conversions if there is no possibility of the virtual function
320 // being overridden:
321 if(obj_base && obj_base->is_derived_())
322 {
323 const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
324 if(obj) // This can be NULL during destruction.
325 {
326 try // Trap C++ exceptions which would normally be lost because this is a C callback.
327 {
328 // Call the virtual member method, which derived classes might override.
329 obj->on_selection_done();
330 return;
331 }
332 catch(...)
333 {
334 Glib::exception_handlers_invoke();
335 }
336 }
337 }
338
339 const auto base = static_cast<BaseClassType*>(
340 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
341 );
342
343 // Call the original underlying C function:
344 if(base && base->selection_done)
345 (*base->selection_done)(self);
346 }
move_selected_callback(GtkMenuShell * self,gint p0)347 gboolean MenuShell_Class::move_selected_callback(GtkMenuShell* self, gint p0)
348 {
349 const auto obj_base = static_cast<Glib::ObjectBase*>(
350 Glib::ObjectBase::_get_current_wrapper((GObject*)self));
351
352 // Non-gtkmmproc-generated custom classes implicitly call the default
353 // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
354 // generated classes can use this optimisation, which avoids the unnecessary
355 // parameter conversions if there is no possibility of the virtual function
356 // being overridden:
357 if(obj_base && obj_base->is_derived_())
358 {
359 const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
360 if(obj) // This can be NULL during destruction.
361 {
362 try // Trap C++ exceptions which would normally be lost because this is a C callback.
363 {
364 // Call the virtual member method, which derived classes might override.
365 return obj->on_move_selected(p0
366 );
367 }
368 catch(...)
369 {
370 Glib::exception_handlers_invoke();
371 }
372 }
373 }
374
375 const auto base = static_cast<BaseClassType*>(
376 g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
377 );
378
379 // Call the original underlying C function:
380 if(base && base->move_selected)
381 return (*base->move_selected)(self, p0);
382
383 using RType = gboolean;
384 return RType();
385 }
386
387
wrap_new(GObject * o)388 Glib::ObjectBase* MenuShell_Class::wrap_new(GObject* o)
389 {
390 return manage(new MenuShell((GtkMenuShell*)(o)));
391
392 }
393
394
395 /* The implementation: */
396
397
MenuShell(MenuShell && src)398 MenuShell::MenuShell(MenuShell&& src) noexcept
399 : Gtk::Container(std::move(src))
400 {}
401
operator =(MenuShell && src)402 MenuShell& MenuShell::operator=(MenuShell&& src) noexcept
403 {
404 Gtk::Container::operator=(std::move(src));
405 return *this;
406 }
407
408 MenuShell::CppClassType MenuShell::menushell_class_; // initialize static member
409
get_type()410 GType MenuShell::get_type()
411 {
412 return menushell_class_.init().get_type();
413 }
414
415
get_base_type()416 GType MenuShell::get_base_type()
417 {
418 return gtk_menu_shell_get_type();
419 }
420
421
append(MenuItem & child)422 void MenuShell::append(MenuItem& child)
423 {
424 gtk_menu_shell_append(gobj(), (child).Gtk::Widget::gobj());
425 }
426
prepend(MenuItem & child)427 void MenuShell::prepend(MenuItem& child)
428 {
429 gtk_menu_shell_prepend(gobj(), (child).Gtk::Widget::gobj());
430 }
431
insert(MenuItem & child,int position)432 void MenuShell::insert(MenuItem& child, int position)
433 {
434 gtk_menu_shell_insert(gobj(), (child).Gtk::Widget::gobj(), position);
435 }
436
select_item(MenuItem & menu_item)437 void MenuShell::select_item(MenuItem& menu_item)
438 {
439 gtk_menu_shell_select_item(gobj(), (menu_item).Gtk::Widget::gobj());
440 }
441
deselect()442 void MenuShell::deselect()
443 {
444 gtk_menu_shell_deselect(gobj());
445 }
446
activate_item(MenuItem & menu_item,bool force_deactivate)447 void MenuShell::activate_item(MenuItem& menu_item, bool force_deactivate)
448 {
449 gtk_menu_shell_activate_item(gobj(), (menu_item).Gtk::Widget::gobj(), static_cast<int>(force_deactivate));
450 }
451
select_first(bool search_sensitive)452 void MenuShell::select_first(bool search_sensitive)
453 {
454 gtk_menu_shell_select_first(gobj(), static_cast<int>(search_sensitive));
455 }
456
deactivate()457 void MenuShell::deactivate()
458 {
459 gtk_menu_shell_deactivate(gobj());
460 }
461
cancel()462 void MenuShell::cancel()
463 {
464 gtk_menu_shell_cancel(gobj());
465 }
466
get_take_focus() const467 bool MenuShell::get_take_focus() const
468 {
469 return gtk_menu_shell_get_take_focus(const_cast<GtkMenuShell*>(gobj()));
470 }
471
set_take_focus(bool take_focus)472 void MenuShell::set_take_focus(bool take_focus)
473 {
474 gtk_menu_shell_set_take_focus(gobj(), static_cast<int>(take_focus));
475 }
476
get_selected_item()477 Widget* MenuShell::get_selected_item()
478 {
479 return Glib::wrap(gtk_menu_shell_get_selected_item(gobj()));
480 }
481
get_selected_item() const482 const Widget* MenuShell::get_selected_item() const
483 {
484 return Glib::wrap(gtk_menu_shell_get_selected_item(const_cast<GtkMenuShell*>(gobj())));
485 }
486
get_parent_shell()487 Widget* MenuShell::get_parent_shell()
488 {
489 return Glib::wrap(gtk_menu_shell_get_parent_shell(gobj()));
490 }
491
get_parent_shell() const492 const Widget* MenuShell::get_parent_shell() const
493 {
494 return Glib::wrap(gtk_menu_shell_get_parent_shell(const_cast<GtkMenuShell*>(gobj())));
495 }
496
bind_model(const Glib::RefPtr<Gio::MenuModel> & model,const Glib::ustring & action_namespace,bool with_separators)497 void MenuShell::bind_model(const Glib::RefPtr<Gio::MenuModel>& model, const Glib::ustring& action_namespace, bool with_separators)
498 {
499 gtk_menu_shell_bind_model(gobj(), Glib::unwrap(model), action_namespace.empty() ? nullptr : action_namespace.c_str(), static_cast<int>(with_separators));
500 }
501
bind_model(const Glib::RefPtr<Gio::MenuModel> & model,bool with_separators)502 void MenuShell::bind_model(const Glib::RefPtr<Gio::MenuModel>& model, bool with_separators)
503 {
504 gtk_menu_shell_bind_model(gobj(), Glib::unwrap(model), nullptr, static_cast<int>(with_separators));
505 }
506
507
signal_deactivate()508 Glib::SignalProxy< void > MenuShell::signal_deactivate()
509 {
510 return Glib::SignalProxy< void >(this, &MenuShell_signal_deactivate_info);
511 }
512
513
signal_selection_done()514 Glib::SignalProxy< void > MenuShell::signal_selection_done()
515 {
516 return Glib::SignalProxy< void >(this, &MenuShell_signal_selection_done_info);
517 }
518
519
signal_move_selected()520 Glib::SignalProxy< gboolean,int > MenuShell::signal_move_selected()
521 {
522 return Glib::SignalProxy< gboolean,int >(this, &MenuShell_signal_move_selected_info);
523 }
524
525
signal_insert()526 Glib::SignalProxy< void,Widget*,int > MenuShell::signal_insert()
527 {
528 return Glib::SignalProxy< void,Widget*,int >(this, &MenuShell_signal_insert_info);
529 }
530
531
property_take_focus()532 Glib::PropertyProxy< bool > MenuShell::property_take_focus()
533 {
534 return Glib::PropertyProxy< bool >(this, "take-focus");
535 }
536
property_take_focus() const537 Glib::PropertyProxy_ReadOnly< bool > MenuShell::property_take_focus() const
538 {
539 return Glib::PropertyProxy_ReadOnly< bool >(this, "take-focus");
540 }
541
542
on_deactivate()543 void Gtk::MenuShell::on_deactivate()
544 {
545 const auto base = static_cast<BaseClassType*>(
546 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
547 );
548
549 if(base && base->deactivate)
550 (*base->deactivate)(gobj());
551 }
on_selection_done()552 void Gtk::MenuShell::on_selection_done()
553 {
554 const auto base = static_cast<BaseClassType*>(
555 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
556 );
557
558 if(base && base->selection_done)
559 (*base->selection_done)(gobj());
560 }
on_move_selected(int distance)561 gboolean Gtk::MenuShell::on_move_selected(int distance)
562 {
563 const auto base = static_cast<BaseClassType*>(
564 g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
565 );
566
567 if(base && base->move_selected)
568 return (*base->move_selected)(gobj(),distance);
569
570 using RType = gboolean;
571 return RType();
572 }
573
574
575 } // namespace Gtk
576
577
578