ui/cocoa/window.m

changeset 28
794a5c91c479
parent 25
78ae3efe463f
child 47
97792f44d919
equal deleted inserted replaced
27:77b09bb52ca0 28:794a5c91c479
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include <stdio.h> 29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
30 32
31 #import "window.h" 33 #import "window.h"
32 #import "menu.h" 34 #import "menu.h"
33 #import "toolbar.h" 35 #import "toolbar.h"
34 #import "container.h" 36 #import "container.h"
188 obj->container = ui_window_container(obj, window); 190 obj->container = ui_window_container(obj, window);
189 191
190 192
191 return obj; 193 return obj;
192 } 194 }
195
196 char* ui_openfiledialog(UiObject *obj) {
197 NSOpenPanel* op = [NSOpenPanel openPanel];
198 if ([op runModal] == NSOKButton) {
199 NSArray *urls = [op URLs];
200 NSURL *url = [urls objectAtIndex:0];
201
202 const char *str = [[url path] UTF8String];
203 return (char*)strdup(str);
204 }
205 return NULL;
206 }
207
208 char* ui_savefiledialog(UiObject *obj) {
209 NSSavePanel* sp = [NSSavePanel savePanel];
210 if ([sp runModal] == NSOKButton) {
211 NSURL *url = [sp URL];
212
213 const char *str = [[url path] UTF8String];
214 return (char*)strdup(str);
215 }
216 return NULL;
217 }

mercurial