summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Šimerda <psimerda@redhat.com>2015-02-08 10:38:17 +0100
committerDan Williams <dcbw@redhat.com>2015-02-16 16:02:53 -0600
commit7f45ba6c25a8fe6a94b55b68d6ad20110f288492 (patch)
tree7785262e34347a9c238d5674b2ad165631f6c2c1
parent6f75bfefbd6c0605666191d5153b8a83974a3f1c (diff)
downloadnetwork-manager-applet-7f45ba6c25a8fe6a94b55b68d6ad20110f288492.tar.gz
applet: return icon name from from applet_update_icon()
Whenever possible, return icon name from applet_update_icon() and only load it in foo_set_icon(). https://bugzilla.gnome.org/show_bug.cgi?id=740574
-rw-r--r--src/applet.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/applet.c b/src/applet.c
index 5989b620..b400feff 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -2350,10 +2350,12 @@ applet_add_default_connection_item (NMDevice *device,
static void
foo_set_icon (NMApplet *applet, guint32 layer, GdkPixbuf *pixbuf, char *icon_name)
{
- int i;
-
g_return_if_fail (layer == ICON_LAYER_LINK || layer == ICON_LAYER_VPN);
+ /* Load the pixbuf by icon name */
+ if (icon_name && !pixbuf)
+ pixbuf = nma_icon_check_and_load (icon_name, applet);
+
/* Ignore setting of the same icon as is already displayed */
if (applet->icon_layers[layer] == pixbuf)
return;
@@ -2366,9 +2368,9 @@ foo_set_icon (NMApplet *applet, guint32 layer, GdkPixbuf *pixbuf, char *icon_nam
if (pixbuf)
applet->icon_layers[layer] = g_object_ref (pixbuf);
- if (!applet->icon_layers[0]) {
- pixbuf = g_object_ref (nma_icon_check_and_load ("nm-no-connection", applet));
- } else {
+ if (applet->icon_layers[0]) {
+ int i;
+
pixbuf = gdk_pixbuf_copy (applet->icon_layers[0]);
for (i = ICON_LAYER_LINK + 1; i <= ICON_LAYER_MAX; i++) {
@@ -2382,7 +2384,8 @@ foo_set_icon (NMApplet *applet, guint32 layer, GdkPixbuf *pixbuf, char *icon_nam
0, 0, 1.0, 1.0,
GDK_INTERP_NEAREST, 255);
}
- }
+ } else
+ pixbuf = g_object_ref (nma_icon_check_and_load ("nm-no-connection", applet));
gtk_status_icon_set_from_pixbuf (applet->status_icon, pixbuf);
g_object_unref (pixbuf);
@@ -2910,12 +2913,10 @@ applet_update_icon (gpointer user_data)
case NM_STATE_UNKNOWN:
case NM_STATE_ASLEEP:
icon_name = g_strdup ("nm-no-connection");
- pixbuf = g_object_ref (nma_icon_check_and_load (icon_name, applet));
dev_tip = g_strdup (_("Networking disabled"));
break;
case NM_STATE_DISCONNECTED:
icon_name = g_strdup ("nm-no-connection");
- pixbuf = g_object_ref (nma_icon_check_and_load (icon_name, applet));
dev_tip = g_strdup (_("No network connection"));
break;
default:
@@ -2934,21 +2935,15 @@ applet_update_icon (gpointer user_data)
icon_name = NULL;
active_vpn = applet_get_first_active_vpn_connection (applet, &vpn_state);
if (active_vpn) {
- char *name;
-
switch (vpn_state) {
case NM_VPN_CONNECTION_STATE_ACTIVATED:
icon_name = g_strdup_printf ("nm-vpn-active-lock");
- pixbuf = nma_icon_check_and_load (icon_name, applet);
break;
case NM_VPN_CONNECTION_STATE_PREPARE:
case NM_VPN_CONNECTION_STATE_NEED_AUTH:
case NM_VPN_CONNECTION_STATE_CONNECT:
case NM_VPN_CONNECTION_STATE_IP_CONFIG_GET:
- name = g_strdup_printf ("nm-vpn-connecting%02d", applet->animation_step + 1);
- pixbuf = nma_icon_check_and_load (name, applet);
- g_free (name);
-
+ icon_name = g_strdup_printf ("nm-vpn-connecting%02d", applet->animation_step + 1);
applet->animation_step++;
if (applet->animation_step >= NUM_VPN_CONNECTING_FRAMES)
applet->animation_step = 0;