The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. void FileChooser::showPlatformDialog (Array<File>& results,
  19. const String& title,
  20. const File& file,
  21. const String& filters,
  22. bool isDirectory,
  23. bool selectsFiles,
  24. bool isSave,
  25. bool warnAboutOverwritingExistingFiles,
  26. bool selectMultipleFiles,
  27. FilePreviewComponent* previewComponent)
  28. {
  29. const String separator (":");
  30. String command ("zenity --file-selection");
  31. if (title.isNotEmpty())
  32. command << " --title=\"" << title << "\"";
  33. if (file != File::nonexistent)
  34. command << " --filename=\"" << file.getFullPathName () << "\"";
  35. if (isDirectory)
  36. command << " --directory";
  37. if (isSave)
  38. command << " --save";
  39. if (selectMultipleFiles)
  40. command << " --multiple --separator=\"" << separator << "\"";
  41. command << " 2>&1";
  42. MemoryOutputStream result;
  43. int status = -1;
  44. FILE* stream = popen (command.toUTF8(), "r");
  45. if (stream != 0)
  46. {
  47. for (;;)
  48. {
  49. char buffer [1024];
  50. const int bytesRead = fread (buffer, 1, sizeof (buffer), stream);
  51. if (bytesRead <= 0)
  52. break;
  53. result.write (buffer, bytesRead);
  54. }
  55. status = pclose (stream);
  56. }
  57. if (status == 0)
  58. {
  59. StringArray tokens;
  60. if (selectMultipleFiles)
  61. tokens.addTokens (result.toUTF8(), separator, String::empty);
  62. else
  63. tokens.add (result.toUTF8());
  64. for (int i = 0; i < tokens.size(); i++)
  65. results.add (File (tokens[i]));
  66. return;
  67. }
  68. //xxx ain't got one!
  69. jassertfalse;
  70. }