[network-manager-applet/menu-rework: 7/18] core: refine menu layout and style for active and available connections
- From: Dan Williams <dcbw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [network-manager-applet/menu-rework: 7/18] core: refine menu layout and style for active and available connections
- Date: Fri, 25 Sep 2009 05:48:29 +0000 (UTC)
commit b583c5f337fd25a412da5622b8f95aa8a3d178c2
Author: Alexander Sack <asac ubuntu com>
Date: Fri Sep 18 19:16:54 2009 +0200
core: refine menu layout and style for active and available connections
separate active and not-active/available connections by placing
a labelled separator in the menu. In turn we drop the
"active" device image completely
src/ap-menu-item.c | 5 +++++
src/ap-menu-item.h | 2 ++
src/applet-device-bt.c | 14 +++++++-------
src/applet-device-cdma.c | 13 +++++++------
src/applet-device-gsm.c | 13 +++++++------
src/applet-device-wifi.c | 21 +++++++++------------
src/applet-device-wired.c | 13 +++++++------
src/applet.c | 38 ++++++++++++++++++++++++++++++++++++++
src/applet.h | 6 ++++++
9 files changed, 88 insertions(+), 37 deletions(-)
---
diff --git a/src/ap-menu-item.c b/src/ap-menu-item.c
index dc61fde..7e9968f 100644
--- a/src/ap-menu-item.c
+++ b/src/ap-menu-item.c
@@ -251,6 +251,11 @@ nm_network_menu_item_find_dupe (NMNetworkMenuItem *item, NMAccessPoint *ap)
}
void
+nm_network_menu_item_set_active (NMNetworkMenuItem *item, gboolean active)
+{
+ gtk_widget_set_sensitive (item->strength, active);
+}
+void
nm_network_menu_item_add_dupe (NMNetworkMenuItem *item, NMAccessPoint *ap)
{
const char *path;
diff --git a/src/ap-menu-item.h b/src/ap-menu-item.h
index 470d25f..a44c2e3 100644
--- a/src/ap-menu-item.h
+++ b/src/ap-menu-item.h
@@ -84,4 +84,6 @@ gboolean nm_network_menu_item_find_dupe (NMNetworkMenuItem *item,
void nm_network_menu_item_add_dupe (NMNetworkMenuItem *item,
NMAccessPoint *ap);
+void nm_network_menu_item_set_active (NMNetworkMenuItem * item,
+ gboolean active);
#endif /* __AP_MENU_ITEM_H__ */
diff --git a/src/applet-device-bt.c b/src/applet-device-bt.c
index 0d2985f..5fb9e7e 100644
--- a/src/applet-device-bt.c
+++ b/src/applet-device-bt.c
@@ -102,7 +102,7 @@ add_connection_items (NMDevice *device,
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMConnection *connection = NM_CONNECTION (iter->data);
NMSettingConnection *s_con;
- GtkWidget *item, *image;
+ GtkWidget *item;
if (active == connection) {
if ((flag & ADD_ACTIVE) == 0)
@@ -117,11 +117,6 @@ add_connection_items (NMDevice *device,
gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (item), carrier);
- if (connection == active) {
- image = gtk_image_new_from_pixbuf (applet->active_device_icon);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- }
-
info = g_slice_new0 (BtMenuItemInfo);
info->applet = applet;
info->device = g_object_ref (G_OBJECT (device));
@@ -170,6 +165,9 @@ bt_add_menu_item (NMDevice *device,
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
+ if (active)
+ applet_menu_item_add_complex_separator_helper (menu, applet, _("Active"), NULL, -1);
+
if (g_slist_length (connections))
add_connection_items (device, connections, carrier, active, ADD_ACTIVE, menu, applet);
@@ -182,8 +180,10 @@ bt_add_menu_item (NMDevice *device,
if (!nma_menu_device_check_unusable (device)) {
/* Add menu items for existing bluetooth connections for this device */
- if (g_slist_length (connections))
+ if (g_slist_length (connections)) {
+ applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), NULL, -1);
add_connection_items (device, connections, carrier, active, ADD_INACTIVE, menu, applet);
+ }
}
g_slist_free (connections);
diff --git a/src/applet-device-cdma.c b/src/applet-device-cdma.c
index 2e67913..f158ef2 100644
--- a/src/applet-device-cdma.c
+++ b/src/applet-device-cdma.c
@@ -186,7 +186,7 @@ add_connection_items (NMDevice *device,
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMConnection *connection = NM_CONNECTION (iter->data);
NMSettingConnection *s_con;
- GtkWidget *item, *image;
+ GtkWidget *item;
if (active == connection) {
if ((flag & ADD_ACTIVE) == 0)
@@ -200,11 +200,6 @@ add_connection_items (NMDevice *device,
item = gtk_image_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
- if (connection == active) {
- image = gtk_image_new_from_pixbuf (applet->active_device_icon);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- }
-
info = g_slice_new0 (CdmaMenuItemInfo);
info->applet = applet;
info->device = g_object_ref (G_OBJECT (device));
@@ -284,6 +279,9 @@ cdma_add_menu_item (NMDevice *device,
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
+ if (active)
+ applet_menu_item_add_complex_separator_helper (menu, applet, _("Active"), NULL, -1);
+
if (g_slist_length (connections))
add_connection_items (device, connections, active, ADD_ACTIVE, menu, applet);
@@ -295,6 +293,9 @@ cdma_add_menu_item (NMDevice *device,
}
if (!nma_menu_device_check_unusable (device)) {
+ if ((!active && g_slist_length (connections)) || (active && g_slist_length (connections) > 1))
+ applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), NULL, -1);
+
if (g_slist_length (connections))
add_connection_items (device, connections, active, ADD_INACTIVE, menu, applet);
else
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index f949af0..293e295 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -187,7 +187,7 @@ add_connection_items (NMDevice *device,
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMConnection *connection = NM_CONNECTION (iter->data);
NMSettingConnection *s_con;
- GtkWidget *item, *image;
+ GtkWidget *item;
if (active == connection) {
if ((flag & ADD_ACTIVE) == 0)
@@ -201,11 +201,6 @@ add_connection_items (NMDevice *device,
item = gtk_image_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
- if (connection == active) {
- image = gtk_image_new_from_pixbuf (applet->active_device_icon);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- }
-
info = g_slice_new0 (GSMMenuItemInfo);
info->applet = applet;
info->device = g_object_ref (G_OBJECT (device));
@@ -285,6 +280,9 @@ gsm_add_menu_item (NMDevice *device,
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
+ if (active)
+ applet_menu_item_add_complex_separator_helper (menu, applet, _("Active"), NULL, -1);
+
if (g_slist_length (connections))
add_connection_items (device, connections, active, ADD_ACTIVE, menu, applet);
@@ -296,6 +294,9 @@ gsm_add_menu_item (NMDevice *device,
}
if (!nma_menu_device_check_unusable (device)) {
+ if ((!active && g_slist_length (connections)) || (active && g_slist_length (connections) > 1))
+ applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), NULL, -1);
+
if (g_slist_length (connections))
add_connection_items (device, connections, active, ADD_INACTIVE, menu, applet);
else
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index ea52be8..bc8aa7c 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -562,7 +562,6 @@ add_one_ap_menu_item (NMDeviceWifi *device,
const GByteArray *ssid;
struct dup_data dup_data = { NULL, NULL };
NMNetworkMenuItem *item = NULL;
- GtkWidget *image;
/* Don't add BSSs that hide their SSID */
ssid = nm_access_point_get_ssid (ap);
@@ -593,19 +592,13 @@ add_one_ap_menu_item (NMDeviceWifi *device,
item = add_new_ap_item (device, ap, &dup_data, active_ap, active, connections, menu, applet);
}
+ if (!active_ap || active_ap == ap)
+ nm_network_menu_item_set_active (item, TRUE);
+ else
+ nm_network_menu_item_set_active (item, FALSE);
+
if (!active_ap)
return;
-
- g_signal_handlers_block_matched (item, G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
- G_CALLBACK (wireless_menu_item_activate), NULL);
-
- if (nm_network_menu_item_find_dupe (item, active_ap)) {
- image = gtk_image_new_from_pixbuf (applet->active_device_icon);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- }
-
- g_signal_handlers_unblock_matched (item, G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
- G_CALLBACK (wireless_menu_item_activate), NULL);
}
static gint
@@ -714,6 +707,8 @@ wireless_add_menu_item (NMDevice *device,
gtk_widget_show (item);
active_ap = nm_device_wifi_get_active_access_point (wdev);
+ if (active_ap)
+ applet_menu_item_add_complex_separator_helper (menu, applet, _("Active"), NULL, -1);
add_one_ap_menu_item (wdev, active_ap, connections, active_ap, active, menu, applet);
/* Notify user of unmanaged or unavailable device */
@@ -725,6 +720,8 @@ wireless_add_menu_item (NMDevice *device,
}
if (!nma_menu_device_check_unusable (device)) {
+ applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), NULL, -1);
+
/* Add all networks in our network list to the menu */
for (i = 0; aps && (i < aps->len); i++)
sorted_aps = g_slist_append (sorted_aps, g_ptr_array_index (aps, i));
diff --git a/src/applet-device-wired.c b/src/applet-device-wired.c
index cd5cb92..f48783b 100644
--- a/src/applet-device-wired.c
+++ b/src/applet-device-wired.c
@@ -127,7 +127,7 @@ add_connection_items (NMDevice *device,
for (iter = connections; iter; iter = g_slist_next (iter)) {
NMConnection *connection = NM_CONNECTION (iter->data);
NMSettingConnection *s_con;
- GtkWidget *item, *image;
+ GtkWidget *item;
if (active == connection) {
if ((flag & ADD_ACTIVE) == 0)
@@ -142,11 +142,6 @@ add_connection_items (NMDevice *device,
gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (item), carrier);
- if (connection == active) {
- image = gtk_image_new_from_pixbuf (applet->active_device_icon);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- }
-
info = g_slice_new0 (WiredMenuItemInfo);
info->applet = applet;
info->device = g_object_ref (G_OBJECT (device));
@@ -242,6 +237,9 @@ wired_add_menu_item (NMDevice *device,
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
+ if (active)
+ applet_menu_item_add_complex_separator_helper (menu, applet, _("Active"), NULL, -1);
+
if (g_slist_length (connections))
add_connection_items (device, connections, carrier, active, ADD_ACTIVE, menu, applet);
@@ -253,6 +251,9 @@ wired_add_menu_item (NMDevice *device,
}
if (!nma_menu_device_check_unusable (device)) {
+ if ((!active && g_slist_length (connections)) || (active && g_slist_length (connections) > 1))
+ applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), NULL, -1);
+
if (g_slist_length (connections))
add_connection_items (device, connections, carrier, active, ADD_INACTIVE, menu, applet);
else
diff --git a/src/applet.c b/src/applet.c
index 3fb320e..f121bfb 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -417,6 +417,44 @@ applet_menu_item_activate_helper (NMDevice *device,
}
}
+void
+applet_menu_item_add_complex_separator_helper (GtkWidget *menu,
+ NMApplet *applet,
+ const gchar* label,
+ GdkPixbuf *favicon,
+ int pos)
+{
+ GtkWidget *menu_item = gtk_image_menu_item_new ();
+ GtkWidget *box = gtk_hbox_new (FALSE, 0);
+ GtkWidget *xlabel = NULL;
+ GtkWidget *favimg = NULL;
+ if (favicon)
+ favimg = gtk_image_new_from_pixbuf (favicon);
+ if (label) {
+ xlabel = gtk_label_new ("Favorites");
+ gtk_label_set_markup (GTK_LABEL (xlabel), label);
+ }
+ if (favimg || xlabel)
+ gtk_box_pack_start (GTK_BOX (box), gtk_hseparator_new (), TRUE, TRUE, 5);
+ if (xlabel)
+ gtk_box_pack_start (GTK_BOX (box), xlabel, FALSE, FALSE, 2);
+ if (favimg)
+ gtk_box_pack_start (GTK_BOX (box), favimg, FALSE, FALSE, 2);
+
+ gtk_box_pack_start (GTK_BOX (box), gtk_hseparator_new (), TRUE, TRUE, 5);
+
+ g_object_set (G_OBJECT (menu_item),
+ "child", box,
+ "sensitive", FALSE,
+ NULL);
+ if (pos < 0)
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+ else
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), menu_item, pos);
+ return;
+}
+
+
static void
applet_clear_notify (NMApplet *applet)
{
diff --git a/src/applet.h b/src/applet.h
index 761d891..395722e 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -221,6 +221,12 @@ void applet_menu_item_activate_helper (NMDevice *device,
void applet_menu_item_disconnect_helper (NMDevice *device,
NMApplet *applet);
+void applet_menu_item_add_complex_separator_helper (GtkWidget *menu,
+ NMApplet *applet,
+ const gchar* label,
+ GdkPixbuf *favicon,
+ int pos);
+
NMSettingsConnectionInterface *applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet);
void applet_do_notify (NMApplet *applet,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]