From a4190caa85842de9af9880729c41b07945265cf2 Mon Sep 17 00:00:00 2001 From: Umang Jain Date: Fri, 28 Feb 2020 17:23:09 +0530 Subject: [PATCH] panels: lock: Disable lock screen when autologin is enabled Note 2020-08-26: This patch has been in Endless OS since 2014; proposing it upstream. Presumably if you have autologin enabled you're not depending on your account password to keep your computer secure. --- panels/lock/cc-lock-panel.c | 42 +++++++++++++++++++++++++++--------- panels/lock/cc-lock-panel.ui | 4 ++-- panels/lock/meson.build | 6 +++++- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/panels/lock/cc-lock-panel.c b/panels/lock/cc-lock-panel.c index 86800e871b..f2907f0413 100644 --- a/panels/lock/cc-lock-panel.c +++ b/panels/lock/cc-lock-panel.c @@ -24,6 +24,7 @@ #include "cc-lock-resources.h" #include "cc-util.h" +#include #include #include @@ -46,6 +47,9 @@ struct _CcLockPanel GtkSwitch *usb_protection_switch; GDBusProxy *usb_proxy; GtkListBoxRow *usb_protection_row; + + GtkWidget *automatic_screen_lock_delay_row; + GtkWidget *automatic_screen_lock_row; }; CC_PANEL_REGISTER (CcLockPanel, cc_lock_panel) @@ -270,6 +274,8 @@ cc_lock_panel_class_init (CcLockPanelClass *klass) gtk_widget_class_bind_template_child (widget_class, CcLockPanel, show_notifications_switch); gtk_widget_class_bind_template_child (widget_class, CcLockPanel, usb_protection_switch); gtk_widget_class_bind_template_child (widget_class, CcLockPanel, usb_protection_row); + gtk_widget_class_bind_template_child (widget_class, CcLockPanel, automatic_screen_lock_row); + gtk_widget_class_bind_template_child (widget_class, CcLockPanel, automatic_screen_lock_delay_row); gtk_widget_class_bind_template_callback (widget_class, on_blank_screen_delay_changed_cb); gtk_widget_class_bind_template_callback (widget_class, on_lock_combo_changed_cb); @@ -279,6 +285,9 @@ static void cc_lock_panel_init (CcLockPanel *self) { guint value; + ActUserManager *um; + ActUser *user; + gboolean automatic_login; g_resources_register (cc_lock_get_resource ()); @@ -295,17 +304,30 @@ cc_lock_panel_init (CcLockPanel *self) self->notification_settings = g_settings_new ("org.gnome.desktop.notifications"); self->session_settings = g_settings_new ("org.gnome.desktop.session"); - g_settings_bind (self->lock_settings, - "lock-enabled", - self->automatic_screen_lock_switch, - "active", - G_SETTINGS_BIND_DEFAULT); + um = act_user_manager_get_default (); + user = act_user_manager_get_user_by_id (um, getuid ()); + automatic_login = act_user_get_automatic_login (user); - g_settings_bind (self->lock_settings, - "lock-enabled", - self->lock_after_combo, - "sensitive", - G_SETTINGS_BIND_GET); + if (automatic_login) + { + gtk_switch_set_active (self->automatic_screen_lock_switch, FALSE); + gtk_widget_set_sensitive (self->automatic_screen_lock_row, FALSE); + gtk_widget_set_sensitive (self->automatic_screen_lock_delay_row, FALSE); + } + else + { + g_settings_bind (self->lock_settings, + "lock-enabled", + self->automatic_screen_lock_switch, + "active", + G_SETTINGS_BIND_DEFAULT); + + g_settings_bind (self->lock_settings, + "lock-enabled", + self->lock_after_combo, + "sensitive", + G_SETTINGS_BIND_GET); + } set_lock_value_for_combo (self->lock_after_combo, self); diff --git a/panels/lock/cc-lock-panel.ui b/panels/lock/cc-lock-panel.ui index f32dde1115..3fdf537d33 100644 --- a/panels/lock/cc-lock-panel.ui +++ b/panels/lock/cc-lock-panel.ui @@ -60,7 +60,7 @@ - + true Automatic Screen _Lock automatic_screen_lock_switch @@ -77,7 +77,7 @@ - + true Automatic _Screen Lock Delay Period after the screen blanks when the screen is automatically locked. diff --git a/panels/lock/meson.build b/panels/lock/meson.build index 0661af4fa0..10ab3aca2e 100644 --- a/panels/lock/meson.build +++ b/panels/lock/meson.build @@ -29,12 +29,16 @@ sources += gnome.compile_resources( export: true ) +deps = common_deps + [ + accounts_dep, +] + cflags += '-DGNOMELOCALEDIR="@0@"'.format(control_center_localedir) panels_libs += static_library( cappletname, sources: sources, include_directories: [top_inc, common_inc], - dependencies: common_deps, + dependencies: deps, c_args: cflags ) -- GitLab