[gimp] libgimpbase: implement show in file manager for OS X platform



commit 97a9d1c53fa79e736347ca214fe3f81888d09b47
Author: Kristian Rietveld <kris loopnest org>
Date:   Thu Feb 19 21:39:05 2015 +0100

    libgimpbase: implement show in file manager for OS X platform

 libgimpbase/gimputils.c |   37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 deletions(-)
---
diff --git a/libgimpbase/gimputils.c b/libgimpbase/gimputils.c
index 698dfd8..2a6d57e 100644
--- a/libgimpbase/gimputils.c
+++ b/libgimpbase/gimputils.c
@@ -24,6 +24,10 @@
 #include <string.h>
 #include <stdio.h>
 
+#ifdef PLATFORM_OSX
+#include <AppKit/AppKit.h>
+#endif
+
 #include <gio/gio.h>
 
 #include "gimpbasetypes.h"
@@ -357,18 +361,31 @@ gimp_file_show_in_file_manager (GFile   *file,
 #elif defined(PLATFORM_OSX)
 
   {
-#if 0
-    /* found on stackoverflow, please turn this into working code...
-     */
-    NSArray *fileURLs = [NSArray arrayWithObjects:fileURL1, /* ... */ nil];
+    gchar    *uri;
+    NSString *filename;
+    NSURL    *url;
+    gboolean  retval = TRUE;
 
-    [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs];
-#endif
+    uri = g_file_get_uri (file);
+    filename = [NSString stringWithUTF8String:uri];
 
-    g_set_error_literal (error, G_FILE_ERROR, 0,
-                         "Please implement something in "
-                         "gimp_file_show_in_file_manager().");
-    return FALSE;
+    url = [NSURL URLWithString:filename];
+    if (url)
+      {
+        NSArray *url_array = [NSArray arrayWithObject:url];
+
+        [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:url_array];
+      }
+    else
+      {
+        g_set_error (error, G_FILE_ERROR, 0,
+                     _("Cannot convert '%s' into a valid NSURL."), uri);
+        retval = FALSE;
+      }
+
+    g_free (uri);
+
+    return retval;
   }
 
 #else /* UNIX */


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