[network-manager-applet/menu-rework: 18/18] menu: get rid of --- Active --- separator; kill favorites icons



commit fbbd1b6be4a62f1812d29ace4b918ac4e8d9d716
Author: Dan Williams <dcbw redhat com>
Date:   Thu Sep 24 22:40:42 2009 -0700

    menu: get rid of --- Active --- separator; kill favorites icons

 src/applet-device-bt.c    |    7 +----
 src/applet-device-cdma.c  |    7 +----
 src/applet-device-gsm.c   |    7 +----
 src/applet-device-wifi.c  |   11 ++-----
 src/applet-device-wired.c |    7 +----
 src/applet.c              |   72 ++++-----------------------------------------
 src/applet.h              |    7 ----
 7 files changed, 13 insertions(+), 105 deletions(-)
---
diff --git a/src/applet-device-bt.c b/src/applet-device-bt.c
index 0e8ab8e..50a009e 100644
--- a/src/applet-device-bt.c
+++ b/src/applet-device-bt.c
@@ -127,8 +127,6 @@ add_connection_items (NMDevice *device,
 		                       info,
 		                       (GClosureNotify) bt_menu_item_info_destroy, 0);
 
-		applet_menu_item_favorize_helper (GTK_BIN (item), applet->favorites_icon, TRUE);
-
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	}
 }
@@ -163,9 +161,6 @@ 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);
 
@@ -179,7 +174,7 @@ 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)) {
-			applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), NULL, -1);
+			applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), -1);
 			add_connection_items (device, connections, carrier, active, ADD_INACTIVE, menu, applet);
 		}
 	}
diff --git a/src/applet-device-cdma.c b/src/applet-device-cdma.c
index 45610f7..47009b5 100644
--- a/src/applet-device-cdma.c
+++ b/src/applet-device-cdma.c
@@ -210,8 +210,6 @@ add_connection_items (NMDevice *device,
 		                       info,
 		                       (GClosureNotify) cdma_menu_item_info_destroy, 0);
 
-		applet_menu_item_favorize_helper (GTK_BIN (item), applet->favorites_icon, TRUE);
-
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	}
 }
@@ -281,9 +279,6 @@ 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);
 
@@ -296,7 +291,7 @@ 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);
+			applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), -1);
 
 		if (g_slist_length (connections))
 			add_connection_items (device, connections, active, ADD_INACTIVE, menu, applet);
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index 231771f..78d41ff 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -211,8 +211,6 @@ add_connection_items (NMDevice *device,
 		                       info,
 		                       (GClosureNotify) gsm_menu_item_info_destroy, 0);
 
-		applet_menu_item_favorize_helper (GTK_BIN (item), applet->favorites_icon, TRUE);
-
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	}
 }
@@ -274,9 +272,6 @@ 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);
 
@@ -289,7 +284,7 @@ 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);
+			applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), -1);
 
 		if (g_slist_length (connections))
 			add_connection_items (device, connections, active, ADD_INACTIVE, menu, applet);
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index df8fb47..7f55284 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -546,8 +546,6 @@ add_new_ap_item (NMDeviceWifi *device,
 		                       0);
 	}
 
-	applet_menu_item_favorize_helper (GTK_BIN (item), applet->favorites_icon, is_favorite);
-
 	g_slist_free (ap_connections);
 	return item;
 }
@@ -586,9 +584,8 @@ 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) {
+		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 {
@@ -596,7 +593,7 @@ add_one_ap_menu_item (NMDeviceWifi *device,
 		menu_list = g_list_append (menu_list, item);
 	}
 
-	if (!active_ap || active_ap == ap)
+	if (active_ap == ap)
 		nm_network_menu_item_set_active (item, TRUE);
 	else
 		nm_network_menu_item_set_active (item, FALSE);
@@ -754,7 +751,6 @@ wireless_add_menu_item (NMDevice *device,
 
 	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);
 		menu_list = add_one_ap_menu_item (wdev, active_ap, connections, active_ap, active, menu_list, applet);
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_list->data);
 		g_list_free (menu_list);
@@ -770,7 +766,7 @@ 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);
+		applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), -1);
 
 		/* Add all networks in our network list to the menu */
 		for (i = 0; aps && (i < aps->len); i++)
@@ -792,7 +788,6 @@ wireless_add_menu_item (NMDevice *device,
 		folded_menu_item = gtk_menu_item_new_with_mnemonic (_("More networks..."));
 		submenu = gtk_menu_new ();
 		gtk_menu_item_set_submenu (GTK_MENU_ITEM (folded_menu_item), submenu);
-		applet_menu_item_favorize_helper (GTK_BIN (folded_menu_item), applet->favorites_icon, FALSE);
 		applet_menu_add_items_top_and_fold_sorted_helper (GTK_MENU (menu),
 		                                                  menu_list,
 		                                                  5,
diff --git a/src/applet-device-wired.c b/src/applet-device-wired.c
index 545e3ce..c144254 100644
--- a/src/applet-device-wired.c
+++ b/src/applet-device-wired.c
@@ -152,8 +152,6 @@ add_connection_items (NMDevice *device,
 		                       info,
 		                       (GClosureNotify) wired_menu_item_info_destroy, 0);
 
-		applet_menu_item_favorize_helper (GTK_BIN (item), applet->favorites_icon, TRUE);
-
 		gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 	}
 }
@@ -231,9 +229,6 @@ 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);
 
@@ -246,7 +241,7 @@ 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);
+			applet_menu_item_add_complex_separator_helper (menu, applet, _("Available"), -1);
 
 		if (g_slist_length (connections))
 			add_connection_items (device, connections, carrier, active, ADD_INACTIVE, menu, applet);
diff --git a/src/applet.c b/src/applet.c
index 0d86759..c8d8f19 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -421,27 +421,21 @@ 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");
+		xlabel = gtk_label_new (NULL);
 		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), gtk_hseparator_new (), TRUE, TRUE, 0);
 		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);
+	gtk_box_pack_start (GTK_BOX (box), gtk_hseparator_new (), TRUE, TRUE, 0);
 
 	g_object_set (G_OBJECT (menu_item),
 	              "child", box,
@@ -455,56 +449,6 @@ applet_menu_item_add_complex_separator_helper (GtkWidget *menu,
 }
 
 void
-applet_menu_item_favorize_helper (GtkBin *binitem,
-                                  GdkPixbuf *favoritePixbuf,
-                                  gboolean is_favorite)
-{
-	GtkWidget *child;
-	GtkWidget *box;
-	gpointer already_favorized_ptr;
-
-	g_assert (binitem);
-	g_assert (favoritePixbuf);
-
-	child = gtk_bin_get_child (binitem);
-	box = gtk_hbox_new (FALSE, 0);
-	already_favorized_ptr = g_object_get_data (G_OBJECT (binitem), "favorite");
-
-	if (already_favorized_ptr)
-		goto abort;
-
-	if (!is_favorite) {
-		int image_width, image_height;
-		GtkWidget *placeholder = gtk_alignment_new (0,0,0,0);
-		g_object_ref (child);
-		image_width = gdk_pixbuf_get_width (favoritePixbuf);
-		image_height = gdk_pixbuf_get_height (favoritePixbuf);
-		gtk_container_remove (GTK_CONTAINER (binitem), child);
-		gtk_container_add (GTK_CONTAINER (binitem), box);
-		gtk_widget_set_size_request (placeholder, image_width, image_height);
-		gtk_box_pack_start (GTK_BOX (box), placeholder, FALSE, FALSE, 0);
-		gtk_box_pack_start (GTK_BOX (box), child, TRUE, TRUE, 4);
-		g_object_unref (child);
-		g_object_set_data (G_OBJECT (binitem), "favorite", GINT_TO_POINTER (1));
-	} else {
-		GtkWidget *image = gtk_image_new_from_pixbuf (favoritePixbuf);
-		g_assert (image);
-		g_object_ref (child);
-		gtk_container_remove (GTK_CONTAINER (binitem), child);
-		gtk_container_add (GTK_CONTAINER (binitem), box);
-		gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
-		gtk_box_pack_start (GTK_BOX (box), child, TRUE, TRUE, 4);
-		g_object_unref (child);
-		g_object_set_data (G_OBJECT (binitem), "favorite", GINT_TO_POINTER (2));
-	}
-
-	return;
-abort:
-	g_object_ref_sink (box);
-	g_object_unref (box);
-}
-
-void
 applet_menu_add_items_top_and_fold_sorted_helper (GtkMenu *menu,
                                                   GList *items,
                                                   guint top_count,
@@ -1455,7 +1399,6 @@ nma_menu_device_get_menu_item (NMDevice *device,
 		                       info,
 		                       (GClosureNotify) applet_device_info_destroy, 0);
 		gtk_widget_set_sensitive (item, TRUE);
-		applet_menu_item_favorize_helper (GTK_BIN (item), applet->favorites_icon, FALSE);
 		break;
 	}
 	default:
@@ -2666,7 +2609,6 @@ static void nma_icons_free (NMApplet *applet)
 	CLEAR_ICON(applet->wireless_75_icon);
 	CLEAR_ICON(applet->wireless_100_icon);
 	CLEAR_ICON(applet->secure_lock_icon);
-	CLEAR_ICON(applet->favorites_icon);
 
 	for (i = 0; i < NUM_CONNECTING_STAGES; i++) {
 		for (j = 0; j < NUM_CONNECTING_FRAMES; j++)
@@ -2737,8 +2679,6 @@ nma_icons_load (NMApplet *applet)
 		g_free (name);
 	}
 
-	ICON_LOAD(applet->favorites_icon, "emblem-favorite");
-
 	applet->icons_loaded = TRUE;
 
 out:
diff --git a/src/applet.h b/src/applet.h
index 9a08133..9899754 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -121,8 +121,6 @@ typedef struct
 	GdkPixbuf *		vpn_connecting_icons[NUM_VPN_CONNECTING_FRAMES];
 	GdkPixbuf *		vpn_lock_icon;
 
-	GdkPixbuf *		favorites_icon;
-
 	/* Active status icon pixbufs */
 	GdkPixbuf *		icon_layers[ICON_LAYER_MAX + 1];
 
@@ -229,13 +227,8 @@ void applet_menu_item_disconnect_helper (NMDevice *device,
 void applet_menu_item_add_complex_separator_helper (GtkWidget *menu,
                                                     NMApplet *applet,
                                                     const gchar* label,
-                                                    GdkPixbuf *favicon,
                                                     int pos);
 
-void applet_menu_item_favorize_helper (GtkBin *binitem,
-                                       GdkPixbuf *favoritePixbuf,
-                                       gboolean is_favorite);
-
 void applet_menu_add_items_top_and_fold_sorted_helper (GtkMenu *menu,
                                                        GList *items,
                                                        guint top_count,



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