summaryrefslogtreecommitdiff
path: root/mate-session/gsm-logout-dialog.c
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2013-11-07 19:38:44 +0100
committerStefano Karapetsas <[email protected]>2013-11-07 19:38:44 +0100
commitc38e25ccb5f77ae4bfca9a43e54b4554220bdba9 (patch)
tree3917c71710a202026cef5ac72237f0680401becf /mate-session/gsm-logout-dialog.c
parentc17333cbd562c8021ad152b6a41d7eaa46617719 (diff)
downloadmate-session-manager-c38e25ccb5f77ae4bfca9a43e54b4554220bdba9.tar.bz2
mate-session-manager-c38e25ccb5f77ae4bfca9a43e54b4554220bdba9.tar.xz
Make upower optional
This commit is just an improved version of the pull request by Wolfgang Ulbrich at https://github.com/mate-desktop/mate-session-manager/pull/38 making it working with both upower and systemd, and improving configure part
Diffstat (limited to 'mate-session/gsm-logout-dialog.c')
-rw-r--r--mate-session/gsm-logout-dialog.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/mate-session/gsm-logout-dialog.c b/mate-session/gsm-logout-dialog.c
index 1a79875..323f123 100644
--- a/mate-session/gsm-logout-dialog.c
+++ b/mate-session/gsm-logout-dialog.c
@@ -27,7 +27,9 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#ifdef HAVE_UPOWER
#include <upower.h>
+#endif
#include "gsm-logout-dialog.h"
#ifdef HAVE_SYSTEMD
@@ -52,8 +54,9 @@ typedef enum {
struct _GsmLogoutDialogPrivate
{
GsmDialogLogoutType type;
-
+#ifdef HAVE_UPOWER
UpClient *up_client;
+#endif
#ifdef HAVE_SYSTEMD
GsmSystemd *systemd;
#endif
@@ -147,9 +150,9 @@ gsm_logout_dialog_init (GsmLogoutDialog *logout_dialog)
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (logout_dialog), TRUE);
gtk_window_set_keep_above (GTK_WINDOW (logout_dialog), TRUE);
gtk_window_stick (GTK_WINDOW (logout_dialog));
-
+#ifdef HAVE_UPOWER
logout_dialog->priv->up_client = up_client_new ();
-
+#endif
#ifdef HAVE_SYSTEMD
if (LOGIND_RUNNING())
logout_dialog->priv->systemd = gsm_get_systemd ();
@@ -176,12 +179,12 @@ gsm_logout_dialog_destroy (GsmLogoutDialog *logout_dialog,
g_source_remove (logout_dialog->priv->timeout_id);
logout_dialog->priv->timeout_id = 0;
}
-
+#ifdef HAVE_UPOWER
if (logout_dialog->priv->up_client) {
g_object_unref (logout_dialog->priv->up_client);
logout_dialog->priv->up_client = NULL;
}
-
+#endif
#ifdef HAVE_SYSTEMD
if (logout_dialog->priv->systemd) {
g_object_unref (logout_dialog->priv->systemd);
@@ -201,13 +204,17 @@ static gboolean
gsm_logout_supports_system_suspend (GsmLogoutDialog *logout_dialog)
{
gboolean ret;
+ ret = FALSE;
#ifdef HAVE_SYSTEMD
if (LOGIND_RUNNING())
ret = gsm_systemd_can_suspend (logout_dialog->priv->systemd);
+#endif
+#if defined(HAVE_SYSTEMD) && defined(HAVE_UPOWER)
else
#endif
+#ifdef HAVE_UPOWER
ret = up_client_get_can_suspend (logout_dialog->priv->up_client);
-
+#endif
return ret;
}
@@ -215,13 +222,17 @@ static gboolean
gsm_logout_supports_system_hibernate (GsmLogoutDialog *logout_dialog)
{
gboolean ret;
+ ret = FALSE;
#ifdef HAVE_SYSTEMD
if (LOGIND_RUNNING())
ret = gsm_systemd_can_hibernate (logout_dialog->priv->systemd);
+#endif
+#if defined(HAVE_SYSTEMD) && defined(HAVE_UPOWER)
else
#endif
+#ifdef HAVE_UPOWER
ret = up_client_get_can_hibernate (logout_dialog->priv->up_client);
-
+#endif
return ret;
}