From d022543be3b0968c4a6851c120b78b289c156e8e Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 15 Nov 2017 18:17:25 +0100 Subject: Catch Gtk::IconThemeError --- src/ui/widget/dock-item.cpp | 7 ++++++- src/ui/widget/imagetoggler.cpp | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp index 18ab70eb4..4a06163e1 100644 --- a/src/ui/widget/dock-item.cpp +++ b/src/ui/widget/dock-item.cpp @@ -45,7 +45,12 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l int width = 0; int height = 0; Gtk::IconSize::lookup(Gtk::ICON_SIZE_MENU, width, height); - _icon_pixbuf = iconTheme->load_icon(icon_name, width); + try { + _icon_pixbuf = iconTheme->load_icon(icon_name, width); + } + catch (const Gtk::IconThemeError& e) { + std::cerr << "DocItem::DocItem(): " << e.what() << std::endl; + } } if ( _icon_pixbuf ) { diff --git a/src/ui/widget/imagetoggler.cpp b/src/ui/widget/imagetoggler.cpp index a2783ecb1..38c84ca51 100644 --- a/src/ui/widget/imagetoggler.cpp +++ b/src/ui/widget/imagetoggler.cpp @@ -16,6 +16,8 @@ #include "widgets/toolbox.h" #include "ui/icon-names.h" +#include + namespace Inkscape { namespace UI { namespace Widget { @@ -37,8 +39,13 @@ ImageToggler::ImageToggler( char const* on, char const* off) : int phys = width; Glib::RefPtr icon_theme = Gtk::IconTheme::get_default(); - _property_pixbuf_on = icon_theme->load_icon(_pixOnName, phys, (Gtk::IconLookupFlags)0); - _property_pixbuf_off = icon_theme->load_icon(_pixOffName, phys, (Gtk::IconLookupFlags)0); + try { + _property_pixbuf_on = icon_theme->load_icon(_pixOnName, phys, (Gtk::IconLookupFlags)0); + _property_pixbuf_off = icon_theme->load_icon(_pixOffName, phys, (Gtk::IconLookupFlags)0); + } + catch (const Gtk::IconThemeError& e) { + std::cerr << "ImageToggler::ImageToggler(): " << e.what() << std::endl; + } property_pixbuf() = _property_pixbuf_off.get_value(); } -- cgit v1.2.3 From 1dfb2e9909f35cb96e4b697b62fe9e613ee50d61 Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Wed, 15 Nov 2017 19:36:31 +0100 Subject: Add auto update margins on checkbutton --- src/ui/widget/page-sizer.cpp | 28 +++++++++++++++++++++++++--- src/ui/widget/page-sizer.h | 4 ++++ 2 files changed, 29 insertions(+), 3 deletions(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 06d54b682..521a67604 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -481,6 +481,7 @@ PageSizer::init () _changedvy_connection = _viewboxY.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); _changedvw_connection = _viewboxW.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); _changedvh_connection = _viewboxH.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); + _changedlk_connection = _marginLock.signal_clicked().connect (sigc::mem_fun (*this, &PageSizer::on_margin_lock_changed)); _changedmt_connection = _marginTop.signal_value_changed().connect (sigc::bind(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginTop)); _changedmb_connection = _marginBottom.signal_value_changed().connect (sigc::bind(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginBottom)); _changedml_connection = _marginLeft.signal_value_changed().connect (sigc::bind(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginLeft)); @@ -903,9 +904,30 @@ PageSizer::on_viewbox_changed() } } -/** - * Callback for viewbox widgets - */ +void +PageSizer::on_margin_lock_changed() +{ + if (_marginLock.get_active()) { + double left = _marginLeft.getValue(); + double right = _marginRight.getValue(); + double top = _marginTop.getValue(); + double bottom = _marginBottom.getValue(); + if (Geom::are_near(left,right)) { + if (Geom::are_near(left, top)) { + on_margin_changed(&_marginBottom); + } else { + on_margin_changed(&_marginTop); + } + } else { + if (Geom::are_near(left, top)) { + on_margin_changed(&_marginRight); + } else { + on_margin_changed(&_marginLeft); + } + } + } +} + void PageSizer::on_margin_changed(RegisteredScalar* widg) { diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index 7cf8bacfd..6a8403627 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -166,6 +166,9 @@ public: * Updates the margin widgets. If lock widget is active */ void on_margin_changed(RegisteredScalar* widg); + + void on_margin_lock_changed(); + /** * Updates the scale widgets. (Just changes the values of the ui widgets.) */ @@ -271,6 +274,7 @@ protected: sigc::connection _changedvy_connection; sigc::connection _changedvw_connection; sigc::connection _changedvh_connection; + sigc::connection _changedlk_connection; sigc::connection _changedmt_connection; sigc::connection _changedmb_connection; sigc::connection _changedml_connection; -- cgit v1.2.3 From 80216e644715b722adb1c12ca22d4414e95cb7d6 Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Wed, 15 Nov 2017 20:31:33 +0100 Subject: Fix unincilizated value that not work in release mode. also remove duplicate variable --- src/ui/widget/page-sizer.cpp | 6 +++--- src/ui/widget/page-sizer.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 521a67604..bed86089c 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -933,13 +933,13 @@ PageSizer::on_margin_changed(RegisteredScalar* widg) { double value = widg->getValue(); if (_widgetRegistry->isUpdating()) return; - if (_marginLock.get_active() && !_marginLocked) { - _marginLocked = true; + if (_marginLock.get_active() && !_lockMarginUpdate) { + _lockMarginUpdate = true; _marginLeft.setValue(value); _marginRight.setValue(value); _marginTop.setValue(value); _marginBottom.setValue(value); - _marginLocked = false; + _lockMarginUpdate = false; } } diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index 6a8403627..c84780677 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -240,7 +240,6 @@ protected: RegisteredScalar _marginBottom; Gtk::Button _fitPageButton; bool _lockMarginUpdate; - bool _marginLocked; // Document scale Gtk::Frame _scaleFrame; -- cgit v1.2.3 From f72cca74858a0b6e5227f18b9be82203aab551c9 Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Thu, 16 Nov 2017 17:15:37 +0100 Subject: Add tooggle icon button intead checkbox --- src/ui/widget/page-sizer.cpp | 21 ++++++++++++++++----- src/ui/widget/page-sizer.h | 17 +++++++++-------- 2 files changed, 25 insertions(+), 13 deletions(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index bed86089c..b9c5b34ba 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -219,7 +219,8 @@ PageSizer::PageSizer(Registry & _wr) _dimensionUnits( _("U_nits:"), "units", _wr ), _dimensionWidth( _("_Width:"), _("Width of paper"), "width", _dimensionUnits, _wr ), _dimensionHeight( _("_Height:"), _("Height of paper"), "height", _dimensionUnits, _wr ), - _marginLock( _("L_ock"), _("Lock margins"), "lock-margins", _wr ), + _marginLock( _(""), _("Lock margins"), "lock-margins", _wr, false, NULL, NULL), + _lock_icon(), _marginTop( _("T_op margin:"), _("Top margin"), "fit-margin-top", _wr ), _marginLeft( _("L_eft:"), _("Left margin"), "fit-margin-left", _wr), _marginRight( _("Ri_ght:"), _("Right margin"), "fit-margin-right", _wr), @@ -249,7 +250,6 @@ PageSizer::PageSizer(Registry & _wr) _viewboxY.setDigits(2); _viewboxW.setDigits(2); _viewboxH.setDigits(2); - _dimensionWidth.setRange( 0.00001, 10000000 ); _dimensionHeight.setRange( 0.00001, 10000000 ); _scaleX.setRange( 0.00001, 100000 ); @@ -370,7 +370,6 @@ PageSizer::PageSizer(Registry & _wr) //## Set up margin settings _marginTable.set_border_width(4); - _marginTable.set_row_spacing(4); _marginTable.set_column_spacing(4); @@ -384,10 +383,19 @@ PageSizer::PageSizer(Registry & _wr) _marginLeft.set_hexpand(); _marginLeft.set_vexpand(); _marginTable.attach(_marginLeft, 0, 1, 1, 1); - + + _marginLock.set_active(false); _marginLock.set_halign(Gtk::ALIGN_CENTER); _marginLock.set_hexpand(); _marginLock.set_vexpand(); + + //_lock_icon = new Gtk::Image(); + _lock_icon.set_halign(Gtk::ALIGN_CENTER); + _lock_icon.set_valign(Gtk::ALIGN_START); + _lock_icon.set_from_icon_name("object-unlocked", Gtk::ICON_SIZE_LARGE_TOOLBAR); + _lock_icon.show(); + _marginLock.add(_lock_icon); + _marginTable.attach(_marginLock, 1, 1, 1, 1); _marginRight.set_halign(Gtk::ALIGN_CENTER); @@ -481,7 +489,7 @@ PageSizer::init () _changedvy_connection = _viewboxY.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); _changedvw_connection = _viewboxW.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); _changedvh_connection = _viewboxH.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); - _changedlk_connection = _marginLock.signal_clicked().connect (sigc::mem_fun (*this, &PageSizer::on_margin_lock_changed)); + _changedlk_connection = _marginLock.signal_toggled().connect (sigc::mem_fun (*this, &PageSizer::on_margin_lock_changed)); _changedmt_connection = _marginTop.signal_value_changed().connect (sigc::bind(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginTop)); _changedmb_connection = _marginBottom.signal_value_changed().connect (sigc::bind(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginBottom)); _changedml_connection = _marginLeft.signal_value_changed().connect (sigc::bind(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginLeft)); @@ -908,6 +916,7 @@ void PageSizer::on_margin_lock_changed() { if (_marginLock.get_active()) { + _lock_icon.set_from_icon_name("object-locked", Gtk::ICON_SIZE_LARGE_TOOLBAR); double left = _marginLeft.getValue(); double right = _marginRight.getValue(); double top = _marginTop.getValue(); @@ -925,6 +934,8 @@ PageSizer::on_margin_lock_changed() on_margin_changed(&_marginLeft); } } + } else { + _lock_icon.set_from_icon_name("object-unlocked", Gtk::ICON_SIZE_LARGE_TOOLBAR); } } diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index c84780677..29cd204b9 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -232,14 +232,15 @@ protected: //### Fit Page options Gtk::Expander _fitPageMarginExpander; - Gtk::Grid _marginTable; - RegisteredCheckButton _marginLock; - RegisteredScalar _marginTop; - RegisteredScalar _marginLeft; - RegisteredScalar _marginRight; - RegisteredScalar _marginBottom; - Gtk::Button _fitPageButton; - bool _lockMarginUpdate; + Gtk::Grid _marginTable; + RegisteredToggleButton _marginLock; + Gtk::Image _lock_icon; + RegisteredScalar _marginTop; + RegisteredScalar _marginLeft; + RegisteredScalar _marginRight; + RegisteredScalar _marginBottom; + Gtk::Button _fitPageButton; + bool _lockMarginUpdate; // Document scale Gtk::Frame _scaleFrame; -- cgit v1.2.3 From e6ad9a51d3222a8842a2d0819e7e58e7bd7f5fa7 Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Thu, 16 Nov 2017 17:22:12 +0100 Subject: Add label --- src/ui/widget/page-sizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/widget') diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index b9c5b34ba..7a3909975 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -219,7 +219,7 @@ PageSizer::PageSizer(Registry & _wr) _dimensionUnits( _("U_nits:"), "units", _wr ), _dimensionWidth( _("_Width:"), _("Width of paper"), "width", _dimensionUnits, _wr ), _dimensionHeight( _("_Height:"), _("Height of paper"), "height", _dimensionUnits, _wr ), - _marginLock( _(""), _("Lock margins"), "lock-margins", _wr, false, NULL, NULL), + _marginLock( _("Loc_k margins"), _("Lock margins"), "lock-margins", _wr, false, NULL, NULL), _lock_icon(), _marginTop( _("T_op margin:"), _("Top margin"), "fit-margin-top", _wr ), _marginLeft( _("L_eft:"), _("Left margin"), "fit-margin-left", _wr), -- cgit v1.2.3