/* Copyright (C) 1998-2002 The gtkmm Development Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see . */ #include #include _DEPRECATE_IFDEF_START static void SignalProxy_PopupPosition_gtk_callback(GtkMenu*, int* x, int* y, gboolean* push_in, void* data) { auto the_slot = static_cast(data); int temp_x = (x) ? *x : 0; int temp_y = (y) ? *y : 0; bool temp_push_in = (push_in) ? bool(*push_in) : false; try { (*the_slot)(temp_x, temp_y, temp_push_in); } catch(...) { Glib::exception_handlers_invoke(); } if(x) *x = temp_x; if(y) *y = temp_y; if(push_in) *push_in = temp_push_in; } static void SignalProxy_PopupPosition_gtk_callback_destroy(void* data) { auto the_slot = static_cast(data); delete the_slot; } _DEPRECATE_IFDEF_END namespace Gtk { Menu::Menu(const Glib::RefPtr& model) : _CONSTRUCT() { //g_return_val_if_fail (G_IS_MENU_MODEL (model), NULL); bind_model(model, true); } _DEPRECATE_IFDEF_START G_GNUC_BEGIN_IGNORE_DEPRECATIONS void Menu::popup(const SlotPositionCalc& position_calc_slot, guint button, guint32 activate_time, const Glib::RefPtr& device) { // Tell GTK+ to call the static function with the slot's address as the extra // data, so that the static function can then call the sigc::slot: if(!device) gtk_menu_popup(gobj(), nullptr, nullptr, &SignalProxy_PopupPosition_gtk_callback, const_cast(&position_calc_slot), button, activate_time); else { auto slot_copy = new SlotPositionCalc(position_calc_slot); //Deleted in the destroy callback. gtk_menu_popup_for_device(gobj(), device->gobj(), nullptr, nullptr, &SignalProxy_PopupPosition_gtk_callback, slot_copy, &SignalProxy_PopupPosition_gtk_callback_destroy, button, activate_time); } } void Menu::popup(MenuShell& parent_menu_shell, MenuItem& parent_menu_item, const SlotPositionCalc& position_calc_slot, guint button, guint32 activate_time, const Glib::RefPtr& device) { // Tell GTK+ to call the static function with the slot's address as the extra // data, so that the static function can then call the sigc::slot: if(!device) gtk_menu_popup(gobj(), parent_menu_shell.Gtk::Widget::gobj(), parent_menu_item.Gtk::Widget::gobj(), &SignalProxy_PopupPosition_gtk_callback, const_cast(&position_calc_slot), button, activate_time); else { auto slot_copy = new SlotPositionCalc(position_calc_slot); //Deleted in the destroy callback. gtk_menu_popup_for_device(gobj(), device->gobj(), parent_menu_shell.Gtk::Widget::gobj(), parent_menu_item.Gtk::Widget::gobj(), &SignalProxy_PopupPosition_gtk_callback, slot_copy, &SignalProxy_PopupPosition_gtk_callback_destroy, button, activate_time); } } void Menu::popup(guint button, guint32 activate_time, const Glib::RefPtr& device) { if(!device) gtk_menu_popup(gobj(), nullptr, nullptr, nullptr, nullptr, button, activate_time); else gtk_menu_popup_for_device(gobj(), device->gobj(), nullptr, nullptr, nullptr, nullptr, nullptr, button, activate_time); } G_GNUC_END_IGNORE_DEPRECATIONS _DEPRECATE_IFDEF_END void Menu::reorder_child(const MenuItem& child, int position) { gtk_menu_reorder_child( gobj(), const_cast(child.Gtk::Widget::gobj()), position); } void Menu::unset_accel_group() { gtk_menu_set_accel_group(gobj(), nullptr); } _DEPRECATE_IFDEF_START G_GNUC_BEGIN_IGNORE_DEPRECATIONS void Menu::unset_title() { gtk_menu_set_title(gobj(), nullptr); } G_GNUC_END_IGNORE_DEPRECATIONS _DEPRECATE_IFDEF_END void Menu::attach_to_widget(Widget& attach_widget) { gtk_menu_attach_to_widget(gobj(), (attach_widget).gobj(), nullptr /* allowed by the C docs. */); } } // namespace Gtk