diff options
author | Stefano Karapetsas <[email protected]> | 2013-07-23 01:33:10 -0700 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2013-07-23 01:33:10 -0700 |
commit | 4c5c81c6bc16812cb62a53b7257167cddef28a7c (patch) | |
tree | 5340050689948130a567be5c3d0c9a32817c3ff1 /src/gpm-manager.c | |
parent | 6ebb90a3029238c6d57fc67fd3ba2d2fbc4065a8 (diff) | |
parent | 247f3aeeffd20e0971641d8bb9ab1337f81991cd (diff) | |
download | mate-power-manager-4c5c81c6bc16812cb62a53b7257167cddef28a7c.tar.bz2 mate-power-manager-4c5c81c6bc16812cb62a53b7257167cddef28a7c.tar.xz |
Merge pull request #61 from lxnay/fix-github-master
Move logind / consolekit detection to runtime
Diffstat (limited to 'src/gpm-manager.c')
-rw-r--r-- | src/gpm-manager.c | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/src/gpm-manager.c b/src/gpm-manager.c index 9b697b5..c99bd09 100644 --- a/src/gpm-manager.c +++ b/src/gpm-manager.c @@ -33,9 +33,6 @@ #ifdef HAVE_UNISTD_H #include <unistd.h> #endif /* HAVE_UNISTD_H */ -#ifdef WITH_SYSTEMD_INHIBIT -#include <systemd/sd-daemon.h> -#endif /* WITH_SYSTEMD_INHIBIT */ #include <glib/gi18n.h> #include <gtk/gtk.h> @@ -103,10 +100,8 @@ struct GpmManagerPrivate NotifyNotification *notification_warning_low; NotifyNotification *notification_discharging; NotifyNotification *notification_fully_charged; -#ifdef WITH_SYSTEMD_INHIBIT gint32 systemd_inhibit; GDBusProxy *systemd_inhibit_proxy; -#endif }; typedef enum { @@ -1847,9 +1842,8 @@ gpm_manager_control_resume_cb (GpmControl *control, GpmControlAction action, Gpm g_timeout_add_seconds (1, gpm_manager_reset_just_resumed_cb, manager); } -#ifdef WITH_SYSTEMD_INHIBIT /** - * gpm_main_system_inhibit: + * gpm_main_systemd_inhibit: * * Return a fd to the to the inhibitor, that we can close on exit. * @@ -1917,7 +1911,6 @@ gpm_manager_systemd_inhibit (GDBusProxy *proxy) { egg_debug ("Inhibiting systemd sleep - success"); return r; } -#endif /** * gpm_manager_init: @@ -1929,20 +1922,17 @@ gpm_manager_init (GpmManager *manager) gboolean check_type_cpu; gint timeout; DBusGConnection *connection; - GDBusConnection *g_connection; + GDBusConnection *g_connection; GError *error = NULL; manager->priv = GPM_MANAGER_GET_PRIVATE (manager); connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - g_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); - -#ifdef WITH_SYSTEMD_INHIBIT - /* We want to inhibit the systemd suspend options, and take care of them ourselves */ - if (sd_booted() > 0) { - manager->priv->systemd_inhibit = gpm_manager_systemd_inhibit (manager->priv->systemd_inhibit_proxy); - } + g_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); -#endif + /* We want to inhibit the systemd suspend options, and take care of them ourselves */ + if (LOGIND_RUNNING()) { + manager->priv->systemd_inhibit = gpm_manager_systemd_inhibit (manager->priv->systemd_inhibit_proxy); + } /* init to unthrottled */ manager->priv->screensaver_ac_throttle_id = 0; @@ -2101,16 +2091,15 @@ gpm_manager_finalize (GObject *object) g_object_unref (manager->priv->client); g_object_unref (manager->priv->status_icon); -#ifdef WITH_SYSTEMD_INHIBIT - /* Let systemd take over again ... */ - if (manager->priv->systemd_inhibit > 0) { - close(manager->priv->systemd_inhibit); - } - if (manager->priv->systemd_inhibit_proxy != NULL) { - g_object_unref (manager->priv->systemd_inhibit_proxy); - } - //g_object_unref (manager->priv->systemd_inhibit); -#endif + if (LOGIND_RUNNING()) { + /* Let systemd take over again ... */ + if (manager->priv->systemd_inhibit > 0) { + close(manager->priv->systemd_inhibit); + } + if (manager->priv->systemd_inhibit_proxy != NULL) { + g_object_unref (manager->priv->systemd_inhibit_proxy); + } + } G_OBJECT_CLASS (gpm_manager_parent_class)->finalize (object); } |