Commit 16ef5809 authored by Dan Williams's avatar Dan Williams
Browse files

2005-05-14 Dan Williams <dcbw@redhat.com>

	* gnome/applet/nm-device.c
		- (network_device_sort_wireless_networks, sort_networks_function): New functions to
			sort wireless networks alphabetically

	* gnome/applet/applet-dbus-devices.c
		- (mwa_dbus_devices_lock_and_copy): Sort network device's wireless network lists
			before copying them over to the GUI


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@629 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent f35de1c5
2005-05-14 Dan Williams <dcbw@redhat.com>
* gnome/applet/nm-device.c
- (network_device_sort_wireless_networks, sort_networks_function): New functions to
sort wireless networks alphabetically
* gnome/applet/applet-dbus-devices.c
- (mwa_dbus_devices_lock_and_copy): Sort network device's wireless network lists
before copying them over to the GUI
2005-05-14 Dan Williams <dcbw@redhat.com>
* src/NetworkManager.c
......
......@@ -1343,11 +1343,22 @@ static gboolean nmwa_dbus_devices_lock_and_copy (NMWirelessApplet *applet)
/* Only copy over if we have a complete data model */
if (g_slist_length (applet->dev_pending_call_list) == 0)
{
GSList *elt;
nmwa_dbus_check_drivers (applet);
/* Sort the devices for display */
applet->dbus_device_list = g_slist_sort (applet->dbus_device_list, sort_devices_function);
/* Sort the wireless networks of each device */
for (elt = applet->dbus_device_list; elt; elt = g_slist_next (elt))
{
NetworkDevice *dev = (NetworkDevice *)(elt->data);
if (dev && network_device_is_wireless (dev))
network_device_sort_wireless_networks (dev);
}
/* Now copy the data over to the GUI side */
g_mutex_lock (applet->data_mutex);
nmwa_copy_data_model (applet);
......
......@@ -344,6 +344,37 @@ void network_device_remove_wireless_network (NetworkDevice *dev, WirelessNetwork
}
static int sort_networks_function (WirelessNetwork *a, WirelessNetwork *b)
{
const char *name_a = wireless_network_get_essid (a);
const char *name_b = wireless_network_get_essid (b);
if (name_a && !name_b)
return -1;
else if (!name_a && name_b)
return 1;
else if (!name_a && !name_b)
return 0;
else
return strcasecmp (name_a, name_b);
}
/*
* network_device_sort_wireless_networks
*
* Alphabetize the wireless networks list
*
*/
void network_device_sort_wireless_networks (NetworkDevice *dev)
{
g_return_if_fail (dev != NULL);
g_return_if_fail (dev->type == DEVICE_TYPE_WIRELESS_ETHERNET);
dev->networks = g_slist_sort (dev->networks, (GCompareFunc) sort_networks_function);
}
/*
* network_device_get_num_wireless_networks
*
......
......@@ -53,6 +53,8 @@ void network_device_add_wireless_network (NetworkDevice *dev, WirelessNetwo
void network_device_remove_wireless_network (NetworkDevice *dev, WirelessNetwork *net);
void network_device_clear_wireless_networks (NetworkDevice *dev);
void network_device_sort_wireless_networks (NetworkDevice *dev);
guint network_device_get_num_wireless_networks (NetworkDevice *dev);
const char * network_device_get_address (NetworkDevice *dev);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment