[banshee] OSX: Enable openFiles event for opening in Finder (bgo#682090)



commit 74bcab4926fc27bf6f655ed8fc24bd3324ed036a
Author: Timo DÃrr <timo latecrew de>
Date:   Wed Aug 1 15:21:07 2012 +0200

    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>

 .../Banshee.Osx/Banshee.OsxBackend/OsxService.cs   |   16 ++++++++++++++++
 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 97bb32e..d970fdf 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 ()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]