Merge lp:~tombeckmann/switchboard/cli-open-fixes into lp:~elementary-pantheon/switchboard/switchboard

Proposed by Tom Beckmann
Status: Merged
Approved by: Cody Garver
Approved revision: 462
Merged at revision: 459
Proposed branch: lp:~tombeckmann/switchboard/cli-open-fixes
Merge into: lp:~elementary-pantheon/switchboard/switchboard
Diff against target: 102 lines (+46/-3)
2 files modified
CMakeLists.txt (+3/-1)
src/Switchboard.vala (+43/-2)
To merge this branch: bzr merge lp:~tombeckmann/switchboard/cli-open-fixes
Reviewer Review Type Date Requested Status
Corentin Noël Approve
Sergey "Shnatsel" Davidoff (community) Abstain
Review via email: mp+225763@code.launchpad.net

Commit message

Initialize cheese-gtk before gtk, required for GNOME Control Center compatibility layer

Description of the change

This fixes the crash when opening a gcc plug via commandline, it was caused by the user-accounts plug requiring cheese-gtk to be initialized before gtk. We fix this by initializing cheese-gtk for it. A different solution would have been to have all plugins initialize themselves when switchboard starts, but this approach appears easier and better for performance.

The branch also introduces a translation from gcc plug names to switchboard plug names. The names are taken directly from gcc's source, so they are definitely correct and we can easily swap out our plugs if we replace gcc ones. As shnatsel already mentioned here https://bugs.launchpad.net/elementaryos/+bug/1291738/comments/5 the app that is calling switchboard shouldn't be concerned whether the plug that is opened is native or from gcc, this translation layer allows this behavior. A simple "switchboard sound" or "switchboard keyboard" will now open the corresponding plug, instead of a "switchboard -o hardware-gcc-sound" for example (but it continues to work of course), which would break for all third-parties using this, once we get a sound plug ourselves, as the "gcc" part would be replaced with "pantheon". So translating this centrally in switchboard is definitely the best option.

The gnome-control-center replacement script can now be reduced to basically this http://pastebin.com/BUTPJBNF which appears to work perfectly, including support for additional flags like --debug. I can propose a merge for this when this branch is accepted.

To post a comment you must log in.
460. By Tom Beckmann

fix whitespaces

Revision history for this message
Tom Beckmann (tombeckmann) wrote :

Oups, accidentally moved the translate function in the HAVE_UNITY conditional block. Will fix that once I get back to my computer in around 8h.

461. By Tom Beckmann

move translation method out of HAVE_UNITY block

Revision history for this message
Tom Beckmann (tombeckmann) wrote :

As ricotz pointed out: https://git.gnome.org/browse/gnome-control-center/commit/?id=45d4944b6db031dbc77e515bdae0fac9dbdba50f Initializing cheese-gtk is apparently the way it's supposed to work now.

I fixed the HAVE_UNITY issue now.

Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote :

I'm not a fan of the way translation from short names like "sound" to fully-qualified names is done currently. As far as I understand this will require us to manually track upstream G-C-C plug list changes, which we would of course would like to avoid.

What I tried to do in BASH (and gave up) is to enumerate all existing plugs and then choose the appropriate one automatically, depending on the environment. So if I have e.g. both hardware-pantheon-sound and hardware-gcc-sound and a hypothetical hardware-xfce-sound installed and run "switchboard sound", it should infer the DE from XDG_CURRENT_DESKTOP environment variable (e.g. launch pantheon-sound in pantheon, gcc-sound in GNOME, etc) and fall back to pantheon plugs if no match is found.

I've tried to code that as a BASH wrapper and I could probably even do it if somebody explains me how to find all available plugs. Although working with XDG_DATA_DIRS is complicated in BASH, so I'd prefer to have it in Vala.

Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) :
review: Abstain
Revision history for this message
Corentin Noël (tintou) wrote :

Can you please add a note before the cheese-gtk dependency in CMake that we remember that it is needed by the gcc-compatibility-layer.
While this patch will work for Freya, I really want to push a new standard for settings opening (see https://docs.google.com/a/elementaryos.org/document/d/1N0uqNtVXEFn3cLgNMeN75mP_dpMpCco-7uw5PKow-_Q/edit?usp=sharing )

462. By Tom Beckmann

add note to cmake about cheese dependency

Revision history for this message
Corentin Noël (tintou) wrote :

Okay, let's go ahead.

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 2014-03-17 19:18:13 +0000
+++ CMakeLists.txt 2014-07-08 15:13:36 +0000
@@ -95,6 +95,8 @@
95 gmodule-2.095 gmodule-2.0
96 gtk+-3.0>=3.1096 gtk+-3.0>=3.10
97 gio-unix-2.097 gio-unix-2.0
98 # cheese is required for the GCC panels to work
99 cheese-gtk
98)100)
99find_package(PkgConfig)101find_package(PkgConfig)
100102
@@ -140,4 +142,4 @@
140endif ()142endif ()
141143
142add_subdirectory (schemas)144add_subdirectory (schemas)
143install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/schemas/org.pantheon.switchboard.gschema.xml DESTINATION ${GSETTINGSDIR})
144\ No newline at end of file145\ No newline at end of file
146install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/schemas/org.pantheon.switchboard.gschema.xml DESTINATION ${GSETTINGSDIR})
145147
=== modified file 'src/Switchboard.vala'
--- src/Switchboard.vala 2014-05-27 05:48:46 +0000
+++ src/Switchboard.vala 2014-07-08 15:13:36 +0000
@@ -17,6 +17,8 @@
1717
18namespace Switchboard {18namespace Switchboard {
1919
20 [CCode (cname = "cheese_gtk_init")]
21 public extern static bool cheese_gtk_init ([CCode (array_length_pos = 0.9)] ref unowned string[] argv);
2022
21 public enum WindowState {23 public enum WindowState {
22 NORMAL = 0,24 NORMAL = 0,
@@ -24,7 +26,11 @@
24 }26 }
2527
26 public static int main (string[] args) {28 public static int main (string[] args) {
27 Gtk.init (ref args);29
30 // FIXME the gcc user-accounts plug requires cheese to be initialized before gtk,
31 // otherwise it will crash switchboard if it's loaded before the window and
32 // all its widgets are displayed.
33 cheese_gtk_init (ref args);
2834
29 var app = new SwitchboardApp ();35 var app = new SwitchboardApp ();
30 return app.run (args);36 return app.run (args);
@@ -50,7 +56,7 @@
50 private int default_width = 0;56 private int default_width = 0;
51 private int default_height = 0;57 private int default_height = 0;
5258
53 private static string? plug_to_open = null;59 private static string? plug_to_open = null;
54 private static bool should_animate_next_transition = true;60 private static bool should_animate_next_transition = true;
5561
56 static const OptionEntry[] entries = {62 static const OptionEntry[] entries = {
@@ -94,6 +100,11 @@
94 try {100 try {
95 unowned string[] tmp = args;101 unowned string[] tmp = args;
96 context.parse (ref tmp);102 context.parse (ref tmp);
103
104 // we have an unparsed argument. Assume that it's a gcc plug name
105 if (tmp.length > 1) {
106 plug_to_open = gcc_to_switchboard_code_name (tmp[1]);
107 }
97 } catch (Error e) {108 } catch (Error e) {
98 warning (e.message);109 warning (e.message);
99 return 0;110 return 0;
@@ -439,6 +450,36 @@
439 return (empty ? null : category_item);450 return (empty ? null : category_item);
440 }451 }
441#endif452#endif
453
454 private string? gcc_to_switchboard_code_name (string gcc_name) {
455 // list of names taken from GCC's shell/cc-panel-loader.c
456 switch (gcc_name) {
457 case "background": return "pantheon-desktop";
458 case "bluetooth": return "network-gcc-bluetooth";
459 case "color": return "hardware-gcc-color";
460 case "datetime": return "system-gcc-date";
461 case "display": return "hardware-gcc-display";
462 case "info": return "system-pantheon-about";
463 case "keyboard": return "hardware-pantheon-keyboard";
464 case "network": return "network-gcc-network";
465 case "power": return "system-pantheon-power";
466 case "printers": return "hardware-gcc-printer";
467 case "privacy": return "pantheon-security-privacy";
468 case "region": return "hardware-gcc-region";
469 case "sound": return "hardware-gcc-sound";
470 case "universal-access": return "system-gcc-universalaccess";
471 case "user-accounts": return "hardware-gcc-user";
472 case "wacom": return "hardware-gcc-wacom";
473
474 // not available on our system
475 case "notifications":
476 case "search":
477 case "sharing":
478 return null;
479 }
480
481 return null;
482 }
442 }483 }
443}484}
444485

Subscribers

People subscribed via source and target branches

to all changes: