[gnome-control-center/T20771: 18/44] user-accounts: disable lock screen when autologin is enabled



commit 9fdc02955fe907803567c5cc1431c08744bb8950
Author: Cosimo Cecchi <cosimo endlessm com>
Date:   Tue May 6 14:15:40 2014 -0700

    user-accounts: disable lock screen when autologin is enabled

 configure.ac                      |    1 +
 panels/privacy/cc-privacy-panel.c |   39 +++++++++++++++++++++++++++++-------
 2 files changed, 32 insertions(+), 8 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ff1ec1e..2f30640 100644
--- a/configure.ac
+++ b/configure.ac
@@ -151,6 +151,7 @@ PKG_CHECK_MODULES(PRINTERS_PANEL, $COMMON_MODULES
                   polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION
                   smbclient)
 PKG_CHECK_MODULES(PRIVACY_PANEL, $COMMON_MODULES
+                  accountsservice >= $ACCOUNTSSERVICE_REQUIRED_VERSION
                   polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION)
 PKG_CHECK_MODULES(REGION_PANEL, $COMMON_MODULES
                   polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION
diff --git a/panels/privacy/cc-privacy-panel.c b/panels/privacy/cc-privacy-panel.c
index c00675b..5015497 100644
--- a/panels/privacy/cc-privacy-panel.c
+++ b/panels/privacy/cc-privacy-panel.c
@@ -23,6 +23,7 @@
 #include "cc-privacy-resources.h"
 #include "cc-util.h"
 
+#include <act/act.h>
 #include <gio/gdesktopappinfo.h>
 #include <glib/gi18n.h>
 #include <polkit/polkit.h>
@@ -387,23 +388,45 @@ add_screen_lock (CcPrivacyPanel *self)
   GtkWidget *w;
   GtkWidget *dialog;
   GtkWidget *label;
+  ActUserManager *um;
+  ActUser *user;
+  gboolean automatic_login;
 
-  w = get_on_off_label (self->priv->lock_settings, "lock-enabled");
-  add_row (self, _("Screen Lock"), "screen_lock_dialog", w);
+  um = act_user_manager_get_default ();
+  user = act_user_manager_get_user_by_id (um, getuid ());
+  automatic_login = act_user_get_automatic_login (user);
+
+  if (automatic_login) {
+    add_row (self, _("Screen Lock"), "screen_lock_dialog", gtk_label_new (_("Off")));
+  } else {
+    w = get_on_off_label (self->priv->lock_settings, "lock-enabled");
+    add_row (self, _("Screen Lock"), "screen_lock_dialog", w);
+  }
 
   dialog = self->priv->screen_lock_dialog;
   g_signal_connect (dialog, "delete-event",
                     G_CALLBACK (gtk_widget_hide_on_delete), NULL);
 
   w = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "automatic_screen_lock"));
-  g_settings_bind (self->priv->lock_settings, "lock-enabled",
-                   w, "active",
-                   G_SETTINGS_BIND_DEFAULT);
+
+  if (automatic_login) {
+    gtk_switch_set_active (GTK_SWITCH (w), FALSE);
+    gtk_widget_set_sensitive (w, FALSE);
+  } else {
+    g_settings_bind (self->priv->lock_settings, "lock-enabled",
+                     w, "active",
+                     G_SETTINGS_BIND_DEFAULT);
+  }
 
   w = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "lock_after_combo"));
-  g_settings_bind (self->priv->lock_settings, "lock-enabled",
-                   w, "sensitive",
-                   G_SETTINGS_BIND_GET);
+
+  if (automatic_login) {
+    gtk_widget_set_sensitive (w, FALSE);
+  } else {
+    g_settings_bind (self->priv->lock_settings, "lock-enabled",
+                     w, "sensitive",
+                     G_SETTINGS_BIND_GET);
+  }
 
   label = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "lock_after_label"));
 


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