diff options
| author | Alexander Valavanis <valavanisalex@gmail.com> | 2017-06-29 14:48:37 +0000 |
|---|---|---|
| committer | Alexander Valavanis <valavanisalex@gmail.com> | 2017-06-29 14:48:37 +0000 |
| commit | d6f76e4dd17525bf257a9f0e513e7f9fd4373b79 (patch) | |
| tree | b804b4cf7940612e79ca8a4cb733e293678f4ad1 /src | |
| parent | Use Gtk orientable widgets (diff) | |
| download | inkscape-d6f76e4dd17525bf257a9f0e513e7f9fd4373b79.tar.gz inkscape-d6f76e4dd17525bf257a9f0e513e7f9fd4373b79.zip | |
Rm remaining imagemenuitem usage
Diffstat (limited to 'src')
| -rw-r--r-- | src/ui/dialog/layers.cpp | 35 | ||||
| -rw-r--r-- | src/ui/dialog/objects.cpp | 38 | ||||
| -rw-r--r-- | src/ui/dialog/tags.cpp | 4 |
3 files changed, 42 insertions, 35 deletions
diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index be3b4af06..7a650b034 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -15,7 +15,6 @@ #include "layers.h" #include <gtkmm/icontheme.h> -#include <gtkmm/imagemenuitem.h> #include <gtkmm/separatormenuitem.h> #include <glibmm/main.h> @@ -113,11 +112,12 @@ void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned i Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback, int id ) { - GtkWidget* iconWidget = 0; + Gtk::Image *iconWidget = nullptr; const char* label = 0; if ( iconName ) { - iconWidget = gtk_image_new_from_icon_name( iconName, GTK_ICON_SIZE_MENU ); + iconWidget = Gtk::manage(new Gtk::Image()); + iconWidget->set_from_icon_name( iconName, Gtk::ICON_SIZE_MENU ); } if ( desktop ) { @@ -125,7 +125,8 @@ Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code if ( verb ) { SPAction *action = verb->get_action(Inkscape::ActionContext(desktop)); if ( !iconWidget && action && action->image ) { - iconWidget = gtk_image_new_from_icon_name( action->image, GTK_ICON_SIZE_MENU ); + iconWidget = Gtk::manage(new Gtk::Image()); + iconWidget->set_from_icon_name( action->image, Gtk::ICON_SIZE_MENU ); } if ( action ) { @@ -138,21 +139,23 @@ Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code label = fallback; } - Gtk::Widget* wrapped = 0; - if ( iconWidget ) { - wrapped = Gtk::manage(Glib::wrap(iconWidget)); - wrapped->show(); - } - - - Gtk::MenuItem* item = 0; + auto box = Gtk::manage(new Gtk::Box()); + Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem()); - if (wrapped) { - item = Gtk::manage(new Gtk::ImageMenuItem(*wrapped, label, true)); - } else { - item = Gtk::manage(new Gtk::MenuItem(label, true)); + if (iconWidget) { + box->pack_start(*iconWidget, false, true, 0); + } + else { + Gtk::Label *fake_icon = Gtk::manage(new Gtk::Label("")); + box->pack_start(*fake_icon, false, true, 0); } + Gtk::Label *menu_label = Gtk::manage(new Gtk::Label(label, true)); + menu_label->set_xalign(0.0); + box->pack_start(*menu_label, true, true, 0); + item->add(*box); + item->show_all(); + item->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &LayersPanel::_takeAction), id)); _popupMenu.append(*item); diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index e76da241a..4b673b8b7 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -241,23 +241,25 @@ void ObjectsPanel::_styleButton(Gtk::Button& btn, char const* iconName, char con */ Gtk::MenuItem& ObjectsPanel::_addPopupItem( SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback, int id ) { - GtkWidget* iconWidget = 0; + Gtk::Image *iconWidget = nullptr; const char* label = 0; if ( iconName ) { - iconWidget = gtk_image_new_from_icon_name( iconName, GTK_ICON_SIZE_MENU ); + iconWidget = Gtk::manage(new Gtk::Image()); + iconWidget->set_from_icon_name( iconName, Gtk::ICON_SIZE_MENU ); } if ( desktop ) { Verb *verb = Verb::get( code ); if ( verb ) { - SPAction *action = verb->get_action(desktop); + SPAction *action = verb->get_action(Inkscape::ActionContext(desktop)); if ( !iconWidget && action && action->image ) { - iconWidget = gtk_image_new_from_icon_name( action->image, GTK_ICON_SIZE_MENU ); + iconWidget = Gtk::manage(new Gtk::Image()); + iconWidget->set_from_icon_name( action->image, Gtk::ICON_SIZE_MENU ); } if ( action ) { - // label = action->name; + label = action->name; } } } @@ -266,21 +268,23 @@ Gtk::MenuItem& ObjectsPanel::_addPopupItem( SPDesktop *desktop, unsigned int cod label = fallback; } - Gtk::Widget* wrapped = 0; - if ( iconWidget ) { - wrapped = Gtk::manage(Glib::wrap(iconWidget)); - wrapped->show(); - } - - - Gtk::MenuItem* item = 0; + auto box = Gtk::manage(new Gtk::Box()); + Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem()); - if (wrapped) { - item = Gtk::manage(new Gtk::ImageMenuItem(*wrapped, label, true)); - } else { - item = Gtk::manage(new Gtk::MenuItem(label, true)); + if (iconWidget) { + box->pack_start(*iconWidget, false, true, 0); + } + else { + Gtk::Label *fake_icon = Gtk::manage(new Gtk::Label("")); + box->pack_start(*fake_icon, false, true, 0); } + Gtk::Label *menu_label = Gtk::manage(new Gtk::Label(label, true)); + menu_label->set_xalign(0.0); + box->pack_start(*menu_label, true, true, 0); + item->add(*box); + item->show_all(); + item->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &ObjectsPanel::_takeAction), id)); _popupMenu.append(*item); diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index b990ccfef..176719995 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -155,7 +155,7 @@ Gtk::MenuItem& TagsPanel::_addPopupItem( SPDesktop *desktop, unsigned int code, } if ( action ) { - label = action->name; + // label = action->name; } } } @@ -166,7 +166,7 @@ Gtk::MenuItem& TagsPanel::_addPopupItem( SPDesktop *desktop, unsigned int code, Gtk::Widget* wrapped = 0; if ( iconWidget ) { - wrapped = manage(Glib::wrap(iconWidget)); + wrapped = Gtk::manage(Glib::wrap(iconWidget)); wrapped->show(); } |
