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

Proposed by Danielle Foré
Status: Merged
Approved by: David Hewitt
Approved revision: 298
Merged at revision: 299
Proposed branch: lp:~elementary-pantheon/switchboard-plug-security-privacy/sidebar-nav
Merge into: lp:~elementary-apps/switchboard-plug-security-privacy/trunk
Diff against target: 226 lines (+114/-14)
7 files modified
src/CMakeLists.txt (+2/-0)
src/Plug.vala (+17/-8)
src/Views/FirewallPanel.vala (+5/-3)
src/Views/LockPanel.vala (+1/-0)
src/Views/TrackPanel.vala (+4/-3)
src/Widgets/ServiceItem.vala (+69/-0)
src/Widgets/ServiceList.vala (+16/-0)
To merge this branch: bzr merge lp:~elementary-pantheon/switchboard-plug-security-privacy/sidebar-nav
Reviewer Review Type Date Requested Status
David Hewitt Approve
Review via email: mp+318330@code.launchpad.net

Commit message

Add ServiceItem and ServiceList widgets

Plug.vala: Add ServiceList instead of StackSwitcher

FirewallPanel.vala,
TrackPanel.vala:
* Fix frame issues
* Margin on top

Description of the change

This is mainly to facilitate the fact that we're going to have lots of new pages for the various agents, but it will also allow us to communicate status of various services

To post a comment you must log in.
298. By Danielle Foré

use network-firewall icon

Revision history for this message
David Hewitt (davidmhewitt) wrote :

Looks good, but navigating the plug with the tab key on the keyboard got much harder. It's not too bad with the arrow keys but I feel like the tab focus order isn't what I'd expect it to be. Would you agree?

review: Needs Information
Revision history for this message
Danielle Foré (danrabbit) wrote :

afaik tab focus is set totally by Gtk+ automatically. It seems to work the same way across all the plugs

Revision history for this message
David Hewitt (davidmhewitt) wrote :

It is possible to set the tab focus order with set_focus_chain but I see that the other plugs with a sidebar like the network plug and the language & region plug have what I'd consider a slightly strange focus order. So beyond the scope of this merge request.

Everything else looked good, so I'm approving.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CMakeLists.txt'
2--- src/CMakeLists.txt 2017-02-26 17:34:10 +0000
3+++ src/CMakeLists.txt 2017-02-27 01:30:54 +0000
4@@ -25,6 +25,8 @@
5 Widgets/AppChooser.vala
6 Widgets/AppRow.vala
7 Widgets/ClearUsagePopover.vala
8+ Widgets/ServiceItem.vala
9+ Widgets/ServiceList.vala
10
11 ${CMAKE_CURRENT_BINARY_DIR}/config.vala
12 PACKAGES
13
14=== modified file 'src/Plug.vala'
15--- src/Plug.vala 2017-02-26 18:17:34 +0000
16+++ src/Plug.vala 2017-02-27 01:30:54 +0000
17@@ -78,16 +78,25 @@
18 stack.add_titled (locking, "locking", _("Locking"));
19 stack.add_titled (firewall, "firewall", _("Firewall"));
20
21- var stack_switcher = new Gtk.StackSwitcher ();
22- stack_switcher.set_stack (stack);
23- stack_switcher.halign = Gtk.Align.CENTER;
24- stack_switcher.margin = 12;
25-
26- main_grid.attach (infobar, 0, 0, 1, 1);
27- main_grid.attach (stack_switcher, 0, 1, 1, 1);
28- main_grid.attach (stack, 0, 2, 1, 1);
29+ var grid = new Gtk.Grid ();
30+ grid.attach (infobar, 0, 0, 1, 1);
31+ grid.attach (stack, 0, 3, 1, 1);
32+
33+ var service_list = new ServiceList ();
34+
35+ var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL);
36+ paned.position = 200;
37+ paned.add1 (service_list);
38+ paned.add2 (grid);
39+
40+ main_grid.add (paned);
41 main_grid.show_all ();
42
43+ service_list.row_selected.connect ((row) => {
44+ var title = ((ServiceItem)row).title;
45+ stack.visible_child_name = title;
46+ });
47+
48 try {
49 var permission = new Polkit.Permission.sync ("org.pantheon.security-privacy", Polkit.UnixProcess.new (Posix.getpid ()));
50
51
52=== modified file 'src/Views/FirewallPanel.vala'
53--- src/Views/FirewallPanel.vala 2017-02-19 21:27:25 +0000
54+++ src/Views/FirewallPanel.vala 2017-02-27 01:30:54 +0000
55@@ -42,7 +42,6 @@
56 column_spacing = 12;
57 row_spacing = 6;
58 margin = 12;
59- margin_top = 0;
60 orientation = Gtk.Orientation.VERTICAL;
61
62 var status_grid = new Gtk.Grid ();
63@@ -254,12 +253,15 @@
64 var view_grid = new Gtk.Grid ();
65
66 var scrolled = new Gtk.ScrolledWindow (null, null);
67- scrolled.shadow_type = Gtk.ShadowType.IN;
68 scrolled.expand = true;
69 scrolled.add (view);
70
71 view_grid.attach (scrolled, 0, 0, 1, 1);
72 view_grid.attach (list_toolbar, 0, 1, 1, 1);
73- add (view_grid);
74+
75+ var frame = new Gtk.Frame (null);
76+ frame.add (view_grid);
77+
78+ add (frame);
79 }
80 }
81
82=== modified file 'src/Views/LockPanel.vala'
83--- src/Views/LockPanel.vala 2017-02-19 21:27:25 +0000
84+++ src/Views/LockPanel.vala 2017-02-27 01:30:54 +0000
85@@ -27,6 +27,7 @@
86 public LockPanel () {
87 column_spacing = 12;
88 row_spacing = 6;
89+ margin = 12;
90
91 locker = new Settings ("apps.light-locker");
92
93
94=== modified file 'src/Views/TrackPanel.vala'
95--- src/Views/TrackPanel.vala 2017-02-25 23:38:34 +0000
96+++ src/Views/TrackPanel.vala 2017-02-27 01:30:54 +0000
97@@ -102,7 +102,6 @@
98 column_spacing = 12;
99 row_spacing = 12;
100 margin = 12;
101- margin_top = 0;
102
103 create_include_treeview ();
104 create_exclude_treeview ();
105@@ -231,7 +230,6 @@
106 view.insert_column_with_attributes (-1, "", cell, "markup", NotColumns.NAME);
107
108 var scrolled = new Gtk.ScrolledWindow (null, null);
109- scrolled.shadow_type = Gtk.ShadowType.IN;
110 scrolled.expand = true;
111 scrolled.add (view);
112
113@@ -301,6 +299,9 @@
114 frame_grid.add (scrolled);
115 frame_grid.add (list_toolbar);
116
117+ var frame = new Gtk.Frame (null);
118+ frame.add (frame_grid);
119+
120 var record_label = new Gtk.Label (_("Do not collect data from the following:"));
121 record_label.xalign = 0;
122
123@@ -308,7 +309,7 @@
124 exclude_grid.row_spacing = 6;
125 exclude_grid.orientation = Gtk.Orientation.VERTICAL;
126 exclude_grid.add (record_label);
127- exclude_grid.add (frame_grid);
128+ exclude_grid.add (frame);
129 attach (exclude_grid, 1, 0, 1, 1);
130
131 view.cursor_changed.connect (() => {
132
133=== added file 'src/Widgets/ServiceItem.vala'
134--- src/Widgets/ServiceItem.vala 1970-01-01 00:00:00 +0000
135+++ src/Widgets/ServiceItem.vala 2017-02-27 01:30:54 +0000
136@@ -0,0 +1,69 @@
137+public class ServiceItem: Gtk.ListBoxRow {
138+ public enum Status {
139+ ENABLED,
140+ DISABLED
141+ }
142+
143+ public Status status {
144+ set {
145+ switch (value) {
146+ case Status.ENABLED:
147+ status_icon.icon_name = "user-available";
148+ status_label.label = _("Enabled");
149+ break;
150+ case Status.DISABLED:
151+ status_icon.icon_name = "user-offline";
152+ status_label.label = _("Disabled");
153+ break;
154+ }
155+ status_label.no_show_all = false;
156+ status_label.label = "<span font_size='small'>" + status_label.label + "</span>";
157+ }
158+ }
159+
160+ private Gtk.Image status_icon;
161+ private Gtk.Label status_label;
162+
163+ public string icon_name { get; construct; }
164+ public string label { get; construct; }
165+ public string title { get; construct; }
166+
167+ public ServiceItem (string icon_name, string title, string label) {
168+ Object (icon_name: icon_name,
169+ label: label,
170+ title: title);
171+ }
172+
173+ construct {
174+ var icon = new Gtk.Image.from_icon_name (icon_name, Gtk.IconSize.DND);
175+
176+ var title_label = new Gtk.Label (label);
177+ title_label.get_style_context ().add_class ("h3");
178+ title_label.ellipsize = Pango.EllipsizeMode.END;
179+ title_label.xalign = 0;
180+
181+ status_icon = new Gtk.Image ();
182+ status_icon.halign = Gtk.Align.END;
183+ status_icon.valign = Gtk.Align.END;
184+
185+ status_label = new Gtk.Label (null);
186+ status_label.no_show_all = true;
187+ status_label.use_markup = true;
188+ status_label.ellipsize = Pango.EllipsizeMode.END;
189+ status_label.xalign = 0;
190+
191+ var overlay = new Gtk.Overlay ();
192+ overlay.width_request = 38;
193+ overlay.add (icon);
194+ overlay.add_overlay (status_icon);
195+
196+ var grid = new Gtk.Grid ();
197+ grid.margin = 6;
198+ grid.column_spacing = 6;
199+ grid.attach (overlay, 0, 0, 1, 2);
200+ grid.attach (title_label, 1, 0, 1, 1);
201+ grid.attach (status_label, 1, 1, 1, 1);
202+
203+ add (grid);
204+ }
205+}
206
207=== added file 'src/Widgets/ServiceList.vala'
208--- src/Widgets/ServiceList.vala 1970-01-01 00:00:00 +0000
209+++ src/Widgets/ServiceList.vala 2017-02-27 01:30:54 +0000
210@@ -0,0 +1,16 @@
211+public class ServiceList : Gtk.ListBox {
212+ public ServiceList () {
213+ Object (activate_on_single_click: true,
214+ selection_mode: Gtk.SelectionMode.SINGLE);
215+ }
216+
217+ construct {
218+ var privacy_item = new ServiceItem ("document-open-recent", "tracking", _("Privacy"));
219+ var lock_item = new ServiceItem ("system-lock-screen", "locking", _("Locking"));
220+ var firewall_item = new ServiceItem ("network-firewall", "firewall", _("Firewall"));
221+
222+ add (privacy_item);
223+ add (lock_item);
224+ add (firewall_item);
225+ }
226+}

Subscribers

People subscribed via source and target branches