Merge lp:~elementary-apps/switchboard/cleanup into lp:~elementary-pantheon/switchboard/switchboard

Proposed by Raphael Isemann
Status: Rejected
Rejected by: Julián Unrrein
Proposed branch: lp:~elementary-apps/switchboard/cleanup
Merge into: lp:~elementary-pantheon/switchboard/switchboard
Diff against target: 577 lines (+148/-120)
3 files modified
src/CategoryView.vala (+1/-1)
src/EmbeddedAlert.vala (+1/-1)
src/Switchboard.vala (+146/-118)
To merge this branch: bzr merge lp:~elementary-apps/switchboard/cleanup
Reviewer Review Type Date Requested Status
Julián Unrrein (community) Disapprove
David Gomes (community) Needs Fixing
Review via email: mp+188034@code.launchpad.net

Description of the change

Fixing codestyle.

To post a comment you must log in.
Revision history for this message
Julián Unrrein (junrrein) wrote :

Code style

Diff lines 244-245, 262, 265, 310, 445: Put the blocks of code in separate lines from the "try" and "catch" statements:

try {
    //...
} catch (Error e) {
    //...
}

Diff line 303: A space after "else if" and before the parenthesis.

Diff line 320: A space on the other side of the parenthesis :)

Diff line 380: A space before the opening parenthesis.

Diff line 450: A space after the opening curly brace.

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

I would offer to submit the changes myself (since I'm in ~elementary-apps too) but I am not able to compile this on Luna (GTK >= 3.6 required).

406. By David Gomes

More fixes.

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

Junrrein, I fixed the stuff. Care to re-review?

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

Re-indent diff lines 150, 153, 163-164, 391, they are part of foreach blocks.

You can close lines 163-164 in curly braces for clarity.

Diff line 225: Move the warning to its own line.

Diff line 373: Space after get_file_type.

Diff line 475: Space after search_box_activated.

I see you also fixed stuff I didn't catch, nice!

review: Needs Fixing
407. By David Gomes

Fixed yet more code style.

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

It's ready to go.

Good work Raphael and Munchor!

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

Rejecting this branch because there are major changes coming to Switchboard (see https://code.launchpad.net/~elementary-apps/switchboard/libpeas-isis/+merge/195417).

We should review that branch for code style later instead.

review: Disapprove

Unmerged revisions

407. By David Gomes

Fixed yet more code style.

406. By David Gomes

More fixes.

405. By Raphael Isemann

cleaning CategoryView.vala

404. By Raphael Isemann

cleaning EmbeddedAlert.vala

403. By Raphael Isemann

cleaning Switchboard.vala

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 2013-09-29 19:41:03 +0000
+++ src/CategoryView.vala 2013-12-03 21:13:09 +0000
@@ -53,7 +53,7 @@
53 category_label.margin_left = 12;53 category_label.margin_left = 12;
54 category_label.margin_right = 8;54 category_label.margin_right = 8;
55 var filtered = new Gtk.TreeModelFilter (store, null);55 var filtered = new Gtk.TreeModelFilter (store, null);
56 filtered.set_visible_column(3);56 filtered.set_visible_column (3);
57 filtered.refilter ();57 filtered.refilter ();
58 58
59 var category_plugs = new Gtk.IconView.with_model (filtered);59 var category_plugs = new Gtk.IconView.with_model (filtered);
6060
=== modified file 'src/EmbeddedAlert.vala'
--- src/EmbeddedAlert.vala 2013-01-08 15:21:51 +0000
+++ src/EmbeddedAlert.vala 2013-12-03 21:13:09 +0000
@@ -113,7 +113,7 @@
113 primary_text_label.halign = secondary_text_label.halign = Gtk.Align.START;113 primary_text_label.halign = secondary_text_label.halign = Gtk.Align.START;
114 primary_text_label.justify = Gtk.Justification.LEFT;114 primary_text_label.justify = Gtk.Justification.LEFT;
115 secondary_text_label.justify = Gtk.Justification.FILL;115 secondary_text_label.justify = Gtk.Justification.FILL;
116 image.set_pixel_size(64);116 image.set_pixel_size (64);
117117
118 // TODO: More intelligent icon support, I guess. Or support all the118 // TODO: More intelligent icon support, I guess. Or support all the
119 // MessageType flags.119 // MessageType flags.
120120
=== modified file 'src/Switchboard.vala'
--- src/Switchboard.vala 2013-09-26 08:05:15 +0000
+++ src/Switchboard.vala 2013-12-03 21:13:09 +0000
@@ -1,18 +1,18 @@
1/***1/***
2BEGIN LICENSE2 BEGIN LICENSE
3Copyright (C) 2011-2012 Avi Romanoff <aviromanoff@gmail.com>3 Copyright (C) 2011-2012 Avi Romanoff <aviromanoff@gmail.com>
4This program is free software: you can redistribute it and/or modify it4 This program is free software: you can redistribute it and/or modify it
5under the terms of the GNU Lesser General Public License version 3, as published5 under the terms of the GNU Lesser General Public License version 3, as published
6by the Free Software Foundation.6 by the Free Software Foundation.
77
8This program is distributed in the hope that it will be useful, but8 This program is distributed in the hope that it will be useful, but
9WITHOUT ANY WARRANTY; without even the implied warranties of9 WITHOUT ANY WARRANTY; without even the implied warranties of
10MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR10 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11PURPOSE. See the GNU General Public License for more details.11 PURPOSE. See the GNU General Public License for more details.
1212
13You should have received a copy of the GNU General Public License along13 You should have received a copy of the GNU General Public License along
14with this program. If not, see <http://www.gnu.org/licenses/>.14 with this program. If not, see <http://www.gnu.org/licenses/>.
15END LICENSE15 END LICENSE
16***/16***/
1717
18namespace Switchboard {18namespace Switchboard {
@@ -21,13 +21,13 @@
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";
28 app_years = "2011-2012";28 app_years = "2011-2012";
29 exec_name = "switchboard";29 exec_name = "switchboard";
30 app_launcher = exec_name+".desktop";30 app_launcher = exec_name + ".desktop";
3131
32 build_version = VERSION;32 build_version = VERSION;
33 app_icon = APP_ICON;33 app_icon = APP_ICON;
@@ -51,9 +51,9 @@
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
@@ -65,12 +65,12 @@
6565
66 // Plug data66 // Plug data
67 bool socket_shown;67 bool socket_shown;
68 Gee.HashMap<string, string> current_plug = new Gee.HashMap<string, string>();68 Gee.HashMap<string, string> current_plug = new Gee.HashMap<string, string> ();
69 Gee.HashMap<string, string>[] plugs;69 Gee.HashMap<string, string>[] plugs;
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
@@ -78,9 +78,9 @@
7878
79 public SwitchboardApp () {79 public SwitchboardApp () {
80 }80 }
81 81
82 void build () {82 void build () {
83 main_window = new Gtk.Window();83 main_window = new Gtk.Window ();
8484
85 // Set up defaults85 // Set up defaults
86 main_window.title = APP_TITLE;86 main_window.title = APP_TITLE;
@@ -95,8 +95,8 @@
9595
96 // Set up socket96 // Set up socket
97 socket = new Gtk.Socket ();97 socket = new Gtk.Socket ();
98 socket.set_hexpand(true);98 socket.set_hexpand (true);
99 socket.set_vexpand(true);99 socket.set_vexpand (true);
100100
101 socket.plug_removed.connect (() => {101 socket.plug_removed.connect (() => {
102 plug_closed ();102 plug_closed ();
@@ -108,11 +108,12 @@
108 uint accel_key;108 uint accel_key;
109 Gdk.ModifierType accel_mod;109 Gdk.ModifierType accel_mod;
110 var accel_flags = Gtk.AccelFlags.LOCKED;110 var accel_flags = Gtk.AccelFlags.LOCKED;
111 Gtk.accelerator_parse("<Control>q", out accel_key, out accel_mod);111 Gtk.accelerator_parse ("<Control>q", out accel_key, out accel_mod);
112 accel_group.connect(accel_key, accel_mod, accel_flags, () => {112 accel_group.connect (accel_key, accel_mod, accel_flags, () => {
113 main_window.destroy();113 main_window.destroy ();
114 return true;114 return true;
115 });115 });
116
116 main_window.add_accel_group (accel_group);117 main_window.add_accel_group (accel_group);
117118
118 // ??? Why?119 // ??? Why?
@@ -151,6 +152,7 @@
151152
152 foreach (var label in category_view.category_labels.values)153 foreach (var label in category_view.category_labels.values)
153 label.hide ();154 label.hide ();
155
154 foreach (var view in category_view.category_views.values)156 foreach (var view in category_view.category_views.values)
155 view.hide ();157 view.hide ();
156158
@@ -178,17 +180,19 @@
178 }180 }
179 });181 });
180182
181 foreach (string place in plug_places)183 foreach (string place in plug_places) {
182 if (enumerate_plugs (place))184 if (enumerate_plugs (place)) {
183 any_plugs = true;185 any_plugs = true;
186 }
187 }
184188
185 if (!any_plugs) {189 if (!any_plugs) {
186 show_alert(_("No settings found"), _("Install some and re-launch Switchboard"), Gtk.MessageType.WARNING);190 show_alert (_("No settings found"), _("Install some and re-launch Switchboard"), Gtk.MessageType.WARNING);
187 search_box.sensitive = false;191 search_box.sensitive = false;
188 } else {192 } else {
189 update_libunity_quicklist ();193 update_libunity_quicklist ();
190 }194 }
191 195
192 bool found = false;196 bool found = false;
193 if (plug_to_open != null) {197 if (plug_to_open != null) {
194 foreach (var plug in plugs) {198 foreach (var plug in plugs) {
@@ -201,17 +205,17 @@
201 critical ("Couldn't find %s among the loaded settings.", plug_to_open);205 critical ("Couldn't find %s among the loaded settings.", plug_to_open);
202 }206 }
203 }207 }
204 208
205 foreach (var store in category_view.category_store.values) {209 foreach (var store in category_view.category_store.values) {
206 store.foreach ((model, path, iter) => {210 store.foreach ((model, path, iter) => {
207 store.set_value (iter, 3, true);211 store.set_value (iter, 3, true);
208 return false;212 return false;
209 });213 });
210 }214 }
211 215
212 progress_toolitem.hide ();216 progress_toolitem.hide ();
213 }217 }
214 218
215 void shut_down () {219 void shut_down () {
216 plug_closed ();220 plug_closed ();
217 }221 }
@@ -234,28 +238,30 @@
234 if (current_plug["title"] != title || !socket.visible) {238 if (current_plug["title"] != title || !socket.visible) {
235 try {239 try {
236 // The plug is already selected240 // The plug is already selected
237 debug(_("Closing plug \"%s\" in Switchboard controller..."), current_plug["title"]);241 debug (_("Closing plug \"%s\" in Switchboard controller..."), current_plug["title"]);
238 plug_closed ();242 plug_closed ();
239 243
240 string[] cmd_exploded = (executable!=null)?executable.split (" "):null;244 string[] cmd_exploded = (executable!=null)?executable.split (" "):null;
241 GLib.Process.spawn_async (File.new_for_path (cmd_exploded[0]).get_parent ().245 GLib.Process.spawn_async (File.new_for_path (cmd_exploded[0]).get_parent ().
242 get_path (), cmd_exploded, null, SpawnFlags.SEARCH_PATH, null, null);246 get_path (), cmd_exploded, null, SpawnFlags.SEARCH_PATH, null, null);
243 247
244 // ensure the button is sensitive; it might be the first plug loaded248 // ensure the button is sensitive; it might be the first plug loaded
245 if (!@extern) {249 if (!@extern) {
246 navigation_button.set_sensitive(true);250 navigation_button.set_sensitive (true);
247 navigation_button.set_icon_name ("go-home");251 navigation_button.set_icon_name ("go-home");
248 current_plug["title"] = title;252 current_plug["title"] = title;
249 current_plug["executable"] = executable;253 current_plug["executable"] = executable;
250 switch_to_socket ();254 switch_to_socket ();
251 main_window.title = @"$APP_TITLE - $title";255 main_window.title = @"$APP_TITLE - $title";
252 }256 }
253 } catch { warning(_("Failed to launch plug: title %s | executable %s"), title, executable); }257 } catch {
258 warning (_("Failed to launch plug: title %s | executable %s"), title, executable);
259 }
254 } else {260 } else {
255 navigation_button.set_sensitive(true);261 navigation_button.set_sensitive (true);
256 navigation_button.set_icon_name ("go-home");262 navigation_button.set_icon_name ("go-home");
257 }263 }
258 264
259 if (@extern) {265 if (@extern) {
260 switch_to_icons ();266 switch_to_icons ();
261 }267 }
@@ -270,7 +276,7 @@
270 void handle_navigation_button_clicked () {276 void handle_navigation_button_clicked () {
271 string icon_name = navigation_button.get_icon_name ();277 string icon_name = navigation_button.get_icon_name ();
272 if (icon_name == "go-home") {278 if (icon_name == "go-home") {
273 switch_to_icons();279 switch_to_icons ();
274 navigation_button.set_icon_name ("go-previous");280 navigation_button.set_icon_name ("go-previous");
275 }281 }
276 else {282 else {
@@ -289,25 +295,25 @@
289 socket.hide ();295 socket.hide ();
290 loading.show_all ();296 loading.show_all ();
291 }297 }
292 298
293 // Switches back to the icons299 // Switches back to the icons
294 bool switch_to_icons () {300 bool switch_to_icons () {
295 socket.hide ();301 socket.hide ();
296 loading.hide ();302 loading.hide ();
297 category_view.show ();303 category_view.show ();
298 304
299 socket_shown = false;305 socket_shown = false;
300306
301 // Reset state307 // Reset state
302 reset_title ();308 reset_title ();
303 search_box.set_text("");309 search_box.set_text ("");
304 search_box.sensitive = count_plugs() > 0;310 search_box.sensitive = count_plugs () > 0;
305 progress_label.set_text("");311 progress_label.set_text ("");
306 progress_bar.fraction = 0.0;312 progress_bar.fraction = 0.0;
307 progress_toolitem.visible = false;313 progress_toolitem.visible = false;
308 314
309 plug_closed ();315 plug_closed ();
310 316
311 return true;317 return true;
312 }318 }
313319
@@ -318,19 +324,24 @@
318324
319 // <keyfile's absolute path, keyfile's directory>325 // <keyfile's absolute path, keyfile's directory>
320 List<string> keyfiles = find_plugs (plug_root_dir);326 List<string> keyfiles = find_plugs (plug_root_dir);
321 if (keyfiles.length() == 0) {327 if (keyfiles.length () == 0) {
322 return false;328 return false;
323 } else {329 } else {
324 foreach (string keyfile in keyfiles) {330 foreach (string keyfile in keyfiles) {
325 KeyFile kf = new KeyFile();331 KeyFile kf = new KeyFile ();
326332
327 string head = File.new_for_path(keyfile).get_basename();333 string head = File.new_for_path (keyfile).get_basename ();
328 string parent = File.new_for_path(keyfile).get_parent().get_path();334 string parent = File.new_for_path (keyfile).get_parent ().get_path ();
329335
330 Gee.HashMap<string, string> plug = new Gee.HashMap<string, string> ();336 Gee.HashMap<string, string> plug = new Gee.HashMap<string, string> ();
331 try { kf.load_from_file(keyfile, KeyFileFlags.NONE);337 try {
332 } catch (Error e) { warning("Couldn't load this keyfile, %s (path: %s)", e.message, keyfile); }338 kf.load_from_file (keyfile, KeyFileFlags.NONE);
333 plug["id"] = kf.get_start_group();339 } catch (Error e) {
340 warning ("Couldn't load this keyfile, %s (path: %s)", e.message, keyfile);
341 }
342
343 plug["id"] = kf.get_start_group ();
344
334 try {345 try {
335 var exec = kf.get_string (head, "exec");346 var exec = kf.get_string (head, "exec");
336 //if a path starts with a double slash, we take it as an absolute path347 //if a path starts with a double slash, we take it as an absolute path
@@ -338,14 +349,21 @@
338 exec = exec.substring (1);349 exec = exec.substring (1);
339 plug["extern"] = "1";350 plug["extern"] = "1";
340 } else {351 } else {
341 exec = Path.build_filename(parent, exec);352 exec = Path.build_filename (parent, exec);
342 plug["extern"] = "0";353 plug["extern"] = "0";
343 }354 }
344 355
345 plug["exec"] = exec;356 plug["exec"] = exec;
346 } catch (Error e) { warning("Couldn't read exec field in file %s, %s", keyfile, e.message); }357 } catch (Error e) {
347 try { plug["icon"] = kf.get_string (head, "icon");358 warning ("Couldn't read exec field in file %s, %s", keyfile, e.message);
348 } catch (Error e) { warning("Couldn't read icon field in file %s, %s", keyfile, e.message); }359 }
360
361 try {
362 plug["icon"] = kf.get_string (head, "icon");
363 } catch (Error e) {
364 warning ("Couldn't read icon field in file %s, %s", keyfile, e.message);
365 }
366
349 try {367 try {
350 plug["title"] = kf.get_locale_string (head, "title");368 plug["title"] = kf.get_locale_string (head, "title");
351 string? textdomain = null;369 string? textdomain = null;
@@ -371,7 +389,7 @@
371389
372 // Checks if the file is a .plug file390 // Checks if the file is a .plug file
373 bool is_plug_file (string filename) {391 bool is_plug_file (string filename) {
374 return (filename.down().has_suffix(".plug"));392 return (filename.down ().has_suffix (".plug"));
375 }393 }
376394
377 // Find all .plug files395 // Find all .plug files
@@ -382,10 +400,10 @@
382 } else {400 } else {
383 keyfiles = new List<string> ();401 keyfiles = new List<string> ();
384 foreach(var keyfile in keyfiles_list) {402 foreach(var keyfile in keyfiles_list) {
385 keyfiles.append(keyfile);403 keyfiles.append (keyfile);
386 }404 }
387 }405 }
388 406
389 var directory = File.new_for_path (path);407 var directory = File.new_for_path (path);
390 if (!directory.query_exists ()) {408 if (!directory.query_exists ()) {
391 return null;409 return null;
@@ -395,30 +413,33 @@
395 FileAttribute.STANDARD_NAME + "," + FileAttribute.STANDARD_TYPE, 0);413 FileAttribute.STANDARD_NAME + "," + FileAttribute.STANDARD_TYPE, 0);
396 FileInfo file_info;414 FileInfo file_info;
397 while ((file_info = enumerator.next_file ()) != null) {415 while ((file_info = enumerator.next_file ()) != null) {
398 string file_path = Path.build_filename(path, file_info.get_name());416 string file_path = Path.build_filename (path, file_info.get_name ());
399 if (file_info.get_file_type() == GLib.FileType.REGULAR && 417 if (file_info.get_file_type () == GLib.FileType.REGULAR &&
400 is_plug_file(file_info.get_name())) {418 is_plug_file (file_info.get_name ())) {
401 keyfiles.append(file_path);419 keyfiles.append (file_path);
402 } else if(file_info.get_file_type() == GLib.FileType.DIRECTORY) {420 } else if (file_info.get_file_type () == GLib.FileType.DIRECTORY) {
403 keyfiles = find_plugs(file_path, keyfiles);421 keyfiles = find_plugs (file_path, keyfiles);
404 }422 }
405 }423 }
406 } catch { warning(_(@"Unable to iterate over enumerated plug directory \"$path\"'s contents")); }424 } catch {
407 425 warning (_(@"Unable to iterate over enumerated plug directory \"$path\"'s contents"));
426 }
427
408 return keyfiles;428 return keyfiles;
409 }429 }
410430
411 // Counts how many plugs exist at the moment431 // Counts how many plugs exist at the moment
412 int count_plugs () {432 int count_plugs () {
413
414 uint count = 0;433 uint count = 0;
434
415 foreach (string place in plug_places)435 foreach (string place in plug_places)
416 count += find_plugs (place).length ();436 count += find_plugs (place).length ();
437
417 return (int) count;438 return (int) count;
418 }439 }
419440
420 /*441 /*
421 D-Bus ONLY methods442 D-Bus ONLY methods
422 */443 */
423444
424 public int get_socket_wid () {445 public int get_socket_wid () {
@@ -430,12 +451,12 @@
430451
431 public void progress_bar_set_visible (bool visibility) {452 public void progress_bar_set_visible (bool visibility) {
432453
433 progress_toolitem.set_visible(visibility);454 progress_toolitem.set_visible (visibility);
434 }455 }
435456
436 public void progress_bar_set_text (string text) {457 public void progress_bar_set_text (string text) {
437458
438 progress_label.set_text(text);459 progress_label.set_text (text);
439 }460 }
440461
441 public void progress_bar_set_fraction (double fraction) {462 public void progress_bar_set_fraction (double fraction) {
@@ -445,7 +466,7 @@
445466
446 public void progress_bar_pulse () {467 public void progress_bar_pulse () {
447468
448 progress_bar.pulse();469 progress_bar.pulse ();
449 }470 }
450471
451 public signal void search_box_activated ();472 public signal void search_box_activated ();
@@ -458,7 +479,7 @@
458479
459 public void search_box_set_text (string text) {480 public void search_box_set_text (string text) {
460481
461 plug_closed();482 plug_closed ();
462 search_box.set_text (text);483 search_box.set_text (text);
463 }484 }
464485
@@ -468,7 +489,7 @@
468 }489 }
469490
470 /*491 /*
471 End D-Bus ONLY methods492 End D-Bus ONLY methods
472 */493 */
473494
474 // Sets up the toolbar for the Switchboard app495 // Sets up the toolbar for the Switchboard app
@@ -479,28 +500,30 @@
479 toolbar.get_style_context ().add_class ("primary-toolbar");500 toolbar.get_style_context ().add_class ("primary-toolbar");
480501
481 // Spacing502 // Spacing
482 lspace.set_expand(true);503 lspace.set_expand (true);
483 rspace.set_expand(true);504 rspace.set_expand (true);
484505
485 // Progressbar506 // Progressbar
486 var progress_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);507 var progress_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
487 progress_label = new Gtk.Label ("");508 progress_label = new Gtk.Label ("");
488 progress_label.set_use_markup(true);509 progress_label.set_use_markup (true);
489 progress_bar = new Gtk.ProgressBar ();510 progress_bar = new Gtk.ProgressBar ();
490 progress_toolitem = new Gtk.ToolItem ();511 progress_toolitem = new Gtk.ToolItem ();
491 progress_vbox.pack_start(progress_label, true, false, 0);512 progress_vbox.pack_start (progress_label, true, false, 0);
492 progress_vbox.pack_end(progress_bar, false, false, 0);513 progress_vbox.pack_end (progress_bar, false, false, 0);
493 progress_toolitem.add(progress_vbox);514 progress_toolitem.add (progress_vbox);
494 progress_toolitem.set_expand(true);515 progress_toolitem.set_expand (true);
495516
496 // Searchbar517 // Searchbar
497 search_box = new Gtk.SearchEntry ();518 search_box = new Gtk.SearchEntry ();
498 search_box.set_placeholder_text (_("Search Settings"));519 search_box.set_placeholder_text (_("Search Settings"));
499 search_box.activate.connect(() => search_box_activated());520 search_box.activate.connect (() => search_box_activated ());
500 search_box.changed.connect(() => {521
501 category_view.filter_plugs(search_box.get_text (), this);522 search_box.changed.connect (() => {
502 search_box_text_changed();523 category_view.filter_plugs (search_box.get_text (), this);
524 search_box_text_changed ();
503 });525 });
526
504 search_box.sensitive = (count_plugs () > 0);527 search_box.sensitive = (count_plugs () > 0);
505 var find_toolitem = new Gtk.ToolItem ();528 var find_toolitem = new Gtk.ToolItem ();
506 find_toolitem.add(search_box);529 find_toolitem.add(search_box);
@@ -519,7 +542,7 @@
519 navigation_button = new Gtk.ToolButton (null, null);542 navigation_button = new Gtk.ToolButton (null, null);
520 navigation_button.set_icon_name ("go-previous");543 navigation_button.set_icon_name ("go-previous");
521 navigation_button.clicked.connect (handle_navigation_button_clicked);544 navigation_button.clicked.connect (handle_navigation_button_clicked);
522 navigation_button.set_sensitive(false);545 navigation_button.set_sensitive (false);
523546
524 // Add everything to the toolbar547 // Add everything to the toolbar
525 toolbar.insert (navigation_button, -1);548 toolbar.insert (navigation_button, -1);
@@ -528,7 +551,7 @@
528 toolbar.insert (rspace, -1);551 toolbar.insert (rspace, -1);
529 toolbar.insert (find_toolitem, -1);552 toolbar.insert (find_toolitem, -1);
530 }553 }
531 554
532 public override void activate () {555 public override void activate () {
533 // If app is already running, present the current window.556 // If app is already running, present the current window.
534 if (get_windows () != null) {557 if (get_windows () != null) {
@@ -582,41 +605,46 @@
582 }605 }
583606
584 static const OptionEntry[] entries = {607 static const OptionEntry[] entries = {
585 { "open-plug", 'o', 0, OptionArg.STRING, ref plug_to_open, N_("Open a plug"), "PLUG_NAME" },608 { "open-plug", 'o', 0, OptionArg.STRING, ref plug_to_open, N_("Open a plug"), "PLUG_NAME" },
586 { null }609 { null }
587 };610 };
588611
589 public static int main (string[] args) {612 public static int main (string[] args) {
590
591 var logger = new Granite.Services.Logger ();613 var logger = new Granite.Services.Logger ();
592 logger.initialize(APP_TITLE);614 logger.initialize (APP_TITLE);
593 logger.DisplayLevel = Granite.Services.LogLevel.INFO;615 logger.DisplayLevel = Granite.Services.LogLevel.INFO;
594 message(_(@"Welcome to $APP_TITLE"));616 message (_(@"Welcome to $APP_TITLE"));
595 message(_(@"Version: $VERSION"));617 message (_(@"Version: $VERSION"));
596 message(_("Report any issues/bugs you mind find to lp:switchboard"));618 message (_("Report any issues/bugs you mind find to lp:switchboard"));
597 619
598 Gtk.init (ref args);620 Gtk.init (ref args);
599 621
600 var context = new OptionContext("");622 var context = new OptionContext ("");
601 context.add_main_entries(entries, "switchboard ");623 context.add_main_entries (entries, "switchboard ");
602 context.add_group(Gtk.get_option_group(true));624 context.add_group (Gtk.get_option_group (true));
625
603 try {626 try {
604 context.parse(ref args);627 context.parse (ref args);
605 } catch(Error e) { warning (e.message); }628 } catch(Error e) {
606 629 warning (e.message);
630 }
631
607 // In the future, the plug_root_dir should be overridable by CLI flags.632 // In the future, the plug_root_dir should be overridable by CLI flags.
608 var switchboard_app = new SwitchboardApp ();633 var switchboard_app = new SwitchboardApp ();
609 634
610 GLib.Bus.own_name (BusType.SESSION, "org.elementary.switchboard",635 GLib.Bus.own_name (BusType.SESSION, "org.elementary.switchboard",
611 BusNameOwnerFlags.NONE,636 BusNameOwnerFlags.NONE,
612 (conn) => { 637 (conn) => {
613 try {638 try {
614 conn.register_object("/org/elementary/switchboard", switchboard_app);639 conn.register_object ("/org/elementary/switchboard", switchboard_app);
615 } catch (IOError e) { warning (e.message); }640 } catch (IOError e) {
616 },641 warning (e.message);
617 () => {},642 }
618 () => {logger.notification(_("Switchboard already running. Exiting..")); Process.exit(1);});643 },
619 644
645 () => {},
646 () => { logger.notification (_("Switchboard already running. Exiting..")); Process.exit (1); });
647
620 return switchboard_app.run (args);648 return switchboard_app.run (args);
621 }649 }
622}650}

Subscribers

People subscribed via source and target branches

to all changes: