This is an automated email from the git hooks/post-receive script. eric pushed a commit to branch master in repository xfce/xfce4-power-manager.
commit 6cdc97e979b6924913ce270b06ad92d304e61ee4 Author: Eric Koegel <[email protected]> Date: Sat Apr 12 18:32:49 2014 +0300 Add support for logind suspend/resume (Bug 9963) This patch does runtime checks to see if we can use logind for suspend/resume same as poweroff/reboot. There's still full support for ConsoleKit. --- src/xfpm-power.c | 28 ++++++++++++++++++++++++---- src/xfpm-systemd.c | 47 +++++++++++++++++++++++++++++++++++++++++++---- src/xfpm-systemd.h | 4 ++++ 3 files changed, 71 insertions(+), 8 deletions(-) diff --git a/src/xfpm-power.c b/src/xfpm-power.c index dd952bd..618944a 100644 --- a/src/xfpm-power.c +++ b/src/xfpm-power.c @@ -280,7 +280,20 @@ xfpm_power_get_properties (XfpmPower *power) props = xfpm_power_get_interface_properties (power->priv->proxy_prop, UPOWER_IFACE); - xfpm_power_check_pm (power, props); + if ( LOGIND_RUNNING () ) + { + g_object_get (G_OBJECT (power->priv->systemd), + "can-suspend", &power->priv->can_suspend, + NULL); + g_object_get (G_OBJECT (power->priv->systemd), + "can-hibernate", &power->priv->can_hibernate, + NULL); + } + else + { + xfpm_power_check_pm (power, props); + } + xfpm_power_check_lid (power, props); xfpm_power_check_power (power, props); @@ -351,9 +364,16 @@ xfpm_power_sleep (XfpmPower *power, const gchar *sleep_time, gboolean force) xfpm_lock_screen (); } - dbus_g_proxy_call (power->priv->proxy, sleep_time, &error, - G_TYPE_INVALID, - G_TYPE_INVALID); + if ( LOGIND_RUNNING () ) + { + xfpm_systemd_sleep (power->priv->systemd, sleep_time, &error); + } + else + { + dbus_g_proxy_call (power->priv->proxy, sleep_time, &error, + G_TYPE_INVALID, + G_TYPE_INVALID); + } if ( error ) { diff --git a/src/xfpm-systemd.c b/src/xfpm-systemd.c index 2b840db..236d8cc 100644 --- a/src/xfpm-systemd.c +++ b/src/xfpm-systemd.c @@ -46,6 +46,8 @@ struct XfpmSystemdPrivate { gboolean can_shutdown; gboolean can_restart; + gboolean can_suspend; + gboolean can_hibernate; #ifdef ENABLE_POLKIT XfpmPolkit *polkit; #endif @@ -55,7 +57,9 @@ enum { PROP_0, PROP_CAN_RESTART, - PROP_CAN_SHUTDOWN + PROP_CAN_SHUTDOWN, + PROP_CAN_SUSPEND, + PROP_CAN_HIBERNATE, }; G_DEFINE_TYPE (XfpmSystemd, xfpm_systemd, G_TYPE_OBJECT) @@ -67,6 +71,8 @@ G_DEFINE_TYPE (XfpmSystemd, xfpm_systemd, G_TYPE_OBJECT) #define SYSTEMD_POWEROFF_ACTION "PowerOff" #define SYSTEMD_REBOOT_TEST "org.freedesktop.login1.reboot" #define SYSTEMD_POWEROFF_TEST "org.freedesktop.login1.power-off" +#define SYSTEMD_SUSPEND_TEST "org.freedesktop.login1.suspend" +#define SYSTEMD_HIBERNATE_TEST "org.freedesktop.login1.hibernate" static void xfpm_systemd_class_init (XfpmSystemdClass *klass) @@ -91,6 +97,20 @@ xfpm_systemd_class_init (XfpmSystemdClass *klass) FALSE, G_PARAM_READABLE)); + g_object_class_install_property (object_class, + PROP_CAN_SUSPEND, + g_param_spec_boolean ("can-suspend", + NULL, NULL, + FALSE, + G_PARAM_READABLE)); + + g_object_class_install_property (object_class, + PROP_CAN_HIBERNATE, + g_param_spec_boolean ("can-hibernate", + NULL, NULL, + FALSE, + G_PARAM_READABLE)); + g_type_class_add_private (klass, sizeof (XfpmSystemdPrivate)); } @@ -126,6 +146,12 @@ xfpm_systemd_init (XfpmSystemd *systemd) xfpm_systemd_can_method (systemd, &systemd->priv->can_restart, SYSTEMD_REBOOT_TEST); + xfpm_systemd_can_method (systemd, + &systemd->priv->can_suspend, + SYSTEMD_SUSPEND_TEST); + xfpm_systemd_can_method (systemd, + &systemd->priv->can_hibernate, + SYSTEMD_HIBERNATE_TEST); } static void xfpm_systemd_get_property (GObject *object, @@ -144,6 +170,12 @@ static void xfpm_systemd_get_property (GObject *object, case PROP_CAN_RESTART: g_value_set_boolean (value, systemd->priv->can_restart); break; + case PROP_CAN_SUSPEND: + g_value_set_boolean (value, systemd->priv->can_suspend); + break; + case PROP_CAN_HIBERNATE: + g_value_set_boolean (value, systemd->priv->can_hibernate); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -175,12 +207,12 @@ xfpm_systemd_new (void) if ( G_LIKELY (systemd_obj != NULL ) ) { - g_object_ref (systemd_obj); + g_object_ref (systemd_obj); } else { - systemd_obj = g_object_new (XFPM_TYPE_SYSTEMD, NULL); - g_object_add_weak_pointer (systemd_obj, &systemd_obj); + systemd_obj = g_object_new (XFPM_TYPE_SYSTEMD, NULL); + g_object_add_weak_pointer (systemd_obj, &systemd_obj); } return XFPM_SYSTEMD (systemd_obj); @@ -227,3 +259,10 @@ void xfpm_systemd_reboot (XfpmSystemd *systemd, GError **error) SYSTEMD_REBOOT_ACTION, error); } + +void xfpm_systemd_sleep (XfpmSystemd *systemd, + const gchar *method, + GError **error) +{ + xfpm_systemd_try_method (systemd, method, error); +} diff --git a/src/xfpm-systemd.h b/src/xfpm-systemd.h index 7ade4f4..f50e9fd 100644 --- a/src/xfpm-systemd.h +++ b/src/xfpm-systemd.h @@ -57,6 +57,10 @@ void xfpm_systemd_shutdown (XfpmSystemd *systemd, void xfpm_systemd_reboot (XfpmSystemd *systemd, GError **error); +void xfpm_systemd_sleep (XfpmSystemd *systemd, + const gchar *method, + GError **error); + G_END_DECLS #endif /* __XFPM_SYSTEMD_H */ -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list [email protected] https://mail.xfce.org/mailman/listinfo/xfce4-commits
