Merge lp:~elementary-pantheon/switchboard-plug-parental-controls/bind-active into lp:~elementary-pantheon/switchboard-plug-parental-controls/trunk

Proposed by Danielle Foré
Status: Merged
Approved by: Adam Bieńkowski
Approved revision: 156
Merged at revision: 155
Proposed branch: lp:~elementary-pantheon/switchboard-plug-parental-controls/bind-active
Merge into: lp:~elementary-pantheon/switchboard-plug-parental-controls/trunk
Diff against target: 100 lines (+23/-29)
2 files modified
src/Widgets/ControlPage.vala (+20/-19)
src/Widgets/UserItem.vala (+3/-10)
To merge this branch: bzr merge lp:~elementary-pantheon/switchboard-plug-parental-controls/bind-active
Reviewer Review Type Date Requested Status
Adam Bieńkowski (community) code / testing Approve
Review via email: mp+295277@code.launchpad.net

Commit message

UserItem.vala:
* Bind properties instead of set methods

ControlPage.vala:
* Set page.stack sensitivity instead of page sensitivity

To post a comment you must log in.
Revision history for this message
Adam Bieńkowski (donadigo) wrote :

Nice improvements here! Approve.

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/Widgets/ControlPage.vala'
2--- src/Widgets/ControlPage.vala 2016-03-06 11:20:50 +0000
3+++ src/Widgets/ControlPage.vala 2016-05-20 03:33:34 +0000
4@@ -23,6 +23,7 @@
5 namespace PC.Widgets {
6 public class ControlPage : Gtk.Box {
7 public Act.User user;
8+ public Gtk.Stack stack;
9 private GeneralBox general_box;
10 private AppsBox apps_box;
11 private InternetBox internet_box;
12@@ -50,7 +51,7 @@
13 internet_box.expand = true;
14 internet_box.update_key_file.connect (on_update_key_file);
15
16- var stack = new Gtk.Stack ();
17+ stack = new Gtk.Stack ();
18 stack.add_titled (general_box, "general", _("General"));
19 stack.add_titled (internet_box, "internet", _("Internet"));
20 stack.add_titled (apps_box, "apps", _("Applications"));
21@@ -64,23 +65,23 @@
22 show_all ();
23 }
24
25- public bool get_active () {
26- return apps_box.get_active ();
27- }
28-
29- public void set_active (bool active) {
30- apps_box.set_active (active);
31-
32- if (Utils.get_permission ().get_allowed ()) {
33- if (active) {
34- general_box.refresh ();
35- Utils.call_cli ({"--user", user.get_user_name (), "--enable-restrict"});
36- } else {
37- general_box.set_lock_dock_active (false);
38- general_box.set_printer_active (true);
39- Utils.call_cli ({"--user", user.get_user_name (), "--disable-restrict"});
40- }
41- }
42+ public bool active {
43+ get {
44+ return apps_box.get_active ();
45+ }
46+ set {
47+ apps_box.set_active (value);
48+ if (Utils.get_permission ().get_allowed ()) {
49+ if (value) {
50+ general_box.refresh ();
51+ Utils.call_cli ({"--user", user.get_user_name (), "--enable-restrict"});
52+ } else {
53+ general_box.set_lock_dock_active (false);
54+ general_box.set_printer_active (true);
55+ Utils.call_cli ({"--user", user.get_user_name (), "--disable-restrict"});
56+ }
57+ }
58+ }
59 }
60
61 private void on_update_key_file () {
62@@ -96,4 +97,4 @@
63 Utils.call_cli ({ "--set-contents", key_file.to_data (), "--file", Utils.build_daemon_conf_path (user) });
64 }
65 }
66-}
67\ No newline at end of file
68+}
69
70=== modified file 'src/Widgets/UserItem.vala'
71--- src/Widgets/UserItem.vala 2016-05-19 19:08:11 +0000
72+++ src/Widgets/UserItem.vala 2016-05-20 03:33:34 +0000
73@@ -62,13 +62,10 @@
74 grid.attach (avatar, 0, 0, 1, 2);
75 grid.attach (full_name_label, 1, 0, 1, 1);
76 grid.attach (username_label, 1, 1, 1, 1);
77- grid.attach (master_switch, 2, 0, 1, 2);
78+ grid.attach (master_switch, 2, 0, 1, 2);
79
80- master_switch.notify["active"].connect (() => {
81- bool active = master_switch.get_active ();
82- page.sensitive = active;
83- page.set_active (active);
84- });
85+ master_switch.bind_property ("active", page, "active", BindingFlags.SYNC_CREATE);
86+ master_switch.bind_property ("active", page.stack, "sensitive", BindingFlags.SYNC_CREATE);
87
88 update_ui ();
89
90@@ -77,10 +74,6 @@
91 }
92
93 public void update_ui () {
94- bool active = page.get_active ();
95- master_switch.active = active;
96- page.sensitive = active;
97-
98 try {
99 var avatar_pixbuf = new Gdk.Pixbuf.from_file_at_scale (user.get_icon_file (), 32, 32, true);
100 avatar.pixbuf = avatar_pixbuf;

Subscribers

People subscribed via source and target branches