Merge lp:~tintou/switchboard/fix-load into lp:~elementary-pantheon/switchboard/switchboard

Proposed by Corentin Noël
Status: Merged
Approved by: Cody Garver
Approved revision: 434
Merged at revision: 439
Proposed branch: lp:~tintou/switchboard/fix-load
Merge into: lp:~elementary-pantheon/switchboard/switchboard
Diff against target: 242 lines (+80/-56)
2 files modified
src/CategoryView.vala (+20/-21)
src/Switchboard.vala (+60/-35)
To merge this branch: bzr merge lp:~tintou/switchboard/fix-load
Reviewer Review Type Date Requested Status
No Name (community) Approve
elementary Pantheon team Pending
Review via email: mp+216474@code.launchpad.net

Commit message

Fixed plug load by executing some function in the main thread, new load mechanism that is asynchrone.

Description of the change

New async load of plugs.
Gtk containers are loaded in main thread (it fixes crash at load for G-C-C plugs).

To post a comment you must log in.
Revision history for this message
No Name (nonamenoname) wrote :

Fixed launching GCC plugs. .o option works as expected for gcc/native. Approved

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 2014-04-14 20:39:34 +0000
3+++ src/CategoryView.vala 2014-04-18 18:12:24 +0000
4@@ -113,18 +113,22 @@
5 attach (grid, 0, i, 1, 1);
6 }
7
8- public void load_default_plugs () {
9+ public async void load_default_plugs () {
10 var plugsmanager = Switchboard.PlugsManager.get_default ();
11- foreach (var plug in plugsmanager.get_plugs ()) {
12+ plugsmanager.plug_added.connect ((plug) => {
13 plug.visibility_changed.connect (() => plug_visibility_changed (plug));
14- if (plug.can_show == true) {
15- add_plug (plug);
16+ add_plug (plug);
17+ });
18+
19+ Idle.add (() => {
20+ foreach (var plug in plugsmanager.get_plugs ()) {
21+ plug.visibility_changed.connect (() => plug_visibility_changed (plug));
22+ if (plug.can_show == true) {
23+ add_plug (plug);
24+ }
25 }
26- }
27
28- plugsmanager.plug_added.connect ( (plug) => {
29- plug.visibility_changed.connect (() => plug_visibility_changed (plug));
30- add_plug (plug);
31+ return false;
32 });
33 }
34
35@@ -199,21 +203,16 @@
36 store.set (root, Columns.ICON, icon_pixbuf, Columns.TEXT, plug.display_name,
37 Columns.DESCRIPTION, plug.description, Columns.VISIBLE, true, Columns.PLUG, plug);
38 unowned SwitchboardApp app = (SwitchboardApp) GLib.Application.get_default ();
39-
40- if (Switchboard.PlugsManager.get_default ().has_plugs ()) {
41- app.search_box.sensitive = true;
42- filter_plugs (app.search_box.get_text ());
43-
44- if (plug_to_open != null) {
45- if (plug_to_open.has_suffix (plug.code_name)) {
46- app.current_plug = plug;
47- plug_to_open = null;
48- }
49- }
50-
51+ app.search_box.sensitive = true;
52+ filter_plugs (app.search_box.get_text ());
53 #if HAVE_UNITY
54- app.update_libunity_quicklist ();
55+ app.update_libunity_quicklist ();
56 #endif
57+ if (plug_to_open != null && plug_to_open != "") {
58+ if (plug_to_open.has_suffix (plug.code_name)) {
59+ app.load_plug (plug);
60+ plug_to_open = "";
61+ }
62 }
63 }
64
65
66=== modified file 'src/Switchboard.vala'
67--- src/Switchboard.vala 2014-04-14 20:39:34 +0000
68+++ src/Switchboard.vala 2014-04-18 18:12:24 +0000
69@@ -31,17 +31,18 @@
70 private static bool should_animate_next_transition = true;
71
72 public static int main (string[] args) {
73-
74 Gtk.init (ref args);
75-
76- var context = new OptionContext("");
77- context.add_main_entries(entries, "switchboard ");
78- context.add_group(Gtk.get_option_group(true));
79+
80+ var context = new OptionContext ("");
81+ context.add_main_entries (entries, "switchboard ");
82+ context.add_group (Gtk.get_option_group (true));
83 try {
84- context.parse(ref args);
85- } catch(Error e) { warning (e.message); }
86+ context.parse (ref args);
87+ } catch (Error e) {
88+ warning (e.message);
89+ }
90+
91 var app = new SwitchboardApp ();
92-
93 return app.run (args);
94 }
95
96@@ -81,17 +82,22 @@
97 about_authors = {"Avi Romanoff <avi@elementaryos.org>", "Corentin Noël <tintou@mailoo.org>", null};
98
99 about_license_type = Gtk.License.GPL_3_0;
100-
101- // If plug_to_open was set from the command line
102- if (plug_to_open != null) {
103- should_animate_next_transition = false;
104- }
105 }
106
107 public override void activate () {
108 // If app is already running, present the current window.
109 if (get_windows () != null) {
110 get_windows ().data.present ();
111+ if (plug_to_open != null) {
112+ var plugsmanager = Switchboard.PlugsManager.get_default ();
113+ foreach (var plug in plugsmanager.get_plugs ()) {
114+ if (plug_to_open.has_suffix (plug.code_name)) {
115+ load_plug (plug);
116+ plug_to_open = null;
117+ break;
118+ }
119+ }
120+ }
121 return;
122 }
123
124@@ -100,39 +106,49 @@
125 else
126 Granite.Services.Logger.DisplayLevel = Granite.Services.LogLevel.INFO;
127
128+ // If plug_to_open was set from the command line
129+ if (plug_to_open != null) {
130+ should_animate_next_transition = false;
131+ }
132+
133 loaded_plugs = new Gee.LinkedList <string> ();
134 Switchboard.PlugsManager.get_default ();
135 settings = new GLib.Settings ("org.pantheon.switchboard.saved-state");
136 build ();
137- category_view.load_default_plugs ();
138- if (current_plug != null)
139- load_plug (current_plug);
140-
141+ category_view.load_default_plugs.begin ();
142 Gtk.main ();
143 }
144
145 public void hide_alert () {
146+ alert_view.no_show_all = true;
147+ alert_view.hide ();
148 stack.set_visible_child (category_scrolled);
149 }
150
151 public void show_alert (string primary_text, string secondary_text, Gtk.MessageType type) {
152+ alert_view.no_show_all = false;
153+ alert_view.show_all ();
154 alert_view.set_alert (primary_text, secondary_text, null, true, type);
155 stack.set_visible_child (alert_view);
156 }
157
158 public void load_plug (Switchboard.Plug plug) {
159- if (!loaded_plugs.contains (plug.code_name)) {
160- stack.add_named (plug.get_widget (), plug.code_name);
161- loaded_plugs.add (plug.code_name);
162- }
163-
164- // Launch plug's executable
165- navigation_button.set_sensitive (true);
166- navigation_button.set_text (all_settings_label);
167- navigation_button.show ();
168- headerbar.subtitle = plug.display_name;
169- current_plug = plug;
170- switch_to_plug (plug);
171+ Idle.add (() => {
172+ if (!loaded_plugs.contains (plug.code_name)) {
173+ stack.add_named (plug.get_widget (), plug.code_name);
174+ loaded_plugs.add (plug.code_name);
175+ }
176+
177+ // Launch plug's executable
178+ navigation_button.set_sensitive (true);
179+ navigation_button.set_text (all_settings_label);
180+ navigation_button.show ();
181+ headerbar.subtitle = plug.display_name;
182+ current_plug = plug;
183+ switch_to_plug (plug);
184+
185+ return false;
186+ });
187 }
188
189 #if HAVE_UNITY
190@@ -211,12 +227,13 @@
191 // Set up UI
192 alert_view = new Granite.Widgets.EmbeddedAlert ();
193 alert_view.set_vexpand (true);
194+ alert_view.no_show_all = true;
195
196 stack = new Gtk.Stack ();
197 stack.expand = true;
198+ stack.add_named (alert_view, "alert");
199 stack.add_named (category_scrolled, "main");
200- stack.add_named (alert_view, "alert");
201- stack.set_visible_child (category_scrolled);
202+ stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT;
203
204 main_window.add (stack);
205 main_window.set_application (this);
206@@ -231,7 +248,7 @@
207 show_alert (_("No settings found"), _("Install some and re-launch Switchboard"), Gtk.MessageType.WARNING);
208 search_box.sensitive = false;
209 } else {
210-#if HAVE_UNITY
211+#if HAVE_UNITY
212 update_libunity_quicklist ();
213 #endif
214 }
215@@ -291,17 +308,25 @@
216
217 // Switches to the given plug
218 private void switch_to_plug (Switchboard.Plug plug) {
219- if (should_animate_next_transition) {
220- stack.set_transition_type (Gtk.StackTransitionType.SLIDE_LEFT);
221+ if (should_animate_next_transition == false) {
222+ stack.set_transition_type (Gtk.StackTransitionType.NONE);
223+ should_animate_next_transition = true;
224+ } else if (stack.transition_type == Gtk.StackTransitionType.NONE) {
225+ stack.set_transition_type (Gtk.StackTransitionType.SLIDE_LEFT_RIGHT);
226 }
227+
228 search_box.sensitive = false;
229 plug.shown ();
230 stack.set_visible_child_name (plug.code_name);
231+ category_scrolled.hide ();
232 }
233
234 // Switches back to the icons
235 private bool switch_to_icons () {
236- stack.set_transition_type (Gtk.StackTransitionType.SLIDE_RIGHT);
237+ if (stack.transition_type == Gtk.StackTransitionType.NONE) {
238+ stack.set_transition_type (Gtk.StackTransitionType.SLIDE_LEFT_RIGHT);
239+ }
240+ category_scrolled.show ();
241 stack.set_visible_child (category_scrolled);
242 current_plug.hidden ();
243

Subscribers

People subscribed via source and target branches

to all changes: