From: Jon A. Cruz Date: Mon, 6 Dec 2010 07:31:22 +0000 (-0800) Subject: Restore copies of renamed icons on certain gtk versions. Fixes bug #651678. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d75e8f9955a5abc0013eac647854f921d11d9a73;p=inkscape.git Restore copies of renamed icons on certain gtk versions. Fixes bug #651678. --- diff --git a/src/interface.cpp b/src/interface.cpp index 40d8458a3..b51178eb8 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1,5 +1,3 @@ -#define __SP_INTERFACE_C__ - /** @file * @brief Main UI stuff */ @@ -134,6 +132,8 @@ static void sp_ui_menu_item_set_name(SPAction *action, void *data); static void sp_recent_open(GtkRecentChooser *, gpointer); +static void injectRenamedIcons(); + SPActionEventVector menu_item_event_vector = { {NULL}, NULL, @@ -408,6 +408,11 @@ sp_ui_menu_deselect(gpointer object) void sp_ui_menuitem_add_icon( GtkWidget *item, gchar *icon_name ) { + static bool iconsInjected = false; + if ( !iconsInjected ) { + iconsInjected = true; + injectRenamedIcons(); + } GtkWidget *icon; icon = sp_icon_new( Inkscape::ICON_SIZE_MENU, icon_name ); @@ -1595,6 +1600,32 @@ sp_ui_menu_item_set_name(SPAction */*action*/, Glib::ustring name, void *data) //a menu item in yet another way... } +void injectRenamedIcons() +{ + Glib::RefPtr iconTheme = Gtk::IconTheme::get_default(); + + std::vector< std::pair > renamed; + renamed.push_back(std::make_pair("gtk-file", "document-x-generic")); + renamed.push_back(std::make_pair("gtk-directory", "folder")); + + for ( std::vector< std::pair >::iterator it = renamed.begin(); it < renamed.end(); ++it ) { + bool hasIcon = iconTheme->has_icon(it->first); + bool hasSecondIcon = iconTheme->has_icon(it->second); + + if ( !hasIcon && hasSecondIcon ) { + Glib::ArrayHandle sizes = iconTheme->get_icon_sizes(it->second); + for ( Glib::ArrayHandle::iterator it2 = sizes.begin(); it2 < sizes.end(); ++it2 ) { + Glib::RefPtr pb = iconTheme->load_icon( it->second, *it2 ); + if ( pb ) { + // install a private copy of the pixbuf to avoid pinning a theme + Glib::RefPtr pbCopy = pb->copy(); + Gtk::IconTheme::add_builtin_icon( it->first, *it2, pbCopy ); + } + } + } + } +} + /* Local Variables: