diff options
author | Ken VanDine <ken.vandine@canonical.com> | 2012-03-30 10:45:03 -0400 |
---|---|---|
committer | Package Import Robot <package-import@ubuntu.com> | 2012-03-30 10:45:03 -0400 |
commit | 01d561bf282f03825ca22533f66d72ba44fd85a9 (patch) | |
tree | edee2e0c9543f22f13bf3baed30c9f6096c170a9 /src/music-player-bridge.vala | |
parent | 2e2e1a5d8571b6a75de63ad771be172251a874a3 (diff) | |
parent | 31b5a5a6508535ed1af86919c79d75571f1a65ef (diff) | |
download | ayatana-indicator-sound-01d561bf282f03825ca22533f66d72ba44fd85a9.tar.gz ayatana-indicator-sound-01d561bf282f03825ca22533f66d72ba44fd85a9.tar.bz2 ayatana-indicator-sound-01d561bf282f03825ca22533f66d72ba44fd85a9.zip |
Import upstream version 0.8.5.0
Diffstat (limited to 'src/music-player-bridge.vala')
-rw-r--r-- | src/music-player-bridge.vala | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala index c2d6623..18f1c40 100644 --- a/src/music-player-bridge.vala +++ b/src/music-player-bridge.vala @@ -85,19 +85,20 @@ public class MusicPlayerBridge : GLib.Object DesktopAppInfo desktop_info = info as DesktopAppInfo; var file_path = desktop_info.get_filename (); File f = File.new_for_path (file_path); - FileMonitor monitor; try { - monitor = f.monitor (FileMonitorFlags.SEND_MOVED, null); + FileMonitor monitor = f.monitor (FileMonitorFlags.SEND_MOVED, null); + unowned FileMonitor weak_monitor = monitor; + monitor.changed.connect ((desktop_file, other_file, event_type) => { + this.relevant_desktop_file_changed (desktop_file, other_file, event_type, weak_monitor); + }); + monitor.ref(); // will be unref()ed by relevant_desktop_file_changed() + GLib.debug ("monitoring file '%s'", file_path); + this.file_monitors.set (file_path, mpris_key); } catch (Error e){ warning ("Unable to create a file monitor for %s", info.get_name()); return; } - this.file_monitors.set (file_path, mpris_key); - // Finally watch for a change. - monitor.changed.connect ((desktop_file, other_file, event_type) => { - this.relevant_desktop_file_changed (desktop_file, other_file, event_type, monitor); - }); } private void relevant_desktop_file_changed (File desktop_file, @@ -117,10 +118,13 @@ public class MusicPlayerBridge : GLib.Object warning ("relevant_desktop_file_changed is returning a file which we know nothing about - %s", path); return; - } - this.registered_clients[this.file_monitors[path]].remove_from_menu(); - this.settings_manager.remove_interested (this.file_monitors[path]); - this.registered_clients.unset (this.file_monitors[path]); + } + + var mpris_key = this.file_monitors[path]; + GLib.debug ("file \"%s\" was removed; stopping monitoring \"%s\"", path, mpris_key); + this.registered_clients[mpris_key].remove_from_menu(); + this.settings_manager.remove_interested (mpris_key); + this.registered_clients.unset (mpris_key); monitor.cancel (); monitor.unref(); } |