[gnome-control-center] power: Use logind to discover CanHibernate



commit 364eee3909e37baf6e80d84243a6f84ba6df333f
Author: Jan Alexander Steffens (heftig) <jan steffens gmail com>
Date:   Thu Aug 1 11:55:41 2013 +0200

    power: Use logind to discover CanHibernate
    
    The upower functionality is deprecated and will return an
    error unless upower is built with --enable-deprecated.
    
    The function is also not defined unless the application defines
    UPOWER_ENABLE_DEPRECATED, which g-c-c does not do, and the build
    system currently does not enable the warning (or error) about this.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705275

 panels/power/cc-power-panel.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 7a772d9..3d23e0b 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -1839,6 +1839,8 @@ add_automatic_suspend_section (CcPowerPanel *self)
   GtkWidget *dialog;
   GtkWidget *combo;
   GtkCellRenderer *cell;
+  GVariant *result;
+  GDBusConnection *connection;
 
   /* The default values for these settings are unfortunate for us;
    * timeout == 0, action == suspend means 'do nothing' - just
@@ -1926,7 +1928,31 @@ add_automatic_suspend_section (CcPowerPanel *self)
   gtk_widget_set_margin_bottom (label, 6);
   gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
 
-  if (up_client_get_can_hibernate (self->priv->up_client))
+  value = 0;
+
+  connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
+  result = g_dbus_connection_call_sync (connection,
+                                        "org.freedesktop.login1",
+                                        "/org/freedesktop/login1",
+                                        "org.freedesktop.login1.Manager",
+                                        "CanHibernate",
+                                        NULL,
+                                        NULL,
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        NULL);
+  g_object_unref (connection);
+
+  if (result)
+    {
+      g_variant_get (result, "(s)", &s);
+      if (g_strcmp0 (s, "yes") == 0)
+        value = 1;
+      g_variant_unref(result);
+    }
+
+  if (value)
     {
       model = (GtkTreeModel*)gtk_builder_get_object (priv->builder, "liststore_critical");
       priv->critical_battery_combo = sw = gtk_combo_box_new_with_model (model);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]