From 83c37bd14bcca1b2774bdb9f73c3742da65a65a3 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 3 Apr 2013 22:43:37 -0400 Subject: Remove players when settings key changes --- src/service.vala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/service.vala b/src/service.vala index 1590844..d966de9 100644 --- a/src/service.vala +++ b/src/service.vala @@ -7,6 +7,7 @@ public class IndicatorSound.Service { this.players = new MediaPlayerList (); this.players.player_added.connect (this.player_added); + this.players.player_removed.connect (this.player_removed); this.actions = new SimpleActionGroup (); this.actions.add_entries (action_entries, this); @@ -158,4 +159,18 @@ public class IndicatorSound.Service { eventually_update_player_actions (); player.notify.connect (this.eventually_update_player_actions); } + + void player_removed (MediaPlayer player) { + this.actions.remove (player.id); + + int n = this.menu.get_n_items (); + for (int i = 0; i < n; i++) { + string action; + this.menu.get_item_attribute (i, "action", "s", out action); + if (action == player.id) { + this.menu.remove (i); + break; + } + } + } } -- cgit v1.2.3