summaryrefslogtreecommitdiffstats
path: root/src/widgets/icon.cpp
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2009-04-18 20:48:46 +0000
committerjoncruz <joncruz@users.sourceforge.net>2009-04-18 20:48:46 +0000
commitbb0b998cc7a4ed78c8e8e854113344aaf2eff59a (patch)
treeb8623855b461323b8436186d2328f1e1f253f59d /src/widgets/icon.cpp
parentNew Film Gran Image effect (diff)
downloadinkscape-bb0b998cc7a4ed78c8e8e854113344aaf2eff59a.tar.gz
inkscape-bb0b998cc7a4ed78c8e8e854113344aaf2eff59a.zip
Correct recent changes that had reverted to always use SPIcon when not present as external .png files.
(bzr r7735)
Diffstat (limited to 'src/widgets/icon.cpp')
-rw-r--r--src/widgets/icon.cpp66
1 files changed, 41 insertions, 25 deletions
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index ec3af771e..60cc40a74 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -72,6 +72,8 @@ static GtkIconSize iconSizeLookup[] = {
GTK_ICON_SIZE_MENU, // for Inkscape::ICON_SIZE_DECORATION
};
+static std::map<Glib::ustring, Glib::ustring> legacyNames;
+
class IconCacheItem
{
public:
@@ -203,36 +205,47 @@ static int sp_icon_expose(GtkWidget *widget, GdkEventExpose *event)
return TRUE;
}
+static GdkPixbuf* renderup( gchar const* name, Inkscape::IconSize lsize, unsigned psize );
+
// PUBLIC CALL:
void sp_icon_fetch_pixbuf( SPIcon *icon )
{
+ g_message("sp_icon_fetch_pixbuf(%p) [%s]", icon, icon->name);
if ( icon ) {
if ( !icon->pb ) {
icon->psize = sp_icon_get_phys_size(icon->lsize);
- GtkIconTheme *theme = gtk_icon_theme_get_default();
+ icon->pb = renderup(icon->name, icon->lsize, icon->psize);
+ }
+ }
+}
- GdkPixbuf *pb = 0;
- if (gtk_icon_theme_has_icon(theme, icon->name)) {
- pb = gtk_icon_theme_load_icon(theme, icon->name, icon->psize, (GtkIconLookupFlags) 0, NULL);
- }
- if (!pb) {
- pb = sp_icon_image_load_svg( icon->name, Inkscape::getRegisteredIconSize(icon->lsize), icon->psize );
- // if this was loaded from SVG, add it as a builtin icon
- if (pb) {
- gtk_icon_theme_add_builtin_icon(icon->name, icon->psize, pb);
- }
- }
- if (!pb) {
- pb = sp_icon_image_load_pixmap( icon->name, icon->lsize, icon->psize );
- }
- if ( pb ) {
- icon->pb = pb;
- } else {
- /* TODO: We should do something more useful if we can't load the image. */
- g_warning ("failed to load icon '%s'", icon->name);
- }
+static GdkPixbuf* renderup( gchar const* name, Inkscape::IconSize lsize, unsigned psize ) {
+ GtkIconTheme *theme = gtk_icon_theme_get_default();
+
+ GdkPixbuf *pb = 0;
+ if (gtk_icon_theme_has_icon(theme, name)) {
+ pb = gtk_icon_theme_load_icon(theme, name, psize, (GtkIconLookupFlags) 0, NULL);
+ }
+ if (!pb) {
+ pb = sp_icon_image_load_svg( name, Inkscape::getRegisteredIconSize(lsize), psize );
+ if (!pb && (legacyNames.find(name) != legacyNames.end())) {
+ g_message("Checking fallback [%s]->[%s]", name, legacyNames[name].c_str());
+ pb = sp_icon_image_load_svg( legacyNames[name].c_str(), Inkscape::getRegisteredIconSize(lsize), psize );
+ }
+
+ // if this was loaded from SVG, add it as a builtin icon
+ if (pb) {
+ gtk_icon_theme_add_builtin_icon(name, psize, pb);
}
}
+ if (!pb) {
+ pb = sp_icon_image_load_pixmap( name, lsize, psize );
+ }
+ if ( !pb ) {
+ // TODO: We should do something more useful if we can't load the image.
+ g_warning ("failed to load icon '%s'", name);
+ }
+ return pb;
}
static void sp_icon_screen_changed( GtkWidget *widget, GdkScreen *previous_screen )
@@ -265,8 +278,6 @@ static void sp_icon_theme_changed( SPIcon *icon )
static Glib::ustring icon_cache_key(gchar const *name, unsigned lsize, unsigned psize);
static GdkPixbuf *get_cached_pixbuf(Glib::ustring const &key);
-std::map<Glib::ustring, Glib::ustring> legacyNames;
-
static void setupLegacyNaming() {
legacyNames["view-fullscreen"] = "fullscreen";
legacyNames["edit-select-all"] = "selection_select_all";
@@ -296,8 +307,7 @@ sp_icon_new_full( Inkscape::IconSize lsize, gchar const *name )
if ( stockFound ) {
img = gtk_image_new_from_stock( name, mappedSize );
- }
- else if ( legacyNames.find(name) != legacyNames.end() ) {
+ } else {
img = gtk_image_new_from_icon_name( name, mappedSize );
if ( dump ) {
g_message("gtk_image_new_from_icon_name( '%s', %d ) = %p", name, mappedSize, img);
@@ -329,6 +339,12 @@ sp_icon_new_full( Inkscape::IconSize lsize, gchar const *name )
widget = GTK_WIDGET(img);
img = 0;
+ if (!gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), name)) {
+ // TODO temporary work-around. until background rendering is restored.
+ int psize = sp_icon_get_phys_size(lsize);
+ renderup(name, lsize, psize);
+ }
+
// Add a hook to render if set visible before prerender is done.
// TODO restore g_signal_connect( G_OBJECT(widget), "map", G_CALLBACK(imageMapNamedCB), GINT_TO_POINTER(0) );