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.

102 lines
3.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-9 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. // (This file gets included by juce_linux_NativeCode.cpp, rather than being
  19. // compiled on its own).
  20. #if JUCE_INCLUDED_FILE
  21. //==============================================================================
  22. void FileChooser::showPlatformDialog (Array<File>& results,
  23. const String& title,
  24. const File& file,
  25. const String& filters,
  26. bool isDirectory,
  27. bool selectsFiles,
  28. bool isSave,
  29. bool warnAboutOverwritingExistingFiles,
  30. bool selectMultipleFiles,
  31. FilePreviewComponent* previewComponent)
  32. {
  33. const String separator (":");
  34. String command ("zenity --file-selection");
  35. if (title.isNotEmpty())
  36. command << " --title=\"" << title << "\"";
  37. if (file != File::nonexistent)
  38. command << " --filename=\"" << file.getFullPathName () << "\"";
  39. if (isDirectory)
  40. command << " --directory";
  41. if (isSave)
  42. command << " --save";
  43. if (selectMultipleFiles)
  44. command << " --multiple --separator=\"" << separator << "\"";
  45. command << " 2>&1";
  46. MemoryOutputStream result;
  47. int status = -1;
  48. FILE* stream = popen (command.toUTF8(), "r");
  49. if (stream != 0)
  50. {
  51. for (;;)
  52. {
  53. char buffer [1024];
  54. const int bytesRead = fread (buffer, 1, sizeof (buffer), stream);
  55. if (bytesRead <= 0)
  56. break;
  57. result.write (buffer, bytesRead);
  58. }
  59. status = pclose (stream);
  60. }
  61. if (status == 0)
  62. {
  63. StringArray tokens;
  64. if (selectMultipleFiles)
  65. tokens.addTokens (result.toUTF8(), separator, String::empty);
  66. else
  67. tokens.add (result.toUTF8());
  68. for (int i = 0; i < tokens.size(); i++)
  69. results.add (File (tokens[i]));
  70. return;
  71. }
  72. //xxx ain't got one!
  73. jassertfalse
  74. }
  75. #endif