From ff0dd4905d403242364fa5d63c510b0e1051ee2b Mon Sep 17 00:00:00 2001 From: Alexander Valavanis Date: Wed, 28 Jun 2017 16:57:29 +0200 Subject: Revert "Rm unused fn" This reverts commit 1da12a921c8a5e9f49de799cf9f3e9a642208bd7. --- src/ui/interface.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/ui/interface.cpp') diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index d31aa19a2..c9c00df02 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -142,6 +142,8 @@ static void sp_ui_menu_item_set_name(GtkWidget *data, Glib::ustring const &name); static void sp_recent_open(GtkRecentChooser *, gpointer); +static void injectRenamedIcons(); + static const int MIN_ONSCREEN_DISTANCE = 50; void @@ -1439,6 +1441,33 @@ sp_ui_menu_item_set_name(GtkWidget *data, Glib::ustring const &name) } } } + +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: mode:c++ -- cgit v1.2.3