/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. @import "CPPanel.j"
  23. @implementation CPOpenPanel : CPPanel
  24. {
  25. BOOL _canChooseFiles @accessors(property=canChooseFiles);
  26. BOOL _canChooseDirectories @accessors(property=canChooseDirectories);
  27. BOOL _allowsMultipleSelection @accessors(property=allowsMultipleSelection);
  28. CPURL _directoryURL @accessors(property=directoryURL);
  29. CPArray _URLs;
  30. }
  31. + (id)openPanel
  32. {
  33. return [[CPOpenPanel alloc] init];
  34. }
  35. - (CPInteger)runModal
  36. {
  37. if (typeof window["cpOpenPanel"] === "function")
  38. {
  39. // FIXME: Is this correct???
  40. [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
  41. var options = { directoryURL: [self directoryURL],
  42. canChooseFiles: [self canChooseFiles],
  43. canChooseDirectories: [self canChooseDirectories],
  44. allowsMultipleSelection: [self allowsMultipleSelection] },
  45. result = window.cpOpenPanel(options);
  46. _URLs = result.URLs;
  47. return result.button;
  48. }
  49. throw "-runModal is unimplemented.";
  50. }
  51. - (CPArray)URLs
  52. {
  53. return _URLs;
  54. }
  55. @end