| 1 |
/* Copyright (C) 1998-2002 The gtkmm Development Team |
| 2 |
* |
| 3 |
* This library is free software; you can redistribute it and/or |
| 4 |
* modify it under the terms of the GNU Lesser General Public |
| 5 |
* License as published by the Free Software Foundation; either |
| 6 |
* version 2.1 of the License, or (at your option) any later version. |
| 7 |
* |
| 8 |
* This library is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
* Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public |
| 14 |
* License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include <gtk/gtk.h> |
| 18 |
|
| 19 |
#include <gtkmm/image.h> |
| 20 |
#include <gtkmm/stock.h> |
| 21 |
#include <gtkmm/accellabel.h> |
| 22 |
|
| 23 |
namespace Gtk |
| 24 |
{ |
| 25 |
|
| 26 |
ImageMenuItem::ImageMenuItem(Widget& image, |
| 27 |
const Glib::ustring& label, bool mnemonic) |
| 28 |
: |
| 29 |
_CONSTRUCT() |
| 30 |
{ |
| 31 |
set_image(image); |
| 32 |
add_accel_label(label, mnemonic); |
| 33 |
} |
| 34 |
|
| 35 |
ImageMenuItem::ImageMenuItem(const Glib::ustring& label, bool mnemonic) |
| 36 |
: |
| 37 |
_CONSTRUCT() |
| 38 |
{ |
| 39 |
add_accel_label(label, mnemonic); |
| 40 |
} |
| 41 |
|
| 42 |
ImageMenuItem::ImageMenuItem(const Gtk::StockID& stock_id) |
| 43 |
: |
| 44 |
_CONSTRUCT() |
| 45 |
{ |
| 46 |
auto image = new Gtk::Image(stock_id, ICON_SIZE_MENU); |
| 47 |
image->show(); |
| 48 |
set_image( *(Gtk::manage(image)) ); |
| 49 |
|
| 50 |
Gtk::StockItem item; |
| 51 |
if(Gtk::Stock::lookup(stock_id, item)) |
| 52 |
{ |
| 53 |
add_accel_label(item.get_label(), true); //true = use mnemonic. |
| 54 |
set_accel_key( AccelKey(item.get_keyval(), item.get_modifier()) ); |
| 55 |
} |
| 56 |
else |
| 57 |
{ |
| 58 |
add_accel_label(stock_id.get_string(), false); |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
} // namespace Gtk |