summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/dialog-manager.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /src/ui/dialog/dialog-manager.h
parentInitial commit. (diff)
downloadinkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.tar.xz
inkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/ui/dialog/dialog-manager.h97
1 files changed, 97 insertions, 0 deletions
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 <glibmm/keyfile.h>
+#include <gtkmm/window.h>
+#include <map>
+#include <set>
+#include <memory>
+#include <optional>
+#include <vector>
+
+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<window_position_t> 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<Glib::KeyFile> 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<DialogWindow*> 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<Glib::ustring> 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<std::string, std::shared_ptr<Glib::KeyFile>> _floating_dialogs;
+ // temp set used when dialogs are hidden (F12 toggle)
+ std::set<DialogWindow*> _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 :