summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Dörr <timo@latecrew.de>2012-08-01 15:21:07 +0200
committerBertrand Lorentz <bertrand.lorentz@gmail.com>2012-08-19 22:36:34 +0200
commit74bcab4926fc27bf6f655ed8fc24bd3324ed036a (patch)
tree1e4ce2a29d0a21eae8db8576efe0f5ee6406e834 /src
parent9b5f892fd83019179d6f8de1e905ae2551afc8cf (diff)
OSX: Enable openFiles event for opening in Finder (bgo#682090)
Register a function that handles the openFiles AppleEvent that is sent to Banshee when one opens a file in Finder (i.e. through doubleclick, or right-click "Open With -> Banshee". The event handler enqueues the file and starts playback. Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/Backends/Banshee.Osx/Banshee.OsxBackend/OsxService.cs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Backends/Banshee.Osx/Banshee.OsxBackend/OsxService.cs b/src/Backends/Banshee.Osx/Banshee.OsxBackend/OsxService.cs
index 97bb32e35..d970fdf93 100644
--- a/src/Backends/Banshee.Osx/Banshee.OsxBackend/OsxService.cs
+++ b/src/Backends/Banshee.Osx/Banshee.OsxBackend/OsxService.cs
@@ -69,6 +69,22 @@ namespace Banshee.OsxBackend
is_nsapplication_initialized = true;
}
}
+
+ // Register event that handles openFile AppleEvent, i.e. when
+ // opening a .mp3 file through Finder
+ NSApplication.SharedApplication.OpenFiles += (sender, e) => {
+ foreach (string file in e.Filenames) {
+ // Upon successfull start, we receive a openFile event with the Nereid.exe
+ // since mono passes that event - we ignore it here
+ if (file.ToLower ().EndsWith (".exe")) continue;
+
+ // Put the file on the bus - usually FileSystemQueueSource will
+ // pick this event and put it into a queue
+ ServiceManager.Get<DBusCommandService> ().PushFile (file);
+ }
+ // Immediately start playback of the enqueued files
+ ServiceManager.Get<DBusCommandService> ().PushArgument ("play-enqueued", "");
+ };
}
void IExtensionService.Initialize ()