Merge lp:~larsu/indicator-sound/dont-write-settings-on-startup into lp:indicator-sound/14.04

Proposed by Lars Karlitski
Status: Merged
Approved by: Charles Kerr
Approved revision: 407
Merged at revision: 407
Proposed branch: lp:~larsu/indicator-sound/dont-write-settings-on-startup
Merge into: lp:indicator-sound/14.04
Diff against target: 49 lines (+17/-6)
1 file modified
src/service.vala (+17/-6)
To merge this branch: bzr merge lp:~larsu/indicator-sound/dont-write-settings-on-startup
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+201804@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

Nice fix!

review: Approve
Revision history for this message
Sebastien Bacher (seb128) wrote :

(confirmed that the login write is not happening with that version)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/service.vala'
2--- src/service.vala 2014-01-03 18:42:54 +0000
3+++ src/service.vala 2014-01-15 16:12:32 +0000
4@@ -42,9 +42,9 @@
5 this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE);
6 });
7
8- this.players.sync (settings.get_strv ("interested-media-players"));
9+ this.sync_preferred_players ();
10 this.settings.changed["interested-media-players"].connect ( () => {
11- this.players.sync (settings.get_strv ("interested-media-players"));
12+ this.sync_preferred_players ();
13 });
14
15 if (settings.get_boolean ("show-notify-osd-on-scroll")) {
16@@ -86,6 +86,7 @@
17 MediaPlayerList players;
18 uint player_action_update_id;
19 Notify.Notification notification;
20+ bool syncing_preferred_players = false;
21
22 const double volume_step_percentage = 0.06;
23
24@@ -281,11 +282,21 @@
25 this.player_action_update_id = Idle.add (this.update_player_actions);
26 }
27
28+
29+ void sync_preferred_players () {
30+ this.syncing_preferred_players = true;
31+ this.players.sync (settings.get_strv ("interested-media-players"));
32+ this.syncing_preferred_players = false;
33+ }
34+
35 void update_preferred_players () {
36- var builder = new VariantBuilder (VariantType.STRING_ARRAY);
37- foreach (var player in this.players)
38- builder.add ("s", player.id);
39- this.settings.set_value ("interested-media-players", builder.end ());
40+ /* only write the key if we're not getting this call because we're syncing from the key right now */
41+ if (!this.syncing_preferred_players) {
42+ var builder = new VariantBuilder (VariantType.STRING_ARRAY);
43+ foreach (var player in this.players)
44+ builder.add ("s", player.id);
45+ this.settings.set_value ("interested-media-players", builder.end ());
46+ }
47 }
48
49 void player_added (MediaPlayer player) {

Subscribers

People subscribed via source and target branches