From c38e25ccb5f77ae4bfca9a43e54b4554220bdba9 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Thu, 7 Nov 2013 19:38:44 +0100 Subject: 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 --- mate-session/gsm-logout-dialog.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'mate-session/gsm-logout-dialog.c') 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 #include +#ifdef HAVE_UPOWER #include +#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; } -- cgit v1.2.1