15#include <glibmm/i18n.h>
39 return std::max({widget.get_margin_top(), widget.get_margin_bottom(),
40 widget.get_margin_start(), widget.get_margin_end()});
47 , _inkscape_window(inkscape_window)
48 , _title(_(
"Dialog Window"))
50 g_assert(
_app !=
nullptr);
54 set_name(
"DialogWindow");
55 set_transient_for(*inkscape_window);
58 signal_close_request().connect([
this]{
72 auto shortcut_controller = Gtk::ShortcutController::create(shortcuts_instance.get_liststore());
73 shortcut_controller->set_propagation_phase(Gtk::PropagationPhase::BUBBLE);
74 add_controller(shortcut_controller);
77 auto const box_outer = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
78 set_child(*box_outer);
81 _container = Gtk::make_managed<DialogContainer>(inkscape_window);
91 auto const column = col.get();
92 columns->
append(std::move(col));
95 auto nb = std::make_unique<DialogNotebook>(
_container);
96 auto const dialog_notebook = nb.get();
97 column->append(std::move(nb));
98 column->set_dropzone_sizes(drop_size, drop_size);
99 dialog_notebook->move_page(*
page);
109 Gtk::Requisition minimum_size, natural_size;
110 dialog->get_preferred_size(minimum_size, natural_size);
112 int width = natural_size.get_width() + overhead;
114 window_width = std::max(
width, window_width);
115 window_height = std::max(
height, window_height);
120 set_default_size(window_width, window_height);
127 auto const themecontext = INKSCAPE.themecontext;
128 g_assert(themecontext);
129 themecontext->themechangecallback();
132 auto const key = Gtk::EventControllerKey::create();
133 key->set_propagation_phase(Gtk::PropagationPhase::TARGET);
145 if (!inkscape_window) {
146 std::cerr <<
"DialogWindow::set_inkscape_window: no inkscape_window!" << std::endl;
159 g_assert(
_app !=
nullptr);
168 if (dialogs.size() > 1) {
169 _title =
"Multiple dialogs";
170 }
else if (dialogs.size() == 1) {
171 _title = dialogs.begin()->second->get_name();
180 set_title(
_title +
" - " + Glib::ustring(document_name));
184 if (win_action_group) {
186 gtk_widget_insert_action_group(Gtk::Widget::gobj(),
"win", win_action_group->gobj());
188 std::cerr <<
"DialogWindow::DialogWindow: Can't find InkscapeWindow Gio:ActionGroup!" << std::endl;
206 auto allocation = get_allocation();
210 for (
auto const &[
name, dialog] : dialogs) {
211 Gtk::Requisition minimum_size, natural_size;
212 dialog->get_preferred_size(minimum_size, natural_size);
213 width = std::max(natural_size.get_width(),
width);
224 if (allocation.get_width() >=
width && allocation.get_height() >=
height) {
229 width = std::max(
width, allocation.get_width());
240 unsigned keyval,
unsigned keycode, Gdk::ModifierType state)
Gtk::Application * gtk_app()
The Gtk application instance, or NULL if running headless without display.
SPDocument * get_document()
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
static Preferences * get()
Access the singleton Preferences object.
static Shortcuts & getInstance(bool init=true)
DialogBase is the base class for the dialog system.
Glib::ustring const & get_name() const
void set_inkscape_window(InkscapeWindow *inkscape_window)
DialogMultipaned * get_columns()
std::multimap< Glib::ustring, DialogBase * > const & get_dialogs() const
std::unique_ptr< DialogMultipaned > create_column()
static DialogManager & singleton()
void store_state(DialogWindow &wnd)
void set_dropzone_sizes(int start, int end)
Set the sizes of the DialogMultipaned dropzones.
void append(std::unique_ptr< Gtk::Widget > child)
InkscapeApplication * _app
void update_dialogs()
Update all dialogs that are owned by the DialogWindow's _container.
DialogWindow(InkscapeWindow *window, Gtk::Widget *page=nullptr)
void set_inkscape_window(InkscapeWindow *window)
Change InkscapeWindow that DialogWindow is linked to.
void update_window_size_to_fit_children()
Update window width and height in order to fit all dialogs inisde its container.
bool on_key_pressed(Gtk::EventControllerKey &controller, unsigned keyval, unsigned keycode, Gdk::ModifierType state)
DialogContainer * _container
InkscapeWindow * _inkscape_window
The Inkscape window that dialog window is attached to.
Glib::RefPtr< Gio::SimpleActionGroup > getActionGroup()
char const * getDocumentName() const
basename or other human-readable label for the document.
A base class for all dialogs.
A widget with multiple panes.
static constexpr int INITIAL_WINDOW_HEIGHT
static constexpr int INITIAL_WINDOW_WIDTH
static constexpr int WINDOW_DROPZONE_SIZE
static constexpr int MINIMUM_WINDOW_HEIGHT
static constexpr int WINDOW_DROPZONE_SIZE_LARGE
static constexpr int NOTEBOOK_TAB_HEIGHT
static constexpr int MINIMUM_WINDOW_WIDTH
A window for floating docks.
Inkscape - An SVG editor.
static auto get_max_margin(Gtk::Widget const &widget)
void pack_end(Gtk::Box &box, Gtk::Widget &child, bool const expand, bool const fill, unsigned const padding)
Adds child to box, packed with reference to the end of box.
static cairo_user_data_key_t key
Helpers for using Gtk::Boxes, encapsulating large changes between GTK3 & GTK4.
Gtk <themes> helper code.