ui/cocoa/window.m

changeset 28
794a5c91c479
parent 25
78ae3efe463f
child 47
97792f44d919
--- a/ui/cocoa/window.m	Sat Apr 05 18:41:30 2014 +0200
+++ b/ui/cocoa/window.m	Sun Apr 06 13:21:37 2014 +0200
@@ -27,6 +27,8 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #import "window.h"
 #import "menu.h"
@@ -190,3 +192,26 @@
     
     return obj;
 }
+
+char* ui_openfiledialog(UiObject *obj) {
+    NSOpenPanel* op = [NSOpenPanel openPanel];
+    if ([op runModal] == NSOKButton) {
+        NSArray *urls = [op URLs];
+        NSURL *url = [urls objectAtIndex:0];
+        
+        const char *str = [[url path] UTF8String];
+        return (char*)strdup(str);
+    }
+    return NULL;
+}
+
+char* ui_savefiledialog(UiObject *obj) {
+    NSSavePanel* sp = [NSSavePanel savePanel];
+    if ([sp runModal] == NSOKButton) {
+        NSURL *url = [sp URL];
+        
+        const char *str = [[url path] UTF8String];
+        return (char*)strdup(str);
+    }
+    return NULL;
+}

mercurial