[network-manager-applet] applet: hardcode AP strength icons to 24x24 (bgo #741184)



commit 5814648e6e3a7e825d85e1955736ffa284af541a
Author: Dan Williams <dcbw redhat com>
Date:   Fri Dec 5 16:52:31 2014 -0600

    applet: hardcode AP strength icons to 24x24 (bgo #741184)
    
    The icon size in the menu is currently the same as the size of the
    status icon.  That means if the status icon size is larger than
    24x24 the menu looks awful.
    
    We should be using GTK_ICON_SIZE_MENU here, but that's actually
    a bit too small.  Since GTK hardcodes GTK_ICON_SIZE_MENU to 16x16
    anyway, we might as well hardcode the size we want to use too.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=741184

 src/ap-menu-item.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/src/ap-menu-item.c b/src/ap-menu-item.c
index ca94c32..02386a8 100644
--- a/src/ap-menu-item.c
+++ b/src/ap-menu-item.c
@@ -181,6 +181,15 @@ nm_network_menu_item_best_strength (NMNetworkMenuItem * item,
                                                          GDK_INTERP_NEAREST, 255);
        }
 
+       /* Scale to menu size if larger so the menu doesn't look awful */
+       if (gdk_pixbuf_get_height (pixbuf) > 24 || gdk_pixbuf_get_width (pixbuf) > 24) {
+               GdkPixbuf *scaled;
+
+               scaled = gdk_pixbuf_scale_simple (pixbuf, 24, 24, GDK_INTERP_BILINEAR);
+               g_object_unref (pixbuf);
+               pixbuf = scaled;
+       }
+
        gtk_image_set_from_pixbuf (GTK_IMAGE (item->strength), pixbuf);
        g_object_unref (pixbuf);
 }
@@ -214,8 +223,16 @@ nm_network_menu_item_set_detail (NMNetworkMenuItem *item,
                item->is_encrypted = TRUE;
 
        if (nm_access_point_get_mode (ap) == NM_802_11_MODE_ADHOC) {
+               GdkPixbuf *scaled = NULL;
+
                item->is_adhoc = is_adhoc = TRUE;
-               gtk_image_set_from_pixbuf (GTK_IMAGE (item->detail), adhoc_icon);
+
+               if (gdk_pixbuf_get_height (adhoc_icon) > 24 || gdk_pixbuf_get_width (adhoc_icon) > 24)
+                       scaled = gdk_pixbuf_scale_simple (adhoc_icon, 24, 24, GDK_INTERP_BILINEAR);
+
+               gtk_image_set_from_pixbuf (GTK_IMAGE (item->detail), scaled ? scaled : adhoc_icon);
+
+               g_clear_object (&scaled);
        } else
                gtk_image_set_from_stock (GTK_IMAGE (item->detail), NULL, GTK_ICON_SIZE_MENU);
 


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