[network-manager-applet/menu-rework: 1/18] wifi: replace signal strength progress bars with icons
- From: Dan Williams <dcbw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [network-manager-applet/menu-rework: 1/18] wifi: replace signal strength progress bars with icons
- Date: Fri, 25 Sep 2009 05:47:59 +0000 (UTC)
commit 4955a8cb198158f101bc4be3fe28a48be23dfcbe
Author: Tony Espy <espy ubuntu com>
Date: Thu Sep 10 10:49:42 2009 -0400
wifi: replace signal strength progress bars with icons
Replace the signal strength progress bar in the main menu
with a composite of the tray signal strength icons and an
icon denoting that an AP is secure. No longer show the
secure AP icon in the detail widget.
icons/22/Makefile.am | 3 +-
icons/22/nm-secure-lock.png | Bin 0 -> 563 bytes
src/ap-menu-item.c | 75 +++++++++++++++++++++++--------------------
src/ap-menu-item.h | 3 +-
src/applet-device-wifi.c | 10 ++---
src/applet.c | 2 +
src/applet.h | 1 +
7 files changed, 51 insertions(+), 43 deletions(-)
---
diff --git a/icons/22/Makefile.am b/icons/22/Makefile.am
index 460d472..a7f4df6 100644
--- a/icons/22/Makefile.am
+++ b/icons/22/Makefile.am
@@ -56,7 +56,8 @@ icon_DATA = \
nm-vpn-connecting12.png \
nm-vpn-connecting13.png \
nm-vpn-connecting14.png \
- nm-vpn-active-lock.png
+ nm-vpn-active-lock.png \
+ nm-secure-lock.png
EXTRA_DIST = $(icon_DATA)
diff --git a/icons/22/nm-secure-lock.png b/icons/22/nm-secure-lock.png
new file mode 100644
index 0000000..66abd16
Binary files /dev/null and b/icons/22/nm-secure-lock.png differ
diff --git a/src/ap-menu-item.c b/src/ap-menu-item.c
index 6131549..27abd76 100644
--- a/src/ap-menu-item.c
+++ b/src/ap-menu-item.c
@@ -40,12 +40,6 @@ G_DEFINE_TYPE (NMNetworkMenuItem, nm_network_menu_item, GTK_TYPE_CHECK_MENU_ITEM
static void
nm_network_menu_item_init (NMNetworkMenuItem * item)
{
- PangoFontDescription * fontdesc;
- PangoFontMetrics * metrics;
- PangoContext * context;
- PangoLanguage * lang;
- int ascent;
-
gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
item->hbox = gtk_hbox_new (FALSE, 6);
item->ssid = gtk_label_new (NULL);
@@ -57,19 +51,7 @@ nm_network_menu_item_init (NMNetworkMenuItem * item)
gtk_box_pack_start (GTK_BOX (item->hbox), item->ssid, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (item->hbox), item->detail, FALSE, FALSE, 0);
- item->strength = gtk_progress_bar_new ();
-
- /* get the font ascent for the current font and language */
- context = gtk_widget_get_pango_context (item->strength);
- fontdesc = pango_context_get_font_description (context);
- lang = pango_context_get_language (context);
- metrics = pango_context_get_metrics (context, fontdesc, lang);
- ascent = pango_font_metrics_get_ascent (metrics) * 1.5 / PANGO_SCALE;
- pango_font_metrics_unref (metrics);
-
- /* size our progress bar to be five ascents long */
- gtk_widget_set_size_request (item->strength, ascent * 5, -1);
-
+ item->strength = gtk_image_new ();
gtk_box_pack_end (GTK_BOX (item->hbox), item->strength, FALSE, TRUE, 0);
gtk_widget_show (item->ssid);
@@ -162,15 +144,48 @@ nm_network_menu_item_get_strength (NMNetworkMenuItem * item)
}
void
-nm_network_menu_item_set_strength (NMNetworkMenuItem * item, guint32 strength)
+nm_network_menu_item_set_strength (NMNetworkMenuItem * item,
+ NMAccessPoint *ap,
+ NMApplet *applet)
{
- double percent;
+ guint8 strength;
+ GdkPixbuf *pixbuf = NULL;
+ guint32 ap_flags, ap_wpa, ap_rsn;
g_return_if_fail (item != NULL);
- item->int_strength = CLAMP (strength, 0, 100);
- percent = (double) item->int_strength / 100.0;
- gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (item->strength), percent);
+ ap_flags = nm_access_point_get_flags (ap);
+ ap_wpa = nm_access_point_get_wpa_flags (ap);
+ ap_rsn = nm_access_point_get_rsn_flags (ap);
+ strength = nm_access_point_get_strength(ap);
+ strength = CLAMP (strength, 0, 100);
+
+ item->int_strength = strength;
+
+ if (strength > 80)
+ pixbuf = gdk_pixbuf_copy (applet->wireless_100_icon);
+ else if (strength > 55)
+ pixbuf = gdk_pixbuf_copy (applet->wireless_75_icon);
+ else if (strength > 30)
+ pixbuf = gdk_pixbuf_copy (applet->wireless_50_icon);
+ else if (strength > 5)
+ pixbuf = gdk_pixbuf_copy (applet->wireless_25_icon);
+ else
+ pixbuf = gdk_pixbuf_copy (applet->wireless_00_icon);
+
+ if ((ap_flags & NM_802_11_AP_FLAGS_PRIVACY)
+ || (ap_wpa != NM_802_11_AP_SEC_NONE)
+ || (ap_rsn != NM_802_11_AP_SEC_NONE)) {
+ GdkPixbuf *top = applet->secure_lock_icon;
+
+ gdk_pixbuf_composite (top, pixbuf, 0, 0, gdk_pixbuf_get_width (top),
+ gdk_pixbuf_get_height (top),
+ 0, 0, 1.0, 1.0,
+ GDK_INTERP_NEAREST, 255);
+ }
+
+ gtk_image_set_from_pixbuf (GTK_IMAGE (item->strength), pixbuf);
+ g_object_unref (pixbuf);
}
const guchar *
@@ -190,28 +205,18 @@ nm_network_menu_item_set_detail (NMNetworkMenuItem * item,
GdkPixbuf * adhoc_icon,
guint32 dev_caps)
{
- gboolean encrypted = FALSE, is_adhoc = FALSE;
+ gboolean is_adhoc = FALSE;
guint32 ap_flags, ap_wpa, ap_rsn;
ap_flags = nm_access_point_get_flags (ap);
ap_wpa = nm_access_point_get_wpa_flags (ap);
ap_rsn = nm_access_point_get_rsn_flags (ap);
- if ( (ap_flags & NM_802_11_AP_FLAGS_PRIVACY)
- || (ap_wpa != NM_802_11_AP_SEC_NONE)
- || (ap_rsn != NM_802_11_AP_SEC_NONE))
- encrypted = TRUE;
-
if (nm_access_point_get_mode (ap) == NM_802_11_MODE_ADHOC)
is_adhoc = TRUE;
if (is_adhoc) {
gtk_image_set_from_pixbuf (GTK_IMAGE (item->detail), adhoc_icon);
- } else if (encrypted) {
- if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), "network-wireless-encrypted"))
- gtk_image_set_from_icon_name (GTK_IMAGE (item->detail), "network-wireless-encrypted", GTK_ICON_SIZE_MENU);
- else
- gtk_image_set_from_icon_name (GTK_IMAGE (item->detail), "gnome-lockscreen", GTK_ICON_SIZE_MENU);
} else {
gtk_image_set_from_stock (GTK_IMAGE (item->detail), NULL, GTK_ICON_SIZE_MENU);
}
diff --git a/src/ap-menu-item.h b/src/ap-menu-item.h
index 1d7fdfe..9a96f37 100644
--- a/src/ap-menu-item.h
+++ b/src/ap-menu-item.h
@@ -69,7 +69,8 @@ void nm_network_menu_item_set_ssid (NMNetworkMenuItem * item,
GByteArray * ssid);
guint32 nm_network_menu_item_get_strength (NMNetworkMenuItem * item);
void nm_network_menu_item_set_strength (NMNetworkMenuItem * item,
- guint32 strength);
+ NMAccessPoint *ap,
+ NMApplet *applet);
const guchar * nm_network_menu_item_get_hash (NMNetworkMenuItem * item,
guint32 * length);
void nm_network_menu_item_set_detail (NMNetworkMenuItem * item,
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index 525f74d..e23db3f 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -473,7 +473,6 @@ add_new_ap_item (NMDeviceWifi *device,
NMNetworkMenuItem *item = NULL;
GSList *ap_connections = NULL;
const GByteArray *ssid;
- guint8 strength;
guint32 dev_caps;
ap_connections = filter_connections_for_access_point (connections, device, ap);
@@ -485,10 +484,8 @@ add_new_ap_item (NMDeviceWifi *device,
ssid = nm_access_point_get_ssid (ap);
nm_network_menu_item_set_ssid (item, (GByteArray *) ssid);
- strength = nm_access_point_get_strength (ap);
- nm_network_menu_item_set_strength (item, strength);
-
dev_caps = nm_device_wifi_get_capabilities (device);
+ nm_network_menu_item_set_strength (item, ap, applet);
nm_network_menu_item_set_detail (item, ap, applet->adhoc_icon, dev_caps);
nm_network_menu_item_add_dupe (item, ap);
@@ -585,8 +582,9 @@ add_one_ap_menu_item (NMDeviceWifi *device,
item = NM_NETWORK_MENU_ITEM (dup_data.found);
/* Just update strength if greater than what's there */
- if (nm_network_menu_item_get_strength (item) < strength)
- nm_network_menu_item_set_strength (item, strength);
+ if (nm_network_menu_item_get_strength (item) < strength) {
+ nm_network_menu_item_set_strength (item, ap, applet);
+ }
nm_network_menu_item_add_dupe (item, ap);
} else {
diff --git a/src/applet.c b/src/applet.c
index 13bee6a..708b6b5 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -2368,6 +2368,7 @@ static void nma_icons_free (NMApplet *applet)
CLEAR_ICON(applet->wireless_50_icon);
CLEAR_ICON(applet->wireless_75_icon);
CLEAR_ICON(applet->wireless_100_icon);
+ CLEAR_ICON(applet->secure_lock_icon);
for (i = 0; i < NUM_CONNECTING_STAGES; i++) {
for (j = 0; j < NUM_CONNECTING_FRAMES; j++)
@@ -2416,6 +2417,7 @@ nma_icons_load (NMApplet *applet)
ICON_LOAD(applet->wireless_50_icon, "nm-signal-50");
ICON_LOAD(applet->wireless_75_icon, "nm-signal-75");
ICON_LOAD(applet->wireless_100_icon, "nm-signal-100");
+ ICON_LOAD(applet->secure_lock_icon, "nm-secure-lock");
for (i = 0; i < NUM_CONNECTING_STAGES; i++) {
for (j = 0; j < NUM_CONNECTING_FRAMES; j++) {
diff --git a/src/applet.h b/src/applet.h
index d38e59a..2a09db3 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -112,6 +112,7 @@ typedef struct
GdkPixbuf * wireless_50_icon;
GdkPixbuf * wireless_75_icon;
GdkPixbuf * wireless_100_icon;
+ GdkPixbuf * secure_lock_icon;
#define NUM_CONNECTING_STAGES 3
#define NUM_CONNECTING_FRAMES 11
GdkPixbuf * network_connecting_icons[NUM_CONNECTING_STAGES][NUM_CONNECTING_FRAMES];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]