PageRenderTime 10ms CodeModel.GetById 7ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/AppKit/CPOpenPanel.j

http://github.com/cacaodev/cappuccino
Unknown | 67 lines | 55 code | 12 blank | 0 comment | 0 complexity | 3cf2dd576fd4357ed69baa4a7f9cf7ec MD5 | raw file
 1/*
 2 * CPOpenPanel.j
 3 * AppKit
 4 *
 5 * Created by Ross Boucher.
 6 * Copyright 2009, 280 North, Inc.
 7 *
 8 * This library is free software; you can redistribute it and/or
 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23@import "CPPanel.j"
24
25
26@implementation CPOpenPanel : CPPanel
27{
28    BOOL    _canChooseFiles             @accessors(property=canChooseFiles);
29    BOOL    _canChooseDirectories       @accessors(property=canChooseDirectories);
30    BOOL    _allowsMultipleSelection    @accessors(property=allowsMultipleSelection);
31    CPURL   _directoryURL               @accessors(property=directoryURL);
32    CPArray _URLs;
33}
34
35+ (id)openPanel
36{
37    return [[CPOpenPanel alloc] init];
38}
39
40- (CPInteger)runModal
41{
42    if (typeof window["cpOpenPanel"] === "function")
43    {
44        // FIXME: Is this correct???
45        [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
46
47        var options = { directoryURL: [self directoryURL],
48                        canChooseFiles: [self canChooseFiles],
49                        canChooseDirectories: [self canChooseDirectories],
50                        allowsMultipleSelection: [self allowsMultipleSelection] },
51
52            result = window.cpOpenPanel(options);
53
54        _URLs = result.URLs;
55
56        return result.button;
57    }
58
59    throw "-runModal is unimplemented.";
60}
61
62- (CPArray)URLs
63{
64    return _URLs;
65}
66
67@end