aboutsummaryrefslogtreecommitdiff
path: root/src/service.vala
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2014-01-21 17:45:00 +0000
committerTarmac <Unknown>2014-01-21 17:45:00 +0000
commitf7ab50b8a75ae98e8ec2f8fb4a1da0f66d976ef6 (patch)
tree90220cbb95ef3aa7e68bcaae28aa31a4c7662713 /src/service.vala
parenta7bca00dc9644e3df9c0dc07e157e13a79a3235d (diff)
parente1481295ded3f3cbea4cdc245f348f3d8e925e38 (diff)
downloadayatana-indicator-sound-f7ab50b8a75ae98e8ec2f8fb4a1da0f66d976ef6.tar.gz
ayatana-indicator-sound-f7ab50b8a75ae98e8ec2f8fb4a1da0f66d976ef6.tar.bz2
ayatana-indicator-sound-f7ab50b8a75ae98e8ec2f8fb4a1da0f66d976ef6.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. . Approved by Charles Kerr, PS Jenkins bot.
Diffstat (limited to 'src/service.vala')
-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) {