From: Jon A. Cruz Date: Mon, 6 Dec 2010 00:24:57 +0000 (-0800) Subject: A proper fix for dock item mising icon problem. Fixes bug #658055. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e9c5870c5c454d21d1f463b15bc961359caabb05;p=inkscape.git A proper fix for dock item mising icon problem. Fixes bug #658055. --- diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp index 7b24c00cd..72a20c385 100644 --- a/src/ui/widget/dock-item.cpp +++ b/src/ui/widget/dock-item.cpp @@ -42,21 +42,27 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER); if (!icon_name.empty()) { - int width = 0, height = 0; - Gtk::IconSize::lookup(Gtk::ICON_SIZE_MENU, width, height); - try { - _icon_pixbuf = Gtk::IconTheme::get_default()->load_icon(icon_name, width, (Gtk::IconLookupFlags) 0); - _gdl_dock_item = - gdl_dock_item_new_with_pixbuf_icon(name.c_str(), long_name.c_str(), - _icon_pixbuf->gobj(), gdl_dock_behavior); - } catch (Gtk::IconThemeError) { - // ignore - create the dock item without an icon below + Glib::RefPtr iconTheme = Gtk::IconTheme::get_default(); + // Icon might be in the icon theme, or might be a stock item. Check the proper source: + if ( iconTheme->has_icon(icon_name) ) { + int width = 0; + int height = 0; + Gtk::IconSize::lookup(Gtk::ICON_SIZE_MENU, width, height); + _icon_pixbuf = iconTheme->load_icon(icon_name, width); + } else { + Gtk::StockItem item; + Gtk::StockID stockId(icon_name); + if ( Gtk::StockItem::lookup(stockId, item) ) { + _icon_pixbuf = _dock.getWidget().render_icon( stockId, Gtk::ICON_SIZE_MENU ); + } } } - if (!_gdl_dock_item) { - _gdl_dock_item = - gdl_dock_item_new(name.c_str(), long_name.c_str(), gdl_dock_behavior); + if ( _icon_pixbuf ) { + _gdl_dock_item = gdl_dock_item_new_with_pixbuf_icon( name.c_str(), long_name.c_str(), + _icon_pixbuf->gobj(), gdl_dock_behavior ); + } else { + _gdl_dock_item = gdl_dock_item_new(name.c_str(), long_name.c_str(), gdl_dock_behavior); } _frame.set_shadow_type(Gtk::SHADOW_IN);