[network-manager-netbook] Use the same icons for wireless strength everywhere.



commit fbdc575a08107eeb78ac18efc2f31cf8b40801ac
Author: Tambet Ingo <tambet gmail com>
Date:   Fri Jul 24 12:32:35 2009 +0300

    Use the same icons for wireless strength everywhere.
    
    Get rid of two icon caches, one is enough.
    Remove old unused icons.

 icons/48/Makefile.am       |    4 ----
 icons/48/nm-signal-00.png  |  Bin 315 -> 0 bytes
 icons/48/nm-signal-100.png |  Bin 1548 -> 0 bytes
 icons/48/nm-signal-33.png  |  Bin 645 -> 0 bytes
 icons/48/nm-signal-66.png  |  Bin 1038 -> 0 bytes
 src/nmn-icon-cache.c       |   17 +++++++++++++++--
 src/nmn-status-icon.c      |   30 ++----------------------------
 src/nmn-wifi-item.c        |   14 ++++++++------
 8 files changed, 25 insertions(+), 40 deletions(-)
---
diff --git a/icons/48/Makefile.am b/icons/48/Makefile.am
index 571d8f0..f411012 100644
--- a/icons/48/Makefile.am
+++ b/icons/48/Makefile.am
@@ -1,10 +1,6 @@
 icondir=${datadir}/icons/hicolor/48x48/apps
 icon_DATA = \
 	nm-device-wireless.png \
-	nm-signal-00.png \
-	nm-signal-33.png \
-	nm-signal-66.png \
-	nm-signal-100.png \
 	nm-stage01-connecting01.png \
 	nm-stage01-connecting02.png \
 	nm-stage01-connecting03.png \
diff --git a/src/nmn-icon-cache.c b/src/nmn-icon-cache.c
index 5e019fa..a11725f 100644
--- a/src/nmn-icon-cache.c
+++ b/src/nmn-icon-cache.c
@@ -38,13 +38,26 @@ nmn_icon_cache_get (const char *icon_name)
         pixbuf = (GdkPixbuf *) g_hash_table_lookup (cache, icon_name);
 
     if (!pixbuf) {
-		pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name, 48, 0, &error);
+        /* Prefer theme icons */
+        pixbuf = gtk_icon_theme_load_icon (icon_theme, icon_name, 48, 0, &error);
+
+        if (!pixbuf) {
+            /* Try harder, using our own icons if theme doesn't provide something */
+            char *path;
+
+            path = g_strconcat (ICON_PATH, icon_name, ".png", NULL);
+            pixbuf = gdk_pixbuf_new_from_file (path, NULL);
+            g_free (path);
+        }
+
         if (pixbuf)
             g_hash_table_insert (cache, g_strdup (icon_name), pixbuf);
     }
 
     if (error) {
-        g_warning ("Error loading icon '%s': %s", icon_name, error->message);
+        if (!pixbuf)
+            g_warning ("Error loading icon '%s': %s", icon_name, error->message);
+
         g_error_free (error);
     }
 
diff --git a/src/nmn-status-icon.c b/src/nmn-status-icon.c
index 7cd9461..34046ed 100644
--- a/src/nmn-status-icon.c
+++ b/src/nmn-status-icon.c
@@ -30,7 +30,6 @@ G_DEFINE_TYPE (NmnStatusIcon, nmn_status_icon, GTK_TYPE_STATUS_ICON)
 
 typedef struct {
     NMClient *client;
-    GHashTable *icon_cache;
     StatusImage current_image;
     gboolean active;
     guint activation_step;
@@ -51,8 +50,7 @@ get_icon_filename (StatusImage image,
 {
     GString *str;
 
-    str = g_string_sized_new (128);
-    g_string_append (str, ICON_PATH);
+    str = g_string_sized_new (32);
 
     switch (image) {
     case STATUS_IMAGE_NO_NETWORK:
@@ -85,7 +83,6 @@ get_icon_filename (StatusImage image,
     }
 
     g_string_append (str, active ? "-active" : "-normal");
-    g_string_append (str, ".png");
 
     return g_string_free (str, FALSE);
 }
@@ -98,27 +95,7 @@ update_icon (NmnStatusIcon *self, StatusImage image)
     GdkPixbuf *pixbuf;
 
     filename = get_icon_filename (image, priv->activation_step, priv->active);
-
-    if (G_UNLIKELY (priv->icon_cache == NULL)) {
-        priv->icon_cache = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
-        pixbuf = NULL;
-    } else {
-        pixbuf = (GdkPixbuf *) g_hash_table_lookup (priv->icon_cache, filename);
-    }
-
-    if (!pixbuf) {
-        GError *error = NULL;
-
-        pixbuf = gdk_pixbuf_new_from_file (filename, &error);
-        if (pixbuf)
-            g_hash_table_insert (priv->icon_cache, filename, pixbuf);
-
-        if (error) {
-            g_warning ("Error loading status icon '%s': %s", filename, error->message);
-            g_error_free (error);
-        }
-    }
-
+    pixbuf = nmn_icon_cache_get (filename);
     g_free (filename);
 
     if (pixbuf) {
@@ -425,9 +402,6 @@ finalize (GObject *object)
         priv->activation_animation_id = 0;
     }
 
-    if (priv->icon_cache)
-        g_hash_table_destroy (priv->icon_cache);
-
     if (priv->client)
         g_object_unref (priv->client);
 
diff --git a/src/nmn-wifi-item.c b/src/nmn-wifi-item.c
index 798967e..227a26b 100644
--- a/src/nmn-wifi-item.c
+++ b/src/nmn-wifi-item.c
@@ -64,14 +64,16 @@ update_item (NmnWifiItem *self)
     strength = nm_access_point_get_strength (priv->ap);
     strength = CLAMP (strength, 0, 100);
 
-    if (strength > 71)
-        icon = "nm-signal-100";
-    else if (strength > 38)
-        icon = "nm-signal-66";
+    if (strength > 80)
+        icon = "nm-signal-100-active";
+    else if (strength > 55)
+        icon = "nm-signal-75-active";
+    else if (strength > 30)
+        icon = "nm-signal-50-active";
     else if (strength > 5)
-        icon = "nm-signal-33";
+        icon = "nm-signal-25-active";
     else
-        icon = "nm-signal-00";
+        icon = "nm-signal-00-active";
 
 	flags = nm_access_point_get_flags (priv->ap);
 	wpa_flags = nm_access_point_get_wpa_flags (priv->ap);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]