add new sigc++2 directory
[ardour.git] / libs / gtkmm2 / gtk / src / optionmenu.ccg
1 // -*- c++ -*-
2 /* $Id: optionmenu.ccg,v 1.6 2004/04/17 14:44:45 murrayc Exp $ */
3
4 /* 
5  *
6  * Copyright 1998-2002 The gtkmm Development Team
7  *
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.
12  *
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.
17  *
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.
21  */
22
23 #include <gtkmm/menu.h>
24 #include <gtkmm/window.h>
25 #include <gtk/gtkoptionmenu.h>
26
27 namespace Gtk
28 {
29
30
31 OptionMenu::OptionMenu()
32 :
33   _CONSTRUCT()
34 {
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).
38
39   signal_realize().connect(sigc::mem_fun(*this, &OptionMenu::init_accels_handler_));
40 }
41
42 OptionMenu::~OptionMenu()
43 {
44   //GTKMM_LIFECYCLE
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.
49   remove_menu();
50
51   destroy_();
52 }
53
54 void OptionMenu::init_accels_handler_()
55 {
56   if(gobj())
57   {
58     Window *const toplevel = dynamic_cast<Window*>(get_toplevel());
59     if(toplevel && get_menu())
60     {
61       get_menu()->accelerate(*toplevel);
62     }
63   }
64 }
65
66 } /* namespace Gtk */
67
68