Merge lp:~elementary-pantheon/switchboard-plug-parental-controls/ui-cleanups into lp:~elementary-pantheon/switchboard-plug-parental-controls/trunk

Proposed by Danielle Foré
Status: Merged
Approved by: Adam Bieńkowski
Approved revision: 153
Merged at revision: 149
Proposed branch: lp:~elementary-pantheon/switchboard-plug-parental-controls/ui-cleanups
Merge into: lp:~elementary-pantheon/switchboard-plug-parental-controls/trunk
Diff against target: 472 lines (+103/-146)
5 files modified
src/Plug.vala (+1/-4)
src/Widgets/AppsBox.vala (+33/-42)
src/Widgets/GeneralBox.vala (+41/-54)
src/Widgets/InternetBox.vala (+18/-29)
src/Widgets/UserItem.vala (+10/-17)
To merge this branch: bzr merge lp:~elementary-pantheon/switchboard-plug-parental-controls/ui-cleanups
Reviewer Review Type Date Requested Status
Adam Bieńkowski (community) code / testing Approve
Review via email: mp+295250@code.launchpad.net

Commit message

Plug.vala:
* Remove extra box

AppsBox.vala:
* Use Grid instead of Box
* Use View class to style frame instead of hardcoding colors
* Use ActionBar instead of ToolBar with expander
* Make header consistent with InternetBox

GeneralBox.vala:
* Use Grid instead of Box
* Use Property bindings instead of methods
* Use Construct method
* Use View class to style frame instead of hardcoding colors
* Don't hardcode magic number margins

InternetBox.vala:
* Use Grid instead of Box
* Use View class to style frame instead of hardcoding colors
* Make header consistent with AppsBox

UserItem.vala:
* Ellipsize name
* Use Grid instead of Box

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

expand so switch is always at end of the user list

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

Good job on cleaning the UI, looks much more consistent & clean.

review: Approve (code / testing)

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-05-18 15:47:51 +0000
3+++ src/Plug.vala 2016-05-19 19:08:23 +0000
4@@ -44,7 +44,6 @@
5 content = new Gtk.Stack ();
6 content.hexpand = true;
7
8- var sidebar = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
9 list = new Widgets.UserListBox ();
10 list.row_activated.connect ((row) => {
11 if (content.get_children ().find (((Widgets.UserItem) row).page) == null) {
12@@ -59,9 +58,7 @@
13 scrolled_window.add (list);
14 scrolled_window.vexpand = true;
15
16- sidebar.pack_start (scrolled_window, true, true);
17-
18- paned.pack1 (sidebar, false, false);
19+ paned.pack1 (scrolled_window, true, true);
20 paned.pack2 (content, true, false);
21 paned.set_position (240);
22
23
24=== modified file 'src/Widgets/AppsBox.vala'
25--- src/Widgets/AppsBox.vala 2016-05-18 15:39:48 +0000
26+++ src/Widgets/AppsBox.vala 2016-05-19 19:08:23 +0000
27@@ -21,7 +21,7 @@
28 */
29
30 namespace PC.Widgets {
31- public class AppsBox : Gtk.Box {
32+ public class AppsBox : Gtk.Grid {
33 public signal void update_key_file ();
34
35 public string[] targets = {};
36@@ -34,8 +34,8 @@
37 private Gtk.ListBox list_box;
38 private AppChooser apps_popover;
39 private Gtk.Switch admin_switch_btn;
40- private Gtk.ToolButton remove_button;
41- private Gtk.ToolButton clear_button;
42+ private Gtk.Button remove_button;
43+ private Gtk.Button clear_button;
44
45
46 protected class AppEntry : Gtk.ListBoxRow {
47@@ -52,6 +52,7 @@
48 main_grid.orientation = Gtk.Orientation.HORIZONTAL;
49
50 main_grid.margin = 6;
51+ main_grid.margin_start = 12;
52 main_grid.column_spacing = 12;
53
54 var image = new Gtk.Image.from_gicon (info.get_icon (), Gtk.IconSize.LARGE_TOOLBAR);
55@@ -87,75 +88,65 @@
56 this.user = user;
57 entries = new List<AppEntry> ();
58
59- orientation = Gtk.Orientation.VERTICAL;
60- spacing = 12;
61-
62- var admin_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
63-
64- var admin_label = new Gtk.Label (_("Allow access to these apps with admin permission:"));
65- admin_box.add (admin_label);
66-
67- admin_switch_btn = new Gtk.Switch ();
68- admin_switch_btn.notify["active"].connect (on_changed);
69- admin_box.add (admin_switch_btn);
70-
71- var frame = new Gtk.Frame (null);
72- frame.hexpand = frame.vexpand = true;
73-
74- Gdk.RGBA bg = { 1, 1, 1, 1 };
75- frame.override_background_color (0, bg);
76-
77- var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
78- frame.add (main_box);
79+ column_spacing = 12;
80+ row_spacing = 12;
81
82 var scrolled = new Gtk.ScrolledWindow (null, null);
83 scrolled.hexpand = scrolled.vexpand = true;
84
85- var header_label = new Gtk.Label (_("Add apps to prevent %s from using them:").printf (user.get_real_name ()));
86- header_label.margin_start = 6;
87+ var header_label = new Gtk.Label (_("Prevent %s from using these apps:").printf (user.get_real_name ()));
88+ header_label.margin_start = 12;
89+ header_label.margin_top = 6;
90 header_label.halign = Gtk.Align.START;
91 header_label.get_style_context ().add_class ("h4");
92
93- main_box.add (header_label);
94-
95 list_box = new Gtk.ListBox ();
96 list_box.row_selected.connect (on_changed);
97 scrolled.add (list_box);
98
99- var toolbar = new Gtk.Toolbar ();
100- toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_INLINE_TOOLBAR);
101- toolbar.icon_size = Gtk.IconSize.SMALL_TOOLBAR;
102-
103- var add_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("list-add-symbolic", Gtk.IconSize.BUTTON), null);
104+ var add_button = new Gtk.Button.from_icon_name ("list-add-symbolic", Gtk.IconSize.MENU);
105 add_button.tooltip_text = _("Add Prevented Apps…");
106 add_button.clicked.connect (on_add_button_clicked);
107
108- remove_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("list-remove-symbolic", Gtk.IconSize.BUTTON), null);
109+ remove_button = new Gtk.Button.from_icon_name ("list-remove-symbolic", Gtk.IconSize.MENU);
110 remove_button.tooltip_text = _("Remove Selected App");
111 remove_button.sensitive = false;
112 remove_button.clicked.connect (on_remove_button_clicked);
113
114- var expander = new Gtk.ToolItem ();
115- expander.set_expand (true);
116- expander.visible_vertical = false;
117-
118- clear_button = new Gtk.ToolButton (null, _("Clear"));
119+ clear_button = new Gtk.Button.from_icon_name ("edit-clear-all-symbolic", Gtk.IconSize.MENU);
120+ clear_button.tooltip_text = _("Clear All");
121 clear_button.sensitive = false;
122 clear_button.clicked.connect (on_clear_button_clicked);
123
124 apps_popover = new AppChooser (add_button);
125 apps_popover.app_chosen.connect (load_info);
126
127+ var toolbar = new Gtk.ActionBar ();
128+ toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_INLINE_TOOLBAR);
129 toolbar.add (add_button);
130 toolbar.add (remove_button);
131- toolbar.add (expander);
132- toolbar.add (clear_button);
133+ toolbar.pack_end (clear_button);
134
135+ var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
136+ main_box.add (header_label);
137+ main_box.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL));
138 main_box.add (scrolled);
139 main_box.add (toolbar);
140
141- add (frame);
142- add (admin_box);
143+ var frame = new Gtk.Frame (null);
144+ frame.get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW);
145+ frame.add (main_box);
146+
147+ var admin_label = new Gtk.Label (_("Allow access to these apps with admin permission:"));
148+ admin_label.halign = Gtk.Align.END;
149+
150+ admin_switch_btn = new Gtk.Switch ();
151+ admin_switch_btn.halign = Gtk.Align.START;
152+ admin_switch_btn.notify["active"].connect (on_changed);
153+
154+ attach (frame, 0, 0, 2, 1);
155+ attach (admin_label, 0, 1, 1, 1);
156+ attach (admin_switch_btn, 1, 1, 1, 1);
157
158 load_existing ();
159 show_all ();
160
161=== modified file 'src/Widgets/GeneralBox.vala'
162--- src/Widgets/GeneralBox.vala 2016-05-18 15:29:00 +0000
163+++ src/Widgets/GeneralBox.vala 2016-05-19 19:08:23 +0000
164@@ -21,7 +21,7 @@
165 */
166
167 namespace PC.Widgets {
168- public class GeneralBox : Gtk.Box {
169+ public class GeneralBox : Gtk.Grid {
170 private string plank_conf_file_path = "";
171 private Act.User user;
172 private Gtk.CheckButton dock_btn;
173@@ -38,54 +38,53 @@
174 this.user = user;
175 plank_conf_file_path = Path.build_filename (user.get_home_dir (), Vars.PLANK_CONF_DIR);
176
177- margin_start = margin_end = 12;
178- spacing = 12;
179- orientation = Gtk.Orientation.VERTICAL;
180-
181- var allow_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
182- allow_box.halign = Gtk.Align.CENTER;
183+ dock_btn.notify["active"].connect (on_dock_btn_activate);
184+
185+ print_btn.notify["active"].connect (on_print_conf_activate);
186+
187+ limit_switch.notify["active"].connect (on_limit_switch_changed);
188+ limit_switch.bind_property ("active", limit_combobox, "sensitive", GLib.BindingFlags.SYNC_CREATE);
189+ limit_switch.bind_property ("active", frame, "sensitive", GLib.BindingFlags.SYNC_CREATE);
190+
191+ limit_combobox.changed.connect (on_limit_combobox_changed);
192+
193+ weekday_box.changed.connect (update_pam);
194+ weekend_box.changed.connect (update_pam);
195+
196+ monitor_updates ();
197+ update ();
198+ load_restrictions ();
199+ }
200+
201+ construct {
202+ column_spacing = 12;
203+ row_spacing = 6;
204
205 var main_label = new Gtk.Label (_("Allow this user to:"));
206- main_label.valign = Gtk.Align.START;
207- main_label.margin_end = 12;
208- allow_box.add (main_label);
209-
210- var checkbutton_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
211- allow_box.add (checkbutton_box);
212+ main_label.halign = Gtk.Align.END;
213
214 dock_btn = new Gtk.CheckButton.with_label (_("Modify the dock"));
215- dock_btn.notify["active"].connect (on_dock_btn_activate);
216- dock_btn.margin_end = 82;
217- checkbutton_box.add (dock_btn);
218+ dock_btn.halign = Gtk.Align.START;
219
220 print_btn = new Gtk.CheckButton.with_label (_("Configure printing"));
221- print_btn.notify["active"].connect (on_print_conf_activate);
222- checkbutton_box.add (print_btn);
223-
224- var limit_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 12);
225-
226- var limit_method_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
227- limit_method_box.add (new Gtk.Label (_("Limit computer use:")));
228+ print_btn.halign = Gtk.Align.START;
229+ print_btn.margin_bottom = 18;
230+
231+ var limit_method_label = new Gtk.Label (_("Limit computer use:"));
232+ limit_method_label.halign = Gtk.Align.END;
233+
234+ limit_switch = new Gtk.Switch ();
235+ limit_switch.valign = Gtk.Align.CENTER;
236
237 limit_combobox = new Gtk.ComboBoxText ();
238 limit_combobox.hexpand = true;
239- limit_combobox.margin_end = 64;
240 limit_combobox.append (Vars.ALL_ID, _("On weekdays and weekends"));
241 limit_combobox.append (Vars.WEEKDAYS_ID, _("Only on weekdays"));
242 limit_combobox.append (Vars.WEEKENDS_ID, _("Only on weekends"));
243 limit_combobox.active_id = "all";
244- limit_combobox.changed.connect (on_limit_combobox_changed);
245-
246- limit_switch = new Gtk.Switch ();
247- limit_switch.valign = Gtk.Align.CENTER;
248- limit_switch.active = false;
249- limit_switch.notify["active"].connect (on_limit_switch_changed);
250- limit_method_box.add (limit_switch);
251- limit_method_box.add (limit_combobox);
252- limit_box.add (limit_method_box);
253
254 frame = new Gtk.Frame (null);
255- frame.override_background_color (0, { 1, 1, 1, 1 });
256+ frame.get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW);
257
258 var frame_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
259
260@@ -97,22 +96,19 @@
261 weekend_box.margin = 12;
262 weekend_box.halign = Gtk.Align.CENTER;
263
264- weekday_box.changed.connect (update_pam);
265- weekend_box.changed.connect (update_pam);
266-
267 frame_box.add (weekday_box);
268 frame_box.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL));
269 frame_box.add (weekend_box);
270 frame.add (frame_box);
271
272- monitor_updates ();
273- update ();
274- load_restrictions ();
275-
276- this.add (allow_box);
277- this.add (limit_box);
278- this.add (frame);
279- this.show_all ();
280+ attach (main_label, 0, 0, 1, 1);
281+ attach (dock_btn, 1, 0, 2, 1);
282+ attach (print_btn, 1, 1, 2, 1);
283+ attach (limit_method_label, 0, 2, 1, 1);
284+ attach (limit_switch, 1, 2, 1, 1);
285+ attach (limit_combobox, 2, 2, 1, 1);
286+ attach (frame, 0, 3, 3, 1);
287+ show_all ();
288 }
289
290 public void refresh () {
291@@ -221,19 +217,12 @@
292 warning ("%s\n", e.message);
293 }
294
295- update_sensitivity ();
296 /* TODO: Get denied users for printing configuration */
297
298 /* For now, we assume that printing is enabled */
299 print_btn.active = true;
300 }
301
302- private void update_sensitivity () {
303- bool active = limit_switch.get_active ();
304- limit_combobox.sensitive = active;
305- frame.sensitive = active;
306- }
307-
308 private void on_dock_btn_activate () {
309 set_lock_dock_active (!dock_btn.get_active ());
310 }
311@@ -279,8 +268,6 @@
312 } else {
313 PAMControl.try_remove_user_restrict (user.get_user_name ());
314 }
315-
316- update_sensitivity ();
317 }
318
319 private void on_limit_combobox_changed () {
320
321=== modified file 'src/Widgets/InternetBox.vala'
322--- src/Widgets/InternetBox.vala 2016-05-18 15:33:30 +0000
323+++ src/Widgets/InternetBox.vala 2016-05-19 19:08:23 +0000
324@@ -21,7 +21,7 @@
325 */
326
327 namespace PC.Widgets {
328- public class InternetBox : Gtk.Box {
329+ public class InternetBox : Gtk.Grid {
330 public signal void update_key_file ();
331 public string[] urls;
332
333@@ -75,21 +75,7 @@
334
335 url_list = new List<UrlEntry> ();
336
337- orientation = Gtk.Orientation.VERTICAL;
338- margin_start = margin_end = 12;
339- margin_bottom = 32;
340-
341- Gdk.RGBA bg = { 1, 1, 1, 1 };
342-
343- var frame = new Gtk.Frame (null);
344- frame.hexpand = frame.vexpand = true;
345- frame.override_background_color (0, bg);
346-
347- var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
348- main_box.hexpand = main_box.vexpand = true;
349- main_box.margin_top = main_box.margin_bottom = 6;
350-
351- var info_label = new Gtk.Label (_("Blacklist the following sites:"));
352+ var info_label = new Gtk.Label (_("Prevent %s from visiting these websites:").printf (user.get_real_name ()));
353 info_label.halign = Gtk.Align.START;
354 info_label.margin_start = 12;
355 info_label.get_style_context ().add_class ("h4");
356@@ -102,30 +88,33 @@
357
358 scrolled.add (list_box);
359
360- var bottom_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
361- bottom_box.margin_start = bottom_box.margin_end = 6;
362-
363 add_button = new Gtk.Button.with_label (_("Add URL"));
364 add_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
365+ add_button.margin_end = 6;
366 add_button.sensitive = false;
367 add_button.clicked.connect (on_entry_activate);
368
369 entry = new Gtk.Entry ();
370 entry.hexpand = true;
371+ entry.margin_start = 6;
372 entry.set_placeholder_text (_("Add a new URL, for example: google.com"));
373 entry.set_icon_tooltip_text (Gtk.EntryIconPosition.SECONDARY, _("Invalid URL"));
374 entry.changed.connect (on_entry_changed);
375 entry.activate.connect (on_entry_activate);
376
377- bottom_box.add (entry);
378- bottom_box.pack_end (add_button, false, false, 0);
379-
380- main_box.add (info_label);
381- main_box.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL));
382- main_box.add (scrolled);
383- main_box.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL));
384- main_box.add (bottom_box);
385-
386+ var main_box = new Gtk.Grid ();
387+ main_box.column_spacing = 6;
388+ main_box.row_spacing = 6;
389+ main_box.margin_top = main_box.margin_bottom = 6;
390+ main_box.attach (info_label, 0, 0, 2, 1);
391+ main_box.attach (new Gtk.Separator (Gtk.Orientation.HORIZONTAL), 0, 1, 2, 1);
392+ main_box.attach (scrolled, 0, 2, 2, 1);
393+ main_box.attach (new Gtk.Separator (Gtk.Orientation.HORIZONTAL), 0, 3, 2, 1);
394+ main_box.attach (entry, 0, 4, 1, 1);
395+ main_box.attach (add_button, 1, 4, 1, 1);
396+
397+ var frame = new Gtk.Frame (null);
398+ frame.get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW);
399 frame.add (main_box);
400
401 add (frame);
402@@ -200,4 +189,4 @@
403 update ();
404 }
405 }
406-}
407\ No newline at end of file
408+}
409
410=== modified file 'src/Widgets/UserItem.vala'
411--- src/Widgets/UserItem.vala 2016-03-06 18:26:44 +0000
412+++ src/Widgets/UserItem.vala 2016-05-19 19:08:23 +0000
413@@ -41,11 +41,14 @@
414
415 grid = new Gtk.Grid ();
416 grid.margin = 6;
417- grid.margin_left = 12;
418 grid.column_spacing = 6;
419
420+ avatar = new Granite.Widgets.Avatar ();
421+
422 full_name_label = new Gtk.Label ("");
423 full_name_label.halign = Gtk.Align.START;
424+ full_name_label.hexpand = true;
425+ full_name_label.ellipsize = Pango.EllipsizeMode.END;
426 full_name_label.get_style_context ().add_class ("h3");
427
428 username_label = new Gtk.Label ("");
429@@ -53,23 +56,13 @@
430 username_label.use_markup = true;
431 username_label.ellipsize = Pango.EllipsizeMode.END;
432
433- var switch_grid = new Gtk.Grid ();
434- switch_grid.margin_end = 6;
435- switch_grid.valign = Gtk.Align.CENTER;
436-
437 master_switch = new Gtk.Switch ();
438- switch_grid.add (master_switch);
439-
440- var main_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
441-
442- avatar = new Granite.Widgets.Avatar ();
443+ master_switch.valign = Gtk.Align.CENTER;
444
445 grid.attach (avatar, 0, 0, 1, 2);
446- grid.attach (full_name_label, 1, 0, 2, 1);
447- grid.attach (username_label, 1, 1, 1, 1);
448-
449- main_box.add (grid);
450- main_box.pack_end (switch_grid, false, false, 0);
451+ grid.attach (full_name_label, 1, 0, 1, 1);
452+ grid.attach (username_label, 1, 1, 1, 1);
453+ grid.attach (master_switch, 2, 0, 1, 2);
454
455 master_switch.notify["active"].connect (() => {
456 bool active = master_switch.get_active ();
457@@ -79,7 +72,7 @@
458
459 update_ui ();
460
461- add (main_box);
462+ add (grid);
463 show_all ();
464 }
465
466@@ -100,4 +93,4 @@
467 grid.show_all ();
468 }
469 }
470-}
471\ No newline at end of file
472+}

Subscribers

People subscribed via source and target branches