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
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-09-30 06:42:11 +0000
3+++ CMakeLists.txt 2013-12-03 14:31:03 +0000
4@@ -74,6 +74,7 @@
5 src/Resources.vala
6 src/DesktopLauncher.vala
7 src/EmbeddedAlert.vala
8+ src/NavigationButton.vala
9 PACKAGES
10 granite
11 gee-1.0
12
13=== added file 'src/NavigationButton.vala'
14--- src/NavigationButton.vala 1970-01-01 00:00:00 +0000
15+++ src/NavigationButton.vala 2013-12-03 14:31:03 +0000
16@@ -0,0 +1,50 @@
17+/***
18+ BEGIN LICENSE
19+
20+ Copyright (C) 2013 elementary, LLC.
21+ This program is free software: you can redistribute it and/or modify it
22+ under the terms of the GNU Lesser General Public License version 3, as
23+ published by the Free Software Foundation.
24+
25+ This program is distributed in the hope that it will be useful, but
26+ WITHOUT ANY WARRANTY; without even the implied warranties of
27+ MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
28+ PURPOSE. See the GNU General Public License for more details.
29+
30+ You should have received a copy of the GNU General Public License along
31+ with this program. If not, see <http://www.gnu.org/licenses>
32+
33+ END LICENSE
34+***/
35+
36+namespace Switchboard {
37+
38+ public class NavigationButton : Gtk.Button {
39+
40+ private Gtk.Label text;
41+
42+ public NavigationButton () {
43+ can_focus = false;
44+ valign = Gtk.Align.CENTER;
45+ vexpand = false;
46+
47+ Gtk.Box button_b = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
48+ var icon = new Gtk.Image.from_icon_name ("go-previous-symbolic",
49+ Gtk.IconSize.MENU);
50+ text = new Gtk.Label ("");
51+
52+ button_b.pack_start (icon, true, true, 2);
53+ button_b.pack_start (text, true, true, 2);
54+
55+ this.add (button_b);
56+ }
57+
58+ public string get_text () {
59+ return text.label;
60+ }
61+
62+ public void set_text (string text) {
63+ this.text.label = text;
64+ }
65+ }
66+}
67
68=== modified file 'src/Switchboard.vala'
69--- src/Switchboard.vala 2013-09-26 08:05:15 +0000
70+++ src/Switchboard.vala 2013-12-03 14:31:03 +0000
71@@ -21,7 +21,7 @@
72
73 [DBus (name = "org.elementary.switchboard")]
74 public class SwitchboardApp : Granite.Application {
75-
76+
77 construct {
78 application_id = "org.elementary.Switchboard";
79 program_name = "Switchboard";
80@@ -45,15 +45,15 @@
81 Gtk.Label progress_label;
82 Gtk.SearchEntry search_box;
83 Gtk.Toolbar toolbar;
84- Gtk.ToolButton navigation_button;
85+ Switchboard.NavigationButton navigation_button;
86 // Public so we can hide it after show_all()
87 public Gtk.ToolItem progress_toolitem;
88 // These two wrap the progress bar
89 Gtk.ToolItem lspace = new Gtk.ToolItem ();
90 Gtk.ToolItem rspace = new Gtk.ToolItem ();
91-
92+
93 Gtk.Spinner loading;
94-
95+
96 Gtk.Window main_window;
97
98 // Content area widgets
99@@ -70,15 +70,16 @@
100
101 string[] plug_places = {"/usr/share/plugs/",
102 "/usr/lib/plugs/",
103- "/usr/local/share/plugs/",
104+ "/usr/local/share/plugs/",
105 "/usr/local/lib/plugs/"};
106 string search_box_buffer = "";
107
108 private const string[] SUPPORTED_GETTEXT_DOMAINS_KEYS = {"X-Ubuntu-Gettext-Domain", "X-GNOME-Gettext-Domain"};
109
110- public SwitchboardApp () {
111- }
112-
113+ string all_settings_label = _("All Settings");
114+
115+ public SwitchboardApp () { }
116+
117 void build () {
118 main_window = new Gtk.Window();
119
120@@ -149,6 +150,8 @@
121 category_view.recalculate_columns (width);
122 });
123
124+ navigation_button.hide ();
125+
126 foreach (var label in category_view.category_labels.values)
127 label.hide ();
128 foreach (var view in category_view.category_views.values)
129@@ -188,7 +191,7 @@
130 } else {
131 update_libunity_quicklist ();
132 }
133-
134+
135 bool found = false;
136 if (plug_to_open != null) {
137 foreach (var plug in plugs) {
138@@ -201,17 +204,17 @@
139 critical ("Couldn't find %s among the loaded settings.", plug_to_open);
140 }
141 }
142-
143+
144 foreach (var store in category_view.category_store.values) {
145 store.foreach ((model, path, iter) => {
146 store.set_value (iter, 3, true);
147 return false;
148 });
149 }
150-
151+
152 progress_toolitem.hide ();
153 }
154-
155+
156 void shut_down () {
157 plug_closed ();
158 }
159@@ -236,15 +239,17 @@
160 // The plug is already selected
161 debug(_("Closing plug \"%s\" in Switchboard controller..."), current_plug["title"]);
162 plug_closed ();
163-
164+
165 string[] cmd_exploded = (executable!=null)?executable.split (" "):null;
166 GLib.Process.spawn_async (File.new_for_path (cmd_exploded[0]).get_parent ().
167 get_path (), cmd_exploded, null, SpawnFlags.SEARCH_PATH, null, null);
168-
169+
170 // ensure the button is sensitive; it might be the first plug loaded
171 if (!@extern) {
172- navigation_button.set_sensitive(true);
173- navigation_button.set_icon_name ("go-home");
174+ navigation_button.set_sensitive (true);
175+ navigation_button.set_text (all_settings_label);
176+ navigation_button.show ();
177+
178 current_plug["title"] = title;
179 current_plug["executable"] = executable;
180 switch_to_socket ();
181@@ -252,10 +257,11 @@
182 }
183 } catch { warning(_("Failed to launch plug: title %s | executable %s"), title, executable); }
184 } else {
185- navigation_button.set_sensitive(true);
186- navigation_button.set_icon_name ("go-home");
187+ navigation_button.set_sensitive (true);
188+ navigation_button.set_text (all_settings_label);
189+ navigation_button.show ();
190 }
191-
192+
193 if (@extern) {
194 switch_to_icons ();
195 }
196@@ -268,20 +274,17 @@
197
198 // Handles clicking the navigation button
199 void handle_navigation_button_clicked () {
200- string icon_name = navigation_button.get_icon_name ();
201- if (icon_name == "go-home") {
202+ if (navigation_button.get_text () != current_plug["title"]) {
203 switch_to_icons();
204- navigation_button.set_icon_name ("go-previous");
205- }
206- else {
207+ navigation_button.set_text (current_plug["title"]);
208+ } else {
209 load_plug (current_plug["title"], current_plug["executable"], current_plug["extern"] == "1");
210- navigation_button.set_icon_name ("go-home");
211+ navigation_button.set_text (all_settings_label);
212 }
213 }
214
215 // Switches to the socket view
216 void switch_to_socket () {
217-
218 socket_shown = true;
219 search_box.sensitive = false;
220
221@@ -289,13 +292,13 @@
222 socket.hide ();
223 loading.show_all ();
224 }
225-
226+
227 // Switches back to the icons
228 bool switch_to_icons () {
229 socket.hide ();
230 loading.hide ();
231 category_view.show ();
232-
233+
234 socket_shown = false;
235
236 // Reset state
237@@ -305,9 +308,9 @@
238 progress_label.set_text("");
239 progress_bar.fraction = 0.0;
240 progress_toolitem.visible = false;
241-
242+
243 plug_closed ();
244-
245+
246 return true;
247 }
248
249@@ -341,7 +344,7 @@
250 exec = Path.build_filename(parent, exec);
251 plug["extern"] = "0";
252 }
253-
254+
255 plug["exec"] = exec;
256 } catch (Error e) { warning("Couldn't read exec field in file %s, %s", keyfile, e.message); }
257 try { plug["icon"] = kf.get_string (head, "icon");
258@@ -385,7 +388,7 @@
259 keyfiles.append(keyfile);
260 }
261 }
262-
263+
264 var directory = File.new_for_path (path);
265 if (!directory.query_exists ()) {
266 return null;
267@@ -396,7 +399,7 @@
268 FileInfo file_info;
269 while ((file_info = enumerator.next_file ()) != null) {
270 string file_path = Path.build_filename(path, file_info.get_name());
271- if (file_info.get_file_type() == GLib.FileType.REGULAR &&
272+ if (file_info.get_file_type() == GLib.FileType.REGULAR &&
273 is_plug_file(file_info.get_name())) {
274 keyfiles.append(file_path);
275 } else if(file_info.get_file_type() == GLib.FileType.DIRECTORY) {
276@@ -404,7 +407,7 @@
277 }
278 }
279 } catch { warning(_(@"Unable to iterate over enumerated plug directory \"$path\"'s contents")); }
280-
281+
282 return keyfiles;
283 }
284
285@@ -496,12 +499,15 @@
286 // Searchbar
287 search_box = new Gtk.SearchEntry ();
288 search_box.set_placeholder_text (_("Search Settings"));
289- search_box.activate.connect(() => search_box_activated());
290- search_box.changed.connect(() => {
291- category_view.filter_plugs(search_box.get_text (), this);
292- search_box_text_changed();
293+ search_box.activate.connect (() => search_box_activated ());
294+
295+ search_box.changed.connect (() => {
296+ category_view.filter_plugs (search_box.get_text (), this);
297+ search_box_text_changed ();
298 });
299+
300 search_box.sensitive = (count_plugs () > 0);
301+ search_box.margin = 5;
302 var find_toolitem = new Gtk.ToolItem ();
303 find_toolitem.add(search_box);
304 find_toolitem.margin_right = 6;
305@@ -516,19 +522,21 @@
306 });
307
308 // Nav button
309- navigation_button = new Gtk.ToolButton (null, null);
310- navigation_button.set_icon_name ("go-previous");
311+ navigation_button = new NavigationButton ();
312 navigation_button.clicked.connect (handle_navigation_button_clicked);
313- navigation_button.set_sensitive(false);
314+ navigation_button.margin = 5;
315
316 // Add everything to the toolbar
317- toolbar.insert (navigation_button, -1);
318+
319+ Gtk.ToolItem tool = new Gtk.ToolItem ();
320+ tool.add (navigation_button);
321+ toolbar.insert (tool, -1);
322 toolbar.insert (lspace, -1);
323 toolbar.insert (progress_toolitem, -1);
324 toolbar.insert (rspace, -1);
325 toolbar.insert (find_toolitem, -1);
326 }
327-
328+
329 public override void activate () {
330 // If app is already running, present the current window.
331 if (get_windows () != null) {
332@@ -594,29 +602,29 @@
333 message(_(@"Welcome to $APP_TITLE"));
334 message(_(@"Version: $VERSION"));
335 message(_("Report any issues/bugs you mind find to lp:switchboard"));
336-
337+
338 Gtk.init (ref args);
339-
340+
341 var context = new OptionContext("");
342 context.add_main_entries(entries, "switchboard ");
343 context.add_group(Gtk.get_option_group(true));
344 try {
345 context.parse(ref args);
346 } catch(Error e) { warning (e.message); }
347-
348+
349 // In the future, the plug_root_dir should be overridable by CLI flags.
350 var switchboard_app = new SwitchboardApp ();
351-
352+
353 GLib.Bus.own_name (BusType.SESSION, "org.elementary.switchboard",
354 BusNameOwnerFlags.NONE,
355- (conn) => {
356+ (conn) => {
357 try {
358 conn.register_object("/org/elementary/switchboard", switchboard_app);
359 } catch (IOError e) { warning (e.message); }
360 },
361 () => {},
362 () => {logger.notification(_("Switchboard already running. Exiting..")); Process.exit(1);});
363-
364+
365 return switchboard_app.run (args);
366 }
367 }

Subscribers

People subscribed via source and target branches