From 22d06152d0fabc7fe50bb6829f00b2bac4ed1796 Mon Sep 17 00:00:00 2001 From: Alexander Valavanis Date: Thu, 29 Jun 2017 13:43:56 +0200 Subject: Remove old icon handling code --- src/ui/dialog/layers.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/ui/dialog/layers.cpp') diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index dd9d7ec25..be3b4af06 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -31,7 +31,6 @@ #include "ui/icon-names.h" #include "ui/widget/imagetoggler.h" #include "verbs.h" -#include "widgets/icon.h" #include "sp-root.h" #include "ui/tools/tool-base.h" #include "selection-chemistry.h" @@ -82,7 +81,7 @@ void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned i bool set = false; if ( iconName ) { - GtkWidget *child = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName ); + GtkWidget *child = gtk_image_new_from_icon_name( iconName, GTK_ICON_SIZE_SMALL_TOOLBAR ); gtk_widget_show( child ); btn.add( *Gtk::manage(Glib::wrap(child)) ); btn.set_relief(Gtk::RELIEF_NONE); @@ -94,7 +93,7 @@ void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned i if ( verb ) { SPAction *action = verb->get_action(Inkscape::ActionContext(desktop)); if ( !set && action && action->image ) { - GtkWidget *child = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, action->image ); + GtkWidget *child = gtk_image_new_from_icon_name( action->image, GTK_ICON_SIZE_SMALL_TOOLBAR ); gtk_widget_show( child ); btn.add( *Gtk::manage(Glib::wrap(child)) ); set = true; @@ -118,7 +117,7 @@ Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code const char* label = 0; if ( iconName ) { - iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, iconName ); + iconWidget = gtk_image_new_from_icon_name( iconName, GTK_ICON_SIZE_MENU ); } if ( desktop ) { @@ -126,7 +125,7 @@ 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 = sp_icon_new( Inkscape::ICON_SIZE_MENU, action->image ); + iconWidget = gtk_image_new_from_icon_name( action->image, GTK_ICON_SIZE_MENU ); } if ( action ) { -- cgit v1.2.3 From d6f76e4dd17525bf257a9f0e513e7f9fd4373b79 Mon Sep 17 00:00:00 2001 From: Alexander Valavanis Date: Thu, 29 Jun 2017 16:48:37 +0200 Subject: Rm remaining imagemenuitem usage --- src/ui/dialog/layers.cpp | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'src/ui/dialog/layers.cpp') 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 -#include #include #include @@ -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); -- cgit v1.2.3