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
=== modified file 'src/CategoryView.vala'
--- src/CategoryView.vala 2014-04-14 20:39:34 +0000
+++ src/CategoryView.vala 2014-04-18 18:12:24 +0000
@@ -113,18 +113,22 @@
113 attach (grid, 0, i, 1, 1);113 attach (grid, 0, i, 1, 1);
114 }114 }
115115
116 public void load_default_plugs () {116 public async void load_default_plugs () {
117 var plugsmanager = Switchboard.PlugsManager.get_default ();117 var plugsmanager = Switchboard.PlugsManager.get_default ();
118 foreach (var plug in plugsmanager.get_plugs ()) {118 plugsmanager.plug_added.connect ((plug) => {
119 plug.visibility_changed.connect (() => plug_visibility_changed (plug));119 plug.visibility_changed.connect (() => plug_visibility_changed (plug));
120 if (plug.can_show == true) {120 add_plug (plug);
121 add_plug (plug);121 });
122
123 Idle.add (() => {
124 foreach (var plug in plugsmanager.get_plugs ()) {
125 plug.visibility_changed.connect (() => plug_visibility_changed (plug));
126 if (plug.can_show == true) {
127 add_plug (plug);
128 }
122 }129 }
123 }
124130
125 plugsmanager.plug_added.connect ( (plug) => {131 return false;
126 plug.visibility_changed.connect (() => plug_visibility_changed (plug));
127 add_plug (plug);
128 });132 });
129 }133 }
130 134
@@ -199,21 +203,16 @@
199 store.set (root, Columns.ICON, icon_pixbuf, Columns.TEXT, plug.display_name, 203 store.set (root, Columns.ICON, icon_pixbuf, Columns.TEXT, plug.display_name,
200 Columns.DESCRIPTION, plug.description, Columns.VISIBLE, true, Columns.PLUG, plug);204 Columns.DESCRIPTION, plug.description, Columns.VISIBLE, true, Columns.PLUG, plug);
201 unowned SwitchboardApp app = (SwitchboardApp) GLib.Application.get_default ();205 unowned SwitchboardApp app = (SwitchboardApp) GLib.Application.get_default ();
202206 app.search_box.sensitive = true;
203 if (Switchboard.PlugsManager.get_default ().has_plugs ()) {207 filter_plugs (app.search_box.get_text ());
204 app.search_box.sensitive = true;
205 filter_plugs (app.search_box.get_text ());
206
207 if (plug_to_open != null) {
208 if (plug_to_open.has_suffix (plug.code_name)) {
209 app.current_plug = plug;
210 plug_to_open = null;
211 }
212 }
213
214#if HAVE_UNITY208#if HAVE_UNITY
215 app.update_libunity_quicklist ();209 app.update_libunity_quicklist ();
216#endif210#endif
211 if (plug_to_open != null && plug_to_open != "") {
212 if (plug_to_open.has_suffix (plug.code_name)) {
213 app.load_plug (plug);
214 plug_to_open = "";
215 }
217 }216 }
218 }217 }
219218
220219
=== modified file 'src/Switchboard.vala'
--- src/Switchboard.vala 2014-04-14 20:39:34 +0000
+++ src/Switchboard.vala 2014-04-18 18:12:24 +0000
@@ -31,17 +31,18 @@
31 private static bool should_animate_next_transition = true;31 private static bool should_animate_next_transition = true;
32 32
33 public static int main (string[] args) {33 public static int main (string[] args) {
34
35 Gtk.init (ref args);34 Gtk.init (ref args);
36 35
37 var context = new OptionContext("");36 var context = new OptionContext ("");
38 context.add_main_entries(entries, "switchboard ");37 context.add_main_entries (entries, "switchboard ");
39 context.add_group(Gtk.get_option_group(true));38 context.add_group (Gtk.get_option_group (true));
40 try {39 try {
41 context.parse(ref args);40 context.parse (ref args);
42 } catch(Error e) { warning (e.message); }41 } catch (Error e) {
42 warning (e.message);
43 }
44
43 var app = new SwitchboardApp ();45 var app = new SwitchboardApp ();
44
45 return app.run (args);46 return app.run (args);
46 }47 }
4748
@@ -81,17 +82,22 @@
81 about_authors = {"Avi Romanoff <avi@elementaryos.org>", "Corentin Noël <tintou@mailoo.org>", null};82 about_authors = {"Avi Romanoff <avi@elementaryos.org>", "Corentin Noël <tintou@mailoo.org>", null};
8283
83 about_license_type = Gtk.License.GPL_3_0;84 about_license_type = Gtk.License.GPL_3_0;
84
85 // If plug_to_open was set from the command line
86 if (plug_to_open != null) {
87 should_animate_next_transition = false;
88 }
89 }85 }
9086
91 public override void activate () {87 public override void activate () {
92 // If app is already running, present the current window.88 // If app is already running, present the current window.
93 if (get_windows () != null) {89 if (get_windows () != null) {
94 get_windows ().data.present ();90 get_windows ().data.present ();
91 if (plug_to_open != null) {
92 var plugsmanager = Switchboard.PlugsManager.get_default ();
93 foreach (var plug in plugsmanager.get_plugs ()) {
94 if (plug_to_open.has_suffix (plug.code_name)) {
95 load_plug (plug);
96 plug_to_open = null;
97 break;
98 }
99 }
100 }
95 return;101 return;
96 }102 }
97103
@@ -100,39 +106,49 @@
100 else106 else
101 Granite.Services.Logger.DisplayLevel = Granite.Services.LogLevel.INFO;107 Granite.Services.Logger.DisplayLevel = Granite.Services.LogLevel.INFO;
102108
109 // If plug_to_open was set from the command line
110 if (plug_to_open != null) {
111 should_animate_next_transition = false;
112 }
113
103 loaded_plugs = new Gee.LinkedList <string> ();114 loaded_plugs = new Gee.LinkedList <string> ();
104 Switchboard.PlugsManager.get_default ();115 Switchboard.PlugsManager.get_default ();
105 settings = new GLib.Settings ("org.pantheon.switchboard.saved-state");116 settings = new GLib.Settings ("org.pantheon.switchboard.saved-state");
106 build ();117 build ();
107 category_view.load_default_plugs ();118 category_view.load_default_plugs.begin ();
108 if (current_plug != null)
109 load_plug (current_plug);
110
111 Gtk.main ();119 Gtk.main ();
112 }120 }
113121
114 public void hide_alert () {122 public void hide_alert () {
123 alert_view.no_show_all = true;
124 alert_view.hide ();
115 stack.set_visible_child (category_scrolled);125 stack.set_visible_child (category_scrolled);
116 }126 }
117127
118 public void show_alert (string primary_text, string secondary_text, Gtk.MessageType type) {128 public void show_alert (string primary_text, string secondary_text, Gtk.MessageType type) {
129 alert_view.no_show_all = false;
130 alert_view.show_all ();
119 alert_view.set_alert (primary_text, secondary_text, null, true, type);131 alert_view.set_alert (primary_text, secondary_text, null, true, type);
120 stack.set_visible_child (alert_view);132 stack.set_visible_child (alert_view);
121 }133 }
122134
123 public void load_plug (Switchboard.Plug plug) {135 public void load_plug (Switchboard.Plug plug) {
124 if (!loaded_plugs.contains (plug.code_name)) {136 Idle.add (() => {
125 stack.add_named (plug.get_widget (), plug.code_name);137 if (!loaded_plugs.contains (plug.code_name)) {
126 loaded_plugs.add (plug.code_name);138 stack.add_named (plug.get_widget (), plug.code_name);
127 }139 loaded_plugs.add (plug.code_name);
128140 }
129 // Launch plug's executable141
130 navigation_button.set_sensitive (true);142 // Launch plug's executable
131 navigation_button.set_text (all_settings_label);143 navigation_button.set_sensitive (true);
132 navigation_button.show ();144 navigation_button.set_text (all_settings_label);
133 headerbar.subtitle = plug.display_name;145 navigation_button.show ();
134 current_plug = plug;146 headerbar.subtitle = plug.display_name;
135 switch_to_plug (plug);147 current_plug = plug;
148 switch_to_plug (plug);
149
150 return false;
151 });
136 }152 }
137153
138#if HAVE_UNITY154#if HAVE_UNITY
@@ -211,12 +227,13 @@
211 // Set up UI227 // Set up UI
212 alert_view = new Granite.Widgets.EmbeddedAlert ();228 alert_view = new Granite.Widgets.EmbeddedAlert ();
213 alert_view.set_vexpand (true);229 alert_view.set_vexpand (true);
230 alert_view.no_show_all = true;
214231
215 stack = new Gtk.Stack ();232 stack = new Gtk.Stack ();
216 stack.expand = true;233 stack.expand = true;
234 stack.add_named (alert_view, "alert");
217 stack.add_named (category_scrolled, "main");235 stack.add_named (category_scrolled, "main");
218 stack.add_named (alert_view, "alert");236 stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT;
219 stack.set_visible_child (category_scrolled);
220237
221 main_window.add (stack);238 main_window.add (stack);
222 main_window.set_application (this);239 main_window.set_application (this);
@@ -231,7 +248,7 @@
231 show_alert (_("No settings found"), _("Install some and re-launch Switchboard"), Gtk.MessageType.WARNING);248 show_alert (_("No settings found"), _("Install some and re-launch Switchboard"), Gtk.MessageType.WARNING);
232 search_box.sensitive = false;249 search_box.sensitive = false;
233 } else {250 } else {
234#if HAVE_UNITY 251#if HAVE_UNITY
235 update_libunity_quicklist ();252 update_libunity_quicklist ();
236#endif253#endif
237 }254 }
@@ -291,17 +308,25 @@
291308
292 // Switches to the given plug309 // Switches to the given plug
293 private void switch_to_plug (Switchboard.Plug plug) {310 private void switch_to_plug (Switchboard.Plug plug) {
294 if (should_animate_next_transition) {311 if (should_animate_next_transition == false) {
295 stack.set_transition_type (Gtk.StackTransitionType.SLIDE_LEFT);312 stack.set_transition_type (Gtk.StackTransitionType.NONE);
313 should_animate_next_transition = true;
314 } else if (stack.transition_type == Gtk.StackTransitionType.NONE) {
315 stack.set_transition_type (Gtk.StackTransitionType.SLIDE_LEFT_RIGHT);
296 }316 }
317
297 search_box.sensitive = false;318 search_box.sensitive = false;
298 plug.shown ();319 plug.shown ();
299 stack.set_visible_child_name (plug.code_name);320 stack.set_visible_child_name (plug.code_name);
321 category_scrolled.hide ();
300 }322 }
301323
302 // Switches back to the icons324 // Switches back to the icons
303 private bool switch_to_icons () {325 private bool switch_to_icons () {
304 stack.set_transition_type (Gtk.StackTransitionType.SLIDE_RIGHT);326 if (stack.transition_type == Gtk.StackTransitionType.NONE) {
327 stack.set_transition_type (Gtk.StackTransitionType.SLIDE_LEFT_RIGHT);
328 }
329 category_scrolled.show ();
305 stack.set_visible_child (category_scrolled);330 stack.set_visible_child (category_scrolled);
306 current_plug.hidden ();331 current_plug.hidden ();
307332

Subscribers

People subscribed via source and target branches

to all changes: