diff --git a/share/ui/style.css b/share/ui/style.css
index e9b16316022bf9078254b7353a5d831028d9dcd8..4f3e338f587ae7765e3e0c5d3c095e0cf0da335f 100644
--- a/share/ui/style.css
+++ b/share/ui/style.css
@@ -204,11 +204,6 @@ iconview *:hover {
font-size: 11px;
}
-/* Tool Toolbox */
-#ToolToolbox button {
- min-height: 16px; /* By default this is 24px which adds too much space when using "Smaller" icons. */
-}
-
#CommandPaletteBase {
background-color: @theme_base_color; /* some themes don't seem to have a background color for list rows defined and would end up transparent otherwise */
border: 5px solid @theme_bg_color;
@@ -550,3 +545,28 @@ stackswitcher button {
.color-palette-main-box scrolledwindow undershoot.left {
background-image: none;
}
+
+.tight-flowbox flowboxchild {
+ margin: 0;
+ padding: 0px;
+}
+.tight-flowbox button {
+ margin: 0;
+ padding: 4px;
+}
+
+/* add .small-marks class to Gtk::Scale to have smaller font used, since markup didn't work there */
+scale.small-marks.marks-after {
+ font-size: small;
+}
+
+/* Square toolbar buttons: request square buttons for all toolbars. */
+button.square-button {
+ padding: 3px;
+}
+
+button.square-button image {
+ padding: 0;
+ min-width: 16px;
+ min-height: 16px;
+}
diff --git a/share/ui/toolbar-tool.ui b/share/ui/toolbar-tool.ui
index 2b3825689e53b3e5de068c69ef4b82ceac896474..84580a4602dca6e6871ac8a4e48b1444fb3119ed 100644
--- a/share/ui/toolbar-tool.ui
+++ b/share/ui/toolbar-tool.ui
@@ -1,268 +1,637 @@
-
+
-
-
-
-
diff --git a/src/helper/action.cpp b/src/helper/action.cpp
index 6b09a91405da6a828aded7136f750c3ffb87a809..952b2ed9e7eae3afceea6d8bd6d9ea15e89ffc55 100644
--- a/src/helper/action.cpp
+++ b/src/helper/action.cpp
@@ -23,6 +23,7 @@
#include "desktop.h"
#include "document.h"
#include "verbs.h"
+#include "widgets/toolbox.h"
static void sp_action_finalize (GObject *object);
@@ -238,7 +239,9 @@ SPAction::create_toolbutton_for_verb(unsigned int verb_code,
// Create a button with the required display properties
auto button = Gtk::manage(new Gtk::ToolButton(verb->get_tip()));
- auto icon_widget = sp_get_icon_image(icon_name, "/toolbox/small");
+ auto icon_widget = Gtk::make_managed(); // sp_get_icon_image(icon_name, "/toolbox/small");
+ // Gtk::IconSize icon_size = Inkscape::UI::ToolboxFactory::prefToSize_mm("/toolbox/small");
+ icon_widget->set_from_icon_name(icon_name, Gtk::ICON_SIZE_BUTTON);
button->set_icon_widget(*icon_widget);
button->set_tooltip_text(verb->get_tip());
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index d5e96c86960d1698bb744d40bd089c1c4b97a20a..77522960bfd35dfecc96906aaa036193d22b74a2 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -66,6 +66,8 @@
#include "ui/themes.h"
#include "widgets/desktop-widget.h"
+#include "widgets/toolbox.h"
+#include "widgets/spw-utilities.h"
#include
@@ -1759,34 +1761,83 @@ void InkscapePreferences::initPageUI()
_page_theme.add_line(false, "", *icon_buttons_def, "",
_("Reset theme colors for some symbolic icon themes"),
false);
- {
- Glib::ustring sizeLabels[] = { C_("Icon size", "Larger"), C_("Icon size", "Large"), C_("Icon size", "Small"),
- C_("Icon size", "Smaller") };
- int sizeValues[] = { 3, 2, 0, 1 };
- // "Larger" is 3 to not break existing preference files. Should fix in GTK3
-
- _misc_small_tools.init("/toolbox/tools/small", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 0);
- _page_theme.add_line(false, _("Toolbox icon size:"), _misc_small_tools, _("(requires restart)"),
- _("Set the size for the tool icons."), false);
-
- _misc_small_toolbar.init("/toolbox/small", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 0);
- _page_theme.add_line(false, _("Control bar icon size:"), _misc_small_toolbar, _("(requires restart)"),
- _("Set the size for the icons in tools' control bars."), false);
-
- _misc_small_secondary.init("/toolbox/secondary", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), 1);
- _page_theme.add_line(false, _("Secondary toolbar icon size:"), _misc_small_secondary, _("(requires restart)"),
- _("Set the size for the icons in secondary toolbars."), false);
- }
- {
Glib::ustring menu_icons_labels[] = {_("Yes"), _("No"), _("Theme decides")};
int menu_icons_values[] = {1, -1, 0};
_menu_icons.init("/theme/menuIcons", menu_icons_labels, menu_icons_values, G_N_ELEMENTS(menu_icons_labels), 0);
_page_theme.add_line(false, _("Show icons in menus:"), _menu_icons, _("(requires restart)"),
_("You can either enable or disable all icons in menus. By default, the setting for the 'show-icons' attribute in the 'menus.xml' file determines whether to display icons in menus."), false);
- }
this->AddPage(_page_theme, _("Theming"), iter_ui, PREFS_PAGE_UI_THEME);
symbolicThemeCheck();
+
+ // Toolbars
+ _page_toolbars.add_group_header(_("Toolbars"));
+ {
+ auto custom = Gtk::make_managed();
+ auto dlg = Gtk::make_managed();
+ custom->set_label(_("Customize..."));
+ custom->set_popover(*dlg);
+ custom->set_direction(Gtk::ARROW_DOWN);
+ auto toolbox = Glib::wrap(ToolboxFactory::createToolToolbox());
+ toolbox->show_all();
+ const int MARGIN = 6;
+ toolbox->set_margin_start(MARGIN);
+ toolbox->set_margin_end(MARGIN);
+ toolbox->set_margin_top(MARGIN);
+ toolbox->set_margin_bottom(MARGIN);
+ Glib::ustring visible_buttons_path = ToolboxFactory::tools_visible_buttons;
+
+ sp_traverse_widget_tree(toolbox, [=](Gtk::Widget* widget){
+ if (auto flowbox = dynamic_cast(widget)) {
+ flowbox->set_max_children_per_line(4);
+ flowbox->set_selection_mode();
+ }
+ else if (auto button = dynamic_cast(widget)) {
+ assert(GTK_IS_ACTIONABLE(widget->gobj()));
+ // do not execute any action:
+ gtk_actionable_set_action_name(GTK_ACTIONABLE(widget->gobj()), "");
+
+ button->set_margin_start(MARGIN / 2);
+ button->set_margin_end(MARGIN / 2);
+ button->set_margin_top(MARGIN / 2);
+ button->set_margin_bottom(MARGIN / 2);
+ button->set_sensitive();
+ auto path = visible_buttons_path + sp_get_action_target(button);
+ auto visible = Inkscape::Preferences::get()->getBool(path, true);
+ button->set_active(visible);
+ button->signal_toggled().connect([=](){
+ Inkscape::Preferences::get()->setBool(path, button->get_active());
+ });
+ }
+ return false;
+ });
+
+ dlg->add(*toolbox);
+ _page_toolbars.add_line(false, "Toolbox buttons:", *custom, "", _("Select visible tool buttons"), false);
+
+ struct tbar_info {const char* label; const char* prefs;} toolbars[] = {
+ {_("Toolbox icon size:"), ToolboxFactory::tools_icon_size},
+ {_("Control bar icon size:"), ToolboxFactory::ctrlbars_icon_size},
+ };
+ for (auto&& tbox : toolbars) {
+ auto slider = Gtk::manage(new UI::Widget::PrefSlider(false));
+ const int min = ToolboxFactory::min_pixel_size;
+ const int max = ToolboxFactory::max_pixel_size;
+ slider->init(tbox.prefs, min, max, 1, 4, min, 0);
+ slider->getSlider()->signal_format_value().connect([](double val){
+ return Glib::ustring::format(std::fixed, std::setprecision(0), val * 100.0 / min) + "%";
+ });
+ slider->getSlider()->get_style_context()->add_class("small-marks");
+ for (int i = min; i <= max; i += 8) {
+ slider->getSlider()->add_mark(i, Gtk::POS_BOTTOM, i % min ? "" : (std::to_string(100 * i / min) + "%").c_str());
+ }
+ slider->set_margin_bottom(MARGIN);
+ _page_toolbars.add_line(false, tbox.label, *slider, "", _("Adjust toolbar icon size"));
+ }
+ }
+
+ this->AddPage(_page_toolbars, _("Toolbars"), iter_ui, PREFS_PAGE_UI_TOOLBARS);
+
// Windows
_win_save_geom.init ( _("Save and restore window geometry for each document"), "/options/savewindowgeometry/value", PREFS_WINDOW_GEOMETRY_FILE, true, nullptr);
_win_save_geom_prefs.init ( _("Remember and use last window's geometry"), "/options/savewindowgeometry/value", PREFS_WINDOW_GEOMETRY_LAST, false, &_win_save_geom);
diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h
index cea9df5789fa8f420acf7fd434825aaf281c0c7c..3d838b1c21f36de1a3741007c55f8b13598f0716 100644
--- a/src/ui/dialog/inkscape-preferences.h
+++ b/src/ui/dialog/inkscape-preferences.h
@@ -69,6 +69,7 @@ enum {
PREFS_PAGE_TOOLS_LPETOOL,
PREFS_PAGE_UI,
PREFS_PAGE_UI_THEME,
+ PREFS_PAGE_UI_TOOLBARS,
PREFS_PAGE_UI_WINDOWS,
PREFS_PAGE_UI_GRIDS,
PREFS_PAGE_COMMAND_PALETTE,
@@ -167,6 +168,7 @@ protected:
UI::Widget::DialogPage _page_ui;
UI::Widget::DialogPage _page_notfound;
UI::Widget::DialogPage _page_theme;
+ UI::Widget::DialogPage _page_toolbars;
UI::Widget::DialogPage _page_windows;
UI::Widget::DialogPage _page_grids;
UI::Widget::DialogPage _page_command_palette;
diff --git a/src/ui/icon-loader.cpp b/src/ui/icon-loader.cpp
index c849a2776b17fc96339731f73c9d4473b1f83e96..8216bf8517c07b2b6fdb0bdee850c4a63f3a8377 100644
--- a/src/ui/icon-loader.cpp
+++ b/src/ui/icon-loader.cpp
@@ -44,12 +44,6 @@ Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, Gtk::BuiltinIconSize icon
return icon;
}
-Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gchar const *prefs_size)
-{
- Gtk::IconSize icon_size = Inkscape::UI::ToolboxFactory::prefToSize_mm(prefs_size);
- return sp_get_icon_image(icon_name, icon_size);
-}
-
GtkWidget *sp_get_icon_image(Glib::ustring icon_name, GtkIconSize icon_size)
{
return gtk_image_new_from_icon_name(icon_name.c_str(), icon_size);
@@ -103,16 +97,6 @@ Glib::RefPtr sp_get_icon_pixbuf(Glib::ustring icon_name, GtkIconSiz
return sp_get_icon_pixbuf(icon_name, width * scale);
}
-Glib::RefPtr sp_get_icon_pixbuf(Glib::ustring icon_name, gchar const *prefs_size, int scale)
-{
- // Load icon based in preference size defined allowed values are:
- //"/toolbox/tools/small" Toolbox icon size
- //"/toolbox/small" Control bar icon size
- //"/toolbox/secondary" Secondary toolbar icon size
- GtkIconSize icon_size = Inkscape::UI::ToolboxFactory::prefToSize(prefs_size);
- return sp_get_icon_pixbuf(icon_name, icon_size, scale);
-}
-
/**
* Get the shape icon for this named shape type. For example 'rect'. These icons
* are always symbolic icons no matter the theme in order to be coloured by the highlight
diff --git a/src/ui/icon-loader.h b/src/ui/icon-loader.h
index 187579dcbb9fb021c9eea8e5d3be7f3ba1b5de78..52fe070d4d684aa5848140fad14063fb680905f9 100644
--- a/src/ui/icon-loader.h
+++ b/src/ui/icon-loader.h
@@ -24,7 +24,6 @@ Glib::RefPtr sp_get_icon_pixbuf(Glib::ustring icon_name, gint size)
Glib::RefPtr sp_get_icon_pixbuf(Glib::ustring icon_name, Gtk::IconSize icon_size, int scale=1);
Glib::RefPtr sp_get_icon_pixbuf(Glib::ustring icon_name, Gtk::BuiltinIconSize icon_size, int scale=1);
Glib::RefPtr sp_get_icon_pixbuf(Glib::ustring icon_name, GtkIconSize icon_size, int scale=1);
-Glib::RefPtr sp_get_icon_pixbuf(Glib::ustring icon_name, gchar const *prefs_sice, int scale=1);
Glib::RefPtr sp_get_shape_icon(Glib::ustring shape_type, Gdk::RGBA color, gint size, int scale=1);
#endif // SEEN_INK_ICON_LOADER_H
diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp
index 4ed07b34c9ccb392bd910bed3a0611686f44a1bb..79ebc799a8bd0ee8bb58d3a8d87af16d4ea0ccd5 100644
--- a/src/ui/widget/preferences-widget.cpp
+++ b/src/ui/widget/preferences-widget.cpp
@@ -577,7 +577,7 @@ PrefSlider::on_slider_value_changed()
freeze = true;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble(_prefs_path, _slider->get_value());
- _sb->set_value(_slider->get_value());
+ if (_sb) _sb->set_value(_slider->get_value());
freeze = false;
}
}
@@ -589,15 +589,17 @@ PrefSlider::on_spinbutton_value_changed()
{
freeze = true;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble(_prefs_path, _sb->get_value());
- _slider->set_value(_sb->get_value());
+ if (_sb) {
+ prefs->setDouble(_prefs_path, _sb->get_value());
+ _slider->set_value(_sb->get_value());
+ }
freeze = false;
}
}
bool PrefSlider::on_mnemonic_activate ( bool group_cycling )
{
- return _sb->mnemonic_activate ( group_cycling );
+ return _sb ? _sb->mnemonic_activate ( group_cycling ) : false;
}
void
@@ -618,19 +620,21 @@ PrefSlider::init(Glib::ustring const &prefs_path,
_slider->set_value (value);
_slider->set_digits(digits);
_slider->signal_value_changed().connect(sigc::mem_fun(*this, &PrefSlider::on_slider_value_changed));
- _sb = Gtk::manage(new Inkscape::UI::Widget::SpinButton());
- _sb->signal_value_changed().connect(sigc::mem_fun(*this, &PrefSlider::on_spinbutton_value_changed));
- _sb->set_range (lower, upper);
- _sb->set_increments (step_increment, 0);
- _sb->set_value (value);
- _sb->set_digits(digits);
- _sb->set_halign(Gtk::ALIGN_CENTER);
- _sb->set_valign(Gtk::ALIGN_END);
+ if (_spin) {
+ _sb = Gtk::manage(new Inkscape::UI::Widget::SpinButton());
+ _sb->signal_value_changed().connect(sigc::mem_fun(*this, &PrefSlider::on_spinbutton_value_changed));
+ _sb->set_range (lower, upper);
+ _sb->set_increments (step_increment, 0);
+ _sb->set_value (value);
+ _sb->set_digits(digits);
+ _sb->set_halign(Gtk::ALIGN_CENTER);
+ _sb->set_valign(Gtk::ALIGN_END);
+ }
auto table = Gtk::manage(new Gtk::Grid());
_slider->set_hexpand();
table->attach(*_slider, 0, 0, 1, 1);
- table->attach(*_sb, 1, 0, 1, 1);
+ if (_sb) table->attach(*_sb, 1, 0, 1, 1);
this->pack_start(*table, Gtk::PACK_EXPAND_WIDGET);
}
diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h
index ac5627ca69b55dbbdd9d431edb81863bece70468..f58c4d2b9b6b531fc42d90f89c45d53dc7330477 100644
--- a/src/ui/widget/preferences-widget.h
+++ b/src/ui/widget/preferences-widget.h
@@ -152,7 +152,7 @@ private:
class PrefSlider : public Gtk::Box
{
public:
- PrefSlider() : Gtk::Box(Gtk::ORIENTATION_HORIZONTAL) {}
+ PrefSlider(bool spin = true) : Gtk::Box(Gtk::ORIENTATION_HORIZONTAL) { _spin = spin; }
void init(Glib::ustring const &prefs_path,
double lower, double upper, double step_increment, double page_increment, double default_value, int digits);
@@ -165,9 +165,9 @@ private:
bool on_mnemonic_activate( bool group_cycling ) override;
Glib::ustring _prefs_path;
- Inkscape::UI::Widget::SpinButton *_sb;
-
- Gtk::Scale* _slider;
+ Inkscape::UI::Widget::SpinButton *_sb = nullptr;
+ bool _spin;
+ Gtk::Scale* _slider = nullptr;
bool freeze; // used to block recursive updates of slider and spinbutton
};
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index 9d083667f8ce71056d57263f717c3a7fc1896c3d..fd57558ba72247f82f36624ce49dff08b248c2e0 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -275,6 +275,45 @@ SPDesktopWidget::SPDesktopWidget()
ToolboxFactory::setOrientation( dtw->tool_toolbox, GTK_ORIENTATION_VERTICAL );
dtw->_hbox->pack_start(*Glib::wrap(dtw->tool_toolbox), false, true);
+ auto set_visible_buttons = [=](GtkWidget* tb) {
+ sp_traverse_widget_tree(Glib::wrap(tb), [=](Gtk::Widget* widget) {
+ if (auto flowbox = dynamic_cast(widget)) {
+ flowbox->show();
+ flowbox->set_no_show_all();
+ }
+ else if (auto btn = dynamic_cast(widget)) {
+ auto name = sp_get_action_target(widget);
+ auto show = prefs->getBool(ToolboxFactory::tools_visible_buttons + name, true);
+ auto parent = btn->get_parent();
+ if (show) {
+ parent->show();
+ }
+ else {
+ parent->hide();
+ }
+ }
+ return false;
+ });
+ };
+ auto set_toolbar_prefs = [=]() {
+ int min = ToolboxFactory::min_pixel_size;
+ int max = ToolboxFactory::max_pixel_size;
+ int s = prefs->getIntLimited(ToolboxFactory::tools_icon_size, min, min, max);
+ ToolboxFactory::set_icon_size(tool_toolbox, s);
+ set_visible_buttons(tool_toolbox);
+
+ int size = prefs->getIntLimited(ToolboxFactory::ctrlbars_icon_size, min, min, max);
+ ToolboxFactory::set_icon_size(snap_toolbox, size);
+ ToolboxFactory::set_icon_size(commands_toolbox, size);
+ ToolboxFactory::set_icon_size(aux_toolbox, size);
+ };
+
+ // watch for changes
+ _tb_icon_sizes = prefs->createObserver("/toolbox", [=]() { set_toolbar_prefs(); });
+
+ // restore preferences
+ set_toolbar_prefs();
+
/* Canvas Grid (canvas, rulers, scrollbars, etc.) */
dtw->_canvas_grid = Gtk::manage(new Inkscape::UI::Widget::CanvasGrid(this));
diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h
index 0768636f02cd6afa9759a46bca2dbed9cf0eb179..0a4970ad4ee5acef8df1c0465eee5fb5cb0a347f 100644
--- a/src/widgets/desktop-widget.h
+++ b/src/widgets/desktop-widget.h
@@ -22,6 +22,7 @@
#include
#include "message.h"
+#include "preferences.h"
#include "ui/view/view-widget.h"
#include "preferences.h"
@@ -219,6 +220,7 @@ private:
GtkWidget *aux_toolbox;
GtkWidget *commands_toolbox;
GtkWidget *snap_toolbox;
+ Inkscape::PrefObserver _tb_icon_sizes;
void namedviewModified(SPObject *obj, guint flags);
int zoom_input(double *new_val);
diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp
index a151aff68bfce462edd29c64f3914d301c4c4a25..13347d959f47f632e93da77550674f6d70f95645 100644
--- a/src/widgets/spw-utilities.cpp
+++ b/src/widgets/spw-utilities.cpp
@@ -190,6 +190,20 @@ Gtk::Widget* sp_find_focusable_widget(Gtk::Widget* widget) {
return sp_traverse_widget_tree(widget, [](Gtk::Widget* w) { return w->get_can_focus(); });
}
+
+Glib::ustring sp_get_action_target(Gtk::Widget* widget) {
+ Glib::ustring target;
+
+ if (widget && GTK_IS_ACTIONABLE(widget->gobj())) {
+ auto variant = gtk_actionable_get_action_target_value(GTK_ACTIONABLE(widget->gobj()));
+ auto type = variant ? g_variant_get_type_string(variant) : nullptr;
+ if (type && strcmp(type, "s") == 0) {
+ target = g_variant_get_string(variant, nullptr);
+ }
+ }
+
+ return target;
+}
/*
Local Variables:
mode:c++
diff --git a/src/widgets/spw-utilities.h b/src/widgets/spw-utilities.h
index 1a534a132a741a9b15c0fb22755e81de33e1836d..fc37792b3ed586992b1584c5b922a0259a09a3c1 100644
--- a/src/widgets/spw-utilities.h
+++ b/src/widgets/spw-utilities.h
@@ -44,6 +44,9 @@ Gtk::Widget* sp_traverse_widget_tree(Gtk::Widget* widget, const std::functiongetIntLimited( path, base, 0, G_N_ELEMENTS(sizeChoices) );
- return sizeChoices[index];
+ int size = prefs->getIntLimited(path, 16, 16, 48);
+ return size;
+}
+
+void ToolboxFactory::set_icon_size(GtkWidget* toolbox, int pixel_size) {
+ sp_traverse_widget_tree(Glib::wrap(toolbox), [=](Gtk::Widget* widget) {
+ if (auto ico = dynamic_cast(widget)) {
+ ico->set_from_icon_name(ico->get_icon_name(), static_cast(Gtk::ICON_SIZE_BUTTON));
+ ico->set_pixel_size(pixel_size);
+ }
+ return false;
+ });
}
Gtk::IconSize ToolboxFactory::prefToSize_mm(Glib::ustring const &path, int base)
@@ -254,7 +258,6 @@ static Glib::RefPtr create_or_fetch_actions( SPDesktop* deskto
SP_VERB_SELECTION_UNGROUP,
};
- GtkIconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/small");
Glib::RefPtr mainActions;
if (desktop == nullptr)
{
@@ -275,7 +278,7 @@ static Glib::RefPtr create_or_fetch_actions( SPDesktop* deskto
Inkscape::Verb* verb = Inkscape::Verb::get(i);
if ( verb ) {
if (!mainActions->get_action(verb->get_id())) {
- GtkAction* act = create_action_for_verb( verb, view, toolboxSize );
+ GtkAction* act = create_action_for_verb( verb, view, GTK_ICON_SIZE_MENU);
mainActions->add(Glib::wrap(act));
}
}
@@ -323,21 +326,12 @@ GtkWidget *ToolboxFactory::createToolToolbox()
std::cerr << "ToolboxFactor::createToolToolbox: " << tool_toolbar_builder_file << " file not read! " << ex.what() << std::endl;
}
- Gtk::Toolbar* toolbar = nullptr;
+ Gtk::FlowBox* toolbar = nullptr;
builder->get_widget("tool-toolbar", toolbar);
if (!toolbar) {
std::cerr << "InkscapeWindow: Failed to load tool toolbar!" << std::endl;
} else {
gtk_box_pack_start(GTK_BOX(tb), GTK_WIDGET(toolbar->gobj()), false, false, 0);
-
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if ( prefs->getBool("/toolbox/icononly", true) ) {
- toolbar->set_toolbar_style( Gtk::TOOLBAR_ICONS );
- }
-
- // TODO: Change preference path!
- GtkIconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/tools/small", 1);
- toolbar->set_icon_size (static_cast(toolboxSize));
}
return toolboxNewCommon( tb, BAR_TOOL, GTK_POS_LEFT );
@@ -401,9 +395,6 @@ GtkWidget *ToolboxFactory::createSnapToolbox()
toolbar->set_toolbar_style( Gtk::TOOLBAR_ICONS );
}
simple_snap = prefs->getBool("/toolbox/simplesnap", simple_snap);
-
- GtkIconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
- toolbar->set_icon_size (static_cast(toolboxSize));
}
Gtk::ToolItem* item_simple = nullptr;
@@ -541,8 +532,8 @@ static void setupToolboxCommon( GtkWidget *toolbox,
gtk_toolbar_set_style( GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS );
}
- GtkIconSize toolboxSize = ToolboxFactory::prefToSize(sizePref);
- gtk_toolbar_set_icon_size( GTK_TOOLBAR(toolBar), static_cast(toolboxSize) );
+ int pixel_size = ToolboxFactory::prefToPixelSize(sizePref);
+ ToolboxFactory::set_icon_size(toolBar, pixel_size);
GtkPositionType pos = static_cast(GPOINTER_TO_INT(g_object_get_data( G_OBJECT(toolbox), HANDLE_POS_MARK )));
orientation = ((pos == GTK_POS_LEFT) || (pos == GTK_POS_RIGHT)) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL;
@@ -675,8 +666,8 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
gtk_toolbar_set_style( GTK_TOOLBAR(sub_toolbox), GTK_TOOLBAR_ICONS );
}
- GtkIconSize toolboxSize = ToolboxFactory::prefToSize("/toolbox/small");
- gtk_toolbar_set_icon_size( GTK_TOOLBAR(sub_toolbox), static_cast(toolboxSize) );
+ int pixel_size = ToolboxFactory::prefToPixelSize(ToolboxFactory::ctrlbars_icon_size);
+ ToolboxFactory::set_icon_size(sub_toolbox, pixel_size);
gtk_widget_set_hexpand(sub_toolbox, TRUE);
// Add a swatch widget if swatch tooltip is defined.
@@ -740,7 +731,7 @@ void update_aux_toolbox(SPDesktop * /*desktop*/, ToolBase *eventcontext, GtkWidg
void setup_commands_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
{
- setupToolboxCommon(toolbox, desktop, "toolbar-commands.ui", "/ui/CommandsToolbar", "/toolbox/small");
+ setupToolboxCommon(toolbox, desktop, "toolbar-commands.ui", "/ui/CommandsToolbar", ToolboxFactory::ctrlbars_icon_size);
}
void update_commands_toolbox(SPDesktop * /*desktop*/, ToolBase * /*eventcontext*/, GtkWidget * /*toolbox*/)
diff --git a/src/widgets/toolbox.h b/src/widgets/toolbox.h
index e500cb18f02b0a343d0518329ea138235b121a6a..901cb294400372e0cabafad9dbcc6480211815ce 100644
--- a/src/widgets/toolbox.h
+++ b/src/widgets/toolbox.h
@@ -42,10 +42,17 @@ public:
static Glib::ustring getToolboxName(GtkWidget* toolbox);
- static GtkIconSize prefToSize(Glib::ustring const &path, int base = 0 );
+ static int prefToPixelSize(Glib::ustring const& path);
static Gtk::IconSize prefToSize_mm(Glib::ustring const &path, int base = 0);
+ static void set_icon_size(GtkWidget* toolbox, int pixel_size);
ToolboxFactory() = delete;
+
+ static constexpr const char* tools_icon_size = "/toolbox/tools/iconsize";
+ static constexpr const char* tools_visible_buttons = "/toolbox/tools/buttons/show";
+ static constexpr const char* ctrlbars_icon_size = "/toolbox/controlbars/iconsize";
+ static constexpr const int min_pixel_size = 16;
+ static constexpr const int max_pixel_size = 48;
};