Merge lp:~elementary-pantheon/switchboard-plug-security-privacy/plug-organize into lp:~elementary-apps/switchboard-plug-security-privacy/trunk

Proposed by Danielle Foré
Status: Merged
Approved by: David Hewitt
Approved revision: 295
Merged at revision: 295
Proposed branch: lp:~elementary-pantheon/switchboard-plug-security-privacy/plug-organize
Merge into: lp:~elementary-apps/switchboard-plug-security-privacy/trunk
Diff against target: 104 lines (+32/-26)
1 file modified
src/Plug.vala (+32/-26)
To merge this branch: bzr merge lp:~elementary-pantheon/switchboard-plug-security-privacy/plug-organize
Reviewer Review Type Date Requested Status
David Hewitt code, function Approve
Review via email: mp+318329@code.launchpad.net

Commit message

Plug.vala:
* update copyright header
* brackets on if, add whitespace where appropriate
* group properties with var declarations
* Always show infobar, only showing the unlock action is contingent on getting polkit permission

To post a comment you must log in.
Revision history for this message
David Hewitt (davidmhewitt) :
review: Approve (code, function)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Plug.vala'
2--- src/Plug.vala 2016-11-02 00:52:31 +0000
3+++ src/Plug.vala 2017-02-26 18:18:53 +0000
4@@ -1,6 +1,6 @@
5 // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
6 /*-
7- * Copyright (c) 2014 Security & Privacy Plug (http://launchpad.net/your-project)
8+ * Copyright (c) 2014-2017 elementary LLC. (https://launchpad.net/switchboard-plug-security-privacy)
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12@@ -19,6 +19,7 @@
13 *
14 * Authored by: Corentin Noël <tintou@mailoo.org>
15 */
16+
17 namespace SecurityPrivacy {
18
19 public static Plug plug;
20@@ -57,24 +58,44 @@
21 }
22
23 public override void shown () {
24- if (main_grid.get_children ().length () > 0)
25+ if (main_grid.get_children ().length () > 0) {
26 return;
27+ }
28+
29+ var label = new Gtk.Label (_("Some settings require administrator rights to be changed"));
30+
31+ var infobar = new Gtk.InfoBar ();
32+ infobar.message_type = Gtk.MessageType.INFO;
33+ infobar.no_show_all = true;
34+ infobar.get_content_area ().add (label);
35+
36+ tracking = new TrackPanel ();
37+ var locking = new LockPanel ();
38+ var firewall = new FirewallPanel ();
39
40 stack = new Gtk.Stack ();
41- stack.expand = true;
42+ stack.add_titled (tracking, "tracking", _("Privacy"));
43+ stack.add_titled (locking, "locking", _("Locking"));
44+ stack.add_titled (firewall, "firewall", _("Firewall"));
45+
46+ var stack_switcher = new Gtk.StackSwitcher ();
47+ stack_switcher.set_stack (stack);
48+ stack_switcher.halign = Gtk.Align.CENTER;
49+ stack_switcher.margin = 12;
50+
51+ main_grid.attach (infobar, 0, 0, 1, 1);
52+ main_grid.attach (stack_switcher, 0, 1, 1, 1);
53+ main_grid.attach (stack, 0, 2, 1, 1);
54+ main_grid.show_all ();
55
56 try {
57 var permission = new Polkit.Permission.sync ("org.pantheon.security-privacy", Polkit.UnixProcess.new (Posix.getpid ()));
58- var infobar = new Gtk.InfoBar ();
59- infobar.message_type = Gtk.MessageType.INFO;
60+
61 lock_button = new Gtk.LockButton (permission);
62+
63 var area = infobar.get_action_area () as Gtk.Container;
64- var content = infobar.get_content_area () as Gtk.Container;
65- var label = new Gtk.Label (_("Some settings require administrator rights to be changed"));
66 area.add (lock_button);
67- content.add (label);
68- main_grid.attach (infobar, 0, 0, 1, 1);
69- infobar.no_show_all = true;
70+
71 stack.notify["visible-child-name"].connect (() => {
72 if (permission.allowed == false && stack.visible_child_name == "firewall") {
73 infobar.no_show_all = false;
74@@ -84,6 +105,7 @@
75 infobar.hide ();
76 }
77 });
78+
79 permission.notify["allowed"].connect (() => {
80 if (permission.allowed == false && stack.visible_child_name == "firewall") {
81 infobar.no_show_all = false;
82@@ -96,22 +118,6 @@
83 } catch (Error e) {
84 critical (e.message);
85 }
86-
87- var stack_switcher = new Gtk.StackSwitcher ();
88- stack_switcher.set_stack (stack);
89- stack_switcher.halign = Gtk.Align.CENTER;
90- stack_switcher.margin = 12;
91-
92- tracking = new TrackPanel ();
93- stack.add_titled (tracking, "tracking", _("Privacy"));
94- var locking = new LockPanel ();
95- stack.add_titled (locking, "locking", _("Locking"));
96- var firewall = new FirewallPanel ();
97- stack.add_titled (firewall, "firewall", _("Firewall"));
98-
99- main_grid.attach (stack_switcher, 0, 1, 1, 1);
100- main_grid.attach (stack, 0, 2, 1, 1);
101- main_grid.show_all ();
102 }
103
104 public override void hidden () {

Subscribers

People subscribed via source and target branches