[gnome-power-manager] Port from DeviceKit-power to UPower
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-power-manager] Port from DeviceKit-power to UPower
- Date: Tue, 30 Mar 2010 10:29:32 +0000 (UTC)
commit 4b45d6f8dcdf2594eaa5db755ea31ace97222ff0
Author: Richard Hughes <richard hughsie com>
Date: Tue Mar 30 11:29:27 2010 +0100
Port from DeviceKit-power to UPower
configure.ac | 5 +-
src/Makefile.am | 12 +-
src/gpm-backlight.c | 14 +-
src/gpm-button.c | 8 +-
src/gpm-common.h | 5 -
src/gpm-control.c | 10 +-
src/gpm-engine.c | 259 +++++++++++++++++++------------------
src/gpm-engine.h | 16 +-
src/gpm-graph-widget.c | 12 +-
src/gpm-idle.c | 30 ++--
src/gpm-manager.c | 108 ++++++++--------
src/gpm-prefs-core.c | 8 +-
src/gpm-statistics.c | 339 ++++++++++++++++++++++++------------------------
src/gpm-tray-icon.c | 28 ++--
src/gpm-upower.c | 252 ++++++++++++++++--------------------
src/gpm-upower.h | 14 +-
16 files changed, 547 insertions(+), 573 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index feb1afa..7fa5907 100644
--- a/configure.ac
+++ b/configure.ac
@@ -121,7 +121,7 @@ UNIQUE_REQUIRED=0.9.4
LIBPANEL_REQUIRED=2.0.0
XRANDR_REQUIRED=1.2.0
CANBERRA_REQUIRED=0.10
-DEVKIT_POWER_REQUIRED=008
+UPOWER_REQUIRED=0.9.1
dnl ---------------------------------------------------------------------------
dnl - Check library dependencies
@@ -160,8 +160,7 @@ PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= $LIBNOTIFY_REQUIRED)
PKG_CHECK_MODULES(UNIQUE, unique-1.0 >= $UNIQUE_REQUIRED)
-PKG_CHECK_MODULES(DEVKIT, [
- devkit-power-gobject >= $DEVKIT_POWER_REQUIRED])
+PKG_CHECK_MODULES(UPOWER, upower-glib >= $UPOWER_REQUIRED)
AC_PATH_PROG(GCONFTOOL, gconftool-2)
AM_GCONF_SOURCE_2
diff --git a/src/Makefile.am b/src/Makefile.am
index 652f9fe..1aae62e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,7 +19,7 @@ INCLUDES = \
$(CANBERRA_CFLAGS) \
$(GSTREAMER_CFLAGS) \
-DI_KNOW_THE_DEVICEKIT_POWER_API_IS_SUBJECT_TO_CHANGE \
- $(DEVKIT_CFLAGS) \
+ $(UPOWER_CFLAGS) \
-DBINDIR=\"$(bindir)\" \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DDATADIR=\"$(datadir)\" \
@@ -29,7 +29,7 @@ INCLUDES = \
-DVERSION="\"$(VERSION)\"" \
-DGPM_DATA=\"$(pkgdatadir)\" \
-DGTKBUILDERDIR=\"$(pkgdatadir)\" \
- -DDKP_DISABLE_DEPRECATED \
+ -DUP_DISABLE_DEPRECATED \
-DEGG_LOG_FILE=\""/tmp/gpm.log"\" \
-DEGG_VERBOSE="\"GPM_VERBOSE\"" \
-DEGG_LOGGING="\"GPM_LOGGING\"" \
@@ -94,7 +94,7 @@ gnome_power_statistics_LDADD = \
libgpmshared.a \
$(GLIB_LIBS) \
$(X11_LIBS) \
- $(DEVKIT_LIBS) \
+ $(UPOWER_LIBS) \
$(GNOME_LIBS) \
$(UNIQUE_LIBS) \
$(DBUS_LIBS) \
@@ -118,7 +118,7 @@ gnome_power_preferences_LDADD = \
$(DBUS_LIBS) \
$(UNIQUE_LIBS) \
$(GPM_EXTRA_LIBS) \
- $(DEVKIT_LIBS) \
+ $(UPOWER_LIBS) \
-lm
if HAVE_HAL
@@ -188,7 +188,7 @@ gnome_power_manager_LDADD = \
$(CANBERRA_LIBS) \
$(LIBNOTIFY_LIBS) \
$(GPM_EXTRA_LIBS) \
- $(DEVKIT_LIBS) \
+ $(UPOWER_LIBS) \
-lm
if HAVE_HAL
@@ -256,7 +256,7 @@ gnome_power_self_test_LDADD = \
$(X11_LIBS) \
$(GNOME_LIBS) \
$(GSTREAMER_LIBS) \
- $(DEVKIT_LIBS) \
+ $(UPOWER_LIBS) \
$(DBUS_LIBS) \
$(X11_LIBS) \
$(LIBNOTIFY_LIBS) \
diff --git a/src/gpm-backlight.c b/src/gpm-backlight.c
index 3911baf..ca99aa1 100644
--- a/src/gpm-backlight.c
+++ b/src/gpm-backlight.c
@@ -40,7 +40,7 @@
#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
#include <gconf/gconf-client.h>
-#include <devkit-power-gobject/devicekit-power.h>
+#include <libupower-glib/upower.h>
#include "gpm-button.h"
#include "gpm-backlight.h"
@@ -59,7 +59,7 @@
struct GpmBacklightPrivate
{
- DkpClient *client;
+ UpClient *client;
GpmBrightness *brightness;
GpmButton *button;
GConfClient *conf;
@@ -406,13 +406,13 @@ gpm_conf_gconf_key_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *e
/**
* gpm_backlight_client_changed_cb:
- * @client: The dkp_client class instance
+ * @client: The up_client class instance
* @backlight: This class instance
*
* Does the actions when the ac power source is inserted/removed.
**/
static void
-gpm_backlight_client_changed_cb (DkpClient *client, GpmBacklight *backlight)
+gpm_backlight_client_changed_cb (UpClient *client, GpmBacklight *backlight)
{
gpm_backlight_brightness_evaluate_and_set (backlight, FALSE);
}
@@ -728,8 +728,8 @@ gpm_backlight_init (GpmBacklight *backlight)
g_signal_connect (backlight->priv->brightness, "brightness-changed",
G_CALLBACK (brightness_changed_cb), backlight);
- /* we use dkp_client for the ac-adapter-changed signal */
- backlight->priv->client = dkp_client_new ();
+ /* we use up_client for the ac-adapter-changed signal */
+ backlight->priv->client = up_client_new ();
g_signal_connect (backlight->priv->client, "changed",
G_CALLBACK (gpm_backlight_client_changed_cb), backlight);
@@ -737,11 +737,9 @@ gpm_backlight_init (GpmBacklight *backlight)
backlight->priv->can_dim = gpm_brightness_has_hw (backlight->priv->brightness);
/* we use DeviceKit-power to see if we should show the lid UI */
-#if DKP_CHECK_VERSION(0x009)
g_object_get (backlight->priv->client,
"lid-is-present", &lid_is_present,
NULL);
-#endif
/* expose ui in prefs program */
prefs_server = gpm_prefs_server_new ();
diff --git a/src/gpm-button.c b/src/gpm-button.c
index 6350989..3341b4c 100644
--- a/src/gpm-button.c
+++ b/src/gpm-button.c
@@ -29,7 +29,7 @@
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <X11/XF86keysym.h>
-#include <devkit-power-gobject/devicekit-power.h>
+#include <libupower-glib/upower.h>
#include "gpm-common.h"
#include "gpm-button.h"
@@ -48,7 +48,7 @@ struct GpmButtonPrivate
gchar *last_button;
GTimer *timer;
gboolean lid_is_closed;
- DkpClient *client;
+ UpClient *client;
};
enum {
@@ -283,7 +283,7 @@ gpm_button_reset_time (GpmButton *button)
* gpm_button_client_changed_cb
**/
static void
-gpm_button_client_changed_cb (DkpClient *client, GpmButton *button)
+gpm_button_client_changed_cb (UpClient *client, GpmButton *button)
{
gboolean lid_is_closed;
@@ -323,7 +323,7 @@ gpm_button_init (GpmButton *button)
button->priv->timer = g_timer_new ();
button->priv->lid_is_closed = FALSE;
- button->priv->client = dkp_client_new ();
+ button->priv->client = up_client_new ();
g_signal_connect (button->priv->client, "changed",
G_CALLBACK (gpm_button_client_changed_cb), button);
diff --git a/src/gpm-common.h b/src/gpm-common.h
index 807a34c..5198490 100644
--- a/src/gpm-common.h
+++ b/src/gpm-common.h
@@ -26,11 +26,6 @@
G_BEGIN_DECLS
-/* do this until we depend on DeviceKit-power 009 */
-#ifndef DKP_CHECK_VERSION
-#define DKP_CHECK_VERSION(o) (0)
-#endif
-
#define GPM_DBUS_SERVICE "org.gnome.PowerManager"
#define GPM_DBUS_INTERFACE "org.gnome.PowerManager"
#define GPM_DBUS_INTERFACE_BACKLIGHT "org.gnome.PowerManager.Backlight"
diff --git a/src/gpm-control.c b/src/gpm-control.c
index 1b1a63e..825b164 100644
--- a/src/gpm-control.c
+++ b/src/gpm-control.c
@@ -41,7 +41,7 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <gnome-keyring.h>
#include <gconf/gconf-client.h>
-#include <devkit-power-gobject/devicekit-power.h>
+#include <libupower-glib/upower.h>
#include "egg-debug.h"
#include "egg-console-kit.h"
@@ -56,7 +56,7 @@
struct GpmControlPrivate
{
GConfClient *conf;
- DkpClient *client;
+ UpClient *client;
};
enum {
@@ -178,7 +178,7 @@ gpm_control_suspend (GpmControl *control, GError **error)
egg_debug ("emitting sleep");
g_signal_emit (control, signals [SLEEP], 0, GPM_CONTROL_ACTION_SUSPEND);
- ret = dkp_client_suspend (control->priv->client, error);
+ ret = up_client_suspend_sync (control->priv->client, NULL, error);
egg_debug ("emitting resume");
g_signal_emit (control, signals [RESUME], 0, GPM_CONTROL_ACTION_SUSPEND);
@@ -246,7 +246,7 @@ gpm_control_hibernate (GpmControl *control, GError **error)
egg_debug ("emitting sleep");
g_signal_emit (control, signals [SLEEP], 0, GPM_CONTROL_ACTION_HIBERNATE);
- ret = dkp_client_hibernate (control->priv->client, error);
+ ret = up_client_hibernate_sync (control->priv->client, NULL, error);
egg_debug ("emitting resume");
g_signal_emit (control, signals [RESUME], 0, GPM_CONTROL_ACTION_HIBERNATE);
@@ -325,7 +325,7 @@ gpm_control_init (GpmControl *control)
{
control->priv = GPM_CONTROL_GET_PRIVATE (control);
- control->priv->client = dkp_client_new ();
+ control->priv->client = up_client_new ();
control->priv->conf = gconf_client_get_default ();
}
diff --git a/src/gpm-engine.c b/src/gpm-engine.c
index 7524329..59d65db 100644
--- a/src/gpm-engine.c
+++ b/src/gpm-engine.c
@@ -25,7 +25,7 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <gconf/gconf-client.h>
-#include <devkit-power-gobject/devicekit-power.h>
+#include <libupower-glib/upower.h>
#include "egg-debug.h"
@@ -46,8 +46,8 @@ static void gpm_engine_finalize (GObject *object);
struct GpmEnginePrivate
{
GConfClient *conf;
- DkpClient *client;
- DkpDevice *battery_composite;
+ UpClient *client;
+ UpDevice *battery_composite;
GPtrArray *array;
GpmPhone *phone;
GpmIconPolicy icon_policy;
@@ -83,8 +83,8 @@ static gpointer gpm_engine_object = NULL;
G_DEFINE_TYPE (GpmEngine, gpm_engine, G_TYPE_OBJECT)
-static DkpDevice *gpm_engine_get_composite_device (GpmEngine *engine, DkpDevice *original_device);
-static DkpDevice *gpm_engine_update_composite_device (GpmEngine *engine, DkpDevice *original_device);
+static UpDevice *gpm_engine_get_composite_device (GpmEngine *engine, UpDevice *original_device);
+static UpDevice *gpm_engine_update_composite_device (GpmEngine *engine, UpDevice *original_device);
typedef enum {
GPM_ENGINE_WARNING_NONE = 0,
@@ -98,7 +98,7 @@ typedef enum {
* gpm_engine_get_warning_csr:
**/
static GpmEngineWarning
-gpm_engine_get_warning_csr (GpmEngine *engine, DkpDevice *device)
+gpm_engine_get_warning_csr (GpmEngine *engine, UpDevice *device)
{
gdouble percentage;
@@ -116,7 +116,7 @@ gpm_engine_get_warning_csr (GpmEngine *engine, DkpDevice *device)
* gpm_engine_get_warning_percentage:
**/
static GpmEngineWarning
-gpm_engine_get_warning_percentage (GpmEngine *engine, DkpDevice *device)
+gpm_engine_get_warning_percentage (GpmEngine *engine, UpDevice *device)
{
gdouble percentage;
@@ -136,20 +136,20 @@ gpm_engine_get_warning_percentage (GpmEngine *engine, DkpDevice *device)
* gpm_engine_get_warning_time:
**/
static GpmEngineWarning
-gpm_engine_get_warning_time (GpmEngine *engine, DkpDevice *device)
+gpm_engine_get_warning_time (GpmEngine *engine, UpDevice *device)
{
- DkpDeviceType type;
+ UpDeviceKind kind;
gint64 time_to_empty;
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
"time-to-empty", &time_to_empty,
NULL);
/* this is probably an error condition */
if (time_to_empty == 0) {
- egg_debug ("time zero, falling back to percentage for %s", dkp_device_type_to_text (type));
+ egg_debug ("time zero, falling back to percentage for %s", up_device_kind_to_string (kind));
return gpm_engine_get_warning_percentage (engine, device);
}
@@ -171,15 +171,15 @@ gpm_engine_get_warning_time (GpmEngine *engine, DkpDevice *device)
* Return value: A GpmEngine state, e.g. GPM_ENGINE_WARNING_DISCHARGING
**/
static GpmEngineWarning
-gpm_engine_get_warning (GpmEngine *engine, DkpDevice *device)
+gpm_engine_get_warning (GpmEngine *engine, UpDevice *device)
{
- DkpDeviceType type;
- DkpDeviceState state;
+ UpDeviceKind kind;
+ UpDeviceState state;
GpmEngineWarning warning_type;
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
"state", &state,
NULL);
@@ -187,24 +187,24 @@ gpm_engine_get_warning (GpmEngine *engine, DkpDevice *device)
warning_type = GPM_ENGINE_WARNING_NONE;
/* if the device in question is on ac, don't give a warning */
- if (state == DKP_DEVICE_STATE_CHARGING)
+ if (state == UP_DEVICE_STATE_CHARGING)
goto out;
- if (type == DKP_DEVICE_TYPE_MOUSE ||
- type == DKP_DEVICE_TYPE_KEYBOARD) {
+ if (kind == UP_DEVICE_KIND_MOUSE ||
+ kind == UP_DEVICE_KIND_KEYBOARD) {
warning_type = gpm_engine_get_warning_csr (engine, device);
- } else if (type == DKP_DEVICE_TYPE_UPS ||
- type == DKP_DEVICE_TYPE_PDA) {
+ } else if (kind == UP_DEVICE_KIND_UPS ||
+ kind == UP_DEVICE_KIND_PDA) {
warning_type = gpm_engine_get_warning_percentage (engine, device);
- } else if (type == DKP_DEVICE_TYPE_PHONE) {
+ } else if (kind == UP_DEVICE_KIND_PHONE) {
warning_type = gpm_engine_get_warning_percentage (engine, device);
- } else if (type == DKP_DEVICE_TYPE_BATTERY) {
+ } else if (kind == UP_DEVICE_KIND_BATTERY) {
/* only use the time when it is accurate, and GConf is not disabled */
if (engine->priv->use_time_primary)
warning_type = gpm_engine_get_warning_time (engine, device);
@@ -214,7 +214,7 @@ gpm_engine_get_warning (GpmEngine *engine, DkpDevice *device)
/* If we have no important engines, we should test for discharging */
if (warning_type == GPM_ENGINE_WARNING_NONE) {
- if (state == DKP_DEVICE_STATE_DISCHARGING)
+ if (state == UP_DEVICE_STATE_DISCHARGING)
warning_type = GPM_ENGINE_WARNING_DISCHARGING;
}
@@ -234,7 +234,7 @@ gpm_engine_get_summary (GpmEngine *engine)
{
guint i;
GPtrArray *array;
- DkpDevice *device;
+ UpDevice *device;
GString *tooltip = NULL;
gchar *part;
@@ -267,14 +267,14 @@ gpm_engine_get_summary (GpmEngine *engine)
* Returns the icon
**/
static gchar *
-gpm_engine_get_icon_priv (GpmEngine *engine, DkpDeviceType device_type, GpmEngineWarning warning, gboolean use_state)
+gpm_engine_get_icon_priv (GpmEngine *engine, UpDeviceKind device_kind, GpmEngineWarning warning, gboolean use_state)
{
guint i;
GPtrArray *array;
- DkpDevice *device;
+ UpDevice *device;
GpmEngineWarning warning_temp;
- DkpDeviceType type;
- DkpDeviceState state;
+ UpDeviceKind kind;
+ UpDeviceState state;
gboolean is_present;
/* do we have specific device types? */
@@ -284,24 +284,24 @@ gpm_engine_get_icon_priv (GpmEngine *engine, DkpDeviceType device_type, GpmEngin
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
"state", &state,
"is-present", &is_present,
NULL);
/* if battery then use composite device to cope with multiple batteries */
- if (type == DKP_DEVICE_TYPE_BATTERY)
+ if (kind == UP_DEVICE_KIND_BATTERY)
device = gpm_engine_get_composite_device (engine, device);
warning_temp = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(device), "engine-warning-old"));
- if (type == device_type && is_present) {
+ if (kind == device_kind && is_present) {
if (warning != GPM_ENGINE_WARNING_NONE) {
if (warning_temp == warning)
return gpm_upower_get_device_icon (device);
continue;
}
if (use_state) {
- if (state == DKP_DEVICE_STATE_CHARGING || state == DKP_DEVICE_STATE_DISCHARGING)
+ if (state == UP_DEVICE_STATE_CHARGING || state == UP_DEVICE_STATE_DISCHARGING)
return gpm_upower_get_device_icon (device);
continue;
}
@@ -330,16 +330,16 @@ gpm_engine_get_icon (GpmEngine *engine)
}
/* we try CRITICAL: BATTERY, UPS, MOUSE, KEYBOARD */
- icon = gpm_engine_get_icon_priv (engine, DKP_DEVICE_TYPE_BATTERY, GPM_ENGINE_WARNING_CRITICAL, FALSE);
+ icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_BATTERY, GPM_ENGINE_WARNING_CRITICAL, FALSE);
if (icon != NULL)
return icon;
- icon = gpm_engine_get_icon_priv (engine, DKP_DEVICE_TYPE_UPS, GPM_ENGINE_WARNING_CRITICAL, FALSE);
+ icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_UPS, GPM_ENGINE_WARNING_CRITICAL, FALSE);
if (icon != NULL)
return icon;
- icon = gpm_engine_get_icon_priv (engine, DKP_DEVICE_TYPE_MOUSE, GPM_ENGINE_WARNING_CRITICAL, FALSE);
+ icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_MOUSE, GPM_ENGINE_WARNING_CRITICAL, FALSE);
if (icon != NULL)
return icon;
- icon = gpm_engine_get_icon_priv (engine, DKP_DEVICE_TYPE_KEYBOARD, GPM_ENGINE_WARNING_CRITICAL, FALSE);
+ icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_KEYBOARD, GPM_ENGINE_WARNING_CRITICAL, FALSE);
if (icon != NULL)
return icon;
@@ -350,16 +350,16 @@ gpm_engine_get_icon (GpmEngine *engine)
}
/* we try CRITICAL: BATTERY, UPS, MOUSE, KEYBOARD */
- icon = gpm_engine_get_icon_priv (engine, DKP_DEVICE_TYPE_BATTERY, GPM_ENGINE_WARNING_LOW, FALSE);
+ icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_BATTERY, GPM_ENGINE_WARNING_LOW, FALSE);
if (icon != NULL)
return icon;
- icon = gpm_engine_get_icon_priv (engine, DKP_DEVICE_TYPE_UPS, GPM_ENGINE_WARNING_LOW, FALSE);
+ icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_UPS, GPM_ENGINE_WARNING_LOW, FALSE);
if (icon != NULL)
return icon;
- icon = gpm_engine_get_icon_priv (engine, DKP_DEVICE_TYPE_MOUSE, GPM_ENGINE_WARNING_LOW, FALSE);
+ icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_MOUSE, GPM_ENGINE_WARNING_LOW, FALSE);
if (icon != NULL)
return icon;
- icon = gpm_engine_get_icon_priv (engine, DKP_DEVICE_TYPE_KEYBOARD, GPM_ENGINE_WARNING_LOW, FALSE);
+ icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_KEYBOARD, GPM_ENGINE_WARNING_LOW, FALSE);
if (icon != NULL)
return icon;
@@ -370,10 +370,10 @@ gpm_engine_get_icon (GpmEngine *engine)
}
/* we try (DIS)CHARGING: BATTERY, UPS */
- icon = gpm_engine_get_icon_priv (engine, DKP_DEVICE_TYPE_BATTERY, GPM_ENGINE_WARNING_NONE, TRUE);
+ icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_BATTERY, GPM_ENGINE_WARNING_NONE, TRUE);
if (icon != NULL)
return icon;
- icon = gpm_engine_get_icon_priv (engine, DKP_DEVICE_TYPE_UPS, GPM_ENGINE_WARNING_NONE, TRUE);
+ icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_UPS, GPM_ENGINE_WARNING_NONE, TRUE);
if (icon != NULL)
return icon;
@@ -384,10 +384,10 @@ gpm_engine_get_icon (GpmEngine *engine)
}
/* we try PRESENT: BATTERY, UPS */
- icon = gpm_engine_get_icon_priv (engine, DKP_DEVICE_TYPE_BATTERY, GPM_ENGINE_WARNING_NONE, FALSE);
+ icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_BATTERY, GPM_ENGINE_WARNING_NONE, FALSE);
if (icon != NULL)
return icon;
- icon = gpm_engine_get_icon_priv (engine, DKP_DEVICE_TYPE_UPS, GPM_ENGINE_WARNING_NONE, FALSE);
+ icon = gpm_engine_get_icon_priv (engine, UP_DEVICE_KIND_UPS, GPM_ENGINE_WARNING_NONE, FALSE);
if (icon != NULL)
return icon;
@@ -528,20 +528,20 @@ gpm_engine_conf_key_changed_cb (GConfClient *conf, guint cnxn_id, GConfEntry *en
* gpm_engine_device_check_capacity:
**/
static gboolean
-gpm_engine_device_check_capacity (GpmEngine *engine, DkpDevice *device)
+gpm_engine_device_check_capacity (GpmEngine *engine, UpDevice *device)
{
gboolean ret;
- DkpDeviceType type;
+ UpDeviceKind kind;
gdouble capacity;
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
"capacity", &capacity,
NULL);
/* not laptop battery */
- if (type != DKP_DEVICE_TYPE_BATTERY)
+ if (kind != UP_DEVICE_KIND_BATTERY)
return FALSE;
/* capacity okay */
@@ -564,13 +564,13 @@ gpm_engine_device_check_capacity (GpmEngine *engine, DkpDevice *device)
/**
* gpm_engine_get_composite_device:
**/
-static DkpDevice *
-gpm_engine_get_composite_device (GpmEngine *engine, DkpDevice *original_device)
+static UpDevice *
+gpm_engine_get_composite_device (GpmEngine *engine, UpDevice *original_device)
{
guint battery_devices = 0;
GPtrArray *array;
- DkpDevice *device;
- DkpDeviceType type;
+ UpDevice *device;
+ UpDeviceKind kind;
guint i;
/* find out how many batteries in the system */
@@ -578,9 +578,9 @@ gpm_engine_get_composite_device (GpmEngine *engine, DkpDevice *original_device)
for (i=0;i<array->len;i++) {
device = g_ptr_array_index (engine->priv->array, i);
g_object_get (device,
- "type", &type,
+ "kind", &kind,
NULL);
- if (type == DKP_DEVICE_TYPE_BATTERY)
+ if (kind == UP_DEVICE_KIND_BATTERY)
battery_devices++;
}
@@ -601,8 +601,8 @@ out:
/**
* gpm_engine_update_composite_device:
**/
-static DkpDevice *
-gpm_engine_update_composite_device (GpmEngine *engine, DkpDevice *original_device)
+static UpDevice *
+gpm_engine_update_composite_device (GpmEngine *engine, UpDevice *original_device)
{
guint i;
gdouble percentage;
@@ -619,10 +619,11 @@ gpm_engine_update_composite_device (GpmEngine *engine, DkpDevice *original_devic
gboolean is_discharging = FALSE;
gboolean is_fully_charged = TRUE;
GPtrArray *array;
- DkpDevice *device;
- DkpDeviceState state;
- DkpDeviceType type;
+ UpDevice *device;
+ UpDeviceState state;
+ UpDeviceKind kind;
gboolean debug;
+ gchar *text;
/* are we printing to console? */
debug = egg_debug_enabled ();
@@ -632,26 +633,27 @@ gpm_engine_update_composite_device (GpmEngine *engine, DkpDevice *original_devic
for (i=0;i<array->len;i++) {
device = g_ptr_array_index (engine->priv->array, i);
g_object_get (device,
- "type", &type,
+ "kind", &kind,
"state", &state,
"energy", &energy,
"energy-full", &energy_full,
"energy-rate", &energy_rate,
NULL);
- if (type != DKP_DEVICE_TYPE_BATTERY)
+ if (kind != UP_DEVICE_KIND_BATTERY)
continue;
if (debug) {
- egg_debug ("printing device %i", i);
- dkp_device_print (device);
+ text = up_device_to_text (device);
+ egg_debug ("printing device %i:\n%s", i, text);
+ g_free (text);
}
/* one of these will be charging or discharging */
- if (state == DKP_DEVICE_STATE_CHARGING)
+ if (state == UP_DEVICE_STATE_CHARGING)
is_charging = TRUE;
- if (state == DKP_DEVICE_STATE_DISCHARGING)
+ if (state == UP_DEVICE_STATE_DISCHARGING)
is_discharging = TRUE;
- if (state != DKP_DEVICE_STATE_FULLY_CHARGED)
+ if (state != UP_DEVICE_STATE_FULLY_CHARGED)
is_fully_charged = FALSE;
/* sum up composite */
@@ -673,19 +675,19 @@ gpm_engine_update_composite_device (GpmEngine *engine, DkpDevice *original_devic
/* set composite state */
if (is_charging)
- state = DKP_DEVICE_STATE_CHARGING;
+ state = UP_DEVICE_STATE_CHARGING;
else if (is_discharging)
- state = DKP_DEVICE_STATE_DISCHARGING;
+ state = UP_DEVICE_STATE_DISCHARGING;
else if (is_fully_charged)
- state = DKP_DEVICE_STATE_FULLY_CHARGED;
+ state = UP_DEVICE_STATE_FULLY_CHARGED;
else
- state = DKP_DEVICE_STATE_UNKNOWN;
+ state = UP_DEVICE_STATE_UNKNOWN;
/* calculate a quick and dirty time remaining value */
if (energy_rate_total > 0) {
- if (state == DKP_DEVICE_STATE_DISCHARGING)
+ if (state == UP_DEVICE_STATE_DISCHARGING)
time_to_empty = 3600 * (energy_total / energy_rate_total);
- else if (state == DKP_DEVICE_STATE_CHARGING)
+ else if (state == UP_DEVICE_STATE_CHARGING)
time_to_full = 3600 * ((energy_full_total - energy_total) / energy_rate_total);
}
@@ -702,8 +704,11 @@ gpm_engine_update_composite_device (GpmEngine *engine, DkpDevice *original_devic
"percentage", percentage,
"state", state,
NULL);
- if (debug)
- dkp_device_print (device);
+ if (debug) {
+ text = up_device_to_text (device);
+ egg_debug ("composite:\n%s", text);
+ g_free (text);
+ }
/* force update of icon */
gpm_engine_recalculate_state_icon (engine);
@@ -716,12 +721,12 @@ out:
* gpm_engine_device_add:
**/
static void
-gpm_engine_device_add (GpmEngine *engine, DkpDevice *device)
+gpm_engine_device_add (GpmEngine *engine, UpDevice *device)
{
GpmEngineWarning warning;
- DkpDeviceState state;
- DkpDeviceType type;
- DkpDevice *composite;
+ UpDeviceState state;
+ UpDeviceKind kind;
+ UpDevice *composite;
/* assign warning */
warning = gpm_engine_get_warning (engine, device);
@@ -732,15 +737,15 @@ gpm_engine_device_add (GpmEngine *engine, DkpDevice *device)
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
"state", &state,
NULL);
/* add old state for transitions */
- egg_debug ("adding %s with state %s", dkp_device_get_object_path (device), dkp_device_state_to_text (state));
+ egg_debug ("adding %s with state %s", up_device_get_object_path (device), up_device_state_to_string (state));
g_object_set_data (G_OBJECT(device), "engine-state-old", GUINT_TO_POINTER(state));
- if (type == DKP_DEVICE_TYPE_BATTERY) {
+ if (kind == UP_DEVICE_KIND_BATTERY) {
egg_debug ("updating because we added a device");
composite = gpm_engine_update_composite_device (engine, device);
@@ -756,25 +761,23 @@ gpm_engine_device_add (GpmEngine *engine, DkpDevice *device)
* gpm_engine_check_recall:
**/
static gboolean
-gpm_engine_check_recall (GpmEngine *engine, DkpDevice *device)
+gpm_engine_check_recall (GpmEngine *engine, UpDevice *device)
{
- DkpDeviceType type;
+ UpDeviceKind kind;
gboolean recall_notice = FALSE;
gchar *recall_vendor = NULL;
gchar *recall_url = NULL;
/* get device properties */
g_object_get (device,
- "type", &type,
-#if DKP_CHECK_VERSION(0x009)
+ "kind", &kind,
"recall-notice", &recall_notice,
"recall-vendor", &recall_vendor,
"recall-url", &recall_url,
-#endif
NULL);
/* not battery */
- if (type != DKP_DEVICE_TYPE_BATTERY)
+ if (kind != UP_DEVICE_KIND_BATTERY)
goto out;
/* no recall data */
@@ -801,14 +804,22 @@ gpm_engine_coldplug_idle_cb (GpmEngine *engine)
gboolean has_battery = FALSE;
gboolean has_ups = FALSE;
GpmPrefsServer *prefs_server;
- DkpDevice *device;
- DkpDeviceType type;
+ UpDevice *device;
+ UpDeviceKind kind;
+ gboolean ret;
+ GError *error = NULL;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (GPM_IS_ENGINE (engine), FALSE);
- /* get array */
- engine->priv->array = dkp_client_enumerate_devices (engine->priv->client, NULL);
+ /* get devices from UPower */
+ ret = up_client_enumerate_devices_sync (engine->priv->client, NULL, &error);
+ if (!ret) {
+ egg_error ("failed to get device list: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+ engine->priv->array = up_client_get_devices (engine->priv->client);
/* do we have specific device types? */
array = engine->priv->array;
@@ -817,12 +828,12 @@ gpm_engine_coldplug_idle_cb (GpmEngine *engine)
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
NULL);
- if (type == DKP_DEVICE_TYPE_BATTERY)
+ if (kind == UP_DEVICE_KIND_BATTERY)
has_battery = TRUE;
- else if (type == DKP_DEVICE_TYPE_UPS)
+ else if (kind == UP_DEVICE_KIND_UPS)
has_ups = TRUE;
}
@@ -845,7 +856,7 @@ gpm_engine_coldplug_idle_cb (GpmEngine *engine)
gpm_engine_device_add (engine, device);
gpm_engine_check_recall (engine, device);
}
-
+out:
/* never repeat */
return FALSE;
}
@@ -854,7 +865,7 @@ gpm_engine_coldplug_idle_cb (GpmEngine *engine)
* gpm_engine_device_added_cb:
**/
static void
-gpm_engine_device_added_cb (DkpClient *client, DkpDevice *device, GpmEngine *engine)
+gpm_engine_device_added_cb (UpClient *client, UpDevice *device, GpmEngine *engine)
{
/* add to list */
g_ptr_array_add (engine->priv->array, g_object_ref (device));
@@ -867,7 +878,7 @@ gpm_engine_device_added_cb (DkpClient *client, DkpDevice *device, GpmEngine *eng
* gpm_engine_device_removed_cb:
**/
static void
-gpm_engine_device_removed_cb (DkpClient *client, DkpDevice *device, GpmEngine *engine)
+gpm_engine_device_removed_cb (UpClient *client, UpDevice *device, GpmEngine *engine)
{
gboolean ret;
ret = g_ptr_array_remove (engine->priv->array, device);
@@ -881,22 +892,22 @@ gpm_engine_device_removed_cb (DkpClient *client, DkpDevice *device, GpmEngine *e
* gpm_engine_device_changed_cb:
**/
static void
-gpm_engine_device_changed_cb (DkpClient *client, DkpDevice *device, GpmEngine *engine)
+gpm_engine_device_changed_cb (UpClient *client, UpDevice *device, GpmEngine *engine)
{
- DkpDeviceType type;
- DkpDeviceState state;
- DkpDeviceState state_old;
+ UpDeviceKind kind;
+ UpDeviceState state;
+ UpDeviceState state_old;
GpmEngineWarning warning_old;
GpmEngineWarning warning;
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
NULL);
/* if battery then use composite device to cope with multiple batteries */
- if (type == DKP_DEVICE_TYPE_BATTERY) {
- egg_debug ("updating because %s changed", dkp_device_get_object_path (device));
+ if (kind == UP_DEVICE_KIND_BATTERY) {
+ egg_debug ("updating because %s changed", up_device_get_object_path (device));
device = gpm_engine_update_composite_device (engine, device);
}
@@ -905,15 +916,15 @@ gpm_engine_device_changed_cb (DkpClient *client, DkpDevice *device, GpmEngine *e
"state", &state,
NULL);
- egg_debug ("%s state is now %s", dkp_device_get_object_path (device), dkp_device_state_to_text (state));
+ egg_debug ("%s state is now %s", up_device_get_object_path (device), up_device_state_to_string (state));
/* see if any interesting state changes have happened */
state_old = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(device), "engine-state-old"));
if (state_old != state) {
- if (state == DKP_DEVICE_STATE_DISCHARGING) {
+ if (state == UP_DEVICE_STATE_DISCHARGING) {
egg_debug ("** EMIT: discharging");
g_signal_emit (engine, signals [DISCHARGING], 0, device);
- } else if (state == DKP_DEVICE_STATE_FULLY_CHARGED) {
+ } else if (state == UP_DEVICE_STATE_FULLY_CHARGED) {
egg_debug ("** EMIT: fully charged");
g_signal_emit (engine, signals [FULLY_CHARGED], 0, device);
}
@@ -946,7 +957,7 @@ gpm_engine_device_changed_cb (DkpClient *client, DkpDevice *device, GpmEngine *e
/**
* gpm_engine_get_devices:
*
- * Return value: the DkpDevice array, free with g_ptr_array_unref()
+ * Return value: the UpDevice array, free with g_ptr_array_unref()
**/
GPtrArray *
gpm_engine_get_devices (GpmEngine *engine)
@@ -960,14 +971,14 @@ gpm_engine_get_devices (GpmEngine *engine)
static void
phone_device_added_cb (GpmPhone *phone, guint idx, GpmEngine *engine)
{
- DkpDevice *device;
- device = dkp_device_new ();
+ UpDevice *device;
+ device = up_device_new ();
egg_debug ("phone added %i", idx);
/* get device properties */
g_object_set (device,
- "type", DKP_DEVICE_TYPE_PHONE,
+ "kind", UP_DEVICE_KIND_PHONE,
"is-rechargeable", TRUE,
"native-path", g_strdup_printf ("dummy:phone_%i", idx),
"is-present", TRUE,
@@ -986,8 +997,8 @@ static void
phone_device_removed_cb (GpmPhone *phone, guint idx, GpmEngine *engine)
{
guint i;
- DkpDevice *device;
- DkpDeviceType type;
+ UpDevice *device;
+ UpDeviceKind kind;
egg_debug ("phone removed %i", idx);
@@ -996,10 +1007,10 @@ phone_device_removed_cb (GpmPhone *phone, guint idx, GpmEngine *engine)
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
NULL);
- if (type == DKP_DEVICE_TYPE_PHONE) {
+ if (kind == UP_DEVICE_KIND_PHONE) {
g_ptr_array_remove_index (engine->priv->array, i);
break;
}
@@ -1016,9 +1027,9 @@ static void
phone_device_refresh_cb (GpmPhone *phone, guint idx, GpmEngine *engine)
{
guint i;
- DkpDevice *device;
- DkpDeviceType type;
- DkpDeviceState state;
+ UpDevice *device;
+ UpDeviceKind kind;
+ UpDeviceState state;
gboolean is_present;
gdouble percentage;
@@ -1029,15 +1040,15 @@ phone_device_refresh_cb (GpmPhone *phone, guint idx, GpmEngine *engine)
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
"state", &state,
"percentage", &percentage,
"is-present", &is_present,
NULL);
- if (type == DKP_DEVICE_TYPE_PHONE) {
+ if (kind == UP_DEVICE_KIND_PHONE) {
is_present = gpm_phone_get_present (phone, idx);
- state = gpm_phone_get_on_ac (phone, idx) ? DKP_DEVICE_STATE_CHARGING : DKP_DEVICE_STATE_DISCHARGING;
+ state = gpm_phone_get_on_ac (phone, idx) ? UP_DEVICE_STATE_CHARGING : UP_DEVICE_STATE_DISCHARGING;
percentage = gpm_phone_get_percentage (phone, idx);
break;
}
@@ -1059,7 +1070,7 @@ gpm_engine_init (GpmEngine *engine)
engine->priv = GPM_ENGINE_GET_PRIVATE (engine);
engine->priv->array = g_ptr_array_new_with_free_func (g_object_unref);
- engine->priv->client = dkp_client_new ();
+ engine->priv->client = up_client_new ();
g_signal_connect (engine->priv->client, "device-added",
G_CALLBACK (gpm_engine_device_added_cb), engine);
g_signal_connect (engine->priv->client, "device-removed",
@@ -1081,9 +1092,9 @@ gpm_engine_init (GpmEngine *engine)
G_CALLBACK (phone_device_refresh_cb), engine);
/* create a fake virtual composite battery */
- engine->priv->battery_composite = dkp_device_new ();
+ engine->priv->battery_composite = up_device_new ();
g_object_set (engine->priv->battery_composite,
- "type", DKP_DEVICE_TYPE_BATTERY,
+ "kind", UP_DEVICE_KIND_BATTERY,
"is-rechargeable", TRUE,
"native-path", "dummy:composite_battery",
"power-supply", TRUE,
diff --git a/src/gpm-engine.h b/src/gpm-engine.h
index bb0be63..be1ccd6 100644
--- a/src/gpm-engine.h
+++ b/src/gpm-engine.h
@@ -23,7 +23,7 @@
#define __GPM_ENGINE_H
#include <glib-object.h>
-#include <devkit-power-gobject/devicekit-power.h>
+#include <libupower-glib/upower.h>
G_BEGIN_DECLS
@@ -50,21 +50,21 @@ typedef struct
void (* summary_changed) (GpmEngine *engine,
gchar *status);
void (* perhaps_recall) (GpmEngine *engine,
- DkpDevice *device,
+ UpDevice *device,
const gchar *oem_vendor,
const gchar *website);
void (* low_capacity) (GpmEngine *engine,
- DkpDevice *device);
+ UpDevice *device);
void (* charge_low) (GpmEngine *engine,
- DkpDevice *device);
+ UpDevice *device);
void (* charge_critical) (GpmEngine *engine,
- DkpDevice *device);
+ UpDevice *device);
void (* charge_action) (GpmEngine *engine,
- DkpDevice *device);
+ UpDevice *device);
void (* fully_charged) (GpmEngine *engine,
- DkpDevice *device);
+ UpDevice *device);
void (* discharging) (GpmEngine *engine,
- DkpDevice *device);
+ UpDevice *device);
} GpmEngineClass;
GType gpm_engine_get_type (void);
diff --git a/src/gpm-graph-widget.c b/src/gpm-graph-widget.c
index 571820d..a9ba689 100644
--- a/src/gpm-graph-widget.c
+++ b/src/gpm-graph-widget.c
@@ -131,10 +131,10 @@ gpm_graph_widget_key_data_add (GpmGraphWidget *graph, guint32 color, const gchar
}
/**
- * dkp_graph_get_property:
+ * up_graph_get_property:
**/
static void
-dkp_graph_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+up_graph_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
GpmGraphWidget *graph = GPM_GRAPH_WIDGET (object);
switch (prop_id) {
@@ -175,10 +175,10 @@ dkp_graph_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
}
/**
- * dkp_graph_set_property:
+ * up_graph_set_property:
**/
static void
-dkp_graph_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+up_graph_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
GpmGraphWidget *graph = GPM_GRAPH_WIDGET (object);
@@ -234,8 +234,8 @@ gpm_graph_widget_class_init (GpmGraphWidgetClass *class)
GObjectClass *object_class = G_OBJECT_CLASS (class);
widget_class->expose_event = gpm_graph_widget_expose;
- object_class->get_property = dkp_graph_get_property;
- object_class->set_property = dkp_graph_set_property;
+ object_class->get_property = up_graph_get_property;
+ object_class->set_property = up_graph_set_property;
object_class->finalize = gpm_graph_widget_finalize;
g_type_class_add_private (class, sizeof (GpmGraphWidgetPrivate));
diff --git a/src/gpm-idle.c b/src/gpm-idle.c
index 215cc77..7c0fc5c 100644
--- a/src/gpm-idle.c
+++ b/src/gpm-idle.c
@@ -78,10 +78,10 @@ static gpointer gpm_idle_object = NULL;
G_DEFINE_TYPE (GpmIdle, gpm_idle, G_TYPE_OBJECT)
/**
- * gpm_idle_mode_to_text:
+ * gpm_idle_mode_to_string:
**/
static const gchar *
-gpm_idle_mode_to_text (GpmIdleMode mode)
+gpm_idle_mode_to_string (GpmIdleMode mode)
{
if (mode == GPM_IDLE_MODE_NORMAL)
return "normal";
@@ -105,7 +105,7 @@ gpm_idle_set_mode (GpmIdle *idle, GpmIdleMode mode)
if (mode != idle->priv->mode) {
idle->priv->mode = mode;
- egg_debug ("Doing a state transition: %s", gpm_idle_mode_to_text (mode));
+ egg_debug ("Doing a state transition: %s", gpm_idle_mode_to_string (mode));
g_signal_emit (idle, signals [IDLE_CHANGED], 0, mode);
}
}
@@ -140,7 +140,7 @@ static gboolean
gpm_idle_blank_cb (GpmIdle *idle)
{
if (idle->priv->mode > GPM_IDLE_MODE_BLANK) {
- egg_debug ("ignoring current mode %s", gpm_idle_mode_to_text (idle->priv->mode));
+ egg_debug ("ignoring current mode %s", gpm_idle_mode_to_string (idle->priv->mode));
return FALSE;
}
gpm_idle_set_mode (idle, GPM_IDLE_MODE_BLANK);
@@ -467,7 +467,7 @@ static void
gpm_idle_test_idle_changed_cb (GpmIdle *idle, GpmIdleMode mode, EggTest *test)
{
_mode = mode;
- egg_debug ("idle-changed %s", gpm_idle_mode_to_text (mode));
+ egg_debug ("idle-changed %s", gpm_idle_mode_to_string (mode));
egg_test_loop_quit (test);
}
@@ -541,7 +541,7 @@ gpm_idle_test (gpointer data)
if (mode == GPM_IDLE_MODE_NORMAL)
egg_test_success (test, NULL);
else
- egg_test_failed (test, "mode: %s", gpm_idle_mode_to_text (mode));
+ egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
/************************************************************/
g_print ("*****************************\n");
@@ -555,7 +555,7 @@ gpm_idle_test (gpointer data)
if (_mode == GPM_IDLE_MODE_DIM)
egg_test_success (test, NULL);
else
- egg_test_failed (test, "mode: %s", gpm_idle_mode_to_text (mode));
+ egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
/************************************************************/
egg_test_title (test, "check current mode");
@@ -563,7 +563,7 @@ gpm_idle_test (gpointer data)
if (mode == GPM_IDLE_MODE_DIM)
egg_test_success (test, NULL);
else
- egg_test_failed (test, "mode: %s", gpm_idle_mode_to_text (mode));
+ egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
/************************************************************/
egg_test_title (test, "check x_idle");
@@ -586,7 +586,7 @@ gpm_idle_test (gpointer data)
if (_mode == GPM_IDLE_MODE_BLANK)
egg_test_success (test, NULL);
else
- egg_test_failed (test, "mode: %s", gpm_idle_mode_to_text (mode));
+ egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
/************************************************************/
egg_test_title (test, "check current mode");
@@ -594,7 +594,7 @@ gpm_idle_test (gpointer data)
if (mode == GPM_IDLE_MODE_BLANK)
egg_test_success (test, NULL);
else
- egg_test_failed (test, "mode: %s", gpm_idle_mode_to_text (mode));
+ egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
/************************************************************/
g_print ("**********************\n");
@@ -608,7 +608,7 @@ gpm_idle_test (gpointer data)
if (_mode == GPM_IDLE_MODE_NORMAL)
egg_test_success (test, NULL);
else
- egg_test_failed (test, "mode: %s", gpm_idle_mode_to_text (mode));
+ egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
/************************************************************/
egg_test_title (test, "check current mode");
@@ -616,7 +616,7 @@ gpm_idle_test (gpointer data)
if (mode == GPM_IDLE_MODE_NORMAL)
egg_test_success (test, NULL);
else
- egg_test_failed (test, "mode: %s", gpm_idle_mode_to_text (mode));
+ egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
/************************************************************/
egg_test_title (test, "check x_idle");
@@ -639,7 +639,7 @@ gpm_idle_test (gpointer data)
if (mode == GPM_IDLE_MODE_DIM)
egg_test_success (test, NULL);
else
- egg_test_failed (test, "mode: %s", gpm_idle_mode_to_text (mode));
+ egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
/************************************************************/
egg_test_title (test, "check x_idle");
@@ -654,7 +654,7 @@ gpm_idle_test (gpointer data)
if (mode == GPM_IDLE_MODE_BLANK)
egg_test_success (test, NULL);
else
- egg_test_failed (test, "mode: %s", gpm_idle_mode_to_text (mode));
+ egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
/************************************************************/
egg_test_title (test, "set dpms off");
@@ -673,7 +673,7 @@ gpm_idle_test (gpointer data)
if (mode == GPM_IDLE_MODE_BLANK)
egg_test_success (test, NULL);
else
- egg_test_failed (test, "mode: %s", gpm_idle_mode_to_text (mode));
+ egg_test_failed (test, "mode: %s", gpm_idle_mode_to_string (mode));
/************************************************************/
egg_test_title (test, "check x_idle");
diff --git a/src/gpm-manager.c b/src/gpm-manager.c
index 8e4a18e..0f3c0bb 100644
--- a/src/gpm-manager.c
+++ b/src/gpm-manager.c
@@ -40,7 +40,7 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <gconf/gconf-client.h>
#include <canberra-gtk.h>
-#include <devkit-power-gobject/devicekit-power.h>
+#include <libupower-glib/upower.h>
#include <libnotify/notify.h>
#include "egg-debug.h"
@@ -93,7 +93,7 @@ struct GpmManagerPrivate
guint32 screensaver_lid_throttle_id;
guint32 critical_alert_timeout_id;
ca_proplist *critical_alert_loop_props;
- DkpClient *client;
+ UpClient *client;
gboolean on_battery;
gboolean just_resumed;
GtkStatusIcon *status_icon;
@@ -980,7 +980,7 @@ gpm_manager_get_spindown_timeout (GpmManager *manager)
* gpm_manager_client_changed_cb:
**/
static void
-gpm_manager_client_changed_cb (DkpClient *client, GpmManager *manager)
+gpm_manager_client_changed_cb (UpClient *client, GpmManager *manager)
{
gboolean event_when_closed;
gint timeout;
@@ -1213,7 +1213,7 @@ gpm_manager_perhaps_recall_delay_cb (GpmManager *manager)
* gpm_manager_engine_perhaps_recall_cb:
*/
static void
-gpm_manager_engine_perhaps_recall_cb (GpmEngine *engine, DkpDevice *device, gchar *oem_vendor, gchar *website, GpmManager *manager)
+gpm_manager_engine_perhaps_recall_cb (GpmEngine *engine, UpDevice *device, gchar *oem_vendor, gchar *website, GpmManager *manager)
{
gboolean ret;
@@ -1259,7 +1259,7 @@ gpm_manager_engine_summary_changed_cb (GpmEngine *engine, gchar *summary, GpmMan
* gpm_manager_engine_low_capacity_cb:
*/
static void
-gpm_manager_engine_low_capacity_cb (GpmEngine *engine, DkpDevice *device, GpmManager *manager)
+gpm_manager_engine_low_capacity_cb (GpmEngine *engine, UpDevice *device, GpmManager *manager)
{
gchar *message = NULL;
const gchar *title;
@@ -1296,9 +1296,9 @@ out:
* gpm_manager_engine_fully_charged_cb:
*/
static void
-gpm_manager_engine_fully_charged_cb (GpmEngine *engine, DkpDevice *device, GpmManager *manager)
+gpm_manager_engine_fully_charged_cb (GpmEngine *engine, UpDevice *device, GpmManager *manager)
{
- DkpDeviceType type;
+ UpDeviceKind kind;
gchar *native_path = NULL;
gboolean ret;
guint plural = 1;
@@ -1319,11 +1319,11 @@ gpm_manager_engine_fully_charged_cb (GpmEngine *engine, DkpDevice *device, GpmMa
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
"native-path", &native_path,
NULL);
- if (type == DKP_DEVICE_TYPE_BATTERY) {
+ if (kind == UP_DEVICE_KIND_BATTERY) {
/* is this a dummy composite device, which is plural? */
if (g_str_has_prefix (native_path, "dummy"))
plural = 2;
@@ -1346,9 +1346,9 @@ out:
* gpm_manager_engine_discharging_cb:
*/
static void
-gpm_manager_engine_discharging_cb (GpmEngine *engine, DkpDevice *device, GpmManager *manager)
+gpm_manager_engine_discharging_cb (GpmEngine *engine, UpDevice *device, GpmManager *manager)
{
- DkpDeviceType type;
+ UpDeviceKind kind;
gboolean ret;
const gchar *title;
const gchar *message;
@@ -1356,7 +1356,7 @@ gpm_manager_engine_discharging_cb (GpmEngine *engine, DkpDevice *device, GpmMana
gint64 time_to_empty;
gchar *remaining_text = NULL;
gchar *icon = NULL;
- const gchar *type_desc;
+ const gchar *kind_desc;
/* only action this if specified in gconf */
ret = gconf_client_get_bool (manager->priv->conf, GPM_CONF_NOTIFY_DISCHARGING, NULL);
@@ -1367,7 +1367,7 @@ gpm_manager_engine_discharging_cb (GpmEngine *engine, DkpDevice *device, GpmMana
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
"percentage", &percentage,
"time-to-empty", &time_to_empty,
NULL);
@@ -1375,9 +1375,9 @@ gpm_manager_engine_discharging_cb (GpmEngine *engine, DkpDevice *device, GpmMana
/* only show text if there is a valid time */
if (time_to_empty > 0)
remaining_text = gpm_get_timestring (time_to_empty);
- type_desc = gpm_device_type_to_localised_text (type, 1);
+ kind_desc = gpm_device_kind_to_localised_text (kind, 1);
- if (type == DKP_DEVICE_TYPE_BATTERY) {
+ if (kind == UP_DEVICE_KIND_BATTERY) {
/* TRANSLATORS: laptop battery is now discharging */
title = _("Battery Discharging");
@@ -1387,9 +1387,9 @@ gpm_manager_engine_discharging_cb (GpmEngine *engine, DkpDevice *device, GpmMana
} else {
/* TRANSLATORS: the device is discharging, but we only have a percentage */
message = g_strdup_printf (_("%s discharging (%.1f%%)"),
- type_desc, percentage);
+ kind_desc, percentage);
}
- } else if (type == DKP_DEVICE_TYPE_UPS) {
+ } else if (kind == UP_DEVICE_KIND_UPS) {
/* TRANSLATORS: UPS is now discharging */
title = _("UPS Discharging");
@@ -1399,7 +1399,7 @@ gpm_manager_engine_discharging_cb (GpmEngine *engine, DkpDevice *device, GpmMana
} else {
/* TRANSLATORS: the device is discharging, but we only have a percentage */
message = g_strdup_printf (_("%s discharging (%.1f%%)"),
- type_desc, percentage);
+ kind_desc, percentage);
}
} else {
/* nothing else of interest */
@@ -1422,8 +1422,8 @@ out:
static gboolean
gpm_manager_engine_just_laptop_battery (GpmManager *manager)
{
- DkpDevice *device;
- DkpDeviceType type;
+ UpDevice *device;
+ UpDeviceKind kind;
GPtrArray *array;
gboolean ret = TRUE;
guint i;
@@ -1433,8 +1433,8 @@ gpm_manager_engine_just_laptop_battery (GpmManager *manager)
array = gpm_engine_get_devices (manager->priv->engine);
for (i=0; i<array->len; i++) {
device = g_ptr_array_index (array, i);
- g_object_get (device, "type", &type, NULL);
- if (type != DKP_DEVICE_TYPE_BATTERY) {
+ g_object_get (device, "kind", &kind, NULL);
+ if (kind != UP_DEVICE_KIND_BATTERY) {
ret = FALSE;
break;
}
@@ -1447,33 +1447,33 @@ gpm_manager_engine_just_laptop_battery (GpmManager *manager)
* gpm_manager_engine_charge_low_cb:
*/
static void
-gpm_manager_engine_charge_low_cb (GpmEngine *engine, DkpDevice *device, GpmManager *manager)
+gpm_manager_engine_charge_low_cb (GpmEngine *engine, UpDevice *device, GpmManager *manager)
{
const gchar *title = NULL;
gchar *message = NULL;
gchar *remaining_text;
gchar *icon = NULL;
- DkpDeviceType type;
+ UpDeviceKind kind;
gdouble percentage;
gint64 time_to_empty;
gboolean ret;
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
"percentage", &percentage,
"time-to-empty", &time_to_empty,
NULL);
/* check to see if the batteries have not noticed we are on AC */
- if (type == DKP_DEVICE_TYPE_BATTERY) {
+ if (kind == UP_DEVICE_KIND_BATTERY) {
if (!manager->priv->on_battery) {
egg_warning ("ignoring critically low message as we are not on battery power");
goto out;
}
}
- if (type == DKP_DEVICE_TYPE_BATTERY) {
+ if (kind == UP_DEVICE_KIND_BATTERY) {
/* if the user has no other batteries, drop the "Laptop" wording */
ret = gpm_manager_engine_just_laptop_battery (manager);
@@ -1481,7 +1481,7 @@ gpm_manager_engine_charge_low_cb (GpmEngine *engine, DkpDevice *device, GpmManag
/* TRANSLATORS: laptop battery low, and we only have one battery */
title = _("Battery low");
} else {
- /* TRANSLATORS: laptop battery low, and we have more than one type of battery */
+ /* TRANSLATORS: laptop battery low, and we have more than one kind of battery */
title = _("Laptop battery low");
}
@@ -1490,7 +1490,7 @@ gpm_manager_engine_charge_low_cb (GpmEngine *engine, DkpDevice *device, GpmManag
/* TRANSLATORS: tell the user how much time they have got */
message = g_strdup_printf (_("Approximately <b>%s</b> remaining (%.1f%%)"), remaining_text, percentage);
- } else if (type == DKP_DEVICE_TYPE_UPS) {
+ } else if (kind == UP_DEVICE_KIND_UPS) {
/* TRANSLATORS: UPS is starting to get a little low */
title = _("UPS low");
remaining_text = gpm_get_timestring (time_to_empty);
@@ -1498,28 +1498,28 @@ gpm_manager_engine_charge_low_cb (GpmEngine *engine, DkpDevice *device, GpmManag
/* TRANSLATORS: tell the user how much time they have got */
message = g_strdup_printf (_("You have approximately <b>%s</b> of remaining UPS backup power (%.1f%%)"),
remaining_text, percentage);
- } else if (type == DKP_DEVICE_TYPE_MOUSE) {
+ } else if (kind == UP_DEVICE_KIND_MOUSE) {
/* TRANSLATORS: mouse is getting a little low */
title = _("Mouse battery low");
/* TRANSLATORS: tell user more details */
message = g_strdup_printf (_("The wireless mouse attached to this computer is low in power (%.1f%%)"), percentage);
- } else if (type == DKP_DEVICE_TYPE_KEYBOARD) {
+ } else if (kind == UP_DEVICE_KIND_KEYBOARD) {
/* TRANSLATORS: keyboard is getting a little low */
title = _("Keyboard battery low");
/* TRANSLATORS: tell user more details */
message = g_strdup_printf (_("The wireless keyboard attached to this computer is low in power (%.1f%%)"), percentage);
- } else if (type == DKP_DEVICE_TYPE_PDA) {
+ } else if (kind == UP_DEVICE_KIND_PDA) {
/* TRANSLATORS: PDA is getting a little low */
title = _("PDA battery low");
/* TRANSLATORS: tell user more details */
message = g_strdup_printf (_("The PDA attached to this computer is low in power (%.1f%%)"), percentage);
- } else if (type == DKP_DEVICE_TYPE_PHONE) {
+ } else if (kind == UP_DEVICE_KIND_PHONE) {
/* TRANSLATORS: cell phone (mobile) is getting a little low */
title = _("Cell phone battery low");
@@ -1540,13 +1540,13 @@ out:
* gpm_manager_engine_charge_critical_cb:
*/
static void
-gpm_manager_engine_charge_critical_cb (GpmEngine *engine, DkpDevice *device, GpmManager *manager)
+gpm_manager_engine_charge_critical_cb (GpmEngine *engine, UpDevice *device, GpmManager *manager)
{
const gchar *title = NULL;
gchar *message = NULL;
gchar *action;
gchar *icon = NULL;
- DkpDeviceType type;
+ UpDeviceKind kind;
gdouble percentage;
gint64 time_to_empty;
GpmActionPolicy policy;
@@ -1554,25 +1554,25 @@ gpm_manager_engine_charge_critical_cb (GpmEngine *engine, DkpDevice *device, Gpm
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
"percentage", &percentage,
"time-to-empty", &time_to_empty,
NULL);
/* check to see if the batteries have not noticed we are on AC */
- if (type == DKP_DEVICE_TYPE_BATTERY) {
+ if (kind == UP_DEVICE_KIND_BATTERY) {
if (!manager->priv->on_battery) {
egg_warning ("ignoring critically low message as we are not on battery power");
goto out;
}
}
- if (type == DKP_DEVICE_TYPE_BATTERY) {
+ if (kind == UP_DEVICE_KIND_BATTERY) {
/* if the user has no other batteries, drop the "Laptop" wording */
ret = gpm_manager_engine_just_laptop_battery (manager);
if (ret) {
- /* TRANSLATORS: laptop battery critically low, and only have one type of battery */
+ /* TRANSLATORS: laptop battery critically low, and only have one kind of battery */
title = _("Battery critically low");
} else {
/* TRANSLATORS: laptop battery critically low, and we have more than one type of battery */
@@ -1602,7 +1602,7 @@ gpm_manager_engine_charge_critical_cb (GpmEngine *engine, DkpDevice *device, Gpm
}
g_free (action);
- } else if (type == DKP_DEVICE_TYPE_UPS) {
+ } else if (kind == UP_DEVICE_KIND_UPS) {
gchar *remaining_text;
/* TRANSLATORS: the UPS is very low */
@@ -1614,7 +1614,7 @@ gpm_manager_engine_charge_critical_cb (GpmEngine *engine, DkpDevice *device, Gpm
"Restore AC power to your computer to avoid losing data."),
remaining_text, percentage);
g_free (remaining_text);
- } else if (type == DKP_DEVICE_TYPE_MOUSE) {
+ } else if (kind == UP_DEVICE_KIND_MOUSE) {
/* TRANSLATORS: the mouse battery is very low */
title = _("Mouse battery low");
@@ -1622,7 +1622,7 @@ gpm_manager_engine_charge_critical_cb (GpmEngine *engine, DkpDevice *device, Gpm
message = g_strdup_printf (_("The wireless mouse attached to this computer is very low in power (%.1f%%). "
"This device will soon stop functioning if not charged."),
percentage);
- } else if (type == DKP_DEVICE_TYPE_KEYBOARD) {
+ } else if (kind == UP_DEVICE_KIND_KEYBOARD) {
/* TRANSLATORS: the keyboard battery is very low */
title = _("Keyboard battery low");
@@ -1630,7 +1630,7 @@ gpm_manager_engine_charge_critical_cb (GpmEngine *engine, DkpDevice *device, Gpm
message = g_strdup_printf (_("The wireless keyboard attached to this computer is very low in power (%.1f%%). "
"This device will soon stop functioning if not charged."),
percentage);
- } else if (type == DKP_DEVICE_TYPE_PDA) {
+ } else if (kind == UP_DEVICE_KIND_PDA) {
/* TRANSLATORS: the PDA battery is very low */
title = _("PDA battery low");
@@ -1639,7 +1639,7 @@ gpm_manager_engine_charge_critical_cb (GpmEngine *engine, DkpDevice *device, Gpm
message = g_strdup_printf (_("The PDA attached to this computer is very low in power (%.1f%%). "
"This device will soon stop functioning if not charged."),
percentage);
- } else if (type == DKP_DEVICE_TYPE_PHONE) {
+ } else if (kind == UP_DEVICE_KIND_PHONE) {
/* TRANSLATORS: the cell battery is very low */
title = _("Cell phone battery low");
@@ -1654,10 +1654,10 @@ gpm_manager_engine_charge_critical_cb (GpmEngine *engine, DkpDevice *device, Gpm
icon = gpm_upower_get_device_icon (device);
gpm_manager_notify (manager, &manager->priv->notification_warning_low, title, message, GPM_MANAGER_NOTIFY_TIMEOUT_NEVER, icon, NOTIFY_URGENCY_CRITICAL);
- switch (type) {
+ switch (kind) {
- case DKP_DEVICE_TYPE_BATTERY:
- case DKP_DEVICE_TYPE_UPS:
+ case UP_DEVICE_KIND_BATTERY:
+ case UP_DEVICE_KIND_UPS:
egg_debug ("critical charge level reached, starting sound loop");
gpm_manager_play_loop_start (manager,
GPM_MANAGER_SOUND_BATTERY_LOW,
@@ -1677,29 +1677,29 @@ out:
* gpm_manager_engine_charge_action_cb:
*/
static void
-gpm_manager_engine_charge_action_cb (GpmEngine *engine, DkpDevice *device, GpmManager *manager)
+gpm_manager_engine_charge_action_cb (GpmEngine *engine, UpDevice *device, GpmManager *manager)
{
const gchar *title = NULL;
gchar *action;
gchar *message = NULL;
gchar *icon = NULL;
- DkpDeviceType type;
+ UpDeviceKind kind;
GpmActionPolicy policy;
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
NULL);
/* check to see if the batteries have not noticed we are on AC */
- if (type == DKP_DEVICE_TYPE_BATTERY) {
+ if (kind == UP_DEVICE_KIND_BATTERY) {
if (!manager->priv->on_battery) {
egg_warning ("ignoring critically low message as we are not on battery power");
goto out;
}
}
- if (type == DKP_DEVICE_TYPE_BATTERY) {
+ if (kind == UP_DEVICE_KIND_BATTERY) {
/* TRANSLATORS: laptop battery is really, really, low */
title = _("Laptop battery critically low");
@@ -1738,7 +1738,7 @@ gpm_manager_engine_charge_action_cb (GpmEngine *engine, DkpDevice *device, GpmMa
/* wait 20 seconds for user-panic */
g_timeout_add_seconds (20, (GSourceFunc) manager_critical_action_do, manager);
- } else if (type == DKP_DEVICE_TYPE_UPS) {
+ } else if (kind == UP_DEVICE_KIND_UPS) {
/* TRANSLATORS: UPS is really, really, low */
title = _("UPS critically low");
@@ -1879,7 +1879,7 @@ gpm_manager_init (GpmManager *manager)
manager->priv->notification_fully_charged = NULL;
manager->priv->disks = gpm_disks_new ();
manager->priv->conf = gconf_client_get_default ();
- manager->priv->client = dkp_client_new ();
+ manager->priv->client = up_client_new ();
g_signal_connect (manager->priv->client, "changed",
G_CALLBACK (gpm_manager_client_changed_cb), manager);
diff --git a/src/gpm-prefs-core.c b/src/gpm-prefs-core.c
index 42dfadc..e9c7fda 100644
--- a/src/gpm-prefs-core.c
+++ b/src/gpm-prefs-core.c
@@ -31,7 +31,7 @@
#include <math.h>
#include <string.h>
#include <gconf/gconf-client.h>
-#include <devkit-power-gobject/devicekit-power.h>
+#include <libupower-glib/upower.h>
#include "egg-debug.h"
#include "egg-console-kit.h"
@@ -48,7 +48,7 @@ static void gpm_prefs_finalize (GObject *object);
struct GpmPrefsPrivate
{
- DkpClient *client;
+ UpClient *client;
GtkBuilder *builder;
gboolean has_batteries;
gboolean has_lcd;
@@ -905,7 +905,7 @@ gpm_prefs_init (GpmPrefs *prefs)
prefs->priv = GPM_PREFS_GET_PRIVATE (prefs);
- prefs->priv->client = dkp_client_new ();
+ prefs->priv->client = up_client_new ();
prefs->priv->console = egg_console_kit_new ();
prefs->priv->conf = gconf_client_get_default ();
/* watch gnome-power-manager keys */
@@ -932,7 +932,7 @@ gpm_prefs_init (GpmPrefs *prefs)
prefs->priv->can_shutdown = TRUE;
egg_console_kit_can_stop (prefs->priv->console, &prefs->priv->can_shutdown, NULL);
- /* get values from DkpClient */
+ /* get values from UpClient */
g_object_get (prefs->priv->client,
"can-suspend", &prefs->priv->can_suspend,
"can-hibernate", &prefs->priv->can_hibernate,
diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c
index f92ea16..bd98f89 100644
--- a/src/gpm-statistics.c
+++ b/src/gpm-statistics.c
@@ -29,7 +29,7 @@
#include <gtk/gtk.h>
#include <dbus/dbus-glib.h>
#include <gconf/gconf-client.h>
-#include <devkit-power-gobject/devicekit-power.h>
+#include <libupower-glib/upower.h>
#include "egg-debug.h"
#include "egg-color.h"
@@ -51,7 +51,7 @@ static const gchar *stats_type;
static guint history_time;
static GConfClient *gconf_client;
static gfloat sigma_smoothing = 0.0f;
-static DkpWakeups *wakeups = NULL;
+static UpWakeups *wakeups = NULL;
static GtkWidget *graph_history = NULL;
static GtkWidget *graph_statistics = NULL;
@@ -272,10 +272,10 @@ gpm_stats_update_smooth_data (GPtrArray *list)
}
/**
- * gpm_stats_time_to_text:
+ * gpm_stats_time_to_string:
**/
static gchar *
-gpm_stats_time_to_text (gint seconds)
+gpm_stats_time_to_string (gint seconds)
{
gfloat value = seconds;
@@ -303,10 +303,10 @@ gpm_stats_time_to_text (gint seconds)
}
/**
- * gpm_stats_bool_to_text:
+ * gpm_stats_bool_to_string:
**/
static const gchar *
-gpm_stats_bool_to_text (gboolean ret)
+gpm_stats_bool_to_string (gboolean ret)
{
return ret ? _("Yes") : _("No");
}
@@ -315,13 +315,13 @@ gpm_stats_bool_to_text (gboolean ret)
* gpm_stats_get_printable_device_path:
**/
static gchar *
-gpm_stats_get_printable_device_path (DkpDevice *device)
+gpm_stats_get_printable_device_path (UpDevice *device)
{
const gchar *object_path;
gchar *device_path = NULL;
/* get object path */
- object_path = dkp_device_get_object_path (device);
+ object_path = up_device_get_object_path (device);
if (object_path != NULL)
device_path = g_filename_display_basename (object_path);
@@ -332,16 +332,16 @@ gpm_stats_get_printable_device_path (DkpDevice *device)
* gpm_stats_update_info_page_details:
**/
static void
-gpm_stats_update_info_page_details (DkpDevice *device)
+gpm_stats_update_info_page_details (UpDevice *device)
{
struct tm *time_tm;
time_t t;
gchar time_buf[256];
gchar *text;
guint refreshed;
- DkpDeviceType type;
- DkpDeviceState state;
- DkpDeviceTechnology technology;
+ UpDeviceKind kind;
+ UpDeviceState state;
+ UpDeviceTechnology technology;
gdouble percentage;
gdouble capacity;
gdouble energy;
@@ -366,7 +366,7 @@ gpm_stats_update_info_page_details (DkpDevice *device)
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
"state", &state,
"percentage", &percentage,
"online", &online,
@@ -399,34 +399,34 @@ gpm_stats_update_info_page_details (DkpDevice *device)
gpm_stats_add_info_data (_("Device"), device_path);
g_free (device_path);
- gpm_stats_add_info_data (_("Type"), gpm_device_type_to_localised_text (type, 1));
+ gpm_stats_add_info_data (_("Type"), gpm_device_kind_to_localised_text (kind, 1));
if (vendor != NULL && vendor[0] != '\0')
gpm_stats_add_info_data (_("Vendor"), vendor);
if (model != NULL && model[0] != '\0')
gpm_stats_add_info_data (_("Model"), model);
if (serial != NULL && serial[0] != '\0')
gpm_stats_add_info_data (_("Serial number"), serial);
- gpm_stats_add_info_data (_("Supply"), gpm_stats_bool_to_text (power_supply));
+ gpm_stats_add_info_data (_("Supply"), gpm_stats_bool_to_string (power_supply));
refreshed = (int) (time (NULL) - update_time);
text = g_strdup_printf (ngettext ("%d second", "%d seconds", refreshed), refreshed);
gpm_stats_add_info_data (_("Refreshed"), text);
g_free (text);
- if (type == DKP_DEVICE_TYPE_BATTERY ||
- type == DKP_DEVICE_TYPE_MOUSE ||
- type == DKP_DEVICE_TYPE_KEYBOARD ||
- type == DKP_DEVICE_TYPE_UPS)
- gpm_stats_add_info_data (_("Present"), gpm_stats_bool_to_text (is_present));
- if (type == DKP_DEVICE_TYPE_BATTERY ||
- type == DKP_DEVICE_TYPE_MOUSE ||
- type == DKP_DEVICE_TYPE_KEYBOARD)
- gpm_stats_add_info_data (_("Rechargeable"), gpm_stats_bool_to_text (is_rechargeable));
- if (type == DKP_DEVICE_TYPE_BATTERY ||
- type == DKP_DEVICE_TYPE_MOUSE ||
- type == DKP_DEVICE_TYPE_KEYBOARD)
- gpm_stats_add_info_data (_("State"), dkp_device_state_to_text (state));
- if (type == DKP_DEVICE_TYPE_BATTERY) {
+ if (kind == UP_DEVICE_KIND_BATTERY ||
+ kind == UP_DEVICE_KIND_MOUSE ||
+ kind == UP_DEVICE_KIND_KEYBOARD ||
+ kind == UP_DEVICE_KIND_UPS)
+ gpm_stats_add_info_data (_("Present"), gpm_stats_bool_to_string (is_present));
+ if (kind == UP_DEVICE_KIND_BATTERY ||
+ kind == UP_DEVICE_KIND_MOUSE ||
+ kind == UP_DEVICE_KIND_KEYBOARD)
+ gpm_stats_add_info_data (_("Rechargeable"), gpm_stats_bool_to_string (is_rechargeable));
+ if (kind == UP_DEVICE_KIND_BATTERY ||
+ kind == UP_DEVICE_KIND_MOUSE ||
+ kind == UP_DEVICE_KIND_KEYBOARD)
+ gpm_stats_add_info_data (_("State"), up_device_state_to_string (state));
+ if (kind == UP_DEVICE_KIND_BATTERY) {
text = g_strdup_printf ("%.1f Wh", energy);
gpm_stats_add_info_data (_("Energy"), text);
g_free (text);
@@ -440,49 +440,49 @@ gpm_stats_update_info_page_details (DkpDevice *device)
gpm_stats_add_info_data (_("Energy (design)"), text);
g_free (text);
}
- if (type == DKP_DEVICE_TYPE_BATTERY ||
- type == DKP_DEVICE_TYPE_MONITOR) {
+ if (kind == UP_DEVICE_KIND_BATTERY ||
+ kind == UP_DEVICE_KIND_MONITOR) {
text = g_strdup_printf ("%.1f W", energy_rate);
gpm_stats_add_info_data (_("Rate"), text);
g_free (text);
}
- if (type == DKP_DEVICE_TYPE_UPS ||
- type == DKP_DEVICE_TYPE_BATTERY ||
- type == DKP_DEVICE_TYPE_MONITOR) {
+ if (kind == UP_DEVICE_KIND_UPS ||
+ kind == UP_DEVICE_KIND_BATTERY ||
+ kind == UP_DEVICE_KIND_MONITOR) {
text = g_strdup_printf ("%.1f V", voltage);
gpm_stats_add_info_data (_("Voltage"), text);
g_free (text);
}
- if (type == DKP_DEVICE_TYPE_BATTERY ||
- type == DKP_DEVICE_TYPE_UPS) {
+ if (kind == UP_DEVICE_KIND_BATTERY ||
+ kind == UP_DEVICE_KIND_UPS) {
if (time_to_full >= 0) {
- text = gpm_stats_time_to_text (time_to_full);
+ text = gpm_stats_time_to_string (time_to_full);
gpm_stats_add_info_data (_("Time to full"), text);
g_free (text);
}
if (time_to_empty >= 0) {
- text = gpm_stats_time_to_text (time_to_empty);
+ text = gpm_stats_time_to_string (time_to_empty);
gpm_stats_add_info_data (_("Time to empty"), text);
g_free (text);
}
}
- if (type == DKP_DEVICE_TYPE_BATTERY ||
- type == DKP_DEVICE_TYPE_MOUSE ||
- type == DKP_DEVICE_TYPE_KEYBOARD ||
- type == DKP_DEVICE_TYPE_UPS) {
+ if (kind == UP_DEVICE_KIND_BATTERY ||
+ kind == UP_DEVICE_KIND_MOUSE ||
+ kind == UP_DEVICE_KIND_KEYBOARD ||
+ kind == UP_DEVICE_KIND_UPS) {
text = g_strdup_printf ("%.1f%%", percentage);
gpm_stats_add_info_data (_("Percentage"), text);
g_free (text);
}
- if (type == DKP_DEVICE_TYPE_BATTERY) {
+ if (kind == UP_DEVICE_KIND_BATTERY) {
text = g_strdup_printf ("%.1f%%", capacity);
gpm_stats_add_info_data (_("Capacity"), text);
g_free (text);
}
- if (type == DKP_DEVICE_TYPE_BATTERY)
- gpm_stats_add_info_data (_("Technology"), gpm_device_technology_to_localised_text (technology));
- if (type == DKP_DEVICE_TYPE_LINE_POWER)
- gpm_stats_add_info_data (_("Online"), gpm_stats_bool_to_text (online));
+ if (kind == UP_DEVICE_KIND_BATTERY)
+ gpm_stats_add_info_data (_("Technology"), gpm_device_technology_to_localised_string (technology));
+ if (kind == UP_DEVICE_KIND_LINE_POWER)
+ gpm_stats_add_info_data (_("Online"), gpm_stats_bool_to_string (online));
g_free (vendor);
g_free (serial);
@@ -521,11 +521,11 @@ gpm_stats_set_graph_data (GtkWidget *widget, GPtrArray *data, gboolean use_smoot
* gpm_stats_update_info_page_history:
**/
static void
-gpm_stats_update_info_page_history (DkpDevice *device)
+gpm_stats_update_info_page_history (UpDevice *device)
{
GPtrArray *array;
guint i;
- DkpHistoryObj *hobj;
+ UpHistoryItem *item;
GtkWidget *widget;
gboolean checked;
gboolean points;
@@ -565,7 +565,7 @@ gpm_stats_update_info_page_history (DkpDevice *device)
}
widget = GTK_WIDGET (gtk_builder_get_object (builder, "label_history_nodata"));
- array = dkp_device_get_history (device, history_type, history_time, 150, NULL);
+ array = up_device_get_history_sync (device, history_type, history_time, 150, NULL, NULL);
if (array == NULL) {
/* show no data label and hide graph */
gtk_widget_hide (graph_history);
@@ -581,25 +581,23 @@ gpm_stats_update_info_page_history (DkpDevice *device)
offset = timeval.tv_sec;
for (i=0; i<array->len; i++) {
- hobj = (DkpHistoryObj *) g_ptr_array_index (array, i);
+ item = (UpHistoryItem *) g_ptr_array_index (array, i);
/* abandon this point */
- if (hobj->state == DKP_DEVICE_STATE_UNKNOWN)
+ if (up_history_item_get_state (item) == UP_DEVICE_STATE_UNKNOWN)
continue;
point = gpm_point_obj_new ();
- point->x = (gint32) hobj->time - offset;
- point->y = hobj->value;
- if (hobj->state == DKP_DEVICE_STATE_CHARGING)
+ point->x = (gint32) up_history_item_get_time (item) - offset;
+ point->y = up_history_item_get_value (item);
+ if (up_history_item_get_state (item) == UP_DEVICE_STATE_CHARGING)
point->color = egg_color_from_rgb (255, 0, 0);
- else if (hobj->state == DKP_DEVICE_STATE_DISCHARGING)
+ else if (up_history_item_get_state (item) == UP_DEVICE_STATE_DISCHARGING)
point->color = egg_color_from_rgb (0, 0, 255);
-#if DKP_CHECK_VERSION(0x009)
- else if (hobj->state == DKP_DEVICE_STATE_PENDING_CHARGE)
+ else if (up_history_item_get_state (item) == UP_DEVICE_STATE_PENDING_CHARGE)
point->color = egg_color_from_rgb (200, 0, 0);
- else if (hobj->state == DKP_DEVICE_STATE_PENDING_DISCHARGE)
+ else if (up_history_item_get_state (item) == UP_DEVICE_STATE_PENDING_DISCHARGE)
point->color = egg_color_from_rgb (0, 0, 200);
-#endif
else {
if (g_strcmp0 (history_type, GPM_HISTORY_RATE_VALUE) == 0)
point->color = egg_color_from_rgb (255, 255, 255);
@@ -629,11 +627,11 @@ out:
* gpm_stats_update_info_page_stats:
**/
static void
-gpm_stats_update_info_page_stats (DkpDevice *device)
+gpm_stats_update_info_page_stats (UpDevice *device)
{
GPtrArray *array;
guint i;
- DkpStatsObj *sobj;
+ UpStatsItem *item;
GtkWidget *widget;
gboolean checked;
gboolean points;
@@ -676,7 +674,7 @@ gpm_stats_update_info_page_stats (DkpDevice *device)
}
widget = GTK_WIDGET (gtk_builder_get_object (builder, "label_stats_nodata"));
- array = dkp_device_get_statistics (device, type, NULL);
+ array = up_device_get_statistics_sync (device, type, NULL, NULL);
if (array == NULL) {
/* show no data label and hide graph */
gtk_widget_hide (graph_statistics);
@@ -689,13 +687,13 @@ gpm_stats_update_info_page_stats (DkpDevice *device)
gtk_widget_show (graph_statistics);
for (i=0; i<array->len; i++) {
- sobj = (DkpStatsObj *) g_ptr_array_index (array, i);
+ item = (UpStatsItem *) g_ptr_array_index (array, i);
point = gpm_point_obj_new ();
point->x = i;
if (use_data)
- point->y = sobj->value;
+ point->y = up_stats_item_get_value (item);
else
- point->y = sobj->accuracy;
+ point->y = up_stats_item_get_accuracy (item);
point->color = egg_color_from_rgb (255, 0, 0);
g_ptr_array_add (new, point);
}
@@ -720,7 +718,7 @@ out:
* gpm_stats_update_info_data_page:
**/
static void
-gpm_stats_update_info_data_page (DkpDevice *device, gint page)
+gpm_stats_update_info_data_page (UpDevice *device, gint page)
{
if (page == 0)
gpm_stats_update_info_page_details (device);
@@ -734,7 +732,7 @@ gpm_stats_update_info_data_page (DkpDevice *device, gint page)
* gpm_stats_update_info_data:
**/
static void
-gpm_stats_update_info_data (DkpDevice *device)
+gpm_stats_update_info_data (UpDevice *device)
{
gint page;
GtkNotebook *notebook;
@@ -783,7 +781,7 @@ gpm_stats_update_info_data (DkpDevice *device)
* gpm_stats_format_cmdline:
**/
static gchar *
-gpm_stats_format_cmdline (const DkpWakeupsObj *obj)
+gpm_stats_format_cmdline (UpWakeupItem *item)
{
gchar *found;
gchar *temp = NULL;
@@ -791,41 +789,41 @@ gpm_stats_format_cmdline (const DkpWakeupsObj *obj)
const gchar *temp_ptr;
/* nothing */
- if (obj->cmdline == NULL) {
+ if (up_wakeup_item_get_cmdline (item) == NULL) {
/* TRANSLATORS: the command line was not provided */
temp_ptr = _("No data");
goto out;
}
/* common kernel cmd names */
- if (g_strcmp0 (obj->cmdline, "insmod") == 0) {
+ if (g_strcmp0 (up_wakeup_item_get_cmdline (item), "insmod") == 0) {
/* TRANSLATORS: kernel module, usually a device driver */
temp_ptr = _("Kernel module");
goto out;
}
- if (g_strcmp0 (obj->cmdline, "modprobe") == 0) {
+ if (g_strcmp0 (up_wakeup_item_get_cmdline (item), "modprobe") == 0) {
/* TRANSLATORS: kernel module, usually a device driver */
temp_ptr = _("Kernel module");
goto out;
}
- if (g_strcmp0 (obj->cmdline, "swapper") == 0) {
+ if (g_strcmp0 (up_wakeup_item_get_cmdline (item), "swapper") == 0) {
/* TRANSLATORS: kernel housekeeping */
temp_ptr = _("Kernel core");
goto out;
}
- if (g_strcmp0 (obj->cmdline, "kernel-ipi") == 0) {
+ if (g_strcmp0 (up_wakeup_item_get_cmdline (item), "kernel-ipi") == 0) {
/* TRANSLATORS: interrupt between processors */
temp_ptr = _("Interprocessor interrupt");
goto out;
}
- if (g_strcmp0 (obj->cmdline, "interrupt") == 0) {
+ if (g_strcmp0 (up_wakeup_item_get_cmdline (item), "interrupt") == 0) {
/* TRANSLATORS: unknown interrupt */
temp_ptr = _("Interrupt");
goto out;
}
/* truncate at first space or ':' */
- temp = g_strdup (obj->cmdline);
+ temp = g_strdup (up_wakeup_item_get_cmdline (item));
found = strstr (temp, ":");
if (found != NULL)
*found = '\0';
@@ -842,7 +840,7 @@ gpm_stats_format_cmdline (const DkpWakeupsObj *obj)
out:
/* format command line */
- if (obj->is_userspace)
+ if (up_wakeup_item_get_is_userspace (item))
cmdline = g_markup_escape_text (temp_ptr, -1);
else
cmdline = g_markup_printf_escaped ("<i>%s</i>", temp_ptr);
@@ -856,83 +854,87 @@ out:
* gpm_stats_format_details:
**/
static gchar *
-gpm_stats_format_details (const DkpWakeupsObj *obj)
+gpm_stats_format_details (UpWakeupItem *item)
{
gchar *details;
+ const gchar *data;
+
+ /* get this once to avoid a load of derefs */
+ data = up_wakeup_item_get_details (item);
/* replace common driver names */
- if (g_strcmp0 (obj->details, "i8042") == 0) {
+ if (g_strcmp0 (data, "i8042") == 0) {
/* TRANSLATORS: the keyboard and mouse device event */
details = g_strdup (_("PS/2 keyboard/mouse/touchpad"));
- } else if (g_strcmp0 (obj->details, "acpi") == 0) {
+ } else if (g_strcmp0 (data, "acpi") == 0) {
/* TRANSLATORS: ACPI, the Intel power standard on laptops and desktops */
details = g_strdup (_("ACPI"));
- } else if (g_strcmp0 (obj->details, "ata_piix") == 0) {
+ } else if (g_strcmp0 (data, "ata_piix") == 0) {
/* TRANSLATORS: serial ATA is a new style of hard disk interface */
details = g_strdup (_("Serial ATA"));
- } else if (g_strcmp0 (obj->details, "libata") == 0) {
+ } else if (g_strcmp0 (data, "libata") == 0) {
/* TRANSLATORS: this is the old-style ATA interface */
details = g_strdup (_("ATA host controller"));
- } else if (g_strcmp0 (obj->details, "iwl3945") == 0 || g_strcmp0 (obj->details, "iwlagn") == 0) {
+ } else if (g_strcmp0 (data, "iwl3945") == 0 || g_strcmp0 (data, "iwlagn") == 0) {
/* TRANSLATORS: 802.11 wireless adaptor */
details = g_strdup (_("Intel wireless adaptor"));
/* try to make the wakeup type nicer */
- } else if (g_str_has_prefix (obj->details, "__mod_timer")) {
+ } else if (g_str_has_prefix (data, "__mod_timer")) {
/* TRANSLATORS: a timer is something that fires periodically */
- details = g_strdup_printf (_("Timer %s"), obj->details+12);
- } else if (g_str_has_prefix (obj->details, "mod_timer")) {
+ details = g_strdup_printf (_("Timer %s"), data+12);
+ } else if (g_str_has_prefix (data, "mod_timer")) {
/* TRANSLATORS: a timer is something that fires periodically */
- details = g_strdup_printf (_("Timer %s"), obj->details+10);
- } else if (g_str_has_prefix (obj->details, "hrtimer_start_expires")) {
+ details = g_strdup_printf (_("Timer %s"), data+10);
+ } else if (g_str_has_prefix (data, "hrtimer_start_expires")) {
/* TRANSLATORS: a timer is something that fires periodically */
- details = g_strdup_printf (_("Timer %s"), obj->details+22);
- } else if (g_str_has_prefix (obj->details, "hrtimer_start")) {
+ details = g_strdup_printf (_("Timer %s"), data+22);
+ } else if (g_str_has_prefix (data, "hrtimer_start")) {
/* TRANSLATORS: a timer is something that fires periodically */
- details = g_strdup_printf (_("Timer %s"), obj->details+14);
- } else if (g_str_has_prefix (obj->details, "do_setitimer")) {
+ details = g_strdup_printf (_("Timer %s"), data+14);
+ } else if (g_str_has_prefix (data, "do_setitimer")) {
/* TRANSLATORS: a timer is something that fires periodically */
- details = g_strdup_printf (_("Timer %s"), obj->details+10);
- } else if (g_str_has_prefix (obj->details, "do_nanosleep")) {
+ details = g_strdup_printf (_("Timer %s"), data+10);
+ } else if (g_str_has_prefix (data, "do_nanosleep")) {
/* TRANSLATORS: this is a task that's woken up from sleeping */
- details = g_strdup_printf (_("Sleep %s"), obj->details+13);
- } else if (g_str_has_prefix (obj->details, "enqueue_task_rt")) {
+ details = g_strdup_printf (_("Sleep %s"), data+13);
+ } else if (g_str_has_prefix (data, "enqueue_task_rt")) {
/* TRANSLATORS: this is a new realtime task */
- details = g_strdup_printf (_("New task %s"), obj->details+16);
- } else if (g_str_has_prefix (obj->details, "futex_wait")) {
+ details = g_strdup_printf (_("New task %s"), data+16);
+ } else if (g_str_has_prefix (data, "futex_wait")) {
/* TRANSLATORS: this is a task thats woken to check state */
- details = g_strdup_printf (_("Wait %s"), obj->details+11);
- } else if (g_str_has_prefix (obj->details, "queue_delayed_work_on")) {
+ details = g_strdup_printf (_("Wait %s"), data+11);
+ } else if (g_str_has_prefix (data, "queue_delayed_work_on")) {
/* TRANSLATORS: a work queue is a list of work that has to be done */
- details = g_strdup_printf (_("Work queue %s"), obj->details+22);
- } else if (g_str_has_prefix (obj->details, "queue_delayed_work")) {
+ details = g_strdup_printf (_("Work queue %s"), data+22);
+ } else if (g_str_has_prefix (data, "queue_delayed_work")) {
/* TRANSLATORS: a work queue is a list of work that has to be done */
- details = g_strdup_printf (_("Work queue %s"), obj->details+19);
- } else if (g_str_has_prefix (obj->details, "dst_run_gc")) {
+ details = g_strdup_printf (_("Work queue %s"), data+19);
+ } else if (g_str_has_prefix (data, "dst_run_gc")) {
/* TRANSLATORS: this is when the networking subsystem clears out old entries */
- details = g_strdup_printf (_("Network route flush %s"), obj->details+11);
- } else if (g_str_has_prefix (obj->details, "usb_hcd_poll_rh_status")) {
+ details = g_strdup_printf (_("Network route flush %s"), data+11);
+ } else if (g_str_has_prefix (data, "usb_hcd_poll_rh_status")) {
/* TRANSLATORS: activity on the USB bus */
- details = g_strdup_printf (_("USB activity %s"), obj->details+23);
- } else if (g_str_has_prefix (obj->details, "schedule_hrtimeout_range")) {
+ details = g_strdup_printf (_("USB activity %s"), data+23);
+ } else if (g_str_has_prefix (data, "schedule_hrtimeout_range")) {
/* TRANSLATORS: we've timed out of an aligned timer */
- details = g_strdup_printf (_("Wakeup %s"), obj->details+25);
- } else if (g_str_has_prefix (obj->details, "Local timer interrupts")) {
+ details = g_strdup_printf (_("Wakeup %s"), data+25);
+ } else if (g_str_has_prefix (data, "Local timer interrupts")) {
/* TRANSLATORS: interupts on the system required for basic operation */
details = g_strdup (_("Local interrupts"));
- } else if (g_str_has_prefix (obj->details, "Rescheduling interrupts")) {
+ } else if (g_str_has_prefix (data, "Rescheduling interrupts")) {
/* TRANSLATORS: interrupts when a task gets moved from one core to another */
details = g_strdup (_("Rescheduling interrupts"));
} else
- details = g_markup_escape_text (obj->details, -1);
+ details = g_markup_escape_text (data, -1);
return details;
}
/**
- * gpm_stats_add_wakeups_obj:
+ * gpm_stats_add_wakeups_item:
**/
static void
-gpm_stats_add_wakeups_obj (const DkpWakeupsObj *obj)
+gpm_stats_add_wakeups_item (UpWakeupItem *item)
{
const gchar *icon;
gchar *value;
@@ -941,23 +943,23 @@ gpm_stats_add_wakeups_obj (const DkpWakeupsObj *obj)
gchar *cmdline;
GtkTreeIter iter;
- if (obj->is_userspace) {
+ if (up_wakeup_item_get_is_userspace (item)) {
icon = "application-x-executable";
- id = g_strdup_printf ("%i", obj->id);
+ id = g_strdup_printf ("%i", up_wakeup_item_get_id (item));
} else {
icon = "applications-system";
- if (obj->id < 0xff0)
- id = g_strdup_printf ("IRQ%i", obj->id);
+ if (up_wakeup_item_get_id (item) < 0xff0)
+ id = g_strdup_printf ("IRQ%i", up_wakeup_item_get_id (item));
else
id = g_strdup ("IRQx");
}
/* formate value to one decimal place */
- value = g_strdup_printf ("%.1f", obj->value);
+ value = g_strdup_printf ("%.1f", up_wakeup_item_get_value (item));
/* get formatted lines */
- cmdline = gpm_stats_format_cmdline (obj);
- details = gpm_stats_format_details (obj);
+ cmdline = gpm_stats_format_cmdline (item);
+ details = gpm_stats_format_details (item);
gtk_list_store_append (list_store_wakeups, &iter);
gtk_list_store_set (list_store_wakeups, &iter,
@@ -981,7 +983,7 @@ gpm_stats_update_wakeups_data (void)
GtkWidget *widget;
GtkWidget *page_widget;
guint total;
- DkpWakeupsObj *obj;
+ UpWakeupItem *item;
gchar *text;
guint i;
GError *error = NULL;
@@ -1002,7 +1004,7 @@ gpm_stats_update_wakeups_data (void)
gtk_widget_show (page_widget);
/* show total */
- total = dkp_wakeups_get_total (wakeups, &error);
+ total = up_wakeups_get_total_sync (wakeups, NULL, &error);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "label_total_wakeups"));
if (error == NULL) {
text = g_strdup_printf ("%i", total);
@@ -1015,12 +1017,12 @@ gpm_stats_update_wakeups_data (void)
/* get data */
gtk_list_store_clear (list_store_wakeups);
- array = dkp_wakeups_get_data (wakeups, NULL);
+ array = up_wakeups_get_data_sync (wakeups, NULL, NULL);
if (array == NULL)
return;
for (i=0; i<array->len; i++) {
- obj = g_ptr_array_index (array, i);
- gpm_stats_add_wakeups_obj (obj);
+ item = g_ptr_array_index (array, i);
+ gpm_stats_add_wakeups_item (item);
}
g_ptr_array_unref (array);
}
@@ -1052,7 +1054,7 @@ gpm_stats_set_title (GtkWindow *window, gint page_num)
static void
gpm_stats_notebook_changed_cb (GtkNotebook *notebook, GtkNotebookPage *page, gint page_num, gpointer user_data)
{
- DkpDevice *device;
+ UpDevice *device;
GtkWidget *widget;
/* set the window title depending on the mode */
@@ -1068,8 +1070,8 @@ gpm_stats_notebook_changed_cb (GtkNotebook *notebook, GtkNotebookPage *page, gin
if (g_strcmp0 (current_device, "wakeups") == 0)
return;
- device = dkp_device_new ();
- dkp_device_set_object_path (device, current_device, NULL);
+ device = up_device_new ();
+ up_device_set_object_path_sync (device, current_device, NULL, NULL);
gpm_stats_update_info_data_page (device, page_num);
gpm_stats_update_info_data (device);
g_object_unref (device);
@@ -1081,9 +1083,9 @@ gpm_stats_notebook_changed_cb (GtkNotebook *notebook, GtkNotebookPage *page, gin
static void
gpm_stats_button_update_ui (void)
{
- DkpDevice *device;
- device = dkp_device_new ();
- dkp_device_set_object_path (device, current_device, NULL);
+ UpDevice *device;
+ device = up_device_new ();
+ up_device_set_object_path_sync (device, current_device, NULL, NULL);
gpm_stats_update_info_data (device);
g_object_unref (device);
}
@@ -1096,7 +1098,7 @@ gpm_stats_devices_treeview_clicked_cb (GtkTreeSelection *selection, gboolean dat
{
GtkTreeModel *model;
GtkTreeIter iter;
- DkpDevice *device;
+ UpDevice *device;
/* This will only work in single or browse selection mode! */
if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
@@ -1113,8 +1115,8 @@ gpm_stats_devices_treeview_clicked_cb (GtkTreeSelection *selection, gboolean dat
if (g_strcmp0 (current_device, "wakeups") == 0) {
gpm_stats_update_wakeups_data ();
} else {
- device = dkp_device_new ();
- dkp_device_set_object_path (device, current_device, NULL);
+ device = up_device_new ();
+ up_device_set_object_path_sync (device, current_device, NULL, NULL);
gpm_stats_update_info_data (device);
g_object_unref (device);
}
@@ -1139,21 +1141,21 @@ gpm_stats_window_activated_cb (EggUnique *egg_unique, gpointer data)
* gpm_stats_add_device:
**/
static void
-gpm_stats_add_device (DkpDevice *device)
+gpm_stats_add_device (UpDevice *device)
{
const gchar *id;
GtkTreeIter iter;
const gchar *text;
const gchar *icon;
- DkpDeviceType type;
+ UpDeviceKind kind;
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
NULL);
- id = dkp_device_get_object_path (device);
- text = gpm_device_type_to_localised_text (type, 1);
+ id = up_device_get_object_path (device);
+ text = gpm_device_kind_to_localised_text (kind, 1);
icon = gpm_upower_get_device_icon (device);
gtk_list_store_append (list_store_devices, &iter);
@@ -1167,7 +1169,7 @@ gpm_stats_add_device (DkpDevice *device)
* gpm_stats_data_changed_cb:
**/
static void
-gpm_stats_data_changed_cb (DkpClient *client, gpointer user_data)
+gpm_stats_data_changed_cb (UpClient *client, gpointer user_data)
{
if (g_strcmp0 (current_device, "wakeups") == 0)
gpm_stats_update_wakeups_data ();
@@ -1177,10 +1179,10 @@ gpm_stats_data_changed_cb (DkpClient *client, gpointer user_data)
* gpm_stats_device_added_cb:
**/
static void
-gpm_stats_device_added_cb (DkpClient *client, DkpDevice *device, gpointer user_data)
+gpm_stats_device_added_cb (UpClient *client, UpDevice *device, gpointer user_data)
{
const gchar *object_path;
- object_path = dkp_device_get_object_path (device);
+ object_path = up_device_get_object_path (device);
egg_debug ("added: %s", object_path);
gpm_stats_add_device (device);
}
@@ -1189,10 +1191,10 @@ gpm_stats_device_added_cb (DkpClient *client, DkpDevice *device, gpointer user_d
* gpm_stats_device_changed_cb:
**/
static void
-gpm_stats_device_changed_cb (DkpClient *client, DkpDevice *device, gpointer user_data)
+gpm_stats_device_changed_cb (UpClient *client, UpDevice *device, gpointer user_data)
{
const gchar *object_path;
- object_path = dkp_device_get_object_path (device);
+ object_path = up_device_get_object_path (device);
if (object_path == NULL || current_device == NULL)
return;
egg_debug ("changed: %s", object_path);
@@ -1204,14 +1206,14 @@ gpm_stats_device_changed_cb (DkpClient *client, DkpDevice *device, gpointer user
* gpm_stats_device_removed_cb:
**/
static void
-gpm_stats_device_removed_cb (DkpClient *client, DkpDevice *device, gpointer user_data)
+gpm_stats_device_removed_cb (UpClient *client, UpDevice *device, gpointer user_data)
{
const gchar *object_path;
GtkTreeIter iter;
gchar *id = NULL;
gboolean ret;
- object_path = dkp_device_get_object_path (device);
+ object_path = up_device_get_object_path (device);
egg_debug ("removed: %s", object_path);
if (g_strcmp0 (current_device, object_path) == 0) {
gtk_list_store_clear (list_store_info);
@@ -1480,10 +1482,10 @@ main (int argc, char *argv[])
GtkTreeSelection *selection;
EggUnique *egg_unique;
gboolean ret;
- DkpClient *client;
+ UpClient *client;
GPtrArray *devices;
- DkpDevice *device;
- DkpDeviceType type;
+ UpDevice *device;
+ UpDeviceKind kind;
guint i;
gint page;
gboolean checked;
@@ -1704,54 +1706,55 @@ main (int argc, char *argv[])
g_signal_connect (G_OBJECT (widget), "changed",
G_CALLBACK (gpm_stats_range_combo_changed), NULL);
- client = dkp_client_new ();
+ client = up_client_new ();
g_signal_connect (client, "device-added", G_CALLBACK (gpm_stats_device_added_cb), NULL);
g_signal_connect (client, "device-removed", G_CALLBACK (gpm_stats_device_removed_cb), NULL);
g_signal_connect (client, "device-changed", G_CALLBACK (gpm_stats_device_changed_cb), NULL);
- wakeups = dkp_wakeups_new ();
+ wakeups = up_wakeups_new ();
g_signal_connect (wakeups, "data-changed", G_CALLBACK (gpm_stats_data_changed_cb), NULL);
/* coldplug */
- devices = dkp_client_enumerate_devices (client, NULL);
- if (devices == NULL)
+ ret = up_client_enumerate_devices_sync (client, NULL, NULL);
+ if (!ret)
goto out;
+ devices = up_client_get_devices (client);
/* add devices in visually pleasing order */
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_LINE_POWER)
+ g_object_get (device, "kind", &kind, NULL);
+ if (kind == UP_DEVICE_KIND_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)
+ g_object_get (device, "kind", &kind, NULL);
+ if (kind == UP_DEVICE_KIND_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)
+ g_object_get (device, "kind", &kind, NULL);
+ if (kind == UP_DEVICE_KIND_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)
+ g_object_get (device, "kind", &kind, NULL);
+ if (kind == UP_DEVICE_KIND_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)
+ g_object_get (device, "kind", &kind, NULL);
+ if (kind == UP_DEVICE_KIND_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)
+ g_object_get (device, "kind", &kind, NULL);
+ if (kind == UP_DEVICE_KIND_KEYBOARD)
gpm_stats_add_device (device);
}
@@ -1759,14 +1762,14 @@ main (int argc, char *argv[])
if (devices->len > 0) {
device = g_ptr_array_index (devices, 0);
gpm_stats_update_info_data (device);
- current_device = g_strdup (dkp_device_get_object_path (device));
+ current_device = g_strdup (up_device_get_object_path (device));
}
if (last_device == NULL)
last_device = gconf_client_get_string (gconf_client, GPM_CONF_INFO_LAST_DEVICE, NULL);
/* has capability to measure wakeups */
- ret = dkp_wakeups_has_capability (wakeups);
+ ret = up_wakeups_get_has_capability (wakeups);
if (ret) {
GtkTreeIter iter;
gtk_list_store_append (list_store_devices, &iter);
diff --git a/src/gpm-tray-icon.c b/src/gpm-tray-icon.c
index 569d490..4b9623d 100644
--- a/src/gpm-tray-icon.c
+++ b/src/gpm-tray-icon.c
@@ -39,7 +39,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gconf/gconf-client.h>
-#include <devkit-power-gobject/devicekit-power.h>
+#include <libupower-glib/upower.h>
#include "egg-debug.h"
@@ -201,7 +201,7 @@ gpm_tray_icon_class_init (GpmTrayIconClass *klass)
* gpm_tray_icon_add_device:
**/
static guint
-gpm_tray_icon_add_device (GpmTrayIcon *icon, GtkMenu *menu, const GPtrArray *array, DkpDeviceType type)
+gpm_tray_icon_add_device (GpmTrayIcon *icon, GtkMenu *menu, const GPtrArray *array, UpDeviceKind kind)
{
guint i;
guint added = 0;
@@ -211,8 +211,8 @@ gpm_tray_icon_add_device (GpmTrayIcon *icon, GtkMenu *menu, const GPtrArray *arr
GtkWidget *image;
const gchar *object_path;
const gchar *desc;
- DkpDevice *device;
- DkpDeviceType type_tmp;
+ UpDevice *device;
+ UpDeviceKind kind_tmp;
gdouble percentage;
/* find type */
@@ -221,19 +221,19 @@ gpm_tray_icon_add_device (GpmTrayIcon *icon, GtkMenu *menu, const GPtrArray *arr
/* get device properties */
g_object_get (device,
- "type", &type_tmp,
+ "kind", &kind_tmp,
"percentage", &percentage,
NULL);
- if (type != type_tmp)
+ if (kind != kind_tmp)
continue;
- object_path = dkp_device_get_object_path (device);
+ object_path = up_device_get_object_path (device);
egg_debug ("adding device %s", object_path);
added++;
/* generate the label */
- desc = gpm_device_type_to_localised_text (type, 1);
+ desc = gpm_device_kind_to_localised_text (kind, 1);
label = g_strdup_printf ("%s (%.1f%%)", desc, percentage);
item = gtk_image_menu_item_new_with_label (label);
@@ -270,12 +270,12 @@ gpm_tray_icon_create_menu (GpmTrayIcon *icon, guint32 timestamp)
/* add all device types to the drop down menu */
array = gpm_engine_get_devices (icon->priv->engine);
- dev_cnt += gpm_tray_icon_add_device (icon, menu, array, DKP_DEVICE_TYPE_BATTERY);
- dev_cnt += gpm_tray_icon_add_device (icon, menu, array, DKP_DEVICE_TYPE_UPS);
- dev_cnt += gpm_tray_icon_add_device (icon, menu, array, DKP_DEVICE_TYPE_MOUSE);
- dev_cnt += gpm_tray_icon_add_device (icon, menu, array, DKP_DEVICE_TYPE_KEYBOARD);
- dev_cnt += gpm_tray_icon_add_device (icon, menu, array, DKP_DEVICE_TYPE_PDA);
- dev_cnt += gpm_tray_icon_add_device (icon, menu, array, DKP_DEVICE_TYPE_PHONE);
+ dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_BATTERY);
+ dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_UPS);
+ dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_MOUSE);
+ dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_KEYBOARD);
+ dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_PDA);
+ dev_cnt += gpm_tray_icon_add_device (icon, menu, array, UP_DEVICE_KIND_PHONE);
g_ptr_array_unref (array);
/* skip for things like live-cd's and GDM */
diff --git a/src/gpm-upower.c b/src/gpm-upower.c
index c2eb8bd..838c252 100644
--- a/src/gpm-upower.c
+++ b/src/gpm-upower.c
@@ -22,7 +22,7 @@
#include "config.h"
#include <glib/gi18n.h>
-#include <devkit-power-gobject/devicekit-power.h>
+#include <libupower-glib/upower.h>
#include "egg-debug.h"
#include "egg-precision.h"
@@ -30,8 +30,8 @@
#include "gpm-upower.h"
#include "gpm-common.h"
-#define GPM_DKP_TIME_PRECISION 5*60
-#define GPM_DKP_TEXT_MIN_TIME 120
+#define GPM_UP_TIME_PRECISION 5*60
+#define GPM_UP_TEXT_MIN_TIME 120
/**
* gpm_upower_get_device_icon_index:
@@ -48,7 +48,7 @@
* Return value: The character string for the filename suffix.
**/
static const gchar *
-gpm_upower_get_device_icon_index (DkpDevice *device)
+gpm_upower_get_device_icon_index (UpDevice *device)
{
gdouble percentage;
/* get device properties */
@@ -73,13 +73,13 @@ gpm_upower_get_device_icon_index (DkpDevice *device)
*
**/
gchar *
-gpm_upower_get_device_icon (DkpDevice *device)
+gpm_upower_get_device_icon (UpDevice *device)
{
gchar *filename = NULL;
const gchar *prefix = NULL;
const gchar *index_str;
- DkpDeviceType type;
- DkpDeviceState state;
+ UpDeviceKind kind;
+ UpDeviceState state;
gboolean is_present;
gdouble percentage;
@@ -87,108 +87,78 @@ gpm_upower_get_device_icon (DkpDevice *device)
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
"state", &state,
"percentage", &percentage,
"is-present", &is_present,
NULL);
/* get correct icon prefix */
- prefix = dkp_device_type_to_text (type);
+ prefix = up_device_kind_to_string (kind);
/* get the icon from some simple rules */
- if (type == DKP_DEVICE_TYPE_LINE_POWER) {
+ if (kind == UP_DEVICE_KIND_LINE_POWER) {
filename = g_strdup ("gpm-ac-adapter");
- } else if (type == DKP_DEVICE_TYPE_MONITOR) {
+ } else if (kind == UP_DEVICE_KIND_MONITOR) {
filename = g_strdup ("gpm-monitor");
- } else if (type == DKP_DEVICE_TYPE_UPS) {
+ } else if (kind == UP_DEVICE_KIND_UPS) {
if (!is_present) {
/* battery missing */
filename = g_strdup_printf ("gpm-%s-missing", prefix);
- } else if (state == DKP_DEVICE_STATE_FULLY_CHARGED) {
+ } else if (state == UP_DEVICE_STATE_FULLY_CHARGED) {
filename = g_strdup_printf ("gpm-%s-100", prefix);
- } else if (state == DKP_DEVICE_STATE_CHARGING) {
+ } else if (state == UP_DEVICE_STATE_CHARGING) {
index_str = gpm_upower_get_device_icon_index (device);
filename = g_strdup_printf ("gpm-%s-%s-charging", prefix, index_str);
- } else if (state == DKP_DEVICE_STATE_DISCHARGING) {
+ } else if (state == UP_DEVICE_STATE_DISCHARGING) {
index_str = gpm_upower_get_device_icon_index (device);
filename = g_strdup_printf ("gpm-%s-%s", prefix, index_str);
}
- } else if (type == DKP_DEVICE_TYPE_BATTERY) {
+ } else if (kind == UP_DEVICE_KIND_BATTERY) {
if (!is_present) {
/* battery missing */
filename = g_strdup_printf ("gpm-%s-missing", prefix);
- } else if (state == DKP_DEVICE_STATE_EMPTY) {
+ } else if (state == UP_DEVICE_STATE_EMPTY) {
filename = g_strdup_printf ("gpm-%s-empty", prefix);
- } else if (state == DKP_DEVICE_STATE_FULLY_CHARGED) {
+ } else if (state == UP_DEVICE_STATE_FULLY_CHARGED) {
filename = g_strdup_printf ("gpm-%s-charged", prefix);
-#if !DKP_CHECK_VERSION(0x009)
- } else if (state == DKP_DEVICE_STATE_UNKNOWN && percentage > 95.0f) {
- egg_warning ("fixing up unknown %f", percentage);
- filename = g_strdup_printf ("gpm-%s-charged", prefix);
-#endif
-
- } else if (state == DKP_DEVICE_STATE_CHARGING) {
+ } else if (state == UP_DEVICE_STATE_CHARGING) {
index_str = gpm_upower_get_device_icon_index (device);
filename = g_strdup_printf ("gpm-%s-%s-charging", prefix, index_str);
- } else if (state == DKP_DEVICE_STATE_DISCHARGING) {
+ } else if (state == UP_DEVICE_STATE_DISCHARGING) {
index_str = gpm_upower_get_device_icon_index (device);
filename = g_strdup_printf ("gpm-%s-%s", prefix, index_str);
-#if !DKP_CHECK_VERSION(0x009)
- /* the battery isn't charging or discharging, it's just
- * sitting there half full doing nothing */
- } else {
- DkpClient *client;
- gboolean on_battery;
-
- /* get battery status */
- client = dkp_client_new ();
- g_object_get (client,
- "on-battery", &on_battery,
- NULL);
- g_object_unref (client);
-
- /* try to find a suitable icon depending on AC state */
- if (on_battery) {
- index_str = gpm_upower_get_device_icon_index (device);
- filename = g_strdup_printf ("gpm-%s-%s", prefix, index_str);
- } else {
- index_str = gpm_upower_get_device_icon_index (device);
- filename = g_strdup_printf ("gpm-%s-%s-charging", prefix, index_str);
- }
-#else
- } else if (state == DKP_DEVICE_STATE_PENDING_CHARGE) {
+ } else if (state == UP_DEVICE_STATE_PENDING_CHARGE) {
index_str = gpm_upower_get_device_icon_index (device);
/* FIXME: do new grey icons */
filename = g_strdup_printf ("gpm-%s-%s-charging", prefix, index_str);
- } else if (state == DKP_DEVICE_STATE_PENDING_DISCHARGE) {
+ } else if (state == UP_DEVICE_STATE_PENDING_DISCHARGE) {
index_str = gpm_upower_get_device_icon_index (device);
filename = g_strdup_printf ("gpm-%s-%s", prefix, index_str);
} else {
filename = g_strdup ("gpm-battery-missing");
-#endif
}
- } else if (type == DKP_DEVICE_TYPE_MOUSE ||
- type == DKP_DEVICE_TYPE_KEYBOARD ||
- type == DKP_DEVICE_TYPE_PHONE) {
+ } else if (kind == UP_DEVICE_KIND_MOUSE ||
+ kind == UP_DEVICE_KIND_KEYBOARD ||
+ kind == UP_DEVICE_KIND_PHONE) {
if (!is_present) {
/* battery missing */
filename = g_strdup_printf ("gpm-%s-000", prefix);
- } else if (state == DKP_DEVICE_STATE_FULLY_CHARGED) {
+ } else if (state == UP_DEVICE_STATE_FULLY_CHARGED) {
filename = g_strdup_printf ("gpm-%s-100", prefix);
- } else if (state == DKP_DEVICE_STATE_DISCHARGING) {
+ } else if (state == UP_DEVICE_STATE_DISCHARGING) {
index_str = gpm_upower_get_device_icon_index (device);
filename = g_strdup_printf ("gpm-%s-%s", prefix, index_str);
}
@@ -208,16 +178,16 @@ gpm_upower_get_device_icon (DkpDevice *device)
* gpm_upower_get_device_summary:
**/
gchar *
-gpm_upower_get_device_summary (DkpDevice *device)
+gpm_upower_get_device_summary (UpDevice *device)
{
- const gchar *type_desc = NULL;
+ const gchar *kind_desc = NULL;
gchar *description = NULL;
guint time_to_full_round;
guint time_to_empty_round;
gchar *time_to_full_str;
gchar *time_to_empty_str;
- DkpDeviceType type;
- DkpDeviceState state;
+ UpDeviceKind kind;
+ UpDeviceState state;
gdouble percentage;
gboolean is_present;
gint64 time_to_full;
@@ -225,7 +195,7 @@ gpm_upower_get_device_summary (DkpDevice *device)
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
"state", &state,
"percentage", &percentage,
"is-present", &is_present,
@@ -236,31 +206,31 @@ gpm_upower_get_device_summary (DkpDevice *device)
if (!is_present)
return NULL;
- type_desc = gpm_device_type_to_localised_text (type, 1);
+ kind_desc = gpm_device_kind_to_localised_text (kind, 1);
/* don't display all the extra stuff for keyboards and mice */
- if (type == DKP_DEVICE_TYPE_MOUSE ||
- type == DKP_DEVICE_TYPE_KEYBOARD ||
- type == DKP_DEVICE_TYPE_PDA)
- return g_strdup_printf ("%s (%.1f%%)", type_desc, percentage);
+ if (kind == UP_DEVICE_KIND_MOUSE ||
+ kind == UP_DEVICE_KIND_KEYBOARD ||
+ kind == UP_DEVICE_KIND_PDA)
+ return g_strdup_printf ("%s (%.1f%%)", kind_desc, percentage);
/* we care if we are on AC */
- if (type == DKP_DEVICE_TYPE_PHONE) {
- if (state == DKP_DEVICE_STATE_CHARGING || !state == DKP_DEVICE_STATE_DISCHARGING) {
+ if (kind == UP_DEVICE_KIND_PHONE) {
+ if (state == UP_DEVICE_STATE_CHARGING || !state == UP_DEVICE_STATE_DISCHARGING) {
/* TRANSLATORS: a phone is charging */
- return g_strdup_printf (_("%s charging (%.1f%%)"), type_desc, percentage);
+ return g_strdup_printf (_("%s charging (%.1f%%)"), kind_desc, percentage);
}
- return g_strdup_printf ("%s (%.1f%%)", type_desc, percentage);
+ return g_strdup_printf ("%s (%.1f%%)", kind_desc, percentage);
}
/* precalculate so we don't get Unknown time remaining */
- time_to_full_round = egg_precision_round_down (time_to_full, GPM_DKP_TIME_PRECISION);
- time_to_empty_round = egg_precision_round_down (time_to_empty, GPM_DKP_TIME_PRECISION);
+ time_to_full_round = egg_precision_round_down (time_to_full, GPM_UP_TIME_PRECISION);
+ time_to_empty_round = egg_precision_round_down (time_to_empty, GPM_UP_TIME_PRECISION);
/* we always display "Laptop battery 16 minutes remaining" as we need to clarify what device we are refering to */
- if (state == DKP_DEVICE_STATE_FULLY_CHARGED) {
+ if (state == UP_DEVICE_STATE_FULLY_CHARGED) {
- if (type == DKP_DEVICE_TYPE_BATTERY && time_to_empty_round > GPM_DKP_TEXT_MIN_TIME) {
+ if (kind == UP_DEVICE_KIND_BATTERY && time_to_empty_round > GPM_UP_TEXT_MIN_TIME) {
time_to_empty_str = gpm_get_timestring (time_to_empty_round);
/* TRANSLATORS: The laptop battery is fully charged, and we know a time */
description = g_strdup_printf (_("Battery is fully charged.\nProvides %s laptop runtime"),
@@ -268,27 +238,27 @@ gpm_upower_get_device_summary (DkpDevice *device)
g_free (time_to_empty_str);
} else {
/* TRANSLATORS: the device is fully charged */
- description = g_strdup_printf (_("%s is fully charged"), type_desc);
+ description = g_strdup_printf (_("%s is fully charged"), kind_desc);
}
- } else if (state == DKP_DEVICE_STATE_DISCHARGING) {
+ } else if (state == UP_DEVICE_STATE_DISCHARGING) {
- if (time_to_empty_round > GPM_DKP_TEXT_MIN_TIME) {
+ if (time_to_empty_round > GPM_UP_TEXT_MIN_TIME) {
time_to_empty_str = gpm_get_timestring (time_to_empty_round);
/* TRANSLATORS: the device is discharging, and we have a time remaining */
description = g_strdup_printf (_("%s %s remaining (%.1f%%)"),
- type_desc, time_to_empty_str, percentage);
+ kind_desc, time_to_empty_str, percentage);
g_free (time_to_empty_str);
} else {
/* TRANSLATORS: the device is discharging, but we only have a percentage */
description = g_strdup_printf (_("%s discharging (%.1f%%)"),
- type_desc, percentage);
+ kind_desc, percentage);
}
- } else if (state == DKP_DEVICE_STATE_CHARGING) {
+ } else if (state == UP_DEVICE_STATE_CHARGING) {
- if (time_to_full_round > GPM_DKP_TEXT_MIN_TIME &&
- time_to_empty_round > GPM_DKP_TEXT_MIN_TIME) {
+ if (time_to_full_round > GPM_UP_TEXT_MIN_TIME &&
+ time_to_empty_round > GPM_UP_TEXT_MIN_TIME) {
/* display both discharge and charge time */
time_to_full_str = gpm_get_timestring (time_to_full_round);
@@ -296,43 +266,41 @@ gpm_upower_get_device_summary (DkpDevice *device)
/* TRANSLATORS: the device is charging, and we have a time to full and empty */
description = g_strdup_printf (_("%s %s until charged (%.1f%%)\nProvides %s battery runtime"),
- type_desc, time_to_full_str, percentage, time_to_empty_str);
+ kind_desc, time_to_full_str, percentage, time_to_empty_str);
g_free (time_to_full_str);
g_free (time_to_empty_str);
- } else if (time_to_full_round > GPM_DKP_TEXT_MIN_TIME) {
+ } else if (time_to_full_round > GPM_UP_TEXT_MIN_TIME) {
/* display only charge time */
time_to_full_str = gpm_get_timestring (time_to_full_round);
/* TRANSLATORS: device is charging, and we have a time to full and a percentage */
description = g_strdup_printf (_("%s %s until charged (%.1f%%)"),
- type_desc, time_to_full_str, percentage);
+ kind_desc, time_to_full_str, percentage);
g_free (time_to_full_str);
} else {
/* TRANSLATORS: device is charging, but we only have a percentage */
description = g_strdup_printf (_("%s charging (%.1f%%)"),
- type_desc, percentage);
+ kind_desc, percentage);
}
-#if DKP_CHECK_VERSION(0x009)
- } else if (state == DKP_DEVICE_STATE_PENDING_DISCHARGE) {
+ } else if (state == UP_DEVICE_STATE_PENDING_DISCHARGE) {
/* TRANSLATORS: this is only shown for laptops with multiple batteries */
description = g_strdup_printf (_("%s waiting to discharge (%.1f%%)"),
- type_desc, percentage);
+ kind_desc, percentage);
- } else if (state == DKP_DEVICE_STATE_PENDING_CHARGE) {
+ } else if (state == UP_DEVICE_STATE_PENDING_CHARGE) {
/* TRANSLATORS: this is only shown for laptops with multiple batteries */
- description = g_strdup_printf (_("%s waiting to charge (%.1f%%)"), type_desc, percentage);
-#endif
+ description = g_strdup_printf (_("%s waiting to charge (%.1f%%)"), kind_desc, percentage);
} else {
egg_warning ("in an undefined state we are not charging or "
"discharging and the batteries are also not charged");
- description = g_strdup_printf ("%s (%.1f%%)", type_desc, percentage);
+ description = g_strdup_printf ("%s (%.1f%%)", kind_desc, percentage);
}
return description;
}
@@ -341,14 +309,14 @@ gpm_upower_get_device_summary (DkpDevice *device)
* gpm_upower_get_device_description:
**/
gchar *
-gpm_upower_get_device_description (DkpDevice *device)
+gpm_upower_get_device_description (UpDevice *device)
{
GString *details;
const gchar *text;
gchar *time_str;
- DkpDeviceType type;
- DkpDeviceState state;
- DkpDeviceTechnology technology;
+ UpDeviceKind kind;
+ UpDeviceState state;
+ UpDeviceTechnology technology;
gdouble percentage;
gdouble capacity;
gdouble energy;
@@ -366,7 +334,7 @@ gpm_upower_get_device_description (DkpDevice *device)
/* get device properties */
g_object_get (device,
- "type", &type,
+ "kind", &kind,
"state", &state,
"percentage", &percentage,
"is-present", &is_present,
@@ -384,20 +352,20 @@ gpm_upower_get_device_description (DkpDevice *device)
NULL);
details = g_string_new ("");
- text = gpm_device_type_to_localised_text (type, 1);
+ text = gpm_device_kind_to_localised_text (kind, 1);
/* TRANSLATORS: the type of data, e.g. Laptop battery */
g_string_append_printf (details, "<b>%s</b> %s\n", _("Product:"), text);
if (!is_present) {
/* TRANSLATORS: device is missing */
g_string_append_printf (details, "<b>%s</b> %s\n", _("Status:"), _("Missing"));
- } else if (state == DKP_DEVICE_STATE_FULLY_CHARGED) {
+ } else if (state == UP_DEVICE_STATE_FULLY_CHARGED) {
/* TRANSLATORS: device is charged */
g_string_append_printf (details, "<b>%s</b> %s\n", _("Status:"), _("Charged"));
- } else if (state == DKP_DEVICE_STATE_CHARGING) {
+ } else if (state == UP_DEVICE_STATE_CHARGING) {
/* TRANSLATORS: device is charging */
g_string_append_printf (details, "<b>%s</b> %s\n", _("Status:"), _("Charging"));
- } else if (state == DKP_DEVICE_STATE_DISCHARGING) {
+ } else if (state == UP_DEVICE_STATE_DISCHARGING) {
/* TRANSLATORS: device is discharging */
g_string_append_printf (details, "<b>%s</b> %s\n", _("Status:"), _("Discharging"));
}
@@ -410,8 +378,8 @@ gpm_upower_get_device_description (DkpDevice *device)
/* TRANSLATORS: manufacturer */
g_string_append_printf (details, "<b>%s</b> %s\n", _("Vendor:"), vendor);
}
- if (technology != DKP_DEVICE_TECHNOLOGY_UNKNOWN) {
- text = gpm_device_technology_to_localised_text (technology);
+ if (technology != UP_DEVICE_TECHNOLOGY_UNKNOWN) {
+ text = gpm_device_technology_to_localised_string (technology);
/* TRANSLATORS: how the battery is made, e.g. Lithium Ion */
g_string_append_printf (details, "<b>%s</b> %s\n", _("Technology:"), text);
}
@@ -451,7 +419,7 @@ gpm_upower_get_device_description (DkpDevice *device)
g_string_append_printf (details, "<b>%s</b> %.1f%% (%s)\n",
_("Capacity:"), capacity, condition);
}
- if (type == DKP_DEVICE_TYPE_BATTERY) {
+ if (kind == UP_DEVICE_KIND_BATTERY) {
if (energy > 0) {
/* TRANSLATORS: current charge */
g_string_append_printf (details, "<b>%s</b> %.1f Wh\n",
@@ -475,8 +443,8 @@ gpm_upower_get_device_description (DkpDevice *device)
_("Charge rate:"), energy_rate);
}
}
- if (type == DKP_DEVICE_TYPE_MOUSE ||
- type == DKP_DEVICE_TYPE_KEYBOARD) {
+ if (kind == UP_DEVICE_KIND_MOUSE ||
+ kind == UP_DEVICE_KIND_KEYBOARD) {
if (energy > 0) {
/* TRANSLATORS: the current charge for CSR devices */
g_string_append_printf (details, "<b>%s</b> %.0f/7\n",
@@ -498,124 +466,124 @@ gpm_upower_get_device_description (DkpDevice *device)
}
/**
- * gpm_device_type_to_localised_text:
+ * gpm_device_kind_to_localised_text:
**/
const gchar *
-gpm_device_type_to_localised_text (DkpDeviceType type, guint number)
+gpm_device_kind_to_localised_text (UpDeviceKind kind, guint number)
{
const gchar *text = NULL;
- switch (type) {
- case DKP_DEVICE_TYPE_LINE_POWER:
+ switch (kind) {
+ case UP_DEVICE_KIND_LINE_POWER:
/* TRANSLATORS: system power cord */
text = ngettext ("AC adapter", "AC adapters", number);
break;
- case DKP_DEVICE_TYPE_BATTERY:
+ case UP_DEVICE_KIND_BATTERY:
/* TRANSLATORS: laptop primary battery */
text = ngettext ("Laptop battery", "Laptop batteries", number);
break;
- case DKP_DEVICE_TYPE_UPS:
+ case UP_DEVICE_KIND_UPS:
/* TRANSLATORS: battery-backed AC power source */
text = ngettext ("UPS", "UPSs", number);
break;
- case DKP_DEVICE_TYPE_MONITOR:
+ case UP_DEVICE_KIND_MONITOR:
/* TRANSLATORS: a monitor is a device to measure voltage and current */
text = ngettext ("Monitor", "Monitors", number);
break;
- case DKP_DEVICE_TYPE_MOUSE:
+ case UP_DEVICE_KIND_MOUSE:
/* TRANSLATORS: wireless mice with internal batteries */
text = ngettext ("Wireless mouse", "Wireless mice", number);
break;
- case DKP_DEVICE_TYPE_KEYBOARD:
+ case UP_DEVICE_KIND_KEYBOARD:
/* TRANSLATORS: wireless keyboard with internal battery */
text = ngettext ("Wireless keyboard", "Wireless keyboards", number);
break;
- case DKP_DEVICE_TYPE_PDA:
+ case UP_DEVICE_KIND_PDA:
/* TRANSLATORS: portable device */
text = ngettext ("PDA", "PDAs", number);
break;
- case DKP_DEVICE_TYPE_PHONE:
+ case UP_DEVICE_KIND_PHONE:
/* TRANSLATORS: cell phone (mobile...) */
text = ngettext ("Cell phone", "Cell phones", number);
break;
default:
- egg_warning ("enum unrecognised: %i", type);
- text = dkp_device_type_to_text (type);
+ egg_warning ("enum unrecognised: %i", kind);
+ text = up_device_kind_to_string (kind);
}
return text;
}
/**
- * gpm_device_type_to_icon:
+ * gpm_device_kind_to_icon:
**/
const gchar *
-gpm_device_type_to_icon (DkpDeviceType type)
+gpm_device_kind_to_icon (UpDeviceKind kind)
{
const gchar *icon = NULL;
- switch (type) {
- case DKP_DEVICE_TYPE_LINE_POWER:
+ switch (kind) {
+ case UP_DEVICE_KIND_LINE_POWER:
icon = "gpm-ac-adapter";
break;
- case DKP_DEVICE_TYPE_BATTERY:
+ case UP_DEVICE_KIND_BATTERY:
icon = "battery";
break;
- case DKP_DEVICE_TYPE_UPS:
+ case UP_DEVICE_KIND_UPS:
icon = "network-wired";
break;
- case DKP_DEVICE_TYPE_MONITOR:
+ case UP_DEVICE_KIND_MONITOR:
icon = "application-certificate";
break;
- case DKP_DEVICE_TYPE_MOUSE:
+ case UP_DEVICE_KIND_MOUSE:
icon = "mouse";
break;
- case DKP_DEVICE_TYPE_KEYBOARD:
+ case UP_DEVICE_KIND_KEYBOARD:
icon = "input-keyboard";
break;
- case DKP_DEVICE_TYPE_PDA:
+ case UP_DEVICE_KIND_PDA:
icon = "input-gaming";
break;
- case DKP_DEVICE_TYPE_PHONE:
+ case UP_DEVICE_KIND_PHONE:
icon = "camera-video";
break;
default:
- egg_warning ("enum unrecognised: %i", type);
+ egg_warning ("enum unrecognised: %i", kind);
icon = "gtk-help";
}
return icon;
}
/**
- * gpm_device_technology_to_localised_text:
+ * gpm_device_technology_to_localised_string:
**/
const gchar *
-gpm_device_technology_to_localised_text (DkpDeviceTechnology technology_enum)
+gpm_device_technology_to_localised_string (UpDeviceTechnology technology_enum)
{
const gchar *technology = NULL;
switch (technology_enum) {
- case DKP_DEVICE_TECHNOLOGY_LITHIUM_ION:
+ case UP_DEVICE_TECHNOLOGY_LITHIUM_ION:
/* TRANSLATORS: battery technology */
technology = _("Lithium Ion");
break;
- case DKP_DEVICE_TECHNOLOGY_LITHIUM_POLYMER:
+ case UP_DEVICE_TECHNOLOGY_LITHIUM_POLYMER:
/* TRANSLATORS: battery technology */
technology = _("Lithium Polymer");
break;
- case DKP_DEVICE_TECHNOLOGY_LITHIUM_IRON_PHOSPHATE:
+ case UP_DEVICE_TECHNOLOGY_LITHIUM_IRON_PHOSPHATE:
/* TRANSLATORS: battery technology */
technology = _("Lithium Iron Phosphate");
break;
- case DKP_DEVICE_TECHNOLOGY_LEAD_ACID:
+ case UP_DEVICE_TECHNOLOGY_LEAD_ACID:
/* TRANSLATORS: battery technology */
technology = _("Lead acid");
break;
- case DKP_DEVICE_TECHNOLOGY_NICKEL_CADMIUM:
+ case UP_DEVICE_TECHNOLOGY_NICKEL_CADMIUM:
/* TRANSLATORS: battery technology */
technology = _("Nickel Cadmium");
break;
- case DKP_DEVICE_TECHNOLOGY_NICKEL_METAL_HYDRIDE:
+ case UP_DEVICE_TECHNOLOGY_NICKEL_METAL_HYDRIDE:
/* TRANSLATORS: battery technology */
technology = _("Nickel metal hydride");
break;
- case DKP_DEVICE_TECHNOLOGY_UNKNOWN:
+ case UP_DEVICE_TECHNOLOGY_UNKNOWN:
/* TRANSLATORS: battery technology */
technology = _("Unknown technology");
break;
diff --git a/src/gpm-upower.h b/src/gpm-upower.h
index 67f75cf..7b0580a 100644
--- a/src/gpm-upower.h
+++ b/src/gpm-upower.h
@@ -23,17 +23,17 @@
#define __GPM_DEVICEKIT_H
#include <glib-object.h>
-#include <devkit-power-gobject/devicekit-power.h>
+#include <libupower-glib/upower.h>
G_BEGIN_DECLS
-const gchar *gpm_device_type_to_localised_text (DkpDeviceType type,
+const gchar *gpm_device_kind_to_localised_text (UpDeviceKind kind,
guint number);
-const gchar *gpm_device_type_to_icon (DkpDeviceType type);
-const gchar *gpm_device_technology_to_localised_text (DkpDeviceTechnology technology_enum);
-gchar *gpm_upower_get_device_icon (DkpDevice *device);
-gchar *gpm_upower_get_device_summary (DkpDevice *device);
-gchar *gpm_upower_get_device_description (DkpDevice *device);
+const gchar *gpm_device_kind_to_icon (UpDeviceKind kind);
+const gchar *gpm_device_technology_to_localised_string (UpDeviceTechnology technology_enum);
+gchar *gpm_upower_get_device_icon (UpDevice *device);
+gchar *gpm_upower_get_device_summary (UpDevice *device);
+gchar *gpm_upower_get_device_description (UpDevice *device);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]