6#include <glibmm/keyfile.h>
7#include <glibmm/fileutils.h>
8#include <glibmm/miscutils.h>
9#include <glibmm/ustring.h>
10#include <gdkmm/monitor.h>
11#include <gtkmm/window.h>
15namespace filesystem = std::filesystem;
18#include <boost/filesystem.hpp>
19namespace filesystem = boost::filesystem;
34 std::optional<window_position_t> position = std::nullopt;
36 int width = window.get_width();
37 int height = window.get_height();
49 window.set_default_size(position.
width, position.
height);
65 auto state = container->get_container_state(&*pos);
66 for (
auto const &[
name, dialog] : container->get_dialogs()) {
82 if (wnd->is_visible())
return;
85 wnd->set_visible(
true);
89 app->gtk_app()->add_window(*wnd);
93 if (!wnd->is_visible())
return;
96 wnd->set_visible(
false);
104 for (
auto wnd : windows) {
106 result.push_back(dlg_wnd);
116 for (
auto dlg_wnd : windows) {
117 if (
auto container = dlg_wnd->get_container()) {
118 if (container->get_dialog(dialog_type)) {
131 for (
auto dlg_wnd : windows) {
132 if (
auto container = dlg_wnd->get_container()) {
133 if (
auto dlg = container->get_dialog(dialog_type)) {
158 std::vector<Glib::ustring> dialogs;
159 if (!state)
return dialogs;
162 if (dlg.second.get() == state) {
163 dialogs.emplace_back(dlg.first);
171 if (!docking_container)
return;
184 auto state = dlg.second.get();
185 auto&& type = dlg.first;
186 auto index = std::to_string(idx++);
192 dialogs.emplace_back(type);
200 keyfile->save_to_file(filename);
201 }
catch (Glib::FileError
const &error) {
202 std::cerr << G_STRFUNC <<
": " << error.what() << std::endl;
210 for (
int i = 0; i < count; ++i) {
211 auto index = std::to_string(i + 1);
215 auto keyfile = Glib::KeyFile::create();
216 if (!state.empty()) {
217 keyfile->load_from_data(state);
219 for (
auto type : dialogs) {
227 bool exists = filesystem::exists(filesystem::u8path(filepath));
229 bool exists = filesystem::exists(filesystem::path(filepath));
237 if (!docking_container)
return;
244 auto keyfile = Glib::KeyFile::create();
249 if (exists && keyfile->load_from_file(filename)) {
254 if (include_floating) {
257 }
catch (Glib::Error
const &error) {
258 std::cerr << G_STRFUNC <<
": transient state not loaded - " << error.what() << std::endl;
266 }
catch (Glib::Error
const &error) {
267 std::cerr << G_STRFUNC <<
": dialogs state not loaded - " << error.what() << std::endl;
281 auto keyfile = Glib::KeyFile::create();
287 if (exists && keyfile->load_from_file(filename)) {
295 g_warning(
"Cannot load default dialog state %s", filename.c_str());
static InkscapeApplication * instance()
Singleton instance.
Gtk::Application * gtk_app()
The Gtk application instance, or NULL if running headless without display.
Preference storage class.
static Preferences * get()
Access the singleton Preferences object.
int getInt(Glib::ustring const &pref_path, int def=0)
Retrieve an integer.
DialogBase is the base class for the dialog system.
A widget that manages DialogNotebook's and other widgets inside a horizontal DialogMultipaned contain...
Glib::RefPtr< Glib::KeyFile > save_container_state()
Save container state.
void load_container_state(Glib::KeyFile *keyfile, bool include_floating)
Load last open window's dialog configuration state.
void remove_dialog_floating_state(const Glib::ustring &dialog_type)
std::vector< Glib::ustring > count_dialogs(const Glib::KeyFile *state) const
static DialogManager & singleton()
std::set< DialogWindow * > _hidden_dlg_windows
void restore_dialogs_state(DialogContainer *docking_container, bool include_floating)
void load_transient_state(Glib::KeyFile *keyfile)
void save_dialogs_state(DialogContainer *docking_container)
void set_floating_dialog_visibility(DialogWindow *wnd, bool show)
bool should_open_floating(const Glib::ustring &dialog_type)
void dialog_defaults(DialogContainer *docking_container)
std::map< std::string, std::shared_ptr< Glib::KeyFile > > _floating_dialogs
std::shared_ptr< Glib::KeyFile > find_dialog_state(const Glib::ustring &dialog_type)
void store_state(DialogWindow &wnd)
std::vector< DialogWindow * > get_all_floating_dialog_windows()
DialogWindow * find_floating_dialog_window(const Glib::ustring &dialog_type)
DialogBase * find_floating_dialog(const Glib::ustring &dialog_type)
DialogWindow holds DialogContainer instances for undocked dialogs.
DialogContainer * get_container()
A base class for all dialogs.
A widget that manages DialogNotebook's and other widgets inside a horizontal DialogMultipaned.
A window for floating docks.
@ PREFS_DIALOGS_STATE_SAVE
@ PREFS_DIALOGS_STATE_NONE
std::string get_filename(Type type, char const *filename, bool localized, bool silent)
std::string profile_path()
std::optional< window_position_t > dm_get_window_position(Gtk::Window &window)
const char transient_group[]
bool file_exists(const std::string &filepath)
const char save_dialog_position[]
void dm_restore_window_position(Gtk::Window &window, const window_position_t &position)
const char dialogs_state[]
Singleton class to access the preferences file in a convenient way.
Inkscape::IO::Resource - simple resource API.