From ab02058d7830e1868823b266afae32d03b0a05ea Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Mon, 20 Sep 2010 18:42:40 +0200 Subject: [PATCH] Maemo: Improved icon loading in status applet. --- src/frontends/maemo/src/strongswan-status.c | 38 ++++++++++++++------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/frontends/maemo/src/strongswan-status.c b/src/frontends/maemo/src/strongswan-status.c index cf8964a6a..48a8c7492 100644 --- a/src/frontends/maemo/src/strongswan-status.c +++ b/src/frontends/maemo/src/strongswan-status.c @@ -146,22 +146,36 @@ button_clicked (HildonButton *button, StrongswanStatus *plugin) gtk_widget_show_all (priv->dialog); } +static GdkPixbuf* +load_icon (GtkIconTheme *theme, const gchar *name, gint size) +{ + GdkPixbuf *icon = NULL; + GdkPixbuf *loaded = gtk_icon_theme_load_icon (theme, name, size, + GTK_ICON_LOOKUP_NO_SVG, NULL); + if (loaded) + { /* so we don't have to listen for theme changes, we copy the icon */ + icon = gdk_pixbuf_copy (loaded); + g_object_unref (loaded); + } + return icon; +} + static void load_icons (StrongswanStatusPrivate *priv) { GtkIconTheme *theme = gtk_icon_theme_get_default (); - priv->icons.status_open = gtk_icon_theme_load_icon (theme, - "strongswan_lock_open", - ICON_SIZE_STATUS, GTK_ICON_LOOKUP_NO_SVG, NULL); - priv->icons.status_close = gtk_icon_theme_load_icon (theme, - "strongswan_lock_close", - ICON_SIZE_STATUS, GTK_ICON_LOOKUP_NO_SVG, NULL); - priv->icons.button_open = gtk_icon_theme_load_icon (theme, - "strongswan_lock_open", - ICON_SIZE_BUTTON, GTK_ICON_LOOKUP_NO_SVG, NULL); - priv->icons.button_close = gtk_icon_theme_load_icon (theme, - "strongswan_lock_close", - ICON_SIZE_BUTTON, GTK_ICON_LOOKUP_NO_SVG, NULL); + priv->icons.status_open = load_icon (theme, "strongswan_lock_open", + ICON_SIZE_STATUS); + priv->icons.status_close = load_icon (theme, "strongswan_lock_close", + ICON_SIZE_STATUS); + priv->icons.button_open = load_icon (theme, "strongswan_lock_open", + ICON_SIZE_BUTTON); + priv->icons.button_close = load_icon (theme, "strongswan_lock_close", + ICON_SIZE_BUTTON); + if (!priv->icons.status_open || !priv->icons.button_open) + { + hildon_banner_show_information (NULL, NULL, "failed to load icons"); + } } static void