Merge lp:~jbicha/activity-log-manager/add-security-tab into lp:activity-log-manager

Proposed by Jeremy Bicha
Status: Merged
Merged at revision: 66
Proposed branch: lp:~jbicha/activity-log-manager/add-security-tab
Merge into: lp:activity-log-manager
Diff against target: 241 lines (+187/-0)
5 files modified
po/POTFILES.in (+1/-0)
po/POTFILES.skip (+1/-0)
src/Makefile.am (+1/-0)
src/activity-log-manager.vala (+9/-0)
src/security-widget.vala (+175/-0)
To merge this branch: bzr merge lp:~jbicha/activity-log-manager/add-security-tab
Reviewer Review Type Date Requested Status
Manish Sinha (मनीष सिन्हा) Approve
Review via email: mp+173295@code.launchpad.net

Description of the change

Based mostly on https://wiki.ubuntu.com/SecurityAndPrivacySettings

- According to the design, there should be one more option for "Require my password when logging in" (autologin)

- Also, I couldn't figure out how to directly call the Change Password widget from user-accounts.

I plan to move the other two settings (brightness slider and "delay before the screen blanks") from the Brightness & Lock panel to the Power panel when we land this in Saucy. That's where those settings are in gnome-control-center 3.8 anyway.

To post a comment you must log in.
64. By Jeremy Bicha

add Security tab for Unity (LP: #1189313)

Revision history for this message
Manish Sinha (मनीष सिन्हा) (manishsinha) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'po/POTFILES.in'
2--- po/POTFILES.in 2013-06-12 23:31:37 +0000
3+++ po/POTFILES.in 2013-07-07 19:53:22 +0000
4@@ -3,6 +3,7 @@
5 src/activity-log-manager.vala
6 src/alm.vala
7 src/alm-cc.c
8+src/security-widget.vala
9 src/unified-privacy-files.vala
10 src/unified-privacy-applications.vala
11 src/unified-privacy-history.vala
12
13=== modified file 'po/POTFILES.skip'
14--- po/POTFILES.skip 2013-04-19 06:59:09 +0000
15+++ po/POTFILES.skip 2013-07-07 19:53:22 +0000
16@@ -1,5 +1,6 @@
17 src/activity-log-manager.c
18 src/alm.c
19+src/security-widget.c
20 src/unified-privacy-applications.c
21 src/unified-privacy-history.c
22 src/unified-privacy.c
23
24=== modified file 'src/Makefile.am'
25--- src/Makefile.am 2013-07-03 08:09:42 +0000
26+++ src/Makefile.am 2013-07-07 19:53:22 +0000
27@@ -24,6 +24,7 @@
28 SHARED_SOURCES = \
29 blacklist-dbus.vala \
30 activity-log-manager.vala \
31+ security-widget.vala \
32 unified-privacy-files.vala \
33 unified-privacy-applications.vala \
34 unified-privacy-history.vala \
35
36=== modified file 'src/activity-log-manager.vala'
37--- src/activity-log-manager.vala 2013-06-28 16:24:00 +0000
38+++ src/activity-log-manager.vala 2013-07-07 19:53:22 +0000
39@@ -25,6 +25,7 @@
40
41 public class ActivityLogManager : Gtk.Box {
42 private Gtk.Notebook notebook;
43+ private SecurityWidget security_widget;
44 private PrivacyWidget privacy_widget;
45 private Gtk.Widget whoopsie;
46
47@@ -45,6 +46,14 @@
48 this.pack_start(notebook, true, true, 0);
49 var privacy_label = new Gtk.Label(_("Files & Applications"));
50 notebook.append_page(privacy_widget, privacy_label);
51+
52+ if (GLib.Environment.get_variable ("XDG_CURRENT_DESKTOP") == "Unity")
53+ {
54+ security_widget = new SecurityWidget();
55+ var security_label = new Gtk.Label(_("Security"));
56+ notebook.prepend_page(security_widget, security_label);
57+ }
58+
59 var whoopsie_label = new Gtk.Label(_("Diagnostics"));
60 notebook.append_page(whoopsie, whoopsie_label);
61 this.show_all();
62
63=== added file 'src/security-widget.vala'
64--- src/security-widget.vala 1970-01-01 00:00:00 +0000
65+++ src/security-widget.vala 2013-07-07 19:53:22 +0000
66@@ -0,0 +1,175 @@
67+/* -*- Mode: vala; tab-width: 4; intend-tabs-mode: t -*- */
68+/* alm
69+ *
70+ * Copyright (C) 2013 Jeremy Bicha <jbicha@ubuntu.com>
71+ *
72+ * alm is free software: you can redistribute it and/or modify it
73+ * under the terms of the GNU Lesser General Public License as published
74+ * by the Free Software Foundation, either version 2 of the License, or
75+ * (at your option) any later version.
76+ *
77+ * alm is distributed in the hope that it will be useful, but
78+ * WITHOUT ANY WARRANTY; without even the implied warranty of
79+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
80+ * See the GNU Lesser General Public License for more details.
81+ *
82+ * You should have received a copy of the GNU Lesser General Public License
83+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
84+ */
85+
86+using Gtk;
87+using Gee;
88+
89+namespace Alm {
90+
91+ public class SecurityWidget : Gtk.Box {
92+
93+ private GLib.Settings power_settings;
94+ private GLib.Settings screensaver_settings;
95+
96+ public SecurityWidget () {
97+ Object (orientation: Orientation.VERTICAL);
98+ this.spacing = 5;
99+ this.set_border_width(12);
100+
101+ power_settings = new GLib.Settings ("org.gnome.settings-daemon.plugins.power");
102+ screensaver_settings = new GLib.Settings ("org.gnome.desktop.screensaver");
103+
104+ this.set_up_ui ();
105+ }
106+
107+ private void set_up_ui () {
108+
109+ Gtk.ListStore liststore_delay = new Gtk.ListStore (2, typeof (string), typeof (int));
110+ Gtk.TreeIter iter;
111+ liststore_delay.append (out iter);
112+ liststore_delay.set (iter, 0, "1 second", 1, 0);
113+ liststore_delay.append (out iter);
114+ liststore_delay.set (iter, 0, "30 seconds", 1, 30);
115+ liststore_delay.append (out iter);
116+ liststore_delay.set (iter, 0, "1 minute", 1, 60);
117+ liststore_delay.append (out iter);
118+ liststore_delay.set (iter, 0, "2 minutes", 1, 120);
119+ liststore_delay.append (out iter);
120+ liststore_delay.set (iter, 0, "3 minutes", 1, 180);
121+ liststore_delay.append (out iter);
122+ liststore_delay.set (iter, 0, "5 minutes", 1, 300);
123+ liststore_delay.append (out iter);
124+ liststore_delay.set (iter, 0, "10 minutes", 1, 600);
125+ liststore_delay.append (out iter);
126+ liststore_delay.set (iter, 0, "30 minutes", 1, 1800);
127+ liststore_delay.append (out iter);
128+ liststore_delay.set (iter, 0, "1 hour", 1, 3600);
129+
130+ var grid = new Grid();
131+ grid.set_halign(Align.START);
132+ grid.set_valign(Align.START);
133+ grid.set_margin_top(25);
134+ grid.set_margin_left(25);
135+ grid.set_column_spacing(25);
136+ grid.set_row_spacing(5);
137+ this.add(grid);
138+
139+ var list_focus = new GLib.List<Widget> ();
140+
141+ var header = new Label("");
142+ header.set_markup("<b>%s</b>".printf(_("Require my password when:")));
143+ grid.attach(header, 0, 0, 1, 1);
144+
145+ var checkbox_suspend = new CheckButton.with_mnemonic (_("_Waking from suspend"));
146+ screensaver_settings.bind ("ubuntu-lock-on-suspend", checkbox_suspend, "active", SettingsBindFlags.DEFAULT);
147+ list_focus.append(checkbox_suspend);
148+ grid.attach(checkbox_suspend, 0, 1, 1, 1);
149+
150+ var checkbox_screensaver = new CheckButton.with_mnemonic (_("_Returning from blank screen"));
151+ screensaver_settings.bind ("lock-enabled", checkbox_screensaver, "active", SettingsBindFlags.DEFAULT);
152+ list_focus.append(checkbox_screensaver);
153+ grid.attach(checkbox_screensaver, 0, 2, 1, 1);
154+
155+ var label_combo_delay = new Label(null);
156+ label_combo_delay.set_markup_with_mnemonic(_("_if screen has been blank for"));
157+ label_combo_delay.set_margin_left(18);
158+ grid.attach(label_combo_delay, 0, 3, 1, 1);
159+
160+ var combo_delay = new ComboBox.with_model(liststore_delay);
161+ combo_delay.changed.connect(set_delay_cb);
162+ label_combo_delay.set_mnemonic_widget(combo_delay);
163+ var cell = new CellRendererText();
164+ combo_delay.pack_start(cell, false);
165+ combo_delay.add_attribute(cell, "text", 0);
166+ list_focus.append(combo_delay);
167+ screensaver_settings.changed["lock-enabled"].connect (() => {
168+ combo_delay.sensitive = screensaver_settings.get_boolean("lock-enabled");
169+ });
170+ combo_delay.sensitive = screensaver_settings.get_boolean("lock-enabled");
171+ screensaver_settings.changed["lock-delay"].connect (() => {
172+ get_delay_cb(combo_delay);
173+ });
174+ get_delay_cb(combo_delay);
175+ grid.attach(combo_delay, 1, 3, 1, 1);
176+
177+ var link_password = new Gtk.LinkButton (_("Password Settings"));
178+ link_password.activate_link.connect (() => {
179+ try {
180+ Process.spawn_command_line_async ("gnome-control-center user-accounts");
181+ } catch (SpawnError e) {
182+ stdout.printf ("Error: %s\n", e.message);
183+ }
184+ return true;
185+ });
186+ link_password.set_halign(Align.START);
187+ list_focus.append(link_password);
188+ grid.attach(link_password, 2, 0, 1, 1);
189+
190+ var link_power = new Gtk.LinkButton(_("Power Settings"));
191+ link_power.activate_link.connect (() => {
192+ try {
193+ Process.spawn_command_line_async ("gnome-control-center power");
194+ } catch (SpawnError e) {
195+ stdout.printf ("Error: %s\n", e.message);
196+ }
197+ return true;
198+ });
199+ link_power.set_halign(Align.START);
200+ list_focus.append(link_power);
201+ grid.attach(link_power, 2, 1, 1, 1);
202+
203+ grid.set_focus_chain(list_focus);
204+
205+ }
206+
207+ private void set_delay_cb (Gtk.ComboBox combo)
208+ {
209+ uint seconds;
210+ TreeIter iter;
211+ combo.get_active_iter(out iter);
212+ combo.model.get(iter, 1, out seconds);
213+ screensaver_settings.set_uint("lock-delay", seconds);
214+ }
215+
216+ private void get_delay_cb (Gtk.ComboBox combo)
217+ {
218+ /* try to make the UI match the lock setting */
219+ int i = 0;
220+ int value_prev = 0;
221+ int value_tmp = 0;
222+ TreeModel model = combo.get_model();
223+ TreeIter iter;
224+ model.get_iter_first(out iter);
225+ var value = screensaver_settings.get_uint("lock-delay");
226+ do {
227+ model.get(iter, 1, out value_tmp);
228+ if (value == value_tmp ||
229+ (value_tmp > value_prev && value < value_tmp))
230+ {
231+ combo.set_active_iter(iter);
232+ return;
233+ }
234+ value_prev = value_tmp;
235+ i++;
236+ } while (model.iter_next(ref iter));
237+ combo.set_active(i - 1);
238+ }
239+
240+ }
241+}

Subscribers

People subscribed via source and target branches