[PATCH 1/2] network-manager-applet: more user-friendly network order
- From: dwk <dwksrc gmail com>
- To: networkmanager-list gnome org
- Subject: [PATCH 1/2] network-manager-applet: more user-friendly network order
- Date: Mon, 11 Aug 2014 17:57:34 -0400
Use preconfigured/encrypted/unencrypted sort order for networks in main
menu and submenu. The old behaviour involved this same sort, but masked
its effects with a subsequent alphabetical sort.
Note: patches tested on version 0.9.10.0 from Debian's source tree.
They also apply cleanly to the current git HEAD.
Signed-off-by: David Williams-King <dwksrc gmail com>
---
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index f595e9f..c749cf3 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -718,14 +771,14 @@ sort_by_name (gconstpointer tmpa, gconstpointer tmpb)
return 0;
}
-/* Sort menu items for the top-level menu:
+/* Sort menu items in the order a user is likely to want:
* 1) whether there's a saved connection or not
* a) sort alphabetically within #1
* 2) encrypted without a saved connection
* 3) unencrypted without a saved connection
*/
static gint
-sort_toplevel (gconstpointer tmpa, gconstpointer tmpb)
+sort_interesting_first (gconstpointer tmpa, gconstpointer tmpb)
{
NMNetworkMenuItem *a = NM_NETWORK_MENU_ITEM (tmpa);
NMNetworkMenuItem *b = NM_NETWORK_MENU_ITEM (tmpb);
@@ -851,8 +904,8 @@ wifi_add_menu_item (NMDevice *device,
if (active_item)
menu_items = g_slist_remove (menu_items, active_item);
- /* Sort all the rest of the menu items for the top-level menu */
- menu_items = g_slist_sort (menu_items, sort_toplevel);
+ /* Sort all the rest of the menu items (saved connections first etc) */
+ menu_items = g_slist_sort (menu_items, sort_interesting_first);
if (g_slist_length (menu_items)) {
GSList *submenu_items = NULL;
@@ -872,7 +925,6 @@ wifi_add_menu_item (NMDevice *device,
num_for_toplevel--;
submenu_items = iter->next;
}
- topmenu_items = g_slist_sort (topmenu_items, sort_by_name);
for (iter = topmenu_items; iter; iter = g_slist_next (iter)) {
gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (iter->data));
@@ -884,20 +936,14 @@ wifi_add_menu_item (NMDevice *device,
/* If there are any submenu items, make a submenu for those */
if (submenu_items) {
GtkWidget *subitem, *submenu;
- GSList *sorted_subitems;
subitem = gtk_menu_item_new_with_mnemonic (_("More networks"));
submenu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (subitem), submenu);
- /* Sort the subitems alphabetically */
- sorted_subitems = g_slist_copy (submenu_items);
- sorted_subitems = g_slist_sort (sorted_subitems, sort_by_name);
-
- /* And add the rest to the submenu */
- for (iter = sorted_subitems; iter; iter = g_slist_next (iter))
+ /* And add the rest to the submenu (preserving original order) */
+ for (iter = submenu_items; iter; iter = g_slist_next (iter))
gtk_menu_shell_append (GTK_MENU_SHELL (submenu), GTK_WIDGET (iter->data));
- g_slist_free (sorted_subitems);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), subitem);
gtk_widget_show_all (subitem);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]