aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2013-07-25 16:38:15 +0200
committerLars Uebernickel <lars.uebernickel@canonical.com>2013-07-25 16:38:15 +0200
commitce5583c3d5c8f4cf390936ef567c7088062675df (patch)
tree7fc36fabcf623a4a4c7946558dcb512790479f31
parent997864b9fc62596e8cc238f4c4b77d780651ffb4 (diff)
downloadayatana-indicator-sound-ce5583c3d5c8f4cf390936ef567c7088062675df.tar.gz
ayatana-indicator-sound-ce5583c3d5c8f4cf390936ef567c7088062675df.tar.bz2
ayatana-indicator-sound-ce5583c3d5c8f4cf390936ef567c7088062675df.zip
Export phone menu
For now, this does the same as the one on the desktop, except for starting the the phone's settings ui.
-rw-r--r--data/com.canonical.indicator.sound2
-rw-r--r--src/service.vala21
-rw-r--r--src/sound-menu.vala4
3 files changed, 20 insertions, 7 deletions
diff --git a/data/com.canonical.indicator.sound b/data/com.canonical.indicator.sound
index ccea589..adefae9 100644
--- a/data/com.canonical.indicator.sound
+++ b/data/com.canonical.indicator.sound
@@ -7,7 +7,7 @@ Position=30
ObjectPath=/com/canonical/indicator/sound/desktop
[phone]
-ObjectPath=/com/canonical/indicator/sound/desktop
+ObjectPath=/com/canonical/indicator/sound/phone
[desktop_greeter]
ObjectPath=/com/canonical/indicator/sound/desktop
diff --git a/src/service.vala b/src/service.vala
index c1c6306..8fbd871 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -37,8 +37,12 @@ public class IndicatorSound.Service {
this.actions.add_action (this.create_mic_volume_action ());
this.menus = new HashTable<string, SoundMenu> (str_hash, str_equal);
- this.menus.insert ("desktop", new SoundMenu ());
- this.volume_control.bind_property ("active-mic", this.menus.get("desktop"), "show-mic-volume", BindingFlags.SYNC_CREATE);
+ this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings"));
+ this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings"));
+
+ this.menus.@foreach ( (profile, menu) => {
+ this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE);
+ });
this.players.sync (settings.get_strv ("interested-media-players"));
this.settings.changed["interested-media-players"].connect ( () => {
@@ -63,7 +67,8 @@ public class IndicatorSound.Service {
const ActionEntry[] action_entries = {
{ "root", null, null, "@a{sv} {}", null },
- { "settings", activate_settings, null, null, null },
+ { "desktop-settings", activate_desktop_settings, null, null, null },
+ { "phone-settings", activate_phone_settings, null, null, null },
};
MainLoop loop;
@@ -74,7 +79,7 @@ public class IndicatorSound.Service {
MediaPlayerList players;
uint player_action_update_id;
- void activate_settings (SimpleAction action, Variant? param) {
+ void activate_desktop_settings (SimpleAction action, Variant? param) {
var env = Environment.get_variable ("DESKTOP_SESSION");
string cmd;
if (env == "unity")
@@ -91,6 +96,14 @@ public class IndicatorSound.Service {
}
}
+ void activate_phone_settings (SimpleAction action, Variant? param) {
+ try {
+ Process.spawn_command_line_async ("system-settings sound");
+ } catch (Error e) {
+ warning ("unable to launch sound settings: %s", e.message);
+ }
+ }
+
/* Returns a serialized version of @icon_name suited for the panel */
static Variant serialize_themed_icon (string icon_name)
{
diff --git a/src/sound-menu.vala b/src/sound-menu.vala
index 376ef15..dd50f12 100644
--- a/src/sound-menu.vala
+++ b/src/sound-menu.vala
@@ -19,7 +19,7 @@
class SoundMenu: Object
{
- public SoundMenu () {
+ public SoundMenu (string settings_action) {
/* A sound menu always has at least two sections: the volume section (this.volume_section)
* at the start of the menu, and the settings section at the end. Between those two,
* it has a dynamic amount of player sections, one for each registered player.
@@ -33,7 +33,7 @@ class SoundMenu: Object
this.menu = new Menu ();
this.menu.append_section (null, volume_section);
- this.menu.append (_("Sound Settingsā€¦"), "indicator.settings");
+ this.menu.append (_("Sound Settingsā€¦"), settings_action);
var root_item = new MenuItem (null, "indicator.root");
root_item.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root");