diff --git a/Source/Engine/Platform/Linux/LinuxFileSystem.cpp b/Source/Engine/Platform/Linux/LinuxFileSystem.cpp index 2d89f10a5..860805c9a 100644 --- a/Source/Engine/Platform/Linux/LinuxFileSystem.cpp +++ b/Source/Engine/Platform/Linux/LinuxFileSystem.cpp @@ -20,6 +20,33 @@ const DateTime UnixEpoch(1970, 1, 1); +bool LinuxFileSystem::ShowOpenFileDialog(Window* parentWindow, const StringView& initialDirectory, const StringView& filter, bool multiSelect, const StringView& title, Array& filenames) +{ + const StringAsANSI<> titleAnsi(*title, title.Length()); + char cmd[2048]; + // TODO: multiSelect support + // TODO: filter support + sprintf(cmd, "/usr/bin/zenity --modal --file-selection --title=\"%s\" ", titleAnsi.Get()); + FILE* f = popen(cmd, "r"); + char buf[2048]; + fgets(buf, ARRAY_COUNT(buf), f); + int result = pclose(f); + if (result != 0) + { + return true; + } + const char* c = buf; + while (*c) + { + const char* start = c; + while (*c != '\n') + c++; + filenames.Add(String(start, (int32)(c - start))); + c++; + } + return false; +} + bool LinuxFileSystem::CreateDirectory(const StringView& path) { const StringAsANSI<> pathAnsi(*path, path.Length()); diff --git a/Source/Engine/Platform/Linux/LinuxFileSystem.h b/Source/Engine/Platform/Linux/LinuxFileSystem.h index f0281aa54..5f74ad377 100644 --- a/Source/Engine/Platform/Linux/LinuxFileSystem.h +++ b/Source/Engine/Platform/Linux/LinuxFileSystem.h @@ -13,6 +13,8 @@ class FLAXENGINE_API LinuxFileSystem : public FileSystemBase { public: + // [FileSystemBase] + static bool ShowOpenFileDialog(Window* parentWindow, const StringView& initialDirectory, const StringView& filter, bool multiSelect, const StringView& title, Array& filenames); static bool CreateDirectory(const StringView& path); static bool DeleteDirectory(const String& path, bool deleteContents = true); static bool DirectoryExists(const StringView& path);