diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2010-12-06 07:31:22 +0000 |
|---|---|---|
| committer | Jon A. Cruz <jon@joncruz.org> | 2010-12-06 07:31:22 +0000 |
| commit | 1efe6bec4f9bf503930f2832eab571908b280856 (patch) | |
| tree | ecc3e1ab4599d966fddc905d06c92404c0163dd1 /src/interface.cpp | |
| parent | Fix missing warning icon for missing font on text toolbar. (diff) | |
| download | inkscape-1efe6bec4f9bf503930f2832eab571908b280856.tar.gz inkscape-1efe6bec4f9bf503930f2832eab571908b280856.zip | |
Restore copies of renamed icons on certain gtk versions. Fixes bug #651678.
Fixed bugs:
- https://launchpad.net/bugs/651678
(bzr r9939)
Diffstat (limited to 'src/interface.cpp')
| -rw-r--r-- | src/interface.cpp | 35 |
1 files changed, 33 insertions, 2 deletions
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<Gtk::IconTheme> iconTheme = Gtk::IconTheme::get_default(); + + std::vector< std::pair<Glib::ustring, Glib::ustring> > 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<Glib::ustring, Glib::ustring> >::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<int> sizes = iconTheme->get_icon_sizes(it->second); + for ( Glib::ArrayHandle<int>::iterator it2 = sizes.begin(); it2 < sizes.end(); ++it2 ) { + Glib::RefPtr<Gdk::Pixbuf> pb = iconTheme->load_icon( it->second, *it2 ); + if ( pb ) { + // install a private copy of the pixbuf to avoid pinning a theme + Glib::RefPtr<Gdk::Pixbuf> pbCopy = pb->copy(); + Gtk::IconTheme::add_builtin_icon( it->first, *it2, pbCopy ); + } + } + } + } +} + /* Local Variables: |
