[gnome-session] Port gnome-session to upower
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-session] Port gnome-session to upower
- Date: Mon, 12 Jul 2010 13:15:01 +0000 (UTC)
commit 75935773a6c5b0f7d93ca4fb9a032baa9f7dfa40
Author: Richard Hughes <richard hughsie com>
Date: Mon Jul 12 14:07:02 2010 +0100
Port gnome-session to upower
devkit-power-gobject is deprecated and will be removed in future versions.
UPower 0.9.0 has been required by gnome-power-manager for many months now.
configure.in | 4 ++--
gnome-session/gsm-logout-dialog.c | 24 ++++++++----------------
gnome-session/gsm-manager.c | 28 +++++++++++-----------------
3 files changed, 21 insertions(+), 35 deletions(-)
---
diff --git a/configure.in b/configure.in
index 45ba78d..b96e0b1 100644
--- a/configure.in
+++ b/configure.in
@@ -40,7 +40,7 @@ fi
GLIB_REQUIRED=2.16.0
GTK_REQUIRED=2.90.0
DBUS_GLIB_REQUIRED=0.76
-DEVKIT_POWER_REQUIRED=008
+UPOWER_REQUIRED=0.9.0
dnl ====================================================================
dnl Dependency Checks
@@ -52,7 +52,7 @@ PKG_CHECK_MODULES(GNOME_SESSION,
gio-2.0 >= $GLIB_REQUIRED
gtk+-3.0 >= $GTK_REQUIRED
dbus-glib-1 >= $DBUS_GLIB_REQUIRED
- devkit-power-gobject >= $DEVKIT_POWER_REQUIRED
+ upower-glib >= $UPOWER_REQUIRED
)
PKG_CHECK_MODULES(SESSION_PROPERTIES,
diff --git a/gnome-session/gsm-logout-dialog.c b/gnome-session/gsm-logout-dialog.c
index 760d0ce..ca68714 100644
--- a/gnome-session/gsm-logout-dialog.c
+++ b/gnome-session/gsm-logout-dialog.c
@@ -27,7 +27,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <devkit-power-gobject/devicekit-power.h>
+#include <upower.h>
#include "gsm-logout-dialog.h"
#include "gsm-consolekit.h"
@@ -50,7 +50,7 @@ struct _GsmLogoutDialogPrivate
{
GsmDialogLogoutType type;
- DkpClient *dkp_client;
+ UpClient *up_client;
GsmConsolekit *consolekit;
int timeout;
@@ -142,7 +142,7 @@ gsm_logout_dialog_init (GsmLogoutDialog *logout_dialog)
gtk_window_set_keep_above (GTK_WINDOW (logout_dialog), TRUE);
gtk_window_stick (GTK_WINDOW (logout_dialog));
- logout_dialog->priv->dkp_client = dkp_client_new ();
+ logout_dialog->priv->up_client = up_client_new ();
logout_dialog->priv->consolekit = gsm_get_consolekit ();
@@ -166,9 +166,9 @@ gsm_logout_dialog_destroy (GsmLogoutDialog *logout_dialog,
logout_dialog->priv->timeout_id = 0;
}
- if (logout_dialog->priv->dkp_client) {
- g_object_unref (logout_dialog->priv->dkp_client);
- logout_dialog->priv->dkp_client = NULL;
+ if (logout_dialog->priv->up_client) {
+ g_object_unref (logout_dialog->priv->up_client);
+ logout_dialog->priv->up_client = NULL;
}
if (logout_dialog->priv->consolekit) {
@@ -182,21 +182,13 @@ gsm_logout_dialog_destroy (GsmLogoutDialog *logout_dialog,
static gboolean
gsm_logout_supports_system_suspend (GsmLogoutDialog *logout_dialog)
{
- gboolean ret;
- g_object_get (logout_dialog->priv->dkp_client,
- "can-suspend", &ret,
- NULL);
- return ret;
+ return up_client_get_can_suspend (logout_dialog->priv->up_client);
}
static gboolean
gsm_logout_supports_system_hibernate (GsmLogoutDialog *logout_dialog)
{
- gboolean ret;
- g_object_get (logout_dialog->priv->dkp_client,
- "can-hibernate", &ret,
- NULL);
- return ret;
+ return up_client_get_can_hibernate (logout_dialog->priv->up_client);
}
static gboolean
diff --git a/gnome-session/gsm-manager.c b/gnome-session/gsm-manager.c
index 49fefe6..c85cea6 100644
--- a/gnome-session/gsm-manager.c
+++ b/gnome-session/gsm-manager.c
@@ -38,7 +38,7 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <devkit-power-gobject/devicekit-power.h>
+#include <upower.h>
#include <gtk/gtk.h> /* for logout dialog */
#include <gconf/gconf-client.h>
@@ -135,7 +135,7 @@ struct GsmManagerPrivate
DBusGConnection *connection;
/* Interface with other parts of the system */
- DkpClient *dkp_client;
+ UpClient *up_client;
};
enum {
@@ -987,17 +987,14 @@ manager_attempt_hibernate (GsmManager *manager)
GError *error;
gboolean ret;
- g_object_get (manager->priv->dkp_client,
- "can-hibernate", &can_hibernate,
- NULL);
-
+ can_hibernate = up_client_get_can_hibernate (manager->priv->up_client);
if (can_hibernate) {
/* lock the screen before we suspend */
manager_perhaps_lock (manager);
error = NULL;
- ret = dkp_client_hibernate (manager->priv->dkp_client, &error);
+ ret = up_client_hibernate_sync (manager->priv->up_client, NULL, &error);
if (!ret) {
g_warning ("Unexpected hibernate failure: %s",
error->message);
@@ -1013,17 +1010,14 @@ manager_attempt_suspend (GsmManager *manager)
GError *error;
gboolean ret;
- g_object_get (manager->priv->dkp_client,
- "can-suspend", &can_suspend,
- NULL);
-
+ can_suspend = up_client_get_can_suspend (manager->priv->up_client);
if (can_suspend) {
/* lock the screen before we suspend */
manager_perhaps_lock (manager);
error = NULL;
- ret = dkp_client_suspend (manager->priv->dkp_client, &error);
+ ret = up_client_suspend_sync (manager->priv->up_client, NULL, &error);
if (!ret) {
g_warning ("Unexpected suspend failure: %s",
error->message);
@@ -2202,9 +2196,9 @@ gsm_manager_dispose (GObject *object)
manager->priv->gconf_client = NULL;
}
- if (manager->priv->dkp_client != NULL) {
- g_object_unref (manager->priv->dkp_client);
- manager->priv->dkp_client = NULL;
+ if (manager->priv->up_client != NULL) {
+ g_object_unref (manager->priv->up_client);
+ manager->priv->up_client = NULL;
}
G_OBJECT_CLASS (gsm_manager_parent_class)->dispose (object);
@@ -2435,7 +2429,7 @@ gsm_manager_init (GsmManager *manager)
G_CALLBACK (on_presence_status_changed),
manager);
- manager->priv->dkp_client = dkp_client_new ();
+ manager->priv->up_client = up_client_new ();
/* GConf setup */
gconf_client_add_dir (manager->priv->gconf_client,
@@ -2959,7 +2953,7 @@ gsm_manager_can_shutdown (GsmManager *manager,
gboolean can_suspend;
gboolean can_hibernate;
- g_object_get (manager->priv->dkp_client,
+ g_object_get (manager->priv->up_client,
"can-suspend", &can_suspend,
"can-hibernate", &can_hibernate,
NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]