NOTE: This is a fixed version of the patch: Original commit: loader = gdk_pixbuf_loader_new_with_type ("image/png", &error); Fixed commit: loader = gdk_pixbuf_loader_new_with_type ("png", &error); From bc459bd602ad34911e2ad1779c9b51e76d06f1bd Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 30 Dec 2010 23:09:34 -0600 Subject: [PATCH] applet: fix fallback icon issues for good By embedding the fallback icon into the applet. --- src/Makefile.am | 3 +- src/applet.c | 42 ++++++++++++------ src/fallback-icon.h | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 15 deletions(-) create mode 100644 src/fallback-icon.h diff --git a/src/Makefile.am b/src/Makefile.am index 44a1c56..037577f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -49,7 +49,8 @@ nm_applet_SOURCES = \ mobile-helpers.c \ mobile-helpers.h \ applet-device-bt.h \ - applet-device-bt.c + applet-device-bt.c \ + fallback-icon.h nm_applet_LDADD = \ -lm \ diff --git a/src/applet.c b/src/applet.c index 0fe35ac..a810339 100644 --- a/src/applet.c +++ b/src/applet.c @@ -2780,32 +2780,46 @@ nma_icon_check_and_load (const char *name, GdkPixbuf **icon, NMApplet *applet) return *icon; } -#define FALLBACK_ICON_NAME "gtk-dialog-error" +#include "fallback-icon.h" static gboolean nma_icons_reload (NMApplet *applet) { GError *error = NULL; + GdkPixbufLoader *loader; g_return_val_if_fail (applet->icon_size > 0, FALSE); nma_icons_free (applet); - applet->fallback_icon = gtk_icon_theme_load_icon (applet->icon_theme, - FALLBACK_ICON_NAME, - applet->icon_size, 0, - &error); - if (!applet->fallback_icon) { - g_warning ("Fallback icon '%s' missing: (%d) %s", - FALLBACK_ICON_NAME, - error ? error->code : -1, - (error && error->message) ? error->message : "(unknown)"); - g_clear_error (&error); - /* Die if we can't get even a fallback icon */ - g_assert (applet->fallback_icon); - } + loader = gdk_pixbuf_loader_new_with_type ("png", &error); + if (!loader) + goto error; + + if (!gdk_pixbuf_loader_write (loader, + fallback_icon_data, + sizeof (fallback_icon_data), + &error)) + goto error; + + if (!gdk_pixbuf_loader_close (loader, &error)) + goto error; + + applet->fallback_icon = gdk_pixbuf_loader_get_pixbuf (loader); + g_object_ref (applet->fallback_icon); + g_assert (applet->fallback_icon); + g_object_unref (loader); return TRUE; + +error: + g_warning ("Could not load fallback icon: (%d) %s", + error ? error->code : -1, + (error && error->message) ? error->message : "(unknown)"); + g_clear_error (&error); + /* Die if we can't get a fallback icon */ + g_assert (FALSE); + return FALSE; } static void nma_icon_theme_changed (GtkIconTheme *icon_theme, NMApplet *applet) diff --git a/src/fallback-icon.h b/src/fallback-icon.h new file mode 100644 index 0000000..c17b779 --- /dev/null +++ b/src/fallback-icon.h @@ -0,0 +1,119 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Copyright (C) The GNOME Project. + */ + +/* Hex dump of dialog-error.png from gnome-icon-theme 2.31.0 + * md5sum 28d948cb5e70f54dcb1d6bdba26990fa + */ +static guint8 fallback_icon_data[] = { +0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, +0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x16, +0x08, 0x06, 0x00, 0x00, 0x00, 0xc4, 0xb4, 0x6c, 0x3b, 0x00, 0x00, 0x00, +0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64, +0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0d, +0xd7, 0x00, 0x00, 0x0d, 0xd7, 0x01, 0x42, 0x28, 0x9b, 0x78, 0x00, 0x00, +0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, +0x72, 0x65, 0x00, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63, +0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00, +0x00, 0x03, 0xe3, 0x49, 0x44, 0x41, 0x54, 0x38, 0x8d, 0xb5, 0x94, 0xcb, +0x4f, 0x24, 0x55, 0x14, 0xc6, 0xbf, 0x73, 0x6f, 0x55, 0x35, 0xdd, 0xd5, +0x4d, 0xf3, 0x68, 0x30, 0x83, 0x3c, 0x1b, 0x07, 0x83, 0x19, 0xd9, 0x10, +0x23, 0x71, 0xd5, 0x5b, 0xd6, 0x0e, 0x7b, 0xf6, 0xee, 0x7d, 0xcd, 0x86, +0xcd, 0x64, 0x32, 0x89, 0x7f, 0x81, 0xc6, 0x85, 0x09, 0x2b, 0x65, 0xe3, +0x62, 0x32, 0x0b, 0x37, 0x2c, 0x34, 0x99, 0x89, 0xc6, 0x28, 0x38, 0x43, +0x1c, 0xf0, 0x01, 0x02, 0x0e, 0xd0, 0x3c, 0xaa, 0xfa, 0x51, 0xd5, 0x5d, +0x75, 0xcf, 0x71, 0x41, 0x77, 0xc1, 0x40, 0x6b, 0x66, 0xe3, 0x4d, 0x4e, +0xee, 0xad, 0x5b, 0x75, 0x7e, 0xf5, 0xdd, 0x73, 0xbf, 0x7b, 0x49, 0x44, +0xf0, 0x7f, 0x34, 0xeb, 0x5f, 0xdf, 0x10, 0xe9, 0x72, 0xb1, 0x38, 0x2f, +0x22, 0x73, 0x0c, 0x94, 0x98, 0x79, 0x46, 0x8c, 0x81, 0x61, 0x5e, 0x83, +0x31, 0xab, 0x11, 0xf0, 0xa8, 0x78, 0x70, 0xf0, 0x10, 0x22, 0xa6, 0x63, +0x7a, 0x27, 0xc5, 0xc7, 0x53, 0x53, 0xd3, 0x02, 0xac, 0x50, 0xbe, 0x7b, +0xcc, 0xf4, 0xf6, 0xa4, 0xa5, 0x37, 0xaf, 0x54, 0x7f, 0x1f, 0x98, 0x08, +0x28, 0x9f, 0xc0, 0x9c, 0x9c, 0x70, 0xbc, 0xff, 0x3c, 0x88, 0x0e, 0x8f, +0xb6, 0x59, 0xe4, 0xf6, 0xcd, 0x72, 0x79, 0xe3, 0xbf, 0xc1, 0x44, 0xea, +0xa0, 0x58, 0xfc, 0x40, 0xdb, 0xf6, 0x1d, 0x8c, 0x8f, 0xa6, 0x39, 0x9f, +0x53, 0xe6, 0xf8, 0x14, 0xf0, 0x2b, 0x10, 0xcf, 0x03, 0x04, 0x50, 0x7d, +0x3d, 0x40, 0x77, 0x0e, 0x34, 0x38, 0x00, 0x73, 0x78, 0xc4, 0xe1, 0xda, +0x93, 0x20, 0x0e, 0xc3, 0xbb, 0x53, 0x9e, 0x77, 0x1f, 0x22, 0xdc, 0x11, +0xfc, 0xf7, 0xc4, 0xc4, 0x47, 0xca, 0x75, 0xef, 0xa8, 0xc9, 0x71, 0xd7, +0xf8, 0x15, 0xc8, 0xf6, 0x0e, 0xc0, 0x57, 0x56, 0x24, 0x02, 0x11, 0x81, +0x28, 0x05, 0xf5, 0x5a, 0x11, 0xc8, 0x65, 0x11, 0xfe, 0xf8, 0x73, 0x2d, +0x38, 0x3d, 0xbd, 0xfb, 0x86, 0xef, 0xdf, 0xbb, 0x06, 0xde, 0x1e, 0x1a, +0x9a, 0xb6, 0x53, 0xa9, 0xef, 0xf5, 0xeb, 0x37, 0x5d, 0x79, 0x7e, 0x00, +0x78, 0x3e, 0xe8, 0x7c, 0x15, 0x57, 0xb8, 0x72, 0x01, 0x17, 0x01, 0x7a, +0xf2, 0xa0, 0xd1, 0x61, 0xf8, 0xdf, 0x3d, 0xaa, 0x45, 0xf5, 0xfa, 0x5b, +0xb7, 0x1a, 0x8d, 0x0d, 0x00, 0x50, 0xed, 0x8d, 0x52, 0xc0, 0x8a, 0x1a, +0x2c, 0xa4, 0xe1, 0xf9, 0x20, 0xcf, 0x87, 0x52, 0x0a, 0xa4, 0x35, 0x94, +0x52, 0x50, 0xed, 0xbe, 0x15, 0xd4, 0x0e, 0x22, 0xe0, 0xcc, 0x03, 0x9d, +0x9e, 0x21, 0x3d, 0x39, 0x91, 0x26, 0xcb, 0x5a, 0xf9, 0x8a, 0x48, 0x27, +0xe0, 0xdf, 0x0b, 0x85, 0x79, 0x38, 0xce, 0x28, 0x65, 0x32, 0x4a, 0x0e, +0x8f, 0x92, 0x24, 0x45, 0x74, 0x01, 0xd4, 0x3a, 0x99, 0xbf, 0x1c, 0x20, +0x82, 0xd9, 0xdd, 0x87, 0xdd, 0x93, 0x57, 0x70, 0xdd, 0xb1, 0x29, 0xad, +0xe7, 0x13, 0xb0, 0x88, 0xcc, 0x21, 0xdd, 0x95, 0x86, 0x5f, 0x01, 0xb5, +0x6b, 0xde, 0x4e, 0x6e, 0xab, 0xbc, 0x0a, 0x6c, 0x7f, 0xd3, 0xae, 0xfb, +0xa9, 0x87, 0xae, 0xee, 0x5c, 0x97, 0x10, 0xcd, 0x01, 0x2d, 0x1f, 0x8b, +0x48, 0x49, 0xa5, 0x1c, 0xcd, 0x61, 0x08, 0x25, 0x82, 0xc1, 0xcd, 0x4d, +0x40, 0xeb, 0x0e, 0xee, 0xec, 0xd0, 0xe2, 0x18, 0x7b, 0xc5, 0x22, 0x24, +0x08, 0x60, 0x65, 0x5d, 0x0d, 0xa2, 0x52, 0xa2, 0x98, 0x99, 0x67, 0xc8, +0x71, 0x80, 0xb0, 0x01, 0x01, 0x5e, 0x1e, 0x0a, 0x00, 0x96, 0x75, 0xae, +0x38, 0x08, 0xa1, 0xba, 0xba, 0xc0, 0xc6, 0xcc, 0x5c, 0x80, 0x8d, 0x01, +0x44, 0x00, 0x61, 0x08, 0x33, 0x10, 0xc7, 0x2f, 0x0f, 0x8e, 0xe3, 0x96, +0x53, 0x38, 0x71, 0x0c, 0xd0, 0x2a, 0x85, 0x31, 0x66, 0x3d, 0xaa, 0xd6, +0xde, 0xb1, 0x1d, 0x07, 0x52, 0x0f, 0xb0, 0x3f, 0x39, 0x99, 0x58, 0xed, +0x05, 0xcb, 0x89, 0x40, 0x70, 0xdd, 0x72, 0x22, 0x02, 0x38, 0x0e, 0x22, +0xdf, 0x07, 0x01, 0xeb, 0x89, 0x62, 0x61, 0x5e, 0x8d, 0xaa, 0x55, 0xc3, +0x5a, 0x43, 0xf8, 0x5c, 0x35, 0x5f, 0xea, 0xd9, 0x98, 0xf3, 0xb8, 0x3a, +0xdf, 0x1a, 0x0b, 0x33, 0xe0, 0x38, 0x88, 0x2b, 0x55, 0x23, 0x22, 0xab, +0x09, 0x38, 0x8a, 0xa2, 0xc7, 0x61, 0xa5, 0x1a, 0x20, 0x95, 0x82, 0x11, +0x49, 0x92, 0x3a, 0xc6, 0xd5, 0x1f, 0x88, 0x80, 0x89, 0x20, 0x6e, 0x06, +0xa1, 0x77, 0x16, 0x30, 0xf0, 0x38, 0x01, 0x6f, 0x19, 0xf3, 0x20, 0xae, +0xd5, 0x76, 0xc2, 0xb3, 0x33, 0xa6, 0x9e, 0xfc, 0x45, 0xf2, 0x25, 0x48, +0xfb, 0xf9, 0xda, 0x6a, 0x98, 0xa1, 0xfa, 0xfb, 0xd0, 0x38, 0x3e, 0x61, +0x53, 0x0b, 0x76, 0xfe, 0x00, 0x1e, 0x24, 0xe0, 0x05, 0x11, 0xc3, 0x71, +0x7c, 0xdb, 0xdf, 0xf9, 0x2b, 0x60, 0xdb, 0x02, 0xd2, 0x5d, 0x2f, 0x2a, +0xbc, 0x52, 0x8a, 0xcb, 0x63, 0x72, 0x33, 0x30, 0x29, 0x07, 0x95, 0x3f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, 0xac, 0x50, 0x45, 0x51, 0x63, 0x71, 0x71, 0x91, 0x49, 0x44, +0xda, 0x8a, 0x75, 0xa5, 0x62, 0xb9, 0xc6, 0xae, 0xf6, 0x12, 0x73, 0x3e, +0x1d, 0xc7, 0xfd, 0xef, 0xee, 0xee, 0x96, 0x86, 0x82, 0xe0, 0x56, 0xa1, +0xd9, 0x7c, 0xb3, 0xbb, 0xd9, 0x1c, 0x01, 0x00, 0xcf, 0x71, 0xf6, 0x0e, +0x52, 0xa9, 0x8d, 0xdd, 0x4c, 0xe6, 0xe9, 0xd7, 0x37, 0x86, 0xbf, 0xad, +0xdb, 0xea, 0x94, 0xc4, 0x3e, 0x31, 0x2a, 0x2e, 0x87, 0xc7, 0xc7, 0x67, +0x5b, 0x5b, 0x5b, 0x4d, 0x11, 0x91, 0xe4, 0x3e, 0x26, 0x22, 0x5a, 0x5a, +0x5a, 0xa2, 0xe5, 0xe5, 0x65, 0x3b, 0xce, 0x66, 0xd3, 0xbd, 0x44, 0x19, +0xa3, 0x75, 0x0e, 0x62, 0xb9, 0x8a, 0x90, 0x66, 0xc5, 0x29, 0x2d, 0x42, +0x31, 0x10, 0x13, 0x73, 0x28, 0x8e, 0x53, 0xd7, 0x22, 0x15, 0x1d, 0x45, +0x55, 0x00, 0xf5, 0x5c, 0x2e, 0xd7, 0x5c, 0x5d, 0x5d, 0x35, 0xd2, 0x02, +0xfe, 0x03, 0xc2, 0xb4, 0xab, 0xc5, 0x3d, 0x6e, 0x64, 0x10, 0x00, 0x00, +0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 +}; + -- 1.7.3.4