Merge lp:~donadigo/switchboard/category-view-refresh into lp:~elementary-pantheon/switchboard/switchboard

Proposed by Adam Bieńkowski
Status: Merged
Approved by: Danielle Foré
Approved revision: 701
Merged at revision: 710
Proposed branch: lp:~donadigo/switchboard/category-view-refresh
Merge into: lp:~elementary-pantheon/switchboard/switchboard
Diff against target: 125 lines (+27/-35)
2 files modified
src/CategoryView.vala (+26/-34)
src/Widgets/CategoryFlowBox.vala (+1/-1)
To merge this branch: bzr merge lp:~donadigo/switchboard/category-view-refresh
Reviewer Review Type Date Requested Status
Zisu Andrei (community) Approve
Danielle Foré ux Approve
Review via email: mp+310121@code.launchpad.net

Commit message

* Use GObject construct style
* Remove duplicated if statements
* Simplify some of the code

Description of the change

A CategoryView refresh.

* Use GObject construct style
* Remove duplicated if statements
* Simplify some of the code

To post a comment you must log in.
700. By Adam Bieńkowski

Remove the space change in CategoryFlowBox

Revision history for this message
Zisu Andrei (matzipan) wrote :

Comment inline

review: Needs Fixing
701. By Adam Bieńkowski

Make plug_to_open construct property

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

matzipan: done, ready to review again.

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

afaict, no difference :)

review: Approve (ux)
Revision history for this message
Zisu Andrei (matzipan) wrote :

Yeah, looks good to me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CategoryView.vala'
2--- src/CategoryView.vala 2016-05-12 17:41:11 +0000
3+++ src/CategoryView.vala 2016-12-02 19:16:35 +0000
4@@ -24,19 +24,18 @@
5 public class CategoryView : Gtk.Grid {
6 public signal void plug_selected (Switchboard.Plug plug);
7
8- public Gee.ArrayList <SearchEntry?> plug_search_result;
9- public Switchboard.Category personal_category;
10- public Switchboard.Category hardware_category;
11- public Switchboard.Category network_category;
12- public Switchboard.Category system_category;
13-
14- private string? plug_to_open = null;
15- public PlugsSearch plug_search;
16-
17- public CategoryView (string? plug = null) {
18+ public PlugsSearch plug_search { get; construct; }
19+ public Gee.ArrayList<SearchEntry?> plug_search_result { get; construct; }
20+ public Switchboard.Category personal_category { get; construct; }
21+ public Switchboard.Category hardware_category { get; construct; }
22+ public Switchboard.Category network_category { get; construct; }
23+ public Switchboard.Category system_category { get; construct; }
24+
25+ public string? plug_to_open { get; construct set; default = null; }
26+
27+ construct {
28 orientation = Gtk.Orientation.VERTICAL;
29- plug_to_open = plug;
30-
31+
32 personal_category = new Switchboard.Category (Switchboard.Plug.Category.PERSONAL);
33 hardware_category = new Switchboard.Category (Switchboard.Plug.Category.HARDWARE);
34 network_category = new Switchboard.Category (Switchboard.Plug.Category.NETWORK);
35@@ -51,33 +50,29 @@
36 add (system_category);
37 }
38
39+ public CategoryView (string? plug = null) {
40+ Object (plug_to_open: plug);
41+ }
42+
43 public async void load_default_plugs () {
44 var plugsmanager = Switchboard.PlugsManager.get_default ();
45 plugsmanager.plug_added.connect ((plug) => {
46- plug.visibility_changed.connect (() => plug_visibility_changed (plug));
47+ plug.visibility_changed.connect (() => add_plug (plug));
48 add_plug (plug);
49 });
50
51 Idle.add (() => {
52 foreach (var plug in plugsmanager.get_plugs ()) {
53- plug.visibility_changed.connect (() => plug_visibility_changed (plug));
54- if (plug.can_show == true) {
55- add_plug (plug);
56- }
57+ plug.visibility_changed.connect (() => add_plug (plug));
58+ add_plug (plug);
59 }
60
61 return false;
62 });
63 }
64
65- private void plug_visibility_changed (Switchboard.Plug plug) {
66- if (plug.can_show == true) {
67- add_plug (plug);
68- }
69- }
70-
71 public void add_plug (Switchboard.Plug plug) {
72- if (plug.can_show == false) {
73+ if (!plug.can_show) {
74 return;
75 }
76
77@@ -100,17 +95,15 @@
78 return;
79 }
80
81- unowned SwitchboardApp app = (SwitchboardApp) GLib.Application.get_default ();
82+ unowned SwitchboardApp app = SwitchboardApp.instance;
83 app.search_box.sensitive = true;
84 filter_plugs (app.search_box.get_text ());
85 #if HAVE_UNITY
86 app.update_libunity_quicklist ();
87 #endif
88- if (plug_to_open != null && plug_to_open != "") {
89- if (plug_to_open.has_suffix (plug.code_name)) {
90- app.load_plug (plug);
91- plug_to_open = "";
92- }
93+ if (plug_to_open != null && plug_to_open.has_suffix (plug.code_name)) {
94+ app.load_plug (plug);
95+ plug_to_open = null;
96 }
97 }
98
99@@ -162,11 +155,10 @@
100 any_found = true;
101 }
102
103- unowned SwitchboardApp app = (SwitchboardApp) GLib.Application.get_default ();
104- if (!any_found) {
105- app.show_alert (_("No Results for “%s”".printf (filter)), _("Try changing search terms."), "edit-find-symbolic");
106+ if (any_found) {
107+ SwitchboardApp.instance.hide_alert ();
108 } else {
109- app.hide_alert ();
110+ SwitchboardApp.instance.show_alert (_("No Results for “%s”".printf (filter)), _("Try changing search terms."), "edit-find-symbolic");
111 }
112 }
113
114
115=== modified file 'src/Widgets/CategoryFlowBox.vala'
116--- src/Widgets/CategoryFlowBox.vala 2016-11-03 21:57:17 +0000
117+++ src/Widgets/CategoryFlowBox.vala 2016-12-02 19:16:35 +0000
118@@ -124,7 +124,7 @@
119 if (filter.down () in plug_name.down ()) {
120 return true;
121 }
122-
123+
124 return false;
125 }
126

Subscribers

People subscribed via source and target branches

to all changes: