- Add a patch to use DeviceKit-power rather than the removed methods in

gnome-power-manager.
This commit is contained in:
Richard Hughes 2009-09-28 14:33:46 +00:00
parent 4af82f0ff1
commit 4c58f40a24
2 changed files with 196 additions and 1 deletions

View File

@ -0,0 +1,186 @@
From aa132a553b871a19a8d23fe8e9d93f736f2a4faf Mon Sep 17 00:00:00 2001
From: Richard Hughes <richard@hughsie.com>
Date: Mon, 28 Sep 2009 09:14:33 +0100
Subject: [PATCH] Convert gdm from using gnome-power-manager to DeviceKit-power
---
configure.ac | 7 ++
gui/simple-greeter/Makefile.am | 4 +
gui/simple-greeter/gdm-greeter-login-window.c | 84 ++++++-------------------
3 files changed, 31 insertions(+), 64 deletions(-)
diff --git a/configure.ac b/configure.ac
index 756890a..2cae1cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -51,6 +51,7 @@ LIBXKLAVIER_REQUIRED_VERSION=4.0
LIBCANBERRA_GTK_REQUIRED_VERSION=0.4
#FONTCONFIG_REQUIRED_VERSION=2.6.0
FONTCONFIG_REQUIRED_VERSION=2.5.0
+DEVKIT_POWER_REQUIRED_VERSION=008
EXTRA_COMPILE_WARNINGS(yes)
@@ -103,6 +104,12 @@ PKG_CHECK_MODULES(GCONF,
AC_SUBST(GCONF_CFLAGS)
AC_SUBST(GCONF_LIBS)
+PKG_CHECK_MODULES(DEVKIT_POWER,
+ devkit-power-gobject >= $DEVKIT_POWER_REQUIRED_VERSION
+)
+AC_SUBST(DEVKIT_POWER_CFLAGS)
+AC_SUBST(DEVKIT_POWER_LIBS)
+
PKG_CHECK_MODULES(SIMPLE_GREETER,
dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
gtk+-2.0 >= $GTK_REQUIRED_VERSION
diff --git a/gui/simple-greeter/Makefile.am b/gui/simple-greeter/Makefile.am
index 8c9ae46..4c06bc3 100644
--- a/gui/simple-greeter/Makefile.am
+++ b/gui/simple-greeter/Makefile.am
@@ -18,6 +18,8 @@ AM_CPPFLAGS = \
-DSBINDIR=\""$(sbindir)"\" \
-DGDM_CACHE_DIR=\""$(localstatedir)/cache/gdm"\" \
-DAT_SPI_REGISTRYD_DIR="\"$(AT_SPI_REGISTRYD_DIR)\"" \
+ $(DEVKIT_POWER_CFLAGS) \
+ -DI_KNOW_THE_DEVICEKIT_POWER_API_IS_SUBJECT_TO_CHANGE \
$(DISABLE_DEPRECATED_CFLAGS) \
$(GTK_CFLAGS) \
$(SIMPLE_GREETER_CFLAGS) \
@@ -90,6 +92,7 @@ test_greeter_login_window_LDADD = \
libgdmuser.la \
$(COMMON_LIBS) \
$(SIMPLE_GREETER_LIBS) \
+ $(DEVKIT_POWER_LIBS) \
$(RBAC_LIBS) \
$(NULL)
@@ -324,6 +327,7 @@ gdm_simple_greeter_LDADD = \
$(SIMPLE_GREETER_LIBS) \
$(RBAC_LIBS) \
$(LIBXKLAVIER_LIBS) \
+ $(DEVKIT_POWER_LIBS) \
$(NULL)
gladedir = $(pkgdatadir)
diff --git a/gui/simple-greeter/gdm-greeter-login-window.c b/gui/simple-greeter/gdm-greeter-login-window.c
index c7ea5d6..7d4ef83 100644
--- a/gui/simple-greeter/gdm-greeter-login-window.c
+++ b/gui/simple-greeter/gdm-greeter-login-window.c
@@ -56,6 +56,8 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
+#include <devkit-power-gobject/devicekit-power.h>
+
#include "gdm-settings-client.h"
#include "gdm-settings-keys.h"
#include "gdm-profile.h"
@@ -79,10 +81,6 @@
#define CK_SEAT_INTERFACE "org.freedesktop.ConsoleKit.Seat"
#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
-#define GPM_DBUS_NAME "org.freedesktop.PowerManagement"
-#define GPM_DBUS_PATH "/org/freedesktop/PowerManagement"
-#define GPM_DBUS_INTERFACE "org.freedesktop.PowerManagement"
-
#define GLADE_XML_FILE "gdm-greeter-login-window.glade"
#define KEY_GREETER_DIR "/apps/gdm/simple-greeter"
@@ -480,40 +478,15 @@ adjust_other_login_visibility(GdmGreeterLoginWindow *login_window)
static gboolean
can_suspend (GdmGreeterLoginWindow *login_window)
{
- DBusGConnection *connection;
- DBusGProxy *proxy;
- GError *error;
- gboolean ret;
- gboolean res;
-
- error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (error != NULL) {
- g_warning ("Couldn't connect to power manager: %s", error->message);
- g_error_free (error);
- return FALSE;
- }
- proxy = dbus_g_proxy_new_for_name (connection,
- GPM_DBUS_NAME,
- GPM_DBUS_PATH,
- GPM_DBUS_INTERFACE);
- ret = FALSE;
-
- res = dbus_g_proxy_call (proxy, "CanSuspend",
- &error,
- G_TYPE_INVALID,
- G_TYPE_BOOLEAN,
- &ret,
- G_TYPE_INVALID);
- if (! res) {
- if (error != NULL) {
- g_warning ("Could not ask power manager if user can suspend: %s",
- error->message);
- g_error_free (error);
- }
- ret = FALSE;
- }
+ gboolean ret;
+ DkpClient *dkp_client;
+ /* use DeviceKit-power to get data */
+ dkp_client = dkp_client_new ();
+ g_object_get (dkp_client,
+ "can-suspend", &ret,
+ NULL);
+ g_object_unref (dkp_client);
return ret;
}
@@ -655,36 +628,19 @@ do_disconnect (GdmGreeterLoginWindow *login_window)
static void
do_suspend (GdmGreeterLoginWindow *login_window)
{
- GError *error;
- DBusGConnection *connection;
- DBusGProxy *proxy;
+ gboolean ret;
+ DkpClient *dkp_client;
+ GError *error = NULL;
- g_debug ("GdmGreeterLoginWindow: Suspend button clicked");
-
- error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (error != NULL) {
+ /* use DeviceKit-power to get data */
+ dkp_client = dkp_client_new ();
+ ret = dkp_client_suspend (dkp_client, &error);
+ if (!ret) {
g_warning ("Couldn't suspend: %s", error->message);
g_error_free (error);
return;
}
- proxy = dbus_g_proxy_new_for_name (connection,
- GPM_DBUS_NAME,
- GPM_DBUS_PATH,
- GPM_DBUS_INTERFACE);
- error = NULL;
- dbus_g_proxy_call (proxy,
- "Suspend",
- &error,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (error != NULL) {
- g_warning ("Couldn't suspend: %s", error->message);
- g_error_free (error);
- return;
- }
-
- g_object_unref (proxy);
+ g_object_unref (dkp_client);
}
static void
--
1.6.4.4

View File

@ -16,7 +16,7 @@
Summary: The GNOME Display Manager
Name: gdm
Version: 2.28.0
Release: 2%{?dist}
Release: 3%{?dist}
Epoch: 1
License: GPLv2+
Group: User Interface/X
@ -87,6 +87,7 @@ BuildRequires: check-devel
BuildRequires: iso-codes-devel
BuildRequires: gnome-panel-devel
BuildRequires: libxklavier-devel >= 4.0
BuildRequires: DeviceKit-power-devel >= 008
Provides: service(graphical-login)
@ -94,6 +95,9 @@ Requires: audit-libs >= %{libauditver}
Patch2: gdm-2.26.0-force-active-vt.patch
Patch3: gdm-2.23.92-save-root-window.patch
# https://bugzilla.gnome.org/show_bug.cgi?id=596569
Patch4: gdm-2.28.0-use-devicekit-power.patch
# uses /etc/sysconfig/keyboard and is thus not directly upstreamable
# should probably be changed to get the system layout from the X server
Patch13: gdm-system-keyboard.patch
@ -141,6 +145,7 @@ The GDM fingerprint plugin provides functionality necessary to use a fingerprint
%setup -q
%patch2 -p1 -b .force-active-vt
%patch3 -p1 -b .save-root-window
%patch4 -p1 -b .use-devicekit-power
%patch13 -p1 -b .system-keyboard
%patch19 -p1 -b .multistack
@ -394,6 +399,10 @@ fi
%{_libdir}/gdm/simple-greeter/plugins/fingerprint.so
%changelog
* Mon Sep 28 2009 Richard Hughes <rhughes@redhat.com> - 1:2.28.0-3
- Add a patch to use DeviceKit-power rather than the removed methods in
gnome-power-manager.
* Fri Sep 25 2009 Ray Strode <rstrode@redhat.com> 1:2.28.0-2
- Fix autologin