29#include <glibmm/i18n.h>
30#include <glibmm/ustring.h>
31#include <gtkmm/adjustment.h>
32#include <gtkmm/checkbutton.h>
33#include <gtkmm/grid.h>
34#include <gtkmm/label.h>
35#include <gtkmm/messagedialog.h>
36#include <gtkmm/paned.h>
37#include <gtkmm/widget.h>
87 :
Gtk::Box(
Gtk::Orientation::VERTICAL)
88 , _window{inkscape_window}
90 set_name(
"SPDesktopWidget");
95 _statusbar = Gtk::make_managed<Inkscape::UI::Widget::StatusBar>();
100 _panels = Gtk::make_managed<Inkscape::UI::Dialog::SwatchesPanel>(
true,
"/embedded/swatches");
105 _hbox = Gtk::make_managed<Gtk::Box>();
106 _hbox->set_vexpand(
true);
107 _hbox->set_name(
"DesktopHbox");
109 _tbbox = Gtk::make_managed<Gtk::Paned>(Gtk::Orientation::HORIZONTAL);
110 _tbbox->set_vexpand(
true);
111 _tbbox->set_name(
"ToolboxCanvasPaned");
121 tool_toolbars = std::make_unique<Inkscape::UI::Toolbar::Toolbars>();
124 tool_toolbox = Gtk::make_managed<Inkscape::UI::Toolbar::ToolToolbar>(inkscape_window);
126 _tbbox->set_resize_start_child(
false);
127 _tbbox->set_shrink_start_child(
false);
128 auto adjust_pos = [=,
this](){
129 int minimum_width, natural_width;
131 tool_toolbox->measure(Gtk::Orientation::HORIZONTAL, -1, minimum_width, natural_width, ignore, ignore);
132 if (minimum_width > 0) {
133 int pos =
_tbbox->get_position();
134 int new_pos = pos + minimum_width / 2;
136 new_pos = std::min(new_pos - new_pos % minimum_width, max * minimum_width);
137 if (pos != new_pos)
_tbbox->set_position(new_pos);
140 _tbbox->property_position().signal_changed().connect([=](){ adjust_pos(); });
148 auto tbox_width = prefs->getEntry(
"/toolbox/tools/width");
149 if (tbox_width.isSet()) {
150 _tbbox->set_position(tbox_width.getIntLimited(32, 8, 500));
153 auto set_toolbar_prefs = [=,
this]() {
170 auto cg = std::make_unique<Inkscape::UI::Widget::CanvasGrid>(
this);
178 _container = std::make_unique<DialogContainer>(inkscape_window);
181 _tbbox->set_resize_end_child(
true);
182 _tbbox->set_shrink_end_child(
true);
186 tbox_separator.set_name(
"TBoxCanvasSeparator");
197 command_toolbar = std::make_unique<Inkscape::UI::Toolbar::CommandToolbar>();
221 auto newpos = oldpos ==
_desktops.size() - 1 ? oldpos - 1 : oldpos + 1;
260 auto set_tool = [
this] {
281 setMessage(msgstack->currentMessageType(), msgstack->currentMessage());
288 if (
auto action =
dynamic_cast<Gio::SimpleAction *
>(
_window->lookup_action(
"tool-switch").get())) {
291 if (
auto action =
dynamic_cast<Gio::SimpleAction *
>(
_window->lookup_action(
"canvas-display-mode").get())) {
294 if (
auto action =
dynamic_cast<Gio::SimpleAction *
>(
_window->lookup_action(
"canvas-color-mode").get())) {
297 if (
auto action =
dynamic_cast<Gio::SimpleAction *
>(
_window->lookup_action(
"canvas-color-manage").get())) {
309 auto newpos = Util::safemod<int>(oldpos + by,
_desktops.size());
315 auto prefs = Preferences::get();
346 parent_type::on_unrealize();
363 if (doc->isModifiedSinceSave()) {
371 Name += std::to_string(v);
377 auto const color_mode = canvas->get_color_mode();
380 Name += N_(
"outline");
382 Name += N_(
"no filters");
384 Name += N_(
"enhance thin lines");
386 Name += N_(
"outline overlay");
395 Name += N_(
"grayscale");
397 Name += N_(
"print colors preview");
400 if (Name.back() ==
'(') {
401 Name.erase(Name.size() - 2);
406 Name +=
" - Inkscape";
431 parent_type::on_realize();
433 auto const dark = INKSCAPE.themecontext->isCurrentThemeDark(
_window);
434 Preferences::get()->setBool(
"/theme/darkTheme", dark);
435 INKSCAPE.themecontext->getChangeThemeSignal().emit();
436 INKSCAPE.themecontext->add_gtk_css(
true);
459 if (flags & SP_OBJECT_MODIFIED_FLAG) {
514 window.set_transient_for(*
_window);
541 Gtk::MessageDialog dialog{*
_window, message,
false, Gtk::MessageType::INFO, Gtk::ButtonsType::OK};
542 dialog.property_destroy_with_parent() =
true;
543 dialog.set_name(
"InfoDialog");
544 dialog.set_title(_(
"Note:"));
550 Gtk::MessageDialog dialog{*
_window, text,
false, Gtk::MessageType::WARNING, Gtk::ButtonsType::OK_CANCEL};
552 return response == Gtk::ResponseType::OK;
561 Glib::ustring pref_root;
565 pref_root =
"/focus/";
567 pref_root =
"/fullscreen/";
569 pref_root =
"/window/";
572 command_toolbar->set_visible(prefs->getBool(pref_root +
"commands/state",
true));
574 snap_toolbar->set_visible(prefs->getBool(pref_root +
"snaptoolbox/state",
true));
576 tool_toolbars->set_visible(prefs->getBool(pref_root +
"toppanel/state",
true));
578 tool_toolbox->set_visible(prefs->getBool(pref_root +
"toolbox/state",
true));
580 _statusbar->set_visible(prefs->getBool(pref_root +
"statusbar/state",
true));
583 _panels->set_visible(prefs->getBool(pref_root +
"panels/state",
true));
592 double const width = monitor_geometry.get_width();
593 double const height = monitor_geometry.get_height();
595 widescreen = prefs->getBool(pref_root +
"interface_mode", widescreen);
601 auto orientation_c = GTK_ORIENTATION_HORIZONTAL;
605 orientation_c = GTK_ORIENTATION_HORIZONTAL;
608 orientation_c = GTK_ORIENTATION_VERTICAL;
613 if (
auto toolbar =
dynamic_cast<Gtk::Box *
>(&widget)) {
614 gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar->gobj()), orientation_c);
627 std::cerr <<
"SPDesktopWidget::get_toolbar_by_name: failed to find: " <<
name << std::endl;
650 auto a = sb->get_adjustment();
652 if(a) a->set_value(value);
654 g_warning (
"Could not find GtkAdjustment for %s\n",
id);
661 auto const widget =
const_cast<Gtk::Widget
const *
>(
669 if (
auto const button =
dynamic_cast<Gtk::ToggleButton
const *
>(widget)) {
670 return button->get_active();
684 bool is_perm = prefs->getInt(
"/toolbox/simplesnap", 1) == 2;
689 auto parent = snap.get_parent();
695 if (!snap.get_parent()) {
705 snap.set_valign(Gtk::Align::START);
715 snap.set_valign(Gtk::Align::START);
719 snap.set_valign(Gtk::Align::CENTER);
739 if (!has_focus)
return;
742 if (prefs->
getBool(
"/options/bitmapautoreload/value",
true)) {
744 for (
auto it : imageList) {
745 auto image = cast<SPImage>(it);
746 image->refresh_if_outdated();
812 auto const parent = widget.get_parent();
818 _hbox->remove(widget);
820 g_critical(
"SPDesktopWidget::remove_from_top_toolbar_or_hbox(): unexpected parent!");
Rewrite of code originally in desktop-widget.cpp.
Two-dimensional point with integer coordinates.
constexpr IntCoord x() const noexcept
constexpr IntCoord y() const noexcept
Two-dimensional point that doubles as a vector.
void windowClose(InkscapeWindow *window)
static InkscapeApplication * instance()
Singleton instance.
void setActiveTab(SPDesktop *desktop)
Preference storage class.
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
static Preferences * get()
Access the singleton Preferences object.
void setInt(Glib::ustring const &pref_path, int value)
Set an integer value.
void setBool(Glib::ustring const &pref_path, bool value)
Set a Boolean value.
void setDesktop(SPDesktop *new_desktop)
Called when the desktop might have changed for this dialog.
A widget that manages DialogNotebook's and other widgets inside a horizontal DialogMultipaned contain...
void get_children()=delete
We manage our own child list. Call get_multipaned_children()
void append(std::unique_ptr< Gtk::Widget > child)
DialogWindow holds DialogContainer instances for undocked dialogs.
To do: update description of desktop.
Inkscape::UI::Widget::Canvas * getCanvas() const
Inkscape::MessageStack * messageStack() const
bool is_fullscreen() const
SPNamedView * getNamedView() const
Inkscape::UI::Tools::ToolBase * getTool() const
void setDesktopWidget(SPDesktopWidget *dtw)
bool is_focusMode() const
Checks to see if the user is working in focused mode.
sigc::connection connectEventContextChanged(F &&slot)
char const * getDocumentName() const
basename or other human-readable label for the document.
std::vector< SPObject * > const getResourceList(char const *key)
Inkscape::Util::Unit const * getDisplayUnit() const
Returns namedview's default unit.
sigc::connection connectModified(sigc::slot< void(SPObject *, unsigned int)> slot)
Connects to the modification notification signal.
void init_avoided_shape_geometry(SPDesktop *desktop)
A class for handling shape interaction with libavoid.
sigc::scoped_connection timeout
Editable view implementation.
A widget that manages DialogNotebook's and other widgets inside a horizontal DialogMultipaned.
A widget with multiple panes.
A window for floating docks.
static char const *const parent
TODO: insert short description here.
@ PREFS_DIALOGS_WINDOWS_AGGRESSIVE
std::unique_ptr< Magick::Image > image
Inkscape - An SVG editor.
Interface for locally managing a current status message.
helper functions for retrieving monitor geometry, etc.
void set_icon_sizes(Gtk::Widget *parent, int pixel_size)
Recursively set all the icon sizes inside this parent widget.
Gtk::Widget * find_widget_by_name(Gtk::Widget &parent, Glib::ustring const &name, bool visible_only)
Returns a named descendent of parent, which has the given name, or nullptr if there's none.
std::vector< Gtk::Widget * > get_children(Gtk::Widget &widget)
Get a vector of the widgetʼs children, from get_first_child() through each get_next_sibling().
Gtk::Widget * for_each_child(Gtk::Widget &widget, Func &&func, bool const plus_self=false, bool const recurse=false, int const level=0)
Call Func with a reference to each child of parent, until it returns _break.
int dialog_run(Gtk::Dialog &dialog)
This is a GTK4 porting aid meant to replace the removal of the Gtk::Dialog synchronous API.
Gdk::Rectangle get_monitor_geometry_primary()
get monitor geometry of primary monitor
MessageType
A hint about the meaning of a message; is it an ordinary message, a message advising the user of some...
SVG <image> implementation.
Gtk <themes> helper code.