Merge lp:~elementary-apps/switchboard/fix-bug-1039269 into lp:~elementary-pantheon/switchboard/switchboard

Proposed by David Gomes
Status: Merged
Approved by: Akshay Shekher
Approved revision: 415
Merged at revision: 411
Proposed branch: lp:~elementary-apps/switchboard/fix-bug-1039269
Merge into: lp:~elementary-pantheon/switchboard/switchboard
Diff against target: 367 lines (+108/-49)
3 files modified
CMakeLists.txt (+1/-0)
src/NavigationButton.vala (+50/-0)
src/Switchboard.vala (+57/-49)
To merge this branch: bzr merge lp:~elementary-apps/switchboard/fix-bug-1039269
Reviewer Review Type Date Requested Status
Akshay Shekher (community) Approve
Review via email: mp+197454@code.launchpad.net

Commit message

Use a back-arrow shaped button with text instead of a simple button. Fixes bug #1039269.

Description of the change

To post a comment you must log in.
Revision history for this message
Akshay Shekher (voldyman) wrote :

please add src/Buttons.vala to the repo.

Revision history for this message
David Gomes (davidgomes) wrote :

Don't make it WIP when it needs fixing, I'll fix it later today.
On Dec 3, 2013 2:54 AM, "Akshay Shekher" <email address hidden> wrote:

> The proposal to merge lp:~elementary-apps/switchboard/fix-bug-1039269 into
> lp:switchboard has been updated.
>
> Status: Needs review => Work in progress
>
> For more details, see:
>
> https://code.launchpad.net/~elementary-apps/switchboard/fix-bug-1039269/+merge/197454
> --
>
> https://code.launchpad.net/~elementary-apps/switchboard/fix-bug-1039269/+merge/197454
> Your team elementary Apps team is subscribed to branch
> lp:~elementary-apps/switchboard/fix-bug-1039269.
>

413. By David Gomes

Fixed license header.

Revision history for this message
Akshay Shekher (voldyman) wrote :

the code look fine, i just a few suggestions.

rename the file from Buttons.vala to NavigationButton.vala, it'll look less generic.

In the signal search_box.changed you partially changed the closure, you could also fix the spacing of the bracket on line 294.

since when are we giving the copyright to elementary LLC instead of elementary Developers or <insert project name here> developers?

review: Approve
414. By David Gomes

Fixed file name and some code style.

Revision history for this message
David Gomes (davidgomes) wrote :

Done, and we've been doing that since the Isis cycle began, supposedly.

Revision history for this message
Julián Unrrein (junrrein) wrote :

Rename Buttons.vala in diff line 8 too.

415. By David Gomes

Fixed file name in CMakeLists.txt.

Revision history for this message
Akshay Shekher (voldyman) wrote :

well done.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2013-09-30 06:42:11 +0000
+++ CMakeLists.txt 2013-12-03 14:31:03 +0000
@@ -74,6 +74,7 @@
74 src/Resources.vala74 src/Resources.vala
75 src/DesktopLauncher.vala75 src/DesktopLauncher.vala
76 src/EmbeddedAlert.vala76 src/EmbeddedAlert.vala
77 src/NavigationButton.vala
77PACKAGES78PACKAGES
78 granite79 granite
79 gee-1.080 gee-1.0
8081
=== added file 'src/NavigationButton.vala'
--- src/NavigationButton.vala 1970-01-01 00:00:00 +0000
+++ src/NavigationButton.vala 2013-12-03 14:31:03 +0000
@@ -0,0 +1,50 @@
1/***
2 BEGIN LICENSE
3
4 Copyright (C) 2013 elementary, LLC.
5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License version 3, as
7 published by the Free Software Foundation.
8
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranties of
11 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12 PURPOSE. See the GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with this program. If not, see <http://www.gnu.org/licenses>
16
17 END LICENSE
18***/
19
20namespace Switchboard {
21
22 public class NavigationButton : Gtk.Button {
23
24 private Gtk.Label text;
25
26 public NavigationButton () {
27 can_focus = false;
28 valign = Gtk.Align.CENTER;
29 vexpand = false;
30
31 Gtk.Box button_b = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
32 var icon = new Gtk.Image.from_icon_name ("go-previous-symbolic",
33 Gtk.IconSize.MENU);
34 text = new Gtk.Label ("");
35
36 button_b.pack_start (icon, true, true, 2);
37 button_b.pack_start (text, true, true, 2);
38
39 this.add (button_b);
40 }
41
42 public string get_text () {
43 return text.label;
44 }
45
46 public void set_text (string text) {
47 this.text.label = text;
48 }
49 }
50}
051
=== modified file 'src/Switchboard.vala'
--- src/Switchboard.vala 2013-09-26 08:05:15 +0000
+++ src/Switchboard.vala 2013-12-03 14:31:03 +0000
@@ -21,7 +21,7 @@
2121
22 [DBus (name = "org.elementary.switchboard")]22 [DBus (name = "org.elementary.switchboard")]
23 public class SwitchboardApp : Granite.Application {23 public class SwitchboardApp : Granite.Application {
24 24
25 construct {25 construct {
26 application_id = "org.elementary.Switchboard";26 application_id = "org.elementary.Switchboard";
27 program_name = "Switchboard";27 program_name = "Switchboard";
@@ -45,15 +45,15 @@
45 Gtk.Label progress_label;45 Gtk.Label progress_label;
46 Gtk.SearchEntry search_box;46 Gtk.SearchEntry search_box;
47 Gtk.Toolbar toolbar;47 Gtk.Toolbar toolbar;
48 Gtk.ToolButton navigation_button;48 Switchboard.NavigationButton navigation_button;
49 // Public so we can hide it after show_all()49 // Public so we can hide it after show_all()
50 public Gtk.ToolItem progress_toolitem;50 public Gtk.ToolItem progress_toolitem;
51 // These two wrap the progress bar51 // These two wrap the progress bar
52 Gtk.ToolItem lspace = new Gtk.ToolItem ();52 Gtk.ToolItem lspace = new Gtk.ToolItem ();
53 Gtk.ToolItem rspace = new Gtk.ToolItem ();53 Gtk.ToolItem rspace = new Gtk.ToolItem ();
54 54
55 Gtk.Spinner loading;55 Gtk.Spinner loading;
56 56
57 Gtk.Window main_window;57 Gtk.Window main_window;
5858
59 // Content area widgets59 // Content area widgets
@@ -70,15 +70,16 @@
7070
71 string[] plug_places = {"/usr/share/plugs/",71 string[] plug_places = {"/usr/share/plugs/",
72 "/usr/lib/plugs/",72 "/usr/lib/plugs/",
73 "/usr/local/share/plugs/", 73 "/usr/local/share/plugs/",
74 "/usr/local/lib/plugs/"};74 "/usr/local/lib/plugs/"};
75 string search_box_buffer = "";75 string search_box_buffer = "";
7676
77 private const string[] SUPPORTED_GETTEXT_DOMAINS_KEYS = {"X-Ubuntu-Gettext-Domain", "X-GNOME-Gettext-Domain"};77 private const string[] SUPPORTED_GETTEXT_DOMAINS_KEYS = {"X-Ubuntu-Gettext-Domain", "X-GNOME-Gettext-Domain"};
7878
79 public SwitchboardApp () {79 string all_settings_label = _("All Settings");
80 }80
81 81 public SwitchboardApp () { }
82
82 void build () {83 void build () {
83 main_window = new Gtk.Window();84 main_window = new Gtk.Window();
8485
@@ -149,6 +150,8 @@
149 category_view.recalculate_columns (width);150 category_view.recalculate_columns (width);
150 });151 });
151152
153 navigation_button.hide ();
154
152 foreach (var label in category_view.category_labels.values)155 foreach (var label in category_view.category_labels.values)
153 label.hide ();156 label.hide ();
154 foreach (var view in category_view.category_views.values)157 foreach (var view in category_view.category_views.values)
@@ -188,7 +191,7 @@
188 } else {191 } else {
189 update_libunity_quicklist ();192 update_libunity_quicklist ();
190 }193 }
191 194
192 bool found = false;195 bool found = false;
193 if (plug_to_open != null) {196 if (plug_to_open != null) {
194 foreach (var plug in plugs) {197 foreach (var plug in plugs) {
@@ -201,17 +204,17 @@
201 critical ("Couldn't find %s among the loaded settings.", plug_to_open);204 critical ("Couldn't find %s among the loaded settings.", plug_to_open);
202 }205 }
203 }206 }
204 207
205 foreach (var store in category_view.category_store.values) {208 foreach (var store in category_view.category_store.values) {
206 store.foreach ((model, path, iter) => {209 store.foreach ((model, path, iter) => {
207 store.set_value (iter, 3, true);210 store.set_value (iter, 3, true);
208 return false;211 return false;
209 });212 });
210 }213 }
211 214
212 progress_toolitem.hide ();215 progress_toolitem.hide ();
213 }216 }
214 217
215 void shut_down () {218 void shut_down () {
216 plug_closed ();219 plug_closed ();
217 }220 }
@@ -236,15 +239,17 @@
236 // The plug is already selected239 // The plug is already selected
237 debug(_("Closing plug \"%s\" in Switchboard controller..."), current_plug["title"]);240 debug(_("Closing plug \"%s\" in Switchboard controller..."), current_plug["title"]);
238 plug_closed ();241 plug_closed ();
239 242
240 string[] cmd_exploded = (executable!=null)?executable.split (" "):null;243 string[] cmd_exploded = (executable!=null)?executable.split (" "):null;
241 GLib.Process.spawn_async (File.new_for_path (cmd_exploded[0]).get_parent ().244 GLib.Process.spawn_async (File.new_for_path (cmd_exploded[0]).get_parent ().
242 get_path (), cmd_exploded, null, SpawnFlags.SEARCH_PATH, null, null);245 get_path (), cmd_exploded, null, SpawnFlags.SEARCH_PATH, null, null);
243 246
244 // ensure the button is sensitive; it might be the first plug loaded247 // ensure the button is sensitive; it might be the first plug loaded
245 if (!@extern) {248 if (!@extern) {
246 navigation_button.set_sensitive(true);249 navigation_button.set_sensitive (true);
247 navigation_button.set_icon_name ("go-home");250 navigation_button.set_text (all_settings_label);
251 navigation_button.show ();
252
248 current_plug["title"] = title;253 current_plug["title"] = title;
249 current_plug["executable"] = executable;254 current_plug["executable"] = executable;
250 switch_to_socket ();255 switch_to_socket ();
@@ -252,10 +257,11 @@
252 }257 }
253 } catch { warning(_("Failed to launch plug: title %s | executable %s"), title, executable); }258 } catch { warning(_("Failed to launch plug: title %s | executable %s"), title, executable); }
254 } else {259 } else {
255 navigation_button.set_sensitive(true);260 navigation_button.set_sensitive (true);
256 navigation_button.set_icon_name ("go-home");261 navigation_button.set_text (all_settings_label);
262 navigation_button.show ();
257 }263 }
258 264
259 if (@extern) {265 if (@extern) {
260 switch_to_icons ();266 switch_to_icons ();
261 }267 }
@@ -268,20 +274,17 @@
268274
269 // Handles clicking the navigation button275 // Handles clicking the navigation button
270 void handle_navigation_button_clicked () {276 void handle_navigation_button_clicked () {
271 string icon_name = navigation_button.get_icon_name ();277 if (navigation_button.get_text () != current_plug["title"]) {
272 if (icon_name == "go-home") {
273 switch_to_icons();278 switch_to_icons();
274 navigation_button.set_icon_name ("go-previous");279 navigation_button.set_text (current_plug["title"]);
275 }280 } else {
276 else {
277 load_plug (current_plug["title"], current_plug["executable"], current_plug["extern"] == "1");281 load_plug (current_plug["title"], current_plug["executable"], current_plug["extern"] == "1");
278 navigation_button.set_icon_name ("go-home");282 navigation_button.set_text (all_settings_label);
279 }283 }
280 }284 }
281285
282 // Switches to the socket view286 // Switches to the socket view
283 void switch_to_socket () {287 void switch_to_socket () {
284
285 socket_shown = true;288 socket_shown = true;
286 search_box.sensitive = false;289 search_box.sensitive = false;
287290
@@ -289,13 +292,13 @@
289 socket.hide ();292 socket.hide ();
290 loading.show_all ();293 loading.show_all ();
291 }294 }
292 295
293 // Switches back to the icons296 // Switches back to the icons
294 bool switch_to_icons () {297 bool switch_to_icons () {
295 socket.hide ();298 socket.hide ();
296 loading.hide ();299 loading.hide ();
297 category_view.show ();300 category_view.show ();
298 301
299 socket_shown = false;302 socket_shown = false;
300303
301 // Reset state304 // Reset state
@@ -305,9 +308,9 @@
305 progress_label.set_text("");308 progress_label.set_text("");
306 progress_bar.fraction = 0.0;309 progress_bar.fraction = 0.0;
307 progress_toolitem.visible = false;310 progress_toolitem.visible = false;
308 311
309 plug_closed ();312 plug_closed ();
310 313
311 return true;314 return true;
312 }315 }
313316
@@ -341,7 +344,7 @@
341 exec = Path.build_filename(parent, exec);344 exec = Path.build_filename(parent, exec);
342 plug["extern"] = "0";345 plug["extern"] = "0";
343 }346 }
344 347
345 plug["exec"] = exec;348 plug["exec"] = exec;
346 } catch (Error e) { warning("Couldn't read exec field in file %s, %s", keyfile, e.message); }349 } catch (Error e) { warning("Couldn't read exec field in file %s, %s", keyfile, e.message); }
347 try { plug["icon"] = kf.get_string (head, "icon");350 try { plug["icon"] = kf.get_string (head, "icon");
@@ -385,7 +388,7 @@
385 keyfiles.append(keyfile);388 keyfiles.append(keyfile);
386 }389 }
387 }390 }
388 391
389 var directory = File.new_for_path (path);392 var directory = File.new_for_path (path);
390 if (!directory.query_exists ()) {393 if (!directory.query_exists ()) {
391 return null;394 return null;
@@ -396,7 +399,7 @@
396 FileInfo file_info;399 FileInfo file_info;
397 while ((file_info = enumerator.next_file ()) != null) {400 while ((file_info = enumerator.next_file ()) != null) {
398 string file_path = Path.build_filename(path, file_info.get_name());401 string file_path = Path.build_filename(path, file_info.get_name());
399 if (file_info.get_file_type() == GLib.FileType.REGULAR && 402 if (file_info.get_file_type() == GLib.FileType.REGULAR &&
400 is_plug_file(file_info.get_name())) {403 is_plug_file(file_info.get_name())) {
401 keyfiles.append(file_path);404 keyfiles.append(file_path);
402 } else if(file_info.get_file_type() == GLib.FileType.DIRECTORY) {405 } else if(file_info.get_file_type() == GLib.FileType.DIRECTORY) {
@@ -404,7 +407,7 @@
404 }407 }
405 }408 }
406 } catch { warning(_(@"Unable to iterate over enumerated plug directory \"$path\"'s contents")); }409 } catch { warning(_(@"Unable to iterate over enumerated plug directory \"$path\"'s contents")); }
407 410
408 return keyfiles;411 return keyfiles;
409 }412 }
410413
@@ -496,12 +499,15 @@
496 // Searchbar499 // Searchbar
497 search_box = new Gtk.SearchEntry ();500 search_box = new Gtk.SearchEntry ();
498 search_box.set_placeholder_text (_("Search Settings"));501 search_box.set_placeholder_text (_("Search Settings"));
499 search_box.activate.connect(() => search_box_activated());502 search_box.activate.connect (() => search_box_activated ());
500 search_box.changed.connect(() => {503
501 category_view.filter_plugs(search_box.get_text (), this);504 search_box.changed.connect (() => {
502 search_box_text_changed();505 category_view.filter_plugs (search_box.get_text (), this);
506 search_box_text_changed ();
503 });507 });
508
504 search_box.sensitive = (count_plugs () > 0);509 search_box.sensitive = (count_plugs () > 0);
510 search_box.margin = 5;
505 var find_toolitem = new Gtk.ToolItem ();511 var find_toolitem = new Gtk.ToolItem ();
506 find_toolitem.add(search_box);512 find_toolitem.add(search_box);
507 find_toolitem.margin_right = 6;513 find_toolitem.margin_right = 6;
@@ -516,19 +522,21 @@
516 });522 });
517523
518 // Nav button524 // Nav button
519 navigation_button = new Gtk.ToolButton (null, null);525 navigation_button = new NavigationButton ();
520 navigation_button.set_icon_name ("go-previous");
521 navigation_button.clicked.connect (handle_navigation_button_clicked);526 navigation_button.clicked.connect (handle_navigation_button_clicked);
522 navigation_button.set_sensitive(false);527 navigation_button.margin = 5;
523528
524 // Add everything to the toolbar529 // Add everything to the toolbar
525 toolbar.insert (navigation_button, -1);530
531 Gtk.ToolItem tool = new Gtk.ToolItem ();
532 tool.add (navigation_button);
533 toolbar.insert (tool, -1);
526 toolbar.insert (lspace, -1);534 toolbar.insert (lspace, -1);
527 toolbar.insert (progress_toolitem, -1);535 toolbar.insert (progress_toolitem, -1);
528 toolbar.insert (rspace, -1);536 toolbar.insert (rspace, -1);
529 toolbar.insert (find_toolitem, -1);537 toolbar.insert (find_toolitem, -1);
530 }538 }
531 539
532 public override void activate () {540 public override void activate () {
533 // If app is already running, present the current window.541 // If app is already running, present the current window.
534 if (get_windows () != null) {542 if (get_windows () != null) {
@@ -594,29 +602,29 @@
594 message(_(@"Welcome to $APP_TITLE"));602 message(_(@"Welcome to $APP_TITLE"));
595 message(_(@"Version: $VERSION"));603 message(_(@"Version: $VERSION"));
596 message(_("Report any issues/bugs you mind find to lp:switchboard"));604 message(_("Report any issues/bugs you mind find to lp:switchboard"));
597 605
598 Gtk.init (ref args);606 Gtk.init (ref args);
599 607
600 var context = new OptionContext("");608 var context = new OptionContext("");
601 context.add_main_entries(entries, "switchboard ");609 context.add_main_entries(entries, "switchboard ");
602 context.add_group(Gtk.get_option_group(true));610 context.add_group(Gtk.get_option_group(true));
603 try {611 try {
604 context.parse(ref args);612 context.parse(ref args);
605 } catch(Error e) { warning (e.message); }613 } catch(Error e) { warning (e.message); }
606 614
607 // In the future, the plug_root_dir should be overridable by CLI flags.615 // In the future, the plug_root_dir should be overridable by CLI flags.
608 var switchboard_app = new SwitchboardApp ();616 var switchboard_app = new SwitchboardApp ();
609 617
610 GLib.Bus.own_name (BusType.SESSION, "org.elementary.switchboard",618 GLib.Bus.own_name (BusType.SESSION, "org.elementary.switchboard",
611 BusNameOwnerFlags.NONE,619 BusNameOwnerFlags.NONE,
612 (conn) => { 620 (conn) => {
613 try {621 try {
614 conn.register_object("/org/elementary/switchboard", switchboard_app);622 conn.register_object("/org/elementary/switchboard", switchboard_app);
615 } catch (IOError e) { warning (e.message); }623 } catch (IOError e) { warning (e.message); }
616 },624 },
617 () => {},625 () => {},
618 () => {logger.notification(_("Switchboard already running. Exiting..")); Process.exit(1);});626 () => {logger.notification(_("Switchboard already running. Exiting..")); Process.exit(1);});
619 627
620 return switchboard_app.run (args);628 return switchboard_app.run (args);
621 }629 }
622}630}

Subscribers

People subscribed via source and target branches