diff options
Diffstat (limited to 'platform/linuxbsd/freedesktop_portal_desktop.h')
-rw-r--r-- | platform/linuxbsd/freedesktop_portal_desktop.h | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/platform/linuxbsd/freedesktop_portal_desktop.h b/platform/linuxbsd/freedesktop_portal_desktop.h index a9b83b3844..96c38de2c2 100644 --- a/platform/linuxbsd/freedesktop_portal_desktop.h +++ b/platform/linuxbsd/freedesktop_portal_desktop.h @@ -34,13 +34,14 @@ #ifdef DBUS_ENABLED #include "core/os/thread.h" +#include "core/os/thread_safe.h" #include "servers/display_server.h" struct DBusMessage; struct DBusConnection; struct DBusMessageIter; -class FreeDesktopPortalDesktop { +class FreeDesktopPortalDesktop : public Object { private: bool unsupported = false; @@ -49,23 +50,42 @@ private: bool read_setting(const char *p_namespace, const char *p_key, int p_type, void *r_value); static void append_dbus_string(DBusMessageIter *p_iter, const String &p_string); - static void append_dbus_dict_filters(DBusMessageIter *p_iter, const Vector<String> &p_filters); + static void append_dbus_dict_options(DBusMessageIter *p_iter, const TypedArray<Dictionary> &p_options); + static void append_dbus_dict_filters(DBusMessageIter *p_iter, const Vector<String> &p_filter_names, const Vector<String> &p_filter_exts); static void append_dbus_dict_string(DBusMessageIter *p_iter, const String &p_key, const String &p_value, bool p_as_byte_array = false); static void append_dbus_dict_bool(DBusMessageIter *p_iter, const String &p_key, bool p_value); - static bool file_chooser_parse_response(DBusMessageIter *p_iter, bool &r_cancel, Vector<String> &r_urls); + static bool file_chooser_parse_response(DBusMessageIter *p_iter, const Vector<String> &p_names, bool &r_cancel, Vector<String> &r_urls, int &r_index, Dictionary &r_options); struct FileDialogData { - DBusConnection *connection = nullptr; + Vector<String> filter_names; + DisplayServer::WindowID prev_focus = DisplayServer::INVALID_WINDOW_ID; Callable callback; + String filter; String path; + bool opt_in_cb = false; }; + struct FileDialogCallback { + Callable callback; + Variant status; + Variant files; + Variant index; + Variant options; + bool opt_in_cb = false; + }; + List<FileDialogCallback> pending_cbs; + Mutex file_dialog_mutex; Vector<FileDialogData> file_dialogs; - Thread file_dialog_thread; - SafeFlag file_dialog_thread_abort; + Thread monitor_thread; + SafeFlag monitor_thread_abort; + DBusConnection *monitor_connection = nullptr; + + String theme_path; + Callable system_theme_changed; + void _system_theme_changed_callback(); - static void _thread_file_dialog_monitor(void *p_ud); + static void _thread_monitor(void *p_ud); public: FreeDesktopPortalDesktop(); @@ -73,13 +93,17 @@ public: bool is_supported() { return !unsupported; } - Error file_dialog_show(const String &p_xid, const String &p_title, const String &p_current_directory, const String &p_filename, DisplayServer::FileDialogMode p_mode, const Vector<String> &p_filters, const Callable &p_callback); + Error file_dialog_show(DisplayServer::WindowID p_window_id, const String &p_xid, const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, DisplayServer::FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback, bool p_options_in_cb); + void process_file_dialog_callbacks(); // Retrieve the system's preferred color scheme. // 0: No preference or unknown. // 1: Prefer dark appearance. // 2: Prefer light appearance. uint32_t get_appearance_color_scheme(); + void set_system_theme_change_callback(const Callable &p_system_theme_changed) { + system_theme_changed = p_system_theme_changed; + } }; #endif // DBUS_ENABLED |