aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-12-15 14:32:27 +0000
committerConor Curran <conor.curran@canonical.com>2010-12-15 14:32:27 +0000
commitaaf57407f00aa59df3699794496fd42a731ad7db (patch)
tree62db182817ec8c3de63cd4cb5a4fa53322b69c80
parent57e6249df95fd120eee8ed4013210d359cdeee97 (diff)
downloadayatana-indicator-sound-aaf57407f00aa59df3699794496fd42a731ad7db.tar.gz
ayatana-indicator-sound-aaf57407f00aa59df3699794496fd42a731ad7db.tar.bz2
ayatana-indicator-sound-aaf57407f00aa59df3699794496fd42a731ad7db.zip
settings schema defined and handling code wrote
-rw-r--r--data/com.canonical.indicators.sound.gschema.xml25
-rw-r--r--src/Makefile.am2
-rw-r--r--src/music-player-bridge.vala10
-rw-r--r--src/settings-manager.vala55
-rw-r--r--src/sound-service-dbus.c1
5 files changed, 81 insertions, 12 deletions
diff --git a/data/com.canonical.indicators.sound.gschema.xml b/data/com.canonical.indicators.sound.gschema.xml
index 4284527..e8e4c86 100644
--- a/data/com.canonical.indicators.sound.gschema.xml
+++ b/data/com.canonical.indicators.sound.gschema.xml
@@ -1,19 +1,28 @@
<schemalist>
<schema id="com.canoncial.indicators.sound" path="/apps/indicators/sound/" gettext-domain="indicator-sound">
- <key name="blacklist_entries" type="(as)">
- <default></default>
+ <key name="blacklisted-media-players" type="as">
<summary>A list of applications blacklisted from the sound menu</summary>
+ <default>[]</default>
<description>
- Each media player which abides by the MPRIS2 spec will automatically appear in the menu.
- This array should contain the desktop file names (minus .desktop suffix) of applications which
- do not want to be included in the sound menu.
+ Each media player which abides by the MPRIS2 spec will automatically appear in the menu.
+ This array should contain the desktop file names (minus .desktop suffix) of applications which
+ do not want to be included in the sound menu.
</description>
</key>
- <key name="global_mute" type="b">
- <default>FALSE</default>
+ <key name="interested-media-players" type="as">
+ <summary>A list of applications which at some point have registered with the sound menu</summary>
+ <default>[]</default>
+ <description>
+ Each media player which abides by the MPRIS2 spec will automatically appear in the menu.
+ This array should contain the desktop file names (minus .desktop suffix) of applications which
+ have at some point appeared in the menU. This allows the menu remember and display offlined applications.
+ </description>
+ </key>
+ <key name="global-mute" type="b">
+ <default>false</default>
<summary>Initial setting for global mute (mute all) on the menu </summary>
<description>
- On start up volume should not be muted.
+ On start up volume should not be muted.
</description>
</key>
</schema>
diff --git a/src/Makefile.am b/src/Makefile.am
index 1c381f5..5ef9ef0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -64,7 +64,7 @@ music_bridge_VALASOURCES = \
mpris2-watcher.vala \
mpris2-controller.vala \
player-item.vala \
- familiar-players-db.vala \
+ settings-manager.vala \
fetch-file.vala
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index 51ecc4c..6a45d0c 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -23,6 +23,7 @@ using GLib;
public class MusicPlayerBridge : GLib.Object
{
+ private SettingsManager settings_manager;
private Dbusmenu.Menuitem root_menu;
private HashMap<string, PlayerController> registered_clients;
private Mpris2Watcher watcher;
@@ -35,9 +36,14 @@ public class MusicPlayerBridge : GLib.Object
construct{
this.registered_clients = new HashMap<string, PlayerController> ();
- this.settings = new Settings("com.canonical.indicators.sound");
+ this.settings_manager = new SettingsManager();
+ this.settings_manager.connect.blacklist_updates (on_blacklist_update);
}
+ private void on_black_list_updated ( string[] blacklist )
+ {
+ debug("some blacklist update");
+ }
/*private void try_to_add_inactive_familiar_clients(){
foreach(string app in this.playersDB.records()){
@@ -143,7 +149,7 @@ public class MusicPlayerBridge : GLib.Object
GLib.AppInfo app_info = info as GLib.AppInfo;
return app_info;
}
-
+
private static string? fetch_icon_name(string desktop_path)
{
KeyFile desktop_keyfile = new KeyFile ();
diff --git a/src/settings-manager.vala b/src/settings-manager.vala
new file mode 100644
index 0000000..9068c05
--- /dev/null
+++ b/src/settings-manager.vala
@@ -0,0 +1,55 @@
+/*
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Conor Curran <conor.curran@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+using Gee;
+
+public class SettingsManager : GLib.Object
+{
+ private Settings settings;
+ public signal void blacklist_updates ( string[] new_blacklist );
+
+ public SettingsManager ( ){
+ }
+ construct{
+ this.settings = new Settings ("com.canonical.indicators.sound");
+ settings.changed["blacklisted-media-players"].connect (on_blacklist_event);
+ this.fetch_entries.begin();
+ }
+
+ public string[] fetch_blacklist()
+ {
+ return this.blacklist_updates(this.settings.get_strv ("blacklisted-media-players"));
+ }
+
+ public string[] fetch_interested()
+ {
+ return this.interested_updates(this.settings.get_strv ("interested-media-players"));
+ }
+
+ public bool add_interested(string app_desktop_name)
+ {
+ string[] already_interested = fetch_interested();
+ already_interested.append ( app_desktop_name );
+ return this.settings.set_strv( already_interested );
+ }
+
+ private on_blacklist_event()
+ {
+ this.blacklist_updates(this.settings.get_strv ("blacklisted-media-players"));
+ }
+} \ No newline at end of file
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
index d553285..0760247 100644
--- a/src/sound-service-dbus.c
+++ b/src/sound-service-dbus.c
@@ -42,7 +42,6 @@ struct _SoundServiceDbusPrivate {
gboolean sink_availability;
};
-
/* Signals */
enum {
SINK_INPUT_WHILE_MUTED,