[gnome-power-manager] Add statistics devices in visually pleasing order



commit 137f9087d9be35464465b0717553550c3107497f
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jun 15 10:39:03 2009 +0100

    Add statistics devices in visually pleasing order

 src/gpm-statistics.c |   46 +++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 41 insertions(+), 5 deletions(-)
---
diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c
index 51fbb34..eb911ea 100644
--- a/src/gpm-statistics.c
+++ b/src/gpm-statistics.c
@@ -1416,6 +1416,7 @@ main (int argc, char *argv[])
 	DkpClient *client;
 	GPtrArray *devices;
 	DkpDevice *device;
+	DkpDeviceType type;
 	guint i;
 	gint page;
 	const gchar *object_path;
@@ -1647,14 +1648,49 @@ main (int argc, char *argv[])
 	devices = dkp_client_enumerate_devices (client, NULL);
 	if (devices == NULL)
 		goto out;
+
+	/* add devices in visually pleasing order */
 	for (i=0; i < devices->len; i++) {
 		device = g_ptr_array_index (devices, i);
-		gpm_stats_add_device (device);
-		if (i == 0) {
-			gpm_stats_update_info_data (device);
-			current_device = g_strdup (dkp_device_get_object_path (device));
-		}
+		g_object_get (device, "type", &type, NULL);
+		if (type == DKP_DEVICE_TYPE_LINE_POWER)
+			gpm_stats_add_device (device);
 	}
+	for (i=0; i < devices->len; i++) {
+		device = g_ptr_array_index (devices, i);
+		g_object_get (device, "type", &type, NULL);
+		if (type == DKP_DEVICE_TYPE_BATTERY)
+			gpm_stats_add_device (device);
+	}
+	for (i=0; i < devices->len; i++) {
+		device = g_ptr_array_index (devices, i);
+		g_object_get (device, "type", &type, NULL);
+		if (type == DKP_DEVICE_TYPE_UPS)
+			gpm_stats_add_device (device);
+	}
+	for (i=0; i < devices->len; i++) {
+		device = g_ptr_array_index (devices, i);
+		g_object_get (device, "type", &type, NULL);
+		if (type == DKP_DEVICE_TYPE_MONITOR)
+			gpm_stats_add_device (device);
+	}
+	for (i=0; i < devices->len; i++) {
+		device = g_ptr_array_index (devices, i);
+		g_object_get (device, "type", &type, NULL);
+		if (type == DKP_DEVICE_TYPE_MOUSE)
+			gpm_stats_add_device (device);
+	}
+	for (i=0; i < devices->len; i++) {
+		device = g_ptr_array_index (devices, i);
+		g_object_get (device, "type", &type, NULL);
+		if (type == DKP_DEVICE_TYPE_KEYBOARD)
+			gpm_stats_add_device (device);
+	}
+
+	/* set current device */
+	device = g_ptr_array_index (devices, 0);
+	gpm_stats_update_info_data (device);
+	current_device = g_strdup (dkp_device_get_object_path (device));
 
 	last_device = gconf_client_get_string (gconf_client, GPM_CONF_INFO_LAST_DEVICE, NULL);
 



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