aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2014-01-15 16:32:51 +0100
committerLars Uebernickel <lars.uebernickel@canonical.com>2014-01-15 16:32:51 +0100
commite1481295ded3f3cbea4cdc245f348f3d8e925e38 (patch)
tree90220cbb95ef3aa7e68bcaae28aa31a4c7662713 /src
parenta7bca00dc9644e3df9c0dc07e157e13a79a3235d (diff)
downloadayatana-indicator-sound-e1481295ded3f3cbea4cdc245f348f3d8e925e38.tar.gz
ayatana-indicator-sound-e1481295ded3f3cbea4cdc245f348f3d8e925e38.tar.bz2
ayatana-indicator-sound-e1481295ded3f3cbea4cdc245f348f3d8e925e38.zip
Don't write 'interested-media-players' on startup
IndicatorSound.Service read that gsettings key and inserted the players desktop ids into a MediaPlayerList, which emits "player-added" every time a player is added. This patch makes the service keep track of whether players are added because it is syncing the key or when a player appeared on the bus.
Diffstat (limited to 'src')
-rw-r--r--src/service.vala23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/service.vala b/src/service.vala
index 25a7b18..f228746 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -42,9 +42,9 @@ public class IndicatorSound.Service {
this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE);
});
- this.players.sync (settings.get_strv ("interested-media-players"));
+ this.sync_preferred_players ();
this.settings.changed["interested-media-players"].connect ( () => {
- this.players.sync (settings.get_strv ("interested-media-players"));
+ this.sync_preferred_players ();
});
if (settings.get_boolean ("show-notify-osd-on-scroll")) {
@@ -86,6 +86,7 @@ public class IndicatorSound.Service {
MediaPlayerList players;
uint player_action_update_id;
Notify.Notification notification;
+ bool syncing_preferred_players = false;
const double volume_step_percentage = 0.06;
@@ -281,11 +282,21 @@ public class IndicatorSound.Service {
this.player_action_update_id = Idle.add (this.update_player_actions);
}
+
+ void sync_preferred_players () {
+ this.syncing_preferred_players = true;
+ this.players.sync (settings.get_strv ("interested-media-players"));
+ this.syncing_preferred_players = false;
+ }
+
void update_preferred_players () {
- var builder = new VariantBuilder (VariantType.STRING_ARRAY);
- foreach (var player in this.players)
- builder.add ("s", player.id);
- this.settings.set_value ("interested-media-players", builder.end ());
+ /* only write the key if we're not getting this call because we're syncing from the key right now */
+ if (!this.syncing_preferred_players) {
+ var builder = new VariantBuilder (VariantType.STRING_ARRAY);
+ foreach (var player in this.players)
+ builder.add ("s", player.id);
+ this.settings.set_value ("interested-media-players", builder.end ());
+ }
}
void player_added (MediaPlayer player) {