Merge lp:~voluntatefaber/switchboard/open-plug-fron-CLI into lp:~elementary-pantheon/switchboard/switchboard

Proposed by Andrea Basso
Status: Merged
Approved by: Avi Romanoff
Approved revision: 192
Merge reported by: Avi Romanoff
Merged at revision: not available
Proposed branch: lp:~voluntatefaber/switchboard/open-plug-fron-CLI
Merge into: lp:~elementary-pantheon/switchboard/switchboard
Diff against target: 101 lines (+35/-4)
1 file modified
Switchboard/switchboard-app.vala (+35/-4)
To merge this branch: bzr merge lp:~voluntatefaber/switchboard/open-plug-fron-CLI
Reviewer Review Type Date Requested Status
xapantu (community) Needs Information
Review via email: mp+99430@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Mario Guerriero (mefrio-g) wrote :

Hi Andrea,

I tried to run
"switchboard online-accounts"
"switchboard sound"
"switchboard wallpaper"

but your function didn't work

Revision history for this message
Andrea Basso (voluntatefaber) wrote :

It is supposed to work with -o command: you should use:
switchboard -o "Online Accounts"
Il giorno 27/mar/2012 16.20, "Mario Guerriero" <email address hidden> ha
scritto:
>
> Hi Andrea,
>
> I tried to run
> "switchboard online-accounts"
> "switchboard sound"
> "switchboard wallpaper"
>
> but your function didn't work
> --
>
https://code.launchpad.net/~voluntatefaber/switchboard/open-plug-fron-CLI/+merge/99430
> You are the owner of lp:~voluntatefaber/switchboard/open-plug-fron-CLI.

Revision history for this message
Mario Guerriero (mefrio-g) wrote :

Oh it is a good soluction. More intuitive of the gnome-control-center's one! So, since Cody Garver asked me to check this branch, I approve it

Revision history for this message
xapantu (xapantu) wrote :

How is handled the translation? I think that the keyfiles are automatically translated. If it is the case, this fix won't work. On my computer, I would have to do switchboard -o "Comptes en ligne". Maybe it is more intuitive, but it won't work ;)

review: Needs Information
Revision history for this message
xapantu (xapantu) wrote :

Ah, it is apparently alreay merged. Could you fix it? (I'm speaking to everyone, I won't have the time myself, so, Mario, Cody, Andrea, anyone...) There are two solutions: investigate wether we can get a non translted strings, use the id (e.g; online-acounts), or remove it if there is really no solution, I fear it will create some nasty bugs if we start using them without handling translation ^^".

Revision history for this message
Avi Romanoff (aroman) wrote :

This has been fixed as of rev 225. Switchboard now uses the .plug file's group header for unique id'ing and launching.

So this branch/discussion is now resolved/superceded.

Thanks for the hard work and input everyone!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Switchboard/switchboard-app.vala'
2--- Switchboard/switchboard-app.vala 2012-01-30 16:20:38 +0000
3+++ Switchboard/switchboard-app.vala 2012-03-27 10:56:19 +0000
4@@ -17,6 +17,8 @@
5
6 namespace Switchboard {
7
8+ static string plug_to_open;
9+
10 [DBus (name = "org.elementary.switchboard")]
11 public class SwitchboardApp : Granite.Application {
12
13@@ -59,9 +61,10 @@
14 // Plug data
15 bool socket_shown;
16 Gee.HashMap<string, string> current_plug = new Gee.HashMap<string, string>();
17+ Gee.HashMap<string, string>[] plugs;
18
19 string[] plug_places = {"/usr/share/plugs/", "/usr/lib/plugs/", "/usr/local/share/plugs/", "/usr/local/lib/plugs/"};
20- string search_box_buffer = "";
21+ string search_box_buffer = "";
22
23 public SwitchboardApp () {
24
25@@ -108,6 +111,17 @@
26 enumerate_plugs (place);
27
28 main_window.show ();
29+
30+ bool found = false;
31+ if (plug_to_open != null) {
32+ foreach (var plug in plugs)
33+ if (plug["title"] == plug_to_open) {
34+ load_plug (plug["title"], plug["exec"]);
35+ found = true;
36+ }
37+ if (!found)
38+ critical ("Couldn't find %s between the loaded plugs.", plug_to_open);
39+ }
40 }
41
42 void shutdown() {
43@@ -120,7 +134,7 @@
44 Gtk.main_quit();
45 }
46
47- void load_plug (string title, string executable) {
48+ public void load_plug (string title, string executable) {
49 debug("Selected plug: title %s | executable %s", title, executable);
50 debug("Current plug: %s", current_plug["title"]);
51 // Launch plug's executable
52@@ -234,6 +248,7 @@
53 plug["category"] = "other";
54 }
55 category_view.add_plug (plug);
56+ plugs += plug;
57 }
58 }
59
60@@ -395,9 +410,23 @@
61 toolbar.show_all();
62 }
63 }
64+
65+ static const OptionEntry[] entries = {
66+ { "open-plug", 'o', 0, OptionArg.STRING, ref plug_to_open, "Open a plug", "PLUG_NAME" },
67+ { null }
68+ };
69
70 // Handles a successful connection to D-Bus and launches the app
71- void on_bus_aquired (DBusConnection conn) {
72+ void on_bus_aquired (DBusConnection conn, string[] args) {
73+
74+ var context = new OptionContext("");
75+ context.add_main_entries(entries, "switchboard ");
76+ context.add_group(Gtk.get_option_group(true));
77+ try {
78+ context.parse(ref args);
79+ } catch(Error e) {
80+ print(e.message + "\n");
81+ }
82
83 // In the future, the plug_root_dir should be overridable by CLI flags.
84 SwitchboardApp switchboard_app = new SwitchboardApp ();
85@@ -406,6 +435,8 @@
86 conn.register_object("/org/elementary/switchboard", switchboard_app);
87 } catch (IOError e) {
88 }
89+
90+ switchboard_app.run (args);
91 }
92
93 static int main (string[] args) {
94@@ -420,7 +451,7 @@
95 Gtk.init (ref args);
96 Bus.own_name (BusType.SESSION, "org.elementary.switchboard",
97 BusNameOwnerFlags.NONE,
98- on_bus_aquired,
99+ (conn) => {on_bus_aquired (conn, args);},
100 () => {},
101 () => {logger.notification(_("Switchboard already running. Exiting..")); Process.exit(1);});
102

Subscribers

People subscribed via source and target branches

to all changes: