add new sigc++2 directory
[ardour.git] / libs / gtkmm2 / gtk / src / imagemenuitem.ccg
1 // -*- c++ -*-
2 /* $Id: imagemenuitem.ccg,v 1.2 2003/10/28 17:12:27 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 <gtk/gtkimagemenuitem.h>
24
25 #include <gtkmm/image.h>
26 #include <gtkmm/stock.h>
27 #include <gtkmm/accellabel.h>
28
29 namespace Gtk
30 {
31
32 ImageMenuItem::ImageMenuItem(Widget& image, 
33                              const Glib::ustring& label, bool mnemonic)
34 :
35   _CONSTRUCT()
36 {
37   set_image(image);
38   add_accel_label(label, mnemonic);
39 }
40
41 ImageMenuItem::ImageMenuItem(const Glib::ustring& label, bool mnemonic)
42 :
43   _CONSTRUCT()
44 {
45   add_accel_label(label, mnemonic);
46 }
47
48 ImageMenuItem::ImageMenuItem(const Gtk::StockID& stock_id)
49 :
50   _CONSTRUCT()
51 {
52   Gtk::Image* image = new Gtk::Image(stock_id, ICON_SIZE_MENU);
53   image->show();
54   set_image( *(Gtk::manage(image)) );
55
56   Gtk::StockItem item;
57   if(Gtk::Stock::lookup(stock_id, item))
58   {
59     add_accel_label(item.get_label(), true); //true = use mnemonic.
60     set_accel_key( AccelKey(item.get_keyval(), item.get_modifier()) );
61   }
62   else
63   {
64     add_accel_label(stock_id.get_string(), false);
65   }
66 }
67
68 } // namespace Gtk
69