2 /* $Id: optionmenu.ccg,v 1.6 2004/04/17 14:44:45 murrayc Exp $ */
6 * Copyright 1998-2002 The gtkmm Development Team
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <gtkmm/menu.h>
24 #include <gtkmm/window.h>
25 #include <gtk/gtkoptionmenu.h>
31 OptionMenu::OptionMenu()
35 // Connect to the signal instead of overriding the on_hierarchy_changed()
36 // method because invocation of C++ default signal handlers is skipped
37 // for gtkmmproc-generated classes (a gtkmm-wide optimization).
39 signal_realize().connect(sigc::mem_fun(*this, &OptionMenu::init_accels_handler_));
42 OptionMenu::~OptionMenu()
45 //Remove the menu so that the Menu forgets about this OptionMenu.
46 //Normally the GtkOptionMenu just destroys the Menu (see gtk_option_menu_destroy),
47 //but we prevent premature destruction in general for all widgets,
48 //so the Menu would survive and remember a dead GtkOptionMenu.
54 void OptionMenu::init_accels_handler_()
58 Window *const toplevel = dynamic_cast<Window*>(get_toplevel());
59 if(toplevel && get_menu())
61 get_menu()->accelerate(*toplevel);