[Xfce4-commits] [xfce/xfce4-power-manager] 02/03: get rid of XfpmDeviceState and XfpmDeviceType

noreply at xfce.org noreply at xfce.org
Sun Apr 13 19:35:29 CEST 2014


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfce4-power-manager.

commit 7f4fb9c021fb80d28d2ef7dcdbd3839a39d16f99
Author: Stefan Seyfried <seife+dev at b1-systems.com>
Date:   Sun Apr 13 17:26:51 2014 +0200

    get rid of XfpmDeviceState and XfpmDeviceType
    
    They are only mirroring UpDeviceState and UpDeviceKind
    from libupower-glib anyway.
    
    Signed-off-by: Eric Koegel <eric.koegel at gmail.com>
---
 src/xfpm-battery.c      |  125 ++++++++++++++++++++++++-----------------------
 src/xfpm-battery.h      |    5 +-
 src/xfpm-enum-glib.h    |   26 ----------
 src/xfpm-power-common.c |   47 +++++++++++-------
 src/xfpm-power-info.c   |    7 +--
 src/xfpm-power.c        |   39 +++++++--------
 6 files changed, 115 insertions(+), 134 deletions(-)

diff --git a/src/xfpm-battery.c b/src/xfpm-battery.c
index 9d1b590..dc38d32 100644
--- a/src/xfpm-battery.c
+++ b/src/xfpm-battery.c
@@ -60,8 +60,8 @@ struct XfpmBatteryPrivate
     gchar		   *icon_prefix;
 
     XfpmBatteryCharge       charge;
-    XfpmDeviceState         state;
-    XfpmDeviceType          type;
+    UpDeviceState	    state;
+    UpDeviceKind	    type;
     gboolean		    ac_online;
     gboolean                present;
     guint 		    percentage;
@@ -96,7 +96,7 @@ static guint signals [LAST_SIGNAL] = { 0 };
 G_DEFINE_TYPE (XfpmBattery, xfpm_battery, GTK_TYPE_STATUS_ICON)
 
 static const gchar * G_GNUC_CONST
-xfpm_battery_get_icon_index (XfpmDeviceType type, guint percent)
+xfpm_battery_get_icon_index (UpDeviceKind type, guint percent)
 {
     if (percent < 10)
     {
@@ -104,11 +104,11 @@ xfpm_battery_get_icon_index (XfpmDeviceType type, guint percent)
     }
     else if (percent < 30)
     {
-        return ( (type == XFPM_DEVICE_TYPE_BATTERY || type == XFPM_DEVICE_TYPE_UPS) ? "020" : "030");
+        return ( (type == UP_DEVICE_KIND_BATTERY || type == UP_DEVICE_KIND_UPS) ? "020" : "030");
     }
     else if (percent < 50)
     {
-        return ( (type == XFPM_DEVICE_TYPE_BATTERY || type == XFPM_DEVICE_TYPE_UPS ) ? "040" : "030");
+        return ( (type == UP_DEVICE_KIND_BATTERY || type == UP_DEVICE_KIND_UPS ) ? "040" : "030");
     }
     else if (percent < 70)
     {
@@ -116,7 +116,7 @@ xfpm_battery_get_icon_index (XfpmDeviceType type, guint percent)
     }
     else if (percent < 90)
     {
-        return ((type == XFPM_DEVICE_TYPE_BATTERY || type == XFPM_DEVICE_TYPE_UPS) ? "080" : "060");
+        return ((type == UP_DEVICE_KIND_BATTERY || type == UP_DEVICE_KIND_UPS) ? "080" : "060");
     }
 
     return "100";
@@ -144,7 +144,7 @@ xfpm_battery_refresh_visible (XfpmBattery *battery)
     }
     else if ( show_icon == SHOW_ICON_WHEN_BATTERY_CHARGING_DISCHARGING )
     {
-	if ( battery->priv->state == XFPM_DEVICE_STATE_FULLY_CHARGED )
+	if ( battery->priv->state == UP_DEVICE_STATE_FULLY_CHARGED )
 	    visible = FALSE;
 	else visible = TRUE;
     }
@@ -205,14 +205,14 @@ xfpm_battery_get_message_from_battery_state (XfpmBattery *battery)
     gchar *msg  = NULL;
 
 
-    if (battery->priv->type == XFPM_DEVICE_TYPE_BATTERY || battery->priv->type == XFPM_DEVICE_TYPE_UPS)
+    if (battery->priv->type == UP_DEVICE_KIND_BATTERY || battery->priv->type == UP_DEVICE_KIND_UPS)
     {
 	switch (battery->priv->state)
 	{
-	    case XFPM_DEVICE_STATE_FULLY_CHARGED:
+	    case UP_DEVICE_STATE_FULLY_CHARGED:
 		msg = g_strdup_printf (_("Your %s is fully charged"), battery->priv->battery_name);
 		break;
-	    case XFPM_DEVICE_STATE_CHARGING:
+	    case UP_DEVICE_STATE_CHARGING:
 		msg = g_strdup_printf (_("Your %s is charging"), battery->priv->battery_name);
 
 		if ( battery->priv->time_to_full != 0 )
@@ -229,7 +229,7 @@ xfpm_battery_get_message_from_battery_state (XfpmBattery *battery)
 		}
 
 		break;
-	    case XFPM_DEVICE_STATE_DISCHARGING:
+	    case UP_DEVICE_STATE_DISCHARGING:
 		if (battery->priv->ac_online)
 		    msg =  g_strdup_printf (_("Your %s is discharging"), battery->priv->battery_name);
 		else
@@ -248,7 +248,7 @@ xfpm_battery_get_message_from_battery_state (XfpmBattery *battery)
 			g_free (est_time_str);
 		    }
 		break;
-	    case XFPM_DEVICE_STATE_EMPTY:
+	    case UP_DEVICE_STATE_EMPTY:
 		msg = g_strdup_printf (_("Your %s is empty"), battery->priv->battery_name);
 		break;
 	    default:
@@ -256,20 +256,20 @@ xfpm_battery_get_message_from_battery_state (XfpmBattery *battery)
 	}
 
     }
-    else if (battery->priv->type >= XFPM_DEVICE_TYPE_MONITOR)
+    else if (battery->priv->type >= UP_DEVICE_KIND_MONITOR)
     {
 	switch (battery->priv->state)
 	{
-	    case XFPM_DEVICE_STATE_FULLY_CHARGED:
+	    case UP_DEVICE_STATE_FULLY_CHARGED:
 		msg = g_strdup_printf (_("Your %s is fully charged"), battery->priv->battery_name);
 		break;
-	    case XFPM_DEVICE_STATE_CHARGING:
+	    case UP_DEVICE_STATE_CHARGING:
 		msg = g_strdup_printf (_("Your %s is charging"), battery->priv->battery_name);
 		break;
-	    case XFPM_DEVICE_STATE_DISCHARGING:
+	    case UP_DEVICE_STATE_DISCHARGING:
 		msg =  g_strdup_printf (_("Your %s is discharging"), battery->priv->battery_name);
 		break;
-	    case XFPM_DEVICE_STATE_EMPTY:
+	    case UP_DEVICE_STATE_EMPTY:
 		msg = g_strdup_printf (_("Your %s is empty"), battery->priv->battery_name);
 		break;
 	    default:
@@ -287,48 +287,48 @@ xfpm_battery_refresh_icon (XfpmBattery *battery)
 
     XFPM_DEBUG ("Battery state %d", battery->priv->state);
 
-    if ( battery->priv->type == XFPM_DEVICE_TYPE_BATTERY ||
-	 battery->priv->type == XFPM_DEVICE_TYPE_UPS )
+    if ( battery->priv->type == UP_DEVICE_KIND_BATTERY ||
+	 battery->priv->type == UP_DEVICE_KIND_UPS )
     {
 	if (!battery->priv->present)
 	{
 	    g_snprintf (icon_name, 128, "%s%s", battery->priv->icon_prefix, "missing");
 	}
-	else if (battery->priv->state == XFPM_DEVICE_STATE_FULLY_CHARGED )
+	else if (battery->priv->state == UP_DEVICE_STATE_FULLY_CHARGED )
 	{
 	    g_snprintf (icon_name, 128, "%s%s", battery->priv->icon_prefix, battery->priv->ac_online ? "charged" : "100");
 	}
-	else if ( battery->priv->state == XFPM_DEVICE_STATE_CHARGING ||
-		  battery->priv->state == XFPM_DEVICE_STATE_PENDING_CHARGING)
+	else if ( battery->priv->state == UP_DEVICE_STATE_CHARGING ||
+		  battery->priv->state == UP_DEVICE_STATE_PENDING_CHARGE)
 	{
 	    g_snprintf (icon_name, 128, "%s%s-%s",
 			battery->priv->icon_prefix,
 			xfpm_battery_get_icon_index (battery->priv->type, battery->priv->percentage),
 			"charging");
 	}
-	else if ( battery->priv->state == XFPM_DEVICE_STATE_DISCHARGING ||
-		  battery->priv->state == XFPM_DEVICE_STATE_PENDING_DISCHARGING)
+	else if ( battery->priv->state == UP_DEVICE_STATE_DISCHARGING ||
+		  battery->priv->state == UP_DEVICE_STATE_PENDING_DISCHARGE)
 	{
 	    g_snprintf (icon_name, 128, "%s%s",
 			battery->priv->icon_prefix,
 			xfpm_battery_get_icon_index (battery->priv->type, battery->priv->percentage));
 	}
-	else if ( battery->priv->state == XFPM_DEVICE_STATE_EMPTY)
+	else if ( battery->priv->state == UP_DEVICE_STATE_EMPTY)
 	{
 	    g_snprintf (icon_name, 128, "%s%s", battery->priv->icon_prefix, battery->priv->ac_online ? "000-charging" : "000");
 	}
     }
     else
     {
-	if ( !battery->priv->present || battery->priv->state == XFPM_DEVICE_STATE_EMPTY )
+	if ( !battery->priv->present || battery->priv->state == UP_DEVICE_STATE_EMPTY )
 	{
 	    g_snprintf (icon_name, 128, "%s000", battery->priv->icon_prefix);
 	}
-	else if ( battery->priv->state == XFPM_DEVICE_STATE_FULLY_CHARGED )
+	else if ( battery->priv->state == UP_DEVICE_STATE_FULLY_CHARGED )
 	{
 	    g_snprintf (icon_name, 128, "%s100", battery->priv->icon_prefix);
 	}
-	else if ( battery->priv->state == XFPM_DEVICE_STATE_DISCHARGING || battery->priv->state == XFPM_DEVICE_STATE_CHARGING )
+	else if ( battery->priv->state == UP_DEVICE_STATE_DISCHARGING || battery->priv->state == UP_DEVICE_STATE_CHARGING )
 	{
 	    g_snprintf (icon_name, 128, "%s%s",
 			battery->priv->icon_prefix,
@@ -383,8 +383,8 @@ xfpm_battery_notify_state (XfpmBattery *battery)
     if ( !gtk_status_icon_get_visible (GTK_STATUS_ICON (battery)) )
 	return;
 
-    if ( battery->priv->type == XFPM_DEVICE_TYPE_BATTERY ||
-	 battery->priv->type == XFPM_DEVICE_TYPE_UPS )
+    if ( battery->priv->type == UP_DEVICE_KIND_BATTERY ||
+	 battery->priv->type == UP_DEVICE_KIND_UPS )
     {
 	if ( starting_up )
 	{
@@ -416,7 +416,7 @@ xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip)
 
     power_status = g_strdup_printf (battery->priv->ac_online ? _("Adaptor is online") : _("System is running on battery power"));
 
-    if ( battery->priv->state == XFPM_DEVICE_STATE_FULLY_CHARGED )
+    if ( battery->priv->state == UP_DEVICE_STATE_FULLY_CHARGED )
     {
 	if ( battery->priv->time_to_empty > 0 )
 	{
@@ -436,7 +436,7 @@ xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip)
 				   battery->priv->percentage);
 	}
     }
-    else if ( battery->priv->state == XFPM_DEVICE_STATE_CHARGING )
+    else if ( battery->priv->state == UP_DEVICE_STATE_CHARGING )
     {
 	if ( battery->priv->time_to_full != 0 )
 	{
@@ -456,7 +456,7 @@ xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip)
 				   battery->priv->percentage);
 	}
     }
-    else if ( battery->priv->state == XFPM_DEVICE_STATE_DISCHARGING )
+    else if ( battery->priv->state == UP_DEVICE_STATE_DISCHARGING )
     {
 	if ( battery->priv->time_to_empty != 0 )
 	{
@@ -477,15 +477,15 @@ xfpm_battery_set_tooltip_primary (XfpmBattery *battery, GtkTooltip *tooltip)
 	}
 
     }
-    else if ( battery->priv->state == XFPM_DEVICE_STATE_PENDING_CHARGING )
+    else if ( battery->priv->state == UP_DEVICE_STATE_PENDING_CHARGE )
     {
 	tip = g_strdup_printf (_("%s\n%s waiting to discharge (%i%%)."), power_status, battery->priv->battery_name, battery->priv->percentage);
     }
-    else if ( battery->priv->state == XFPM_DEVICE_STATE_PENDING_DISCHARGING )
+    else if ( battery->priv->state == UP_DEVICE_STATE_PENDING_DISCHARGE )
     {
 	tip = g_strdup_printf (_("%s\n%s waiting to charge (%i%%)."), power_status, battery->priv->battery_name, battery->priv->percentage);
     }
-    else if ( battery->priv->state == XFPM_DEVICE_STATE_EMPTY )
+    else if ( battery->priv->state == UP_DEVICE_STATE_EMPTY )
     {
 	tip = g_strdup_printf (_("%s\nYour %s is empty"), power_status, battery->priv->battery_name);
     }
@@ -554,8 +554,8 @@ xfpm_battery_refresh (XfpmBattery *battery, UpDevice *device)
 
     xfpm_battery_refresh_icon (battery);
 
-    if ( battery->priv->type == XFPM_DEVICE_TYPE_BATTERY ||
-	 battery->priv->type == XFPM_DEVICE_TYPE_UPS )
+    if ( battery->priv->type == UP_DEVICE_KIND_BATTERY ||
+	 battery->priv->type == UP_DEVICE_KIND_UPS )
     {
 	battery->priv->time_to_empty = to_empty;
 	battery->priv->time_to_full  = to_empty;
@@ -590,8 +590,8 @@ xfpm_battery_query_tooltip (GtkStatusIcon *icon,
 
     battery = XFPM_BATTERY (icon);
 
-    if ( battery->priv->type == XFPM_DEVICE_TYPE_BATTERY ||
-	 battery->priv->type == XFPM_DEVICE_TYPE_UPS )
+    if ( battery->priv->type == UP_DEVICE_KIND_BATTERY ||
+	 battery->priv->type == UP_DEVICE_KIND_UPS )
     {
 	xfpm_battery_set_tooltip_primary (battery, tooltip);
 	return TRUE;
@@ -684,10 +684,11 @@ xfpm_battery_class_init (XfpmBatteryClass *klass)
 
     g_object_class_install_property (object_class,
                                      PROP_DEVICE_TYPE,
-                                     g_param_spec_enum ("device-type",
+                                     g_param_spec_uint ("device-type",
                                                         NULL, NULL,
-							XFPM_TYPE_DEVICE_TYPE,
-							XFPM_DEVICE_TYPE_UNKNOWN,
+							UP_DEVICE_KIND_UNKNOWN,
+							UP_DEVICE_KIND_LAST,
+							UP_DEVICE_KIND_UNKNOWN,
                                                         G_PARAM_READABLE));
 
     g_object_class_install_property (object_class,
@@ -710,8 +711,8 @@ xfpm_battery_init (XfpmBattery *battery)
     battery->priv->notify        = xfpm_notify_new ();
     battery->priv->device        = NULL;
     battery->priv->client        = NULL;
-    battery->priv->state         = XFPM_DEVICE_STATE_UNKNOWN;
-    battery->priv->type          = XFPM_DEVICE_TYPE_UNKNOWN;
+    battery->priv->state         = UP_DEVICE_STATE_UNKNOWN;
+    battery->priv->type          = UP_DEVICE_KIND_UNKNOWN;
     battery->priv->charge        = XFPM_BATTERY_CHARGE_UNKNOWN;
     battery->priv->icon_prefix   = NULL;
     battery->priv->time_to_full  = 0;
@@ -759,25 +760,25 @@ xfpm_battery_finalize (GObject *object)
 }
 
 static gchar *
-xfpm_battery_get_icon_prefix_device_enum_type (XfpmDeviceType type)
+xfpm_battery_get_icon_prefix_device_enum_type (UpDeviceKind type)
 {
-    if ( type == XFPM_DEVICE_TYPE_BATTERY )
+    if ( type == UP_DEVICE_KIND_BATTERY )
     {
 	return g_strdup (XFPM_PRIMARY_ICON_PREFIX);
     }
-    else if ( type == XFPM_DEVICE_TYPE_UPS )
+    else if ( type == UP_DEVICE_KIND_UPS )
     {
 	return g_strdup (XFPM_UPS_ICON_PREFIX);
     }
-    else if ( type == XFPM_DEVICE_TYPE_MOUSE )
+    else if ( type == UP_DEVICE_KIND_MOUSE )
     {
 	return g_strdup (XFPM_MOUSE_ICON_PREFIX);
     }
-    else if ( type == XFPM_DEVICE_TYPE_KBD )
+    else if ( type == UP_DEVICE_KIND_KEYBOARD )
     {
 	return g_strdup (XFPM_KBD_ICON_PREFIX);
     }
-    else if ( type == XFPM_DEVICE_TYPE_PHONE )
+    else if ( type == UP_DEVICE_KIND_PHONE )
     {
 	return g_strdup (XFPM_PHONE_ICON_PREFIX);
     }
@@ -786,31 +787,31 @@ xfpm_battery_get_icon_prefix_device_enum_type (XfpmDeviceType type)
 }
 
 static const gchar *
-xfpm_battery_get_name (XfpmDeviceType type)
+xfpm_battery_get_name (UpDeviceKind type)
 {
     const gchar *name = NULL;
 
     switch (type)
     {
-	case XFPM_DEVICE_TYPE_BATTERY:
+	case UP_DEVICE_KIND_BATTERY:
 	    name = _("battery");
 	    break;
-	case XFPM_DEVICE_TYPE_UPS:
+	case UP_DEVICE_KIND_UPS:
 	    name = _("UPS");
 	    break;
-	case XFPM_DEVICE_TYPE_MONITOR:
+	case UP_DEVICE_KIND_MONITOR:
 	    name = _("monitor battery");
 	    break;
-	case XFPM_DEVICE_TYPE_MOUSE:
+	case UP_DEVICE_KIND_MOUSE:
 	    name = _("mouse battery");
 	    break;
-	case XFPM_DEVICE_TYPE_KBD:
+	case UP_DEVICE_KIND_KEYBOARD:
 	    name = _("keyboard battery");
 	    break;
-	case XFPM_DEVICE_TYPE_PDA:
+	case UP_DEVICE_KIND_PDA:
 	    name = _("PDA battery");
 	    break;
-	case XFPM_DEVICE_TYPE_PHONE:
+	case UP_DEVICE_KIND_PHONE:
 	    name = _("Phone battery");
 	    break;
 	default:
@@ -833,7 +834,7 @@ xfpm_battery_new (void)
 
 void xfpm_battery_monitor_device (XfpmBattery *battery,
 				  const char *object_path,
-				  XfpmDeviceType device_type)
+				  UpDeviceKind device_type)
 {
     UpDevice *device;
     battery->priv->type = device_type;
@@ -856,9 +857,9 @@ void xfpm_battery_monitor_device (XfpmBattery *battery,
     xfpm_battery_refresh (battery, device);
 }
 
-XfpmDeviceType xfpm_battery_get_device_type (XfpmBattery *battery)
+UpDeviceKind xfpm_battery_get_device_type (XfpmBattery *battery)
 {
-    g_return_val_if_fail (XFPM_IS_BATTERY (battery), XFPM_DEVICE_TYPE_UNKNOWN );
+    g_return_val_if_fail (XFPM_IS_BATTERY (battery), UP_DEVICE_KIND_UNKNOWN );
 
     return battery->priv->type;
 }
diff --git a/src/xfpm-battery.h b/src/xfpm-battery.h
index a3b57cf..049e335 100644
--- a/src/xfpm-battery.h
+++ b/src/xfpm-battery.h
@@ -24,6 +24,7 @@
 #include <glib-object.h>
 #include <gtk/gtk.h>
 #include <dbus/dbus-glib.h>
+#include <upower.h>
 
 #include "xfpm-enum-glib.h"
 
@@ -57,9 +58,9 @@ GtkStatusIcon              *xfpm_battery_new             (void);
 
 void			    xfpm_battery_monitor_device  (XfpmBattery *battery,
 							  const char *object_path,
-							  XfpmDeviceType device_type);
+							  UpDeviceKind device_type);
 
-XfpmDeviceType	   	    xfpm_battery_get_device_type (XfpmBattery *battery);
+UpDeviceKind		    xfpm_battery_get_device_type (XfpmBattery *battery);
 
 XfpmBatteryCharge	    xfpm_battery_get_charge      (XfpmBattery *battery);
 
diff --git a/src/xfpm-enum-glib.h b/src/xfpm-enum-glib.h
index 5bb70fa..b29a611 100644
--- a/src/xfpm-enum-glib.h
+++ b/src/xfpm-enum-glib.h
@@ -27,32 +27,6 @@
 
 G_BEGIN_DECLS
 
-typedef enum
-{
-    XFPM_DEVICE_TYPE_UNKNOWN,
-    XFPM_DEVICE_TYPE_LINE_POWER,
-    XFPM_DEVICE_TYPE_BATTERY,
-    XFPM_DEVICE_TYPE_UPS,
-    XFPM_DEVICE_TYPE_MONITOR,
-    XFPM_DEVICE_TYPE_MOUSE,
-    XFPM_DEVICE_TYPE_KBD,
-    XFPM_DEVICE_TYPE_PDA,
-    XFPM_DEVICE_TYPE_PHONE
-    
-} XfpmDeviceType;
-  
-typedef enum
-{
-    XFPM_DEVICE_STATE_UNKNOWN,
-    XFPM_DEVICE_STATE_CHARGING,
-    XFPM_DEVICE_STATE_DISCHARGING,
-    XFPM_DEVICE_STATE_EMPTY,
-    XFPM_DEVICE_STATE_FULLY_CHARGED,
-    XFPM_DEVICE_STATE_PENDING_CHARGING,
-    XFPM_DEVICE_STATE_PENDING_DISCHARGING
-    
-} XfpmDeviceState;
-
 /*
  * Order matters
  */
diff --git a/src/xfpm-power-common.c b/src/xfpm-power-common.c
index d2c4ab5..5da6928 100644
--- a/src/xfpm-power-common.c
+++ b/src/xfpm-power-common.c
@@ -24,6 +24,7 @@
 
 #include <libxfce4util/libxfce4util.h>
 #include <dbus/dbus-glib-lowlevel.h>
+#include <upower.h>
 
 #include "xfpm-power-common.h"
 #include "xfpm-enum-glib.h"
@@ -39,23 +40,27 @@ xfpm_power_translate_device_type (guint type)
 {
     switch (type)
     {
-        case XFPM_DEVICE_TYPE_BATTERY:
+        case UP_DEVICE_KIND_BATTERY:
             return _("Battery");
-        case XFPM_DEVICE_TYPE_UPS:
+        case UP_DEVICE_KIND_UPS:
             return _("UPS");
-        case XFPM_DEVICE_TYPE_LINE_POWER:
+        case UP_DEVICE_KIND_LINE_POWER:
             return _("Line power");
-        case XFPM_DEVICE_TYPE_MOUSE:
+        case UP_DEVICE_KIND_MOUSE:
             return _("Mouse");
-        case XFPM_DEVICE_TYPE_KBD:
+        case UP_DEVICE_KIND_KEYBOARD:
             return _("Keyboard");
-	case XFPM_DEVICE_TYPE_MONITOR:
+	case UP_DEVICE_KIND_MONITOR:
 	    return _("Monitor");
-	case XFPM_DEVICE_TYPE_PDA:
+	case UP_DEVICE_KIND_PDA:
 	    return _("PDA");
-	case XFPM_DEVICE_TYPE_PHONE:
+	case UP_DEVICE_KIND_PHONE:
 	    return _("Phone");
-	case XFPM_DEVICE_TYPE_UNKNOWN:
+	case UP_DEVICE_KIND_TABLET:
+	    return _("Tablet");
+	case UP_DEVICE_KIND_COMPUTER:
+	    return _("Computer");
+	case UP_DEVICE_KIND_UNKNOWN:
 	    return _("Unknown");
     }
     
@@ -93,23 +98,29 @@ const gchar *xfpm_power_get_icon_name (guint device_type)
 {
     switch (device_type)
     {
-        case XFPM_DEVICE_TYPE_BATTERY:
+        case UP_DEVICE_KIND_BATTERY:
             return XFPM_BATTERY_ICON;
-        case XFPM_DEVICE_TYPE_UPS:
+        case UP_DEVICE_KIND_UPS:
             return XFPM_UPS_ICON;
-        case XFPM_DEVICE_TYPE_LINE_POWER:
+        case UP_DEVICE_KIND_LINE_POWER:
             return XFPM_AC_ADAPTER_ICON;
-        case XFPM_DEVICE_TYPE_MOUSE:
+        case UP_DEVICE_KIND_MOUSE:
             return XFPM_MOUSE_ICON;
-        case XFPM_DEVICE_TYPE_KBD:
+        case UP_DEVICE_KIND_KEYBOARD:
             return XFPM_KBD_ICON;
-	case XFPM_DEVICE_TYPE_MONITOR:
+	case UP_DEVICE_KIND_MONITOR:
 	    return "monitor";
-	case XFPM_DEVICE_TYPE_PDA:
+	case UP_DEVICE_KIND_COMPUTER:
+	    return "monitor";		/* fixme */
+	case UP_DEVICE_KIND_PDA:
 	    return XFPM_PDA_ICON;
-	case XFPM_DEVICE_TYPE_PHONE:
+	case UP_DEVICE_KIND_PHONE:
 	    return XFPM_PHONE_ICON;
-	case XFPM_DEVICE_TYPE_UNKNOWN:
+	case UP_DEVICE_KIND_TABLET:
+	    return XFPM_PHONE_ICON;
+	case UP_DEVICE_KIND_MEDIA_PLAYER:
+	    return XFPM_PHONE_ICON;	/* fixme */
+	case UP_DEVICE_KIND_UNKNOWN:
 	    return XFPM_BATTERY_ICON;
     }
     
diff --git a/src/xfpm-power-info.c b/src/xfpm-power-info.c
index 263ccbd..72f2403 100644
--- a/src/xfpm-power-info.c
+++ b/src/xfpm-power-info.c
@@ -362,10 +362,7 @@ xfpm_info_add_device_view (XfpmInfo *info, UpDevice *device, const gchar *object
 		  "percentage", &percent,
 		  NULL);
 
-    if (type > XFPM_DEVICE_TYPE_PHONE)
-        type = XFPM_DEVICE_TYPE_UNKNOWN;
-
-    if (type != XFPM_DEVICE_TYPE_UNKNOWN)
+    if (type != UP_DEVICE_KIND_UNKNOWN)
     {
 	battery_type = xfpm_power_translate_device_type (type);
 	gtk_list_store_append (list_store, &iter);
@@ -383,7 +380,7 @@ xfpm_info_add_device_view (XfpmInfo *info, UpDevice *device, const gchar *object
 			-1);
     i++;
     
-    if ( type != XFPM_DEVICE_TYPE_LINE_POWER )
+    if ( type != UP_DEVICE_KIND_LINE_POWER )
     {
 	/*Model*/
 	if (model && strlen (model) > 0)
diff --git a/src/xfpm-power.c b/src/xfpm-power.c
index 35fbd12..8283432 100644
--- a/src/xfpm-power.c
+++ b/src/xfpm-power.c
@@ -261,11 +261,11 @@ xfpm_power_report_error (XfpmPower *power, const gchar *error, const gchar *icon
 
     for ( i = 0; i < len; i++)
     {
-	XfpmDeviceType type;
+	UpDeviceKind type;
 	battery = g_list_nth_data (list, i);
 	type = xfpm_battery_get_device_type (XFPM_BATTERY (battery));
-	if ( type == XFPM_DEVICE_TYPE_BATTERY ||
-	     type == XFPM_DEVICE_TYPE_UPS )
+	if ( type == UP_DEVICE_KIND_BATTERY ||
+	     type == UP_DEVICE_KIND_UPS )
 	     break;
     }
 
@@ -640,14 +640,14 @@ xfpm_power_get_current_charge_state (XfpmPower *power)
     for ( i = 0; i < len; i++)
     {
 	XfpmBatteryCharge battery_charge;
-	XfpmDeviceType type;
+	UpDeviceKind type;
 
 	g_object_get (G_OBJECT (g_list_nth_data (list, i)),
 		      "charge-status", &battery_charge,
 		      "device-type", &type,
 		      NULL);
-	if ( type != XFPM_DEVICE_TYPE_BATTERY &&
-	     type != XFPM_DEVICE_TYPE_UPS )
+	if ( type != UP_DEVICE_KIND_BATTERY &&
+	     type != UP_DEVICE_KIND_UPS )
 	    continue;
 
 	max_charge_status = MAX (max_charge_status, battery_charge);
@@ -989,7 +989,7 @@ xfpm_power_battery_charge_changed_cb (XfpmBattery *battery, XfpmPower *power)
 static void
 xfpm_power_add_device (UpDevice *device, XfpmPower *power)
 {
-    guint device_type = XFPM_DEVICE_TYPE_UNKNOWN;
+    guint device_type = UP_DEVICE_KIND_UNKNOWN;
     const gchar *object_path = up_device_get_object_path(device);
 
     /* hack, this depends on XFPM_DEVICE_TYPE_* being in sync with UP_DEVICE_KIND_* */
@@ -997,20 +997,17 @@ xfpm_power_add_device (UpDevice *device, XfpmPower *power)
 		  "kind", &device_type,
 		  NULL);
 
-    if (device_type > XFPM_DEVICE_TYPE_PHONE)
-        device_type = XFPM_DEVICE_TYPE_UNKNOWN;
+    XFPM_DEBUG ("'%s' device added", up_device_kind_to_string(device_type));
 
-    XFPM_DEBUG_ENUM (device_type, XFPM_TYPE_DEVICE_TYPE, " device added");
-
-    if ( device_type == XFPM_DEVICE_TYPE_BATTERY ||
-	 device_type == XFPM_DEVICE_TYPE_UPS     ||
-	 device_type == XFPM_DEVICE_TYPE_MOUSE   ||
-	 device_type == XFPM_DEVICE_TYPE_KBD     ||
-	 device_type == XFPM_DEVICE_TYPE_PHONE)
+    if ( device_type == UP_DEVICE_KIND_BATTERY	||
+	 device_type == UP_DEVICE_KIND_UPS	||
+	 device_type == UP_DEVICE_KIND_MOUSE	||
+	 device_type == UP_DEVICE_KIND_KEYBOARD	||
+	 device_type == UP_DEVICE_KIND_PHONE)
     {
 	GtkStatusIcon *battery;
-	XFPM_DEBUG_ENUM (device_type, XFPM_TYPE_DEVICE_TYPE,
-			"Battery device detected at : %s", object_path);
+	XFPM_DEBUG( "Battery device type '%s' detected at: %s",
+		     up_device_kind_to_string(device_type), object_path);
 	battery = xfpm_battery_new ();
 	gtk_status_icon_set_visible (battery, FALSE);
 	xfpm_battery_monitor_device (XFPM_BATTERY (battery),
@@ -1495,11 +1492,11 @@ gboolean xfpm_power_has_battery (XfpmPower *power)
 
     for ( i = 0; i < len; i++)
     {
-	XfpmDeviceType type;
+	UpDeviceKind type;
 	battery = g_list_nth_data (list, i);
 	type = xfpm_battery_get_device_type (XFPM_BATTERY (battery));
-	if ( type == XFPM_DEVICE_TYPE_BATTERY ||
-	     type == XFPM_DEVICE_TYPE_UPS )
+	if ( type == UP_DEVICE_KIND_BATTERY ||
+	     type == UP_DEVICE_KIND_UPS )
 	{
 	    ret = TRUE;
 	    break;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list