From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- src/ui/dialog/dialog-manager.h | 97 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/ui/dialog/dialog-manager.h (limited to 'src/ui/dialog/dialog-manager.h') diff --git a/src/ui/dialog/dialog-manager.h b/src/ui/dialog/dialog-manager.h new file mode 100644 index 0000000..fc4cd9b --- /dev/null +++ b/src/ui/dialog/dialog-manager.h @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#ifndef INKSCAPE_UI_DIALOG_MANAGER_H +#define INKSCAPE_UI_DIALOG_MANAGER_H + +#include +#include +#include +#include +#include +#include +#include + +namespace Inkscape { +namespace UI { +namespace Dialog { + +class DialogWindow; +class DialogBase; +class DialogContainer; + +struct window_position_t +{ + int x, y, width, height; +}; + +// try to read window's geometry +std::optional dm_get_window_position(Gtk::Window &window); + +// restore window's geometry +void dm_restore_window_position(Gtk::Window &window, const window_position_t &position); + +class DialogManager +{ +public: + static DialogManager &singleton(); + + // store complete dialog window state (including its container state) + void store_state(DialogWindow &wnd); + + // return true if dialog 'type' should be opened as floating + bool should_open_floating(const Glib::ustring& dialog_type); + + // find instance of dialog 'type' in one of currently open floating dialog windows + DialogBase *find_floating_dialog(const Glib::ustring& dialog_type); + + // find window hosting floating dialog + DialogWindow* find_floating_dialog_window(const Glib::ustring& dialog_type); + + // find floating window state hosting dialog 'code', if there was one + std::shared_ptr find_dialog_state(const Glib::ustring& dialog_type); + + // remove dialog floating state + void remove_dialog_floating_state(const Glib::ustring& dialog_type); + + // save configuration of docked and floating dialogs + void save_dialogs_state(DialogContainer *docking_container); + + // restore state of dialogs + void restore_dialogs_state(DialogContainer *docking_container, bool include_floating); + + // find all floating dialog windows + std::vector get_all_floating_dialog_windows(); + + // show/hide dialog window and keep track of it + void set_floating_dialog_visibility(DialogWindow* wnd, bool show); + +private: + DialogManager() = default; + ~DialogManager() = default; + + std::vector count_dialogs(const Glib::KeyFile *state) const; + void load_transient_state(Glib::KeyFile *keyfile); + void dialog_defaults(); + + // transient dialog state for floating windows user closes + std::map> _floating_dialogs; + // temp set used when dialogs are hidden (F12 toggle) + std::set _hidden_dlg_windows; +}; + +} // namespace Dialog +} // namespace UI +} // namespace Inkscape + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3