From e812fa60f70d86bc2c61d35f433da586e92459fb Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Tue, 6 Aug 2019 23:39:57 +0200 Subject: [PATCH 01/24] working on draging panned --- src/ui/dialog/xml-tree.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 91c24bd4cd..fd838e6451 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -239,6 +239,18 @@ XmlTree::XmlTree() : bool XmlTree::_resized(GdkEventButton *event) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool dir = !prefs->getBool("/dialogs/xml/vertical", true); + int max = int(_paned.property_max_position ()*0.95); + int min = int(_paned.property_max_position ()*0.05); + bool attrtoggler = prefs->getBool("/dialogs/xml/attrtoggler", true); + std::cout << _paned.property_max_position () << std::endl; + std::cout << max << std::endl; + if (attrtoggler && _paned.get_position() > max) { + _paned.property_position() = max; + } + if (attrtoggler && _paned.get_position() < min) { + _paned.property_position() = min; + } prefs->setInt("/dialogs/xml/panedpos", _paned.get_position()); return true; } @@ -249,9 +261,9 @@ void XmlTree::_toggleDirection() bool dir = !prefs->getBool("/dialogs/xml/vertical", true); prefs->setBool("/dialogs/xml/vertical", dir); _paned.set_orientation(dir ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL); - int widthpos = _paned.property_max_position(); - prefs->setInt("/dialogs/xml/panedpos", widthpos / 2); - _paned.set_position(widthpos / 2); + int size = _paned.property_max_position () - _paned.property_min_position(); + prefs->setInt("/dialogs/xml/panedpos", size / 2); + _paned.property_position() = size / 2; } void XmlTree::_attrtoggler() @@ -263,7 +275,7 @@ void XmlTree::_attrtoggler() attributes->show(); _dirtogglerlabel->show(); _direction.show(); - int widthpos = _paned.property_max_position(); + int widthpos = _paned.property_max_position() - _paned.property_min_position(); prefs->setInt("/dialogs/xml/panedpos", widthpos / 2); _paned.set_position(widthpos / 2); } else { -- GitLab From 49db3467ced4b278bdcb0f6aba3b790637d16726 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 17 Aug 2019 02:42:36 +0200 Subject: [PATCH 02/24] Noumerous bug fixes from Maren list --- .../Tango/scalable/actions/horizontal.svg | 157 ++++++++++++++++++ .../icons/Tango/scalable/actions/vertical.svg | 157 ++++++++++++++++++ .../hicolor/scalable/actions/horizontal.svg | 157 ++++++++++++++++++ .../hicolor/scalable/actions/vertical.svg | 157 ++++++++++++++++++ .../symbolic/actions/horizontal-symbolic.svg | 157 ++++++++++++++++++ .../symbolic/actions/vertical-symbolic.svg | 157 ++++++++++++++++++ share/ui/style.css | 7 + src/ui/dialog/attrdialog.cpp | 1 + src/ui/dialog/selectorsdialog.cpp | 62 +++++-- src/ui/dialog/selectorsdialog.h | 8 +- src/ui/dialog/xml-tree.cpp | 88 +++++----- src/ui/dialog/xml-tree.h | 10 +- 12 files changed, 1061 insertions(+), 57 deletions(-) create mode 100644 share/icons/Tango/scalable/actions/horizontal.svg create mode 100644 share/icons/Tango/scalable/actions/vertical.svg create mode 100644 share/icons/hicolor/scalable/actions/horizontal.svg create mode 100644 share/icons/hicolor/scalable/actions/vertical.svg create mode 100644 share/icons/hicolor/symbolic/actions/horizontal-symbolic.svg create mode 100644 share/icons/hicolor/symbolic/actions/vertical-symbolic.svg diff --git a/share/icons/Tango/scalable/actions/horizontal.svg b/share/icons/Tango/scalable/actions/horizontal.svg new file mode 100644 index 0000000000..41f42514a9 --- /dev/null +++ b/share/icons/Tango/scalable/actions/horizontal.svg @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + 13 Nov 2018 + + + Ramón Miranda + + + + + see the license tab + + + + + icon ui + + + This is a little contribution with Inkscape Project +Ramon Miranda www.ramonmiranda.com (design and SVG file) +Jabiertxo (SVG stuff to integrate them in UI) + + + + + + + + + - + + + + Ramon Miranda +Jabier Arraiza + + + + + + + + + + + + + + + + diff --git a/share/icons/Tango/scalable/actions/vertical.svg b/share/icons/Tango/scalable/actions/vertical.svg new file mode 100644 index 0000000000..d625d28679 --- /dev/null +++ b/share/icons/Tango/scalable/actions/vertical.svg @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + 13 Nov 2018 + + + Ramón Miranda + + + + + see the license tab + + + + + icon ui + + + This is a little contribution with Inkscape Project +Ramon Miranda www.ramonmiranda.com (design and SVG file) +Jabiertxo (SVG stuff to integrate them in UI) + + + + + + + + + - + + + + Ramon Miranda +Jabier Arraiza + + + + + + + + + + + + + + + + diff --git a/share/icons/hicolor/scalable/actions/horizontal.svg b/share/icons/hicolor/scalable/actions/horizontal.svg new file mode 100644 index 0000000000..41f42514a9 --- /dev/null +++ b/share/icons/hicolor/scalable/actions/horizontal.svg @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + 13 Nov 2018 + + + Ramón Miranda + + + + + see the license tab + + + + + icon ui + + + This is a little contribution with Inkscape Project +Ramon Miranda www.ramonmiranda.com (design and SVG file) +Jabiertxo (SVG stuff to integrate them in UI) + + + + + + + + + - + + + + Ramon Miranda +Jabier Arraiza + + + + + + + + + + + + + + + + diff --git a/share/icons/hicolor/scalable/actions/vertical.svg b/share/icons/hicolor/scalable/actions/vertical.svg new file mode 100644 index 0000000000..d625d28679 --- /dev/null +++ b/share/icons/hicolor/scalable/actions/vertical.svg @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + 13 Nov 2018 + + + Ramón Miranda + + + + + see the license tab + + + + + icon ui + + + This is a little contribution with Inkscape Project +Ramon Miranda www.ramonmiranda.com (design and SVG file) +Jabiertxo (SVG stuff to integrate them in UI) + + + + + + + + + - + + + + Ramon Miranda +Jabier Arraiza + + + + + + + + + + + + + + + + diff --git a/share/icons/hicolor/symbolic/actions/horizontal-symbolic.svg b/share/icons/hicolor/symbolic/actions/horizontal-symbolic.svg new file mode 100644 index 0000000000..41f42514a9 --- /dev/null +++ b/share/icons/hicolor/symbolic/actions/horizontal-symbolic.svg @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + 13 Nov 2018 + + + Ramón Miranda + + + + + see the license tab + + + + + icon ui + + + This is a little contribution with Inkscape Project +Ramon Miranda www.ramonmiranda.com (design and SVG file) +Jabiertxo (SVG stuff to integrate them in UI) + + + + + + + + + - + + + + Ramon Miranda +Jabier Arraiza + + + + + + + + + + + + + + + + diff --git a/share/icons/hicolor/symbolic/actions/vertical-symbolic.svg b/share/icons/hicolor/symbolic/actions/vertical-symbolic.svg new file mode 100644 index 0000000000..d625d28679 --- /dev/null +++ b/share/icons/hicolor/symbolic/actions/vertical-symbolic.svg @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + 13 Nov 2018 + + + Ramón Miranda + + + + + see the license tab + + + + + icon ui + + + This is a little contribution with Inkscape Project +Ramon Miranda www.ramonmiranda.com (design and SVG file) +Jabiertxo (SVG stuff to integrate them in UI) + + + + + + + + + - + + + + Ramon Miranda +Jabier Arraiza + + + + + + + + + + + + + + + + diff --git a/share/ui/style.css b/share/ui/style.css index a7bed5d596..471985dd12 100644 --- a/share/ui/style.css +++ b/share/ui/style.css @@ -311,6 +311,13 @@ spinbutton undershoot { padding-bottom: 0; } +#XMLAndAttributesDialog .radio.image-button, +#SelectorsAndStyleDialog .radio.image-button { + margin:0; + border-radius:2px; + padding:0px; +} + #InkRuler { font-size: 7pt; } diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp index 3db739059d..b56c37b20c 100644 --- a/src/ui/dialog/attrdialog.cpp +++ b/src/ui/dialog/attrdialog.cpp @@ -113,6 +113,7 @@ AttrDialog::AttrDialog() status.set_size_request(1, -1); status.set_markup(""); status.set_line_wrap(true); + status.get_style_context()->add_class("inksmall"); status_box.pack_start(status, TRUE, TRUE, 0); _getContents()->pack_end(status_box, false, false, 2); diff --git a/src/ui/dialog/selectorsdialog.cpp b/src/ui/dialog/selectorsdialog.cpp index eda036c589..e5434f5c5f 100644 --- a/src/ui/dialog/selectorsdialog.cpp +++ b/src/ui/dialog/selectorsdialog.cpp @@ -21,6 +21,7 @@ #include "style.h" #include "verbs.h" #include "ui/icon-loader.h" +#include "ui/icon-names.h" #include "ui/widget/iconrenderer.h" #include "xml/attribute-record.h" @@ -404,19 +405,29 @@ void SelectorsDialog::_showWidgets() _vadj = _scrolled_window_selectors.get_vadjustment(); _vadj->signal_value_changed().connect(sigc::mem_fun(*this, &SelectorsDialog::_vscrool)); _selectors_box.pack_start(_scrolled_window_selectors, Gtk::PACK_EXPAND_WIDGET); - Gtk::Label *dirtogglerlabel = Gtk::manage(new Gtk::Label(_("Paned vertical"))); + /* Gtk::Label *dirtogglerlabel = Gtk::manage(new Gtk::Label(_("Paned vertical"))); dirtogglerlabel->get_style_context()->add_class("inksmall"); _direction.property_active() = dir; _direction.property_active().signal_changed().connect(sigc::mem_fun(*this, &SelectorsDialog::_toggleDirection)); - _direction.get_style_context()->add_class("inkswitch"); + _direction.get_style_context()->add_class("inkswitch"); */ _styleButton(_create, "list-add", "Add a new CSS Selector"); _create.signal_clicked().connect(sigc::mem_fun(*this, &SelectorsDialog::_addSelector)); _styleButton(_del, "list-remove", "Remove a CSS Selector"); _button_box.pack_start(_create, Gtk::PACK_SHRINK); _button_box.pack_start(_del, Gtk::PACK_SHRINK); - _button_box.pack_start(_direction, false, false, 0); - _button_box.pack_start(*dirtogglerlabel, false, false, 0); - _selectors_box.pack_end(_button_box, false, false, 0); + Gtk::RadioButton::Group group; + Gtk::RadioButton *_horizontal = Gtk::manage(new Gtk::RadioButton()); + Gtk::RadioButton *_vertical = Gtk::manage(new Gtk::RadioButton()); + _horizontal->set_image_from_icon_name(INKSCAPE_ICON("horizontal")); + _vertical->set_image_from_icon_name(INKSCAPE_ICON("vertical")); + _horizontal->set_group(group); + _vertical->set_group(group); + _vertical->set_active(dir); + _vertical->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &SelectorsDialog::_toggleDirection), _vertical)); + _horizontal->property_draw_indicator() = false; + _vertical->property_draw_indicator() = false; + _button_box.pack_end(*_horizontal, false, false, 0); + _button_box.pack_end(*_vertical, false, false, 0); _del.signal_clicked().connect(sigc::mem_fun(*this, &SelectorsDialog::_delSelector)); _del.hide(); _style_dialog = new StyleDialog; @@ -424,36 +435,61 @@ void SelectorsDialog::_showWidgets() _paned.pack1(*_style_dialog, Gtk::SHRINK); _paned.pack2(_selectors_box, true, true); _getContents()->pack_start(_paned, Gtk::PACK_EXPAND_WIDGET); + _getContents()->pack_start(_button_box, false, false, 0); show_all(); int widthpos = _paned.property_max_position(); int panedpos = prefs->getInt("/dialogs/selectors/panedpos", 130); _paned.set_position(panedpos); _paned.property_wide_handle() = true; - _paned.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectorsDialog::_resized), false); + _paned.property_position().signal_changed().connect(sigc::mem_fun(*this, &SelectorsDialog::_childresized)); + _paned.signal_size_allocate().connect(sigc::mem_fun(*this, &SelectorsDialog::_panedresized)); set_size_request(320, 260); set_name("SelectorsAndStyleDialog"); } -bool SelectorsDialog::_resized(GdkEventButton *event) +void SelectorsDialog::_panedresized(Gtk::Allocation allocation) { + g_debug("SelectorsDialog::_panedresized"); + _resized(); +} + +void SelectorsDialog::_childresized() +{ + g_debug("SelectorsDialog::_childresized"); + _resized(); +} + +void SelectorsDialog::_resized() { g_debug("SelectorsDialog::_resized"); _scroollock = true; + if (_updating) { + return; + } + _updating = true; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool dir = !prefs->getBool("/dialogs/selectors/vertical", true); + int max = int(_paned.property_max_position() * 0.95); + int min = int(_paned.property_max_position() * 0.05); + if (_paned.get_position() > max) { + _paned.property_position() = max; + } + if (_paned.get_position() < min) { + _paned.property_position() = min; + } prefs->setInt("/dialogs/selectors/panedpos", _paned.get_position()); - return false; + _updating = false; } - -void SelectorsDialog::_toggleDirection() +void SelectorsDialog::_toggleDirection(Gtk::RadioButton *vertical) { g_debug("SelectorsDialog::_toggleDirection"); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool dir = !prefs->getBool("/dialogs/selectors/vertical", true); + bool dir = vertical->get_active(); prefs->setBool("/dialogs/selectors/vertical", dir); _paned.set_orientation(dir ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL); - int widthpos = _paned.property_max_position(); + _paned.check_resize(); + int widthpos = _paned.property_max_position() - _paned.property_min_position(); prefs->setInt("/dialogs/selectors/panedpos", widthpos / 2); _paned.set_position(widthpos / 2); } diff --git a/src/ui/dialog/selectorsdialog.h b/src/ui/dialog/selectorsdialog.h index 6830a0124e..57c579803b 100644 --- a/src/ui/dialog/selectorsdialog.h +++ b/src/ui/dialog/selectorsdialog.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "xml/helper-observer.h" @@ -120,7 +121,6 @@ class SelectorsDialog : public Widget::Panel { // Widgets Gtk::Paned _paned; Glib::RefPtr _vadj; - Gtk::Switch _direction; Gtk::Box _button_box; Gtk::Box _selectors_box; Gtk::ScrolledWindow _scrolled_window_selectors; @@ -146,9 +146,11 @@ class SelectorsDialog : public Widget::Panel { void _insertClass(SPObject *obj, const Glib::ustring &className); void _removeClass(const std::vector &objVec, const Glib::ustring &className, bool all = false); void _removeClass(SPObject *obj, const Glib::ustring &className, bool all = false); - void _toggleDirection(); + void _toggleDirection(Gtk::RadioButton *vertical); void _showWidgets(); - bool _resized(GdkEventButton *event); + void _resized(); + void _childresized(); + void _panedresized(Gtk::Allocation allocation); void _selectObjects(int, int); // Variables diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index fd838e6451..c87ff1c19d 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -66,7 +66,8 @@ XmlTree::XmlTree() : indent_node_button(), raise_node_button(), lower_node_button(), - new_window(nullptr) + new_window(nullptr), + _updating(false) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; @@ -79,6 +80,7 @@ XmlTree::XmlTree() : status.set_size_request(1, -1); status.set_markup(""); status.set_line_wrap(true); + status.get_style_context()->add_class("inksmall"); status_box.pack_start( status, TRUE, TRUE, 0); contents->pack_start(_paned, true, true, 0); contents->set_valign(Gtk::ALIGN_FILL); @@ -172,28 +174,34 @@ XmlTree::XmlTree() : Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool attrtoggler = prefs->getBool("/dialogs/xml/attrtoggler", true); bool dir = prefs->getBool("/dialogs/xml/vertical", true); - attributes = new AttrDialog; + attributes = new AttrDialog(); _paned.set_orientation(dir ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL); + _paned.check_resize(); _paned.pack1(node_box, Gtk::SHRINK); /* attributes */ Gtk::Box *actionsbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); actionsbox->set_valign(Gtk::ALIGN_START); Gtk::Label *attrtogglerlabel = Gtk::manage(new Gtk::Label(_("Show attributes"))); attrtogglerlabel->set_margin_right(5); - _attrswitch.property_active() = attrtoggler; _attrswitch.get_style_context()->add_class("inkswitch"); _attrswitch.property_active().signal_changed().connect(sigc::mem_fun(*this, &XmlTree::_attrtoggler)); + _attrswitch.property_active() = attrtoggler; attrtogglerlabel->get_style_context()->add_class("inksmall"); - _dirtogglerlabel = Gtk::manage(new Gtk::Label(_("Paned vertical"))); - _direction.property_active() = dir; - _direction.property_active().signal_changed().connect(sigc::mem_fun(*this, &XmlTree::_toggleDirection)); - _direction.get_style_context()->add_class("inkswitch"); - _dirtogglerlabel->get_style_context()->add_class("inksmall"); actionsbox->pack_start(_attrswitch, Gtk::PACK_SHRINK); actionsbox->pack_start(*attrtogglerlabel, Gtk::PACK_SHRINK); - actionsbox->pack_start(_direction, Gtk::PACK_SHRINK); - actionsbox->pack_start(*_dirtogglerlabel, Gtk::PACK_SHRINK); - + Gtk::RadioButton::Group group; + Gtk::RadioButton *_horizontal = Gtk::manage(new Gtk::RadioButton()); + Gtk::RadioButton *_vertical = Gtk::manage(new Gtk::RadioButton()); + _horizontal->set_image_from_icon_name(INKSCAPE_ICON("horizontal")); + _vertical->set_image_from_icon_name(INKSCAPE_ICON("vertical")); + _horizontal->set_group(group); + _vertical->set_group(group); + _vertical->set_active(dir); + _vertical->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &XmlTree::_toggleDirection), _vertical)); + _horizontal->property_draw_indicator() = false; + _vertical->property_draw_indicator() = false; + actionsbox->pack_end(*_horizontal, false, false, 0); + actionsbox->pack_end(*_vertical, false, false, 0); _paned.pack2(*attributes, true, true); contents->pack_start(*actionsbox, false, false, 0); /* Signal handlers */ @@ -213,22 +221,16 @@ XmlTree::XmlTree() : desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &XmlTree::set_tree_desktop) ); deskTrack.connect(GTK_WIDGET(gobj())); int widthpos = _paned.property_max_position(); - int panedpos = prefs->getInt("/dialogs/xml/panedpos", 130); - - _paned.set_position(panedpos); - _paned.signal_button_release_event().connect(sigc::mem_fun(*this, &XmlTree::_resized), - false); /* initial show/hide */ + _paned.property_position().signal_changed().connect(sigc::mem_fun(*this, &XmlTree::_childresized)); + _paned.signal_size_allocate().connect(sigc::mem_fun(*this, &XmlTree::_panedresized)); set_name("XMLAndAttributesDialog"); set_spacing(0); set_size_request(320, 260); show_all(); _paned.property_wide_handle() = true; - if (!attrtoggler) { - attributes->hide(); - _dirtogglerlabel->hide(); - _direction.hide(); - _paned.set_position(widthpos); - } + int panedpos = prefs->getInt("/dialogs/xml/panedpos", 130); + _paned.set_position(panedpos); + _resized(); tree_reset_context(); g_assert(desktop != nullptr); @@ -236,34 +238,50 @@ XmlTree::XmlTree() : } -bool XmlTree::_resized(GdkEventButton *event) +void XmlTree::_panedresized(Gtk::Allocation allocation) { + _resized(); +} + +void XmlTree::_childresized() +{ + _resized(); +} + +void XmlTree::_resized() { + if (_updating) { + return; + } + _updating = true; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool dir = !prefs->getBool("/dialogs/xml/vertical", true); - int max = int(_paned.property_max_position ()*0.95); - int min = int(_paned.property_max_position ()*0.05); + int max = int(_paned.property_max_position() * 0.95); + int min = int(_paned.property_max_position() * 0.05); bool attrtoggler = prefs->getBool("/dialogs/xml/attrtoggler", true); - std::cout << _paned.property_max_position () << std::endl; - std::cout << max << std::endl; if (attrtoggler && _paned.get_position() > max) { _paned.property_position() = max; } if (attrtoggler && _paned.get_position() < min) { _paned.property_position() = min; } + if (!attrtoggler) { + attributes->hide(); + _paned.property_position() = _paned.property_max_position(); + } prefs->setInt("/dialogs/xml/panedpos", _paned.get_position()); - return true; + _updating = false; } -void XmlTree::_toggleDirection() +void XmlTree::_toggleDirection(Gtk::RadioButton *vertical) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool dir = !prefs->getBool("/dialogs/xml/vertical", true); + bool dir = vertical->get_active(); prefs->setBool("/dialogs/xml/vertical", dir); _paned.set_orientation(dir ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL); - int size = _paned.property_max_position () - _paned.property_min_position(); - prefs->setInt("/dialogs/xml/panedpos", size / 2); - _paned.property_position() = size / 2; + _paned.check_resize(); + int widthpos = _paned.property_max_position() - _paned.property_min_position(); + prefs->setInt("/dialogs/xml/panedpos", widthpos / 2); + _paned.set_position(widthpos / 2); } void XmlTree::_attrtoggler() @@ -273,15 +291,11 @@ void XmlTree::_attrtoggler() prefs->setBool("/dialogs/xml/attrtoggler", attrtoggler); if (attrtoggler) { attributes->show(); - _dirtogglerlabel->show(); - _direction.show(); int widthpos = _paned.property_max_position() - _paned.property_min_position(); prefs->setInt("/dialogs/xml/panedpos", widthpos / 2); _paned.set_position(widthpos / 2); } else { attributes->hide(); - _dirtogglerlabel->hide(); - _direction.hide(); int widthpos = _paned.property_max_position(); _paned.set_position(widthpos); } diff --git a/src/ui/dialog/xml-tree.h b/src/ui/dialog/xml-tree.h index f9c3c1c026..d955c14708 100644 --- a/src/ui/dialog/xml-tree.h +++ b/src/ui/dialog/xml-tree.h @@ -24,6 +24,7 @@ #include #include #include +#include #include "message.h" @@ -166,8 +167,10 @@ private: void present() override; void _attrtoggler(); - void _toggleDirection(); - bool _resized(GdkEventButton *event); + void _toggleDirection(Gtk::RadioButton *vertical); + void _resized(); + void _childresized(); + void _panedresized(Gtk::Allocation allocation); bool in_dt_coordsys(SPObject const &item); /** @@ -180,6 +183,7 @@ private: */ gint blocked; + bool _updating; /** * Status bar */ @@ -217,8 +221,6 @@ private: Gtk::VBox node_box; Gtk::HBox status_box; Gtk::Switch _attrswitch; - Gtk::Switch _direction; - Gtk::Label *_dirtogglerlabel; Gtk::Label status; Gtk::Toolbar tree_toolbar; Gtk::ToolButton xml_element_new_button; -- GitLab From 0a9c53d4f6849dc27df78139af98e81d0dae9055 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 17 Aug 2019 10:49:38 +0200 Subject: [PATCH 03/24] css improvements --- share/ui/style.css | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/share/ui/style.css b/share/ui/style.css index 471985dd12..eff919fe75 100644 --- a/share/ui/style.css +++ b/share/ui/style.css @@ -314,8 +314,23 @@ spinbutton undershoot { #XMLAndAttributesDialog .radio.image-button, #SelectorsAndStyleDialog .radio.image-button { margin:0; - border-radius:2px; padding:0px; + border-radius:2px 0 0 2px; +} + +#XMLAndAttributesDialog .radio.image-button:last-child, +#SelectorsAndStyleDialog .radio.image-button:last-child { + border-radius:0 2px 2px 0; + border-left-width:0; +} + +#SelectorsAndStyleDialog treeview button{ + border-width:0; + margin:0 0 1px 0; +} + +switch image{ + color:transparent; } #InkRuler { -- GitLab From 7afbce6f330f62bd36bc8b33036d568af30e090d Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sat, 17 Aug 2019 12:25:23 +0200 Subject: [PATCH 04/24] Fix some Maren bugs --- src/ui/dialog/attrdialog.cpp | 8 +++++--- src/ui/dialog/selectorsdialog.cpp | 6 +++--- src/ui/dialog/styledialog.cpp | 10 +++++----- src/ui/dialog/xml-tree.cpp | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp index b56c37b20c..12d5fb46b5 100644 --- a/src/ui/dialog/attrdialog.cpp +++ b/src/ui/dialog/attrdialog.cpp @@ -108,6 +108,7 @@ AttrDialog::AttrDialog() if (_nameCol) { _nameCol->add_attribute(_nameRenderer->property_text(), _attrColumns._attributeName); } + _store->set_sort_column(1, Gtk::SortType::SORT_ASCENDING); status.set_halign(Gtk::ALIGN_START); status.set_valign(Gtk::ALIGN_CENTER); status.set_size_request(1, -1); @@ -236,6 +237,7 @@ void AttrDialog::onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, co } else { _store->erase(iter); } + break; } } if (new_value && strcmp(new_value, "") != 0) { @@ -244,7 +246,7 @@ void AttrDialog::onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, co { return; } else { - Gtk::TreeModel::Row row = *(_store->append()); + Gtk::TreeModel::Row row = *(_store->prepend()); row[_attrColumns._attributeName] = name; row[_attrColumns._attributeValue] = new_value; } @@ -258,7 +260,7 @@ void AttrDialog::onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, co bool AttrDialog::onAttrCreate(GdkEventButton *event) { if(event->type == GDK_BUTTON_RELEASE && event->button == 1 && this->_repr) { - Gtk::TreeIter iter = _store->append(); + Gtk::TreeIter iter = _store->prepend(); Gtk::TreeModel::Path path = (Gtk::TreeModel::Path)iter; _treeView.set_cursor(path, *_nameCol, true); grab_focus(); @@ -319,7 +321,7 @@ bool AttrDialog::onKeyPressed(GdkEventKey *event) case GDK_KEY_Insert: { // Create new attribute (repeat code, fold into above event!) - Gtk::TreeIter iter = this->_store->append(); + Gtk::TreeIter iter = this->_store->prepend(); Gtk::TreeModel::Path path = (Gtk::TreeModel::Path)iter; this->_treeView.set_cursor(path, *this->_nameCol, true); grab_focus(); diff --git a/src/ui/dialog/selectorsdialog.cpp b/src/ui/dialog/selectorsdialog.cpp index e5434f5c5f..e7ca0a8981 100644 --- a/src/ui/dialog/selectorsdialog.cpp +++ b/src/ui/dialog/selectorsdialog.cpp @@ -892,7 +892,7 @@ void SelectorsDialog::_addToSelector(Gtk::TreeModel::Row row) if (insertid) { multiselector = multiselector + ",#" + id; } - Gtk::TreeModel::Row childrow = *(_store->append(row->children())); + Gtk::TreeModel::Row childrow = *(_store->prepend(row->children())); childrow[_mColumns._colSelector] = "#" + Glib::ustring(id); childrow[_mColumns._colExpand] = false; childrow[_mColumns._colType] = OBJECT; @@ -1250,7 +1250,7 @@ void SelectorsDialog::_addSelector() } } objVec = _getObjVec(selectorValue); - Gtk::TreeModel::Row row = *(_store->append()); + Gtk::TreeModel::Row row = *(_store->prepend()); row[_mColumns._colExpand] = true; row[_mColumns._colType] = SELECTOR; row[_mColumns._colSelector] = selectorValue; @@ -1259,7 +1259,7 @@ void SelectorsDialog::_addSelector() row[_mColumns._colVisible] = true; row[_mColumns._colSelected] = 400; for (auto &obj : objVec) { - Gtk::TreeModel::Row childrow = *(_store->append(row->children())); + Gtk::TreeModel::Row childrow = *(_store->prepend(row->children())); childrow[_mColumns._colSelector] = "#" + Glib::ustring(obj->getId()); childrow[_mColumns._colExpand] = false; childrow[_mColumns._colType] = OBJECT; diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index 75b44f8318..b4db8defb9 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -520,7 +520,7 @@ void StyleDialog::_readStyleElement() attr_prop = parseStyle(style); for (auto iter : obj->style->properties()) { if (attr_prop.count(iter->name)) { - Gtk::TreeModel::Row row = *(store->append()); + Gtk::TreeModel::Row row = *(store->prepend()); row[_mColumns._colSelector] = "style_properties"; row[_mColumns._colSelectorPos] = 0; row[_mColumns._colActive] = true; @@ -701,7 +701,7 @@ void StyleDialog::_readStyleElement() } } else { for (auto iter : result_props) { - Gtk::TreeModel::Row row = *(store->append()); + Gtk::TreeModel::Row row = *(store->prepend()); row[_mColumns._colSelector] = selector; row[_mColumns._colSelectorPos] = selectorpos; row[_mColumns._colActive] = iter.second.second; @@ -774,7 +774,7 @@ void StyleDialog::_readStyleElement() col->add_attribute(value->property_strikethrough(), _mColumns._colStrike); } } - Gtk::TreeIter iterstore = store->append(); + Gtk::TreeIter iterstore = store->prepend(); Gtk::TreeModel::Path path = (Gtk::TreeModel::Path)iterstore; Gtk::TreeModel::Row row = *(iterstore); row[_mColumns._colSelector] = "attributes"; @@ -1017,7 +1017,7 @@ bool StyleDialog::_addRow(GdkEventButton *evt, Glib::RefPtr stor g_debug("StyleDialog::_addRow"); if (evt->type == GDK_BUTTON_RELEASE && evt->button == 1) { - Gtk::TreeIter iter = store->append(); + Gtk::TreeIter iter = store->prepend(); Gtk::TreeModel::Path path = (Gtk::TreeModel::Path)iter; Gtk::TreeModel::Row row = *(iter); row[_mColumns._colSelector] = selector; @@ -1050,7 +1050,7 @@ void StyleDialog::_setAutocompletion(Gtk::Entry *entry, SPStyleEnum const cssenu gint counter = 0; const char * key = cssenum[counter].key; while (key) { - Gtk::TreeModel::Row row = *(completionModel->append()); + Gtk::TreeModel::Row row = *(completionModel->prepend()); row[_mCSSData._colCSSData] = Glib::ustring(key); counter++; key = cssenum[counter].key; diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index c87ff1c19d..743b86126e 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -184,8 +184,8 @@ XmlTree::XmlTree() : Gtk::Label *attrtogglerlabel = Gtk::manage(new Gtk::Label(_("Show attributes"))); attrtogglerlabel->set_margin_right(5); _attrswitch.get_style_context()->add_class("inkswitch"); - _attrswitch.property_active().signal_changed().connect(sigc::mem_fun(*this, &XmlTree::_attrtoggler)); _attrswitch.property_active() = attrtoggler; + _attrswitch.property_active().signal_changed().connect(sigc::mem_fun(*this, &XmlTree::_attrtoggler)); attrtogglerlabel->get_style_context()->add_class("inksmall"); actionsbox->pack_start(_attrswitch, Gtk::PACK_SHRINK); actionsbox->pack_start(*attrtogglerlabel, Gtk::PACK_SHRINK); -- GitLab From f84ff313d45412726b7049f0365579dd4d2a16d3 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sat, 17 Aug 2019 18:08:41 +0200 Subject: [PATCH 05/24] improve styling ro raw images --- share/ui/style.css | 26 +++++++++++--------------- src/inkscape.cpp | 21 ++++++++++++++------- src/ui/dialog/symbols.cpp | 2 +- src/ui/dialog/xml-tree.cpp | 1 + 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/share/ui/style.css b/share/ui/style.css index eff919fe75..3abb805f17 100644 --- a/share/ui/style.css +++ b/share/ui/style.css @@ -109,17 +109,17 @@ image { background-image: image(@theme_fg_color); } -.invert :not(overshoot):not(undershoot):not(.rawimage) { +.invert :not(overshoot):not(undershoot):not(.rawstyle) { color: inherit; background-color: inherit; } -.dark .forcebright :not(overshoot):not(undershoot):not(.rawimage) { +.dark .forcebright :not(overshoot):not(undershoot):not(.rawstyle) { color: inherit; background-color: inherit; } -.bright .forcedark :not(overshoot):not(undershoot):not(.rawimage) { +.bright .forcedark :not(overshoot):not(undershoot):not(.rawstyle) { color: inherit; background-color: inherit; } @@ -313,24 +313,20 @@ spinbutton undershoot { #XMLAndAttributesDialog .radio.image-button, #SelectorsAndStyleDialog .radio.image-button { - margin:0; - padding:0px; - border-radius:2px 0 0 2px; + margin: 0; + padding: 0px; + border-radius: 2px 0 0 2px; } #XMLAndAttributesDialog .radio.image-button:last-child, #SelectorsAndStyleDialog .radio.image-button:last-child { - border-radius:0 2px 2px 0; - border-left-width:0; -} - -#SelectorsAndStyleDialog treeview button{ - border-width:0; - margin:0 0 1px 0; + border-radius: 0 2px 2px 0; + border-left-width: 0; } -switch image{ - color:transparent; +#SelectorsAndStyleDialog treeview button { + border-width: 0; + margin: 0 0 1px 0; } #InkRuler { diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 6614417293..053a966c1e 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -526,16 +526,23 @@ Glib::ustring Application::get_symbolic_colors() css_str += colornamederror; css_str += ";}"; css_str += "#InkRuler,"; - css_str += "image:not(.rawimage)"; + /* ":not(.rawstyle) > image" works only on images in first level of widget container + if in the future we use a complex widget with more levels and we dont want to tweak the color + here, retaining default we can add more lines like ":not(.rawstyle) > > image" */ + css_str += ":not(.rawstyle) > image"; css_str += "{color:"; css_str += colornamed; css_str += ";}"; - css_str += ".dark .forcebright image:not(.rawimage),"; - css_str += ".bright .forcedark image:not(.rawimage),"; - css_str += ".dark image.forcebright:not(.rawimage),"; - css_str += ".bright image.forcedark:not(.rawimage),"; - css_str += ".invert image:not(.rawimage),"; - css_str += "image.invert:not(.rawimage)"; + css_str += ".dark .forcebright :not(.rawstyle) > image,"; + css_str += ".dark .forcebright image:not(.rawstyle),"; + css_str += ".bright .forcedark :not(.rawstyle) > image,"; + css_str += ".bright .forcedark image:not(.rawstyle),"; + css_str += ".dark :not(.rawstyle) > image.forcebright,"; + css_str += ".dark image.forcebright:not(.rawstyle),"; + css_str += ".bright :not(.rawstyle) > image.forcedark,"; + css_str += ".bright image.forcedark:not(.rawstyle),"; + css_str += ".invert :not(.rawstyle) > image,"; + css_str += ".invert image:not(.rawstyle)"; css_str += "{color:"; css_str += colornamed_inverse; css_str += ";}"; diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index de5184058e..2ecf612d20 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -207,7 +207,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : overlay_opacity = new Gtk::Image(); overlay_opacity->set_halign(Gtk::ALIGN_START); overlay_opacity->set_valign(Gtk::ALIGN_START); - overlay_opacity->get_style_context()->add_class("rawimage"); + overlay_opacity->get_style_context()->add_class("rawstyle"); // No results overlay_icon = sp_get_icon_image("searching", Gtk::ICON_SIZE_DIALOG); diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 743b86126e..ef0e508676 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -184,6 +184,7 @@ XmlTree::XmlTree() : Gtk::Label *attrtogglerlabel = Gtk::manage(new Gtk::Label(_("Show attributes"))); attrtogglerlabel->set_margin_right(5); _attrswitch.get_style_context()->add_class("inkswitch"); + _attrswitch.get_style_context()->add_class("rawstyle"); _attrswitch.property_active() = attrtoggler; _attrswitch.property_active().signal_changed().connect(sigc::mem_fun(*this, &XmlTree::_attrtoggler)); attrtogglerlabel->get_style_context()->add_class("inksmall"); -- GitLab From e7f06273b6d520ba5118e7591a0f1cb73ae7d2ad Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 18 Aug 2019 23:08:56 +0200 Subject: [PATCH 06/24] Remove warnings and fix https://gitlab.com/inkscape/inkscape/issues/379 --- src/ui/dialog/attrdialog.cpp | 114 +++++++++++++++++++++++++++------- src/ui/dialog/attrdialog.h | 7 ++- src/ui/dialog/styledialog.cpp | 73 +++++++++++++++------- src/ui/dialog/styledialog.h | 6 +- 4 files changed, 154 insertions(+), 46 deletions(-) diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp index 12d5fb46b5..f5aa7ccd11 100644 --- a/src/ui/dialog/attrdialog.cpp +++ b/src/ui/dialog/attrdialog.cpp @@ -103,12 +103,13 @@ AttrDialog::AttrDialog() _nameRenderer->property_editable() = true; _nameRenderer->property_placeholder_text().set_value(_("Attribute Name")); _nameRenderer->signal_edited().connect(sigc::mem_fun(*this, &AttrDialog::nameEdited)); + _nameRenderer->signal_editing_started().connect(sigc::mem_fun(*this, &AttrDialog::startNameEdit)); + _treeView.append_column(_("Name"), *_nameRenderer); _nameCol = _treeView.get_column(1); if (_nameCol) { _nameCol->add_attribute(_nameRenderer->property_text(), _attrColumns._attributeName); } - _store->set_sort_column(1, Gtk::SortType::SORT_ASCENDING); status.set_halign(Gtk::ALIGN_START); status.set_valign(Gtk::ALIGN_CENTER); status.set_size_request(1, -1); @@ -128,6 +129,7 @@ AttrDialog::AttrDialog() _valueRenderer->property_placeholder_text().set_value(_("Attribute Value")); _valueRenderer->property_ellipsize().set_value(Pango::ELLIPSIZE_MIDDLE); _valueRenderer->signal_edited().connect(sigc::mem_fun(*this, &AttrDialog::valueEdited)); + _valueRenderer->signal_editing_started().connect(sigc::mem_fun(*this, &AttrDialog::startValueEdit)); _treeView.append_column(_("Value"), *_valueRenderer); _valueCol = _treeView.get_column(2); if (_valueCol) { @@ -135,12 +137,11 @@ AttrDialog::AttrDialog() } attr_reset_context(0); _getContents()->pack_start(_mainBox, Gtk::PACK_EXPAND_WIDGET); - setDesktop(getDesktop()); + _prev_cell = nullptr; + _updating = false; } - - /** * @brief AttrDialog::~AttrDialog * Class destructor @@ -154,6 +155,29 @@ AttrDialog::~AttrDialog() _message_changed_connection.~connection(); } +void AttrDialog::startNameEdit(Gtk::CellEditable *cell, const Glib::ustring &path) +{ + if (_prev_cell) { + cell->property_editing_canceled() = true; + _prev_cell = nullptr; + return; + } + Gtk::Entry *entry = dynamic_cast(cell); + entry->signal_key_press_event().connect(sigc::bind(sigc::mem_fun(*this, &AttrDialog::onNameKeyPressed), entry)); + _prev_cell = cell; +} + +void AttrDialog::startValueEdit(Gtk::CellEditable *cell, const Glib::ustring &path) +{ + if (_prev_cell) { + cell->property_editing_canceled() = true; + _prev_cell = nullptr; + return; + } + Gtk::Entry *entry = dynamic_cast(cell); + entry->signal_key_press_event().connect(sigc::bind(sigc::mem_fun(*this, &AttrDialog::onValueKeyPressed), entry)); + _prev_cell = cell; +} /** * @brief AttrDialog::setDesktop @@ -226,6 +250,9 @@ void AttrDialog::attr_reset_context(gint attr) */ void AttrDialog::onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, const gchar * new_value) { + if (_updating) { + return; + } for(auto iter: this->_store->children()) { Gtk::TreeModel::Row row = *iter; @@ -301,22 +328,24 @@ bool AttrDialog::onKeyPressed(GdkEventKey *event) if(this->_repr) { auto selection = this->_treeView.get_selection(); Gtk::TreeModel::Row row = *(selection->get_selected()); + Gtk::TreeIter iter = *(selection->get_selected()); + Gtk::TreeModel::Path modelpath = (Gtk::TreeModel::Path)iter; + bool ret = false; switch (event->keyval) { case GDK_KEY_Delete: case GDK_KEY_KP_Delete: - { - // Create new attribute (repeat code, fold into above event!) - Glib::ustring name = row[_attrColumns._attributeName]; - if(name == "content") { - return true; - } else { - this->_store->erase(row); - this->_repr->setAttribute(name.c_str(), nullptr, false); - this->setUndo(_("Delete attribute")); + { + // Create new attribute (repeat code, fold into above event!) + Glib::ustring name = row[_attrColumns._attributeName]; + if(name != "content") { + this->_store->erase(row); + this->_repr->setAttribute(name.c_str(), nullptr, false); + this->setUndo(_("Delete attribute")); + } + ret = true; } - return true; - } + break; case GDK_KEY_plus: case GDK_KEY_Insert: { @@ -325,13 +354,42 @@ bool AttrDialog::onKeyPressed(GdkEventKey *event) Gtk::TreeModel::Path path = (Gtk::TreeModel::Path)iter; this->_treeView.set_cursor(path, *this->_nameCol, true); grab_focus(); - return true; + ret = true; } + break; } } return false; } +bool AttrDialog::onNameKeyPressed(GdkEventKey *event, Gtk::Entry *entry) +{ + g_debug("StyleDialog::_onNameKeyPressed"); + bool ret = false; + switch (event->keyval) { + case GDK_KEY_Tab: + case GDK_KEY_KP_Tab: + entry->editing_done(); + ret = true; + break; + } + return ret; +} + + +bool AttrDialog::onValueKeyPressed(GdkEventKey *event, Gtk::Entry *entry) +{ + g_debug("StyleDialog::_onValueKeyPressed"); + bool ret = false; + switch (event->keyval) { + case GDK_KEY_Tab: + case GDK_KEY_KP_Tab: + entry->editing_done(); + ret = true; + break; + } + return ret; +} /** * @brief AttrDialog::nameEdited @@ -345,29 +403,33 @@ void AttrDialog::nameEdited (const Glib::ustring& path, const Glib::ustring& nam Gtk::TreeModel::Path modelpath = (Gtk::TreeModel::Path)iter; Gtk::TreeModel::Row row = *iter; if(row && this->_repr) { + _prev_cell = nullptr; Glib::ustring old_name = row[_attrColumns._attributeName]; if (old_name == name) { _treeView.set_cursor(modelpath, *_valueCol, true); grab_focus(); return; } - if (old_name == "content" || - old_name == name) - { + if (old_name == "content") { return; - } + } Glib::ustring value = row[_attrColumns._attributeValue]; // Move to editing value, we set the name as a temporary store value if (!old_name.empty()) { // Remove old named value + _updating = true; _repr->setAttribute(old_name.c_str(), nullptr, false); + _updating = false; } if (!name.empty()) { row[_attrColumns._attributeName] = name; - _repr->setAttribute(name.c_str(), value, false); _treeView.set_cursor(modelpath, *_valueCol, true); grab_focus(); + _updating = true; + _repr->setAttribute(name.c_str(), value, false); + _updating = false; } + this->setUndo(_("Rename attribute")); } } @@ -380,9 +442,12 @@ void AttrDialog::nameEdited (const Glib::ustring& path, const Glib::ustring& nam */ void AttrDialog::valueEdited (const Glib::ustring& path, const Glib::ustring& value) { + Gtk::TreeModel::Row row = *_store->get_iter(path); if(row && this->_repr) { + _prev_cell = nullptr; Glib::ustring name = row[_attrColumns._attributeName]; + Glib::ustring old_value = row[_attrColumns._attributeValue]; if(name.empty()) return; if (name == "content") { _repr->setContent(value.c_str()); @@ -392,7 +457,14 @@ void AttrDialog::valueEdited (const Glib::ustring& path, const Glib::ustring& va if(!value.empty()) { row[_attrColumns._attributeValue] = value; } + Inkscape::Selection *selection = _desktop->getSelection(); + SPObject *obj = nullptr; + if (selection->objects().size() == 1) { + obj = selection->objects().back(); + obj->style->readFromObject(obj); + obj->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + } this->setUndo(_("Change attribute value")); } } diff --git a/src/ui/dialog/attrdialog.h b/src/ui/dialog/attrdialog.h index 68ea14cc9f..c7a534d46c 100644 --- a/src/ui/dialog/attrdialog.h +++ b/src/ui/dialog/attrdialog.h @@ -73,12 +73,13 @@ public: Gtk::ScrolledWindow _scrolledWindow; Gtk::HBox _buttonBox; Gtk::Button _buttonAddAttribute; - // Variables - Inkscape SPDesktop* _desktop; Inkscape::XML::Node* _repr; Gtk::HBox status_box; Gtk::Label status; + Gtk::CellEditable *_prev_cell; + bool _updating; // Helper functions void setDesktop(SPDesktop* desktop) override; @@ -95,9 +96,13 @@ public: */ sigc::connection _message_changed_connection; void onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, const gchar * new_value); + bool onNameKeyPressed(GdkEventKey *event, Gtk::Entry *entry); + bool onValueKeyPressed(GdkEventKey *event, Gtk::Entry *entry); void onAttrDelete(Glib::ustring path); bool onAttrCreate(GdkEventButton *event); bool onKeyPressed(GdkEventKey *event); + void startNameEdit(Gtk::CellEditable *cell, const Glib::ustring &path); + void startValueEdit(Gtk::CellEditable *cell, const Glib::ustring &path); void nameEdited(const Glib::ustring &path, const Glib::ustring &name); void valueEdited(const Glib::ustring &path, const Glib::ustring &value); diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index b4db8defb9..40034dd146 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -223,6 +223,7 @@ StyleDialog::StyleDialog() _selection_changed_connection = getDesktop()->getSelection()->connectChanged( sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged))); + // Add watchers _updateWatchers(); @@ -1144,7 +1145,9 @@ StyleDialog::_startValueEdit(Gtk::CellEditable* cell, const Glib::ustring& path, _setAutocompletion(entry, enum_color_interpolation); } entry->signal_key_release_event().connect( - sigc::bind(sigc::mem_fun(*this, &StyleDialog::_onValueKeyReleased), cell)); + sigc::bind(sigc::mem_fun(*this, &StyleDialog::_onValueKeyReleased), entry)); + entry->signal_key_press_event().connect( + sigc::bind(sigc::mem_fun(*this, &StyleDialog::_onValueKeyPressed), entry)); } } @@ -1165,7 +1168,8 @@ void StyleDialog::_startNameEdit(Gtk::CellEditable *cell, const Glib::ustring &p } Gtk::Entry *entry = dynamic_cast(cell); entry->set_completion(entry_completion); - entry->signal_key_release_event().connect(sigc::bind(sigc::mem_fun(*this, &StyleDialog::_onNameKeyReleased), cell)); + entry->signal_key_release_event().connect(sigc::bind(sigc::mem_fun(*this, &StyleDialog::_onNameKeyReleased), entry)); + entry->signal_key_press_event().connect(sigc::bind(sigc::mem_fun(*this, &StyleDialog::_onNameKeyPressed), entry)); } /** @@ -1258,56 +1262,81 @@ void StyleDialog::_activeToggled(const Glib::ustring &path, Glib::RefPtrkeyval) { case GDK_KEY_Tab: case GDK_KEY_KP_Tab: - case GDK_KEY_colon: { - cell->editing_done(); - return true; - } + entry->editing_done(); + ret = true; + break; + } + return ret; +} + +bool StyleDialog::_onNameKeyReleased(GdkEventKey *event, Gtk::Entry *entry) +{ + g_debug("StyleDialog::_onNameKeyReleased"); + bool ret = false; + switch (event->keyval) { + case GDK_KEY_equal: + case GDK_KEY_colon: + entry->editing_done(); + ret = true; + break; case GDK_KEY_Shift_L: case GDK_KEY_Shift_R: case GDK_KEY_semicolon: { - Gtk::Entry *entry = dynamic_cast(cell); Glib::ustring text = entry->get_text(); auto i = std::min(text.find(";"), text.find(":")); if (i != std::string::npos) { - cell->editing_done(); - return true; + entry->editing_done(); + ret = true; } + break; } } - return false; + return ret; } -bool StyleDialog::_onValueKeyReleased(GdkEventKey *event, Gtk::CellEditable *cell) +bool StyleDialog::_onValueKeyPressed(GdkEventKey *event, Gtk::Entry *entry) { g_debug("StyleDialog::_onValueKeyReleased"); - + bool ret = false; switch (event->keyval) { case GDK_KEY_Tab: case GDK_KEY_KP_Tab: - case GDK_KEY_semicolon: { - cell->editing_done(); - return true; - } + entry->editing_done(); + ret = true; + break; + } + return ret; +} + +bool StyleDialog::_onValueKeyReleased(GdkEventKey *event, Gtk::Entry *entry) +{ + g_debug("StyleDialog::_onValueKeyReleased"); + bool ret = false; + switch (event->keyval) { + case GDK_KEY_semicolon: + entry->editing_done(); + ret = true; + break; case GDK_KEY_Shift_L: case GDK_KEY_Shift_R: case GDK_KEY_colon: { - Gtk::Entry *entry = dynamic_cast(cell); Glib::ustring text = entry->get_text(); auto i = std::min(text.find(";"), text.find(":")); if (i != std::string::npos) { - cell->editing_done(); - return true; + entry->editing_done(); + ret = true; } + break; } } - return false; + return ret; } void StyleDialog::_addWatcherRecursive(Inkscape::XML::Node *node) diff --git a/src/ui/dialog/styledialog.h b/src/ui/dialog/styledialog.h index 90b9d298fc..12ea5dcf04 100644 --- a/src/ui/dialog/styledialog.h +++ b/src/ui/dialog/styledialog.h @@ -132,8 +132,10 @@ class StyleDialog : public Widget::Panel { void _onPropDelete(Glib::ustring path, Glib::RefPtr store); void _nameEdited(const Glib::ustring &path, const Glib::ustring &name, Glib::RefPtr store, Gtk::TreeView *css_tree); - bool _onNameKeyReleased(GdkEventKey *event, Gtk::CellEditable *cell); - bool _onValueKeyReleased(GdkEventKey *event, Gtk::CellEditable *cell); + bool _onNameKeyReleased(GdkEventKey *event, Gtk::Entry *entry); + bool _onValueKeyReleased(GdkEventKey *event, Gtk::Entry *entry); + bool _onNameKeyPressed(GdkEventKey *event, Gtk::Entry *entry); + bool _onValueKeyPressed(GdkEventKey *event, Gtk::Entry *entry); void _onLinkObj(Glib::ustring path, Glib::RefPtr store); void _valueEdited(const Glib::ustring &path, const Glib::ustring &value, Glib::RefPtr store); void _startNameEdit(Gtk::CellEditable *cell, const Glib::ustring &path); -- GitLab From aa8d3c75b96437945e1fecbd853154d5acfa5bac Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 18 Aug 2019 23:11:32 +0200 Subject: [PATCH 07/24] Fix bug https://gitlab.com/inkscape/inkscape/issues/379 and remove editor warnings --- src/ui/dialog/attrdialog.cpp | 51 ++++++++++++++--------------- src/ui/dialog/selectorsdialog.cpp | 8 +++-- src/ui/dialog/selectorsdialog.h | 4 +-- src/ui/dialog/styledialog.cpp | 3 +- src/ui/dialog/xml-tree.cpp | 53 ++++++++++++++----------------- src/ui/dialog/xml-tree.h | 2 +- 6 files changed, 58 insertions(+), 63 deletions(-) diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp index f5aa7ccd11..0fd8c28c71 100644 --- a/src/ui/dialog/attrdialog.cpp +++ b/src/ui/dialog/attrdialog.cpp @@ -104,7 +104,7 @@ AttrDialog::AttrDialog() _nameRenderer->property_placeholder_text().set_value(_("Attribute Name")); _nameRenderer->signal_edited().connect(sigc::mem_fun(*this, &AttrDialog::nameEdited)); _nameRenderer->signal_editing_started().connect(sigc::mem_fun(*this, &AttrDialog::startNameEdit)); - + _treeView.append_column(_("Name"), *_nameRenderer); _nameCol = _treeView.get_column(1); if (_nameCol) { @@ -330,22 +330,20 @@ bool AttrDialog::onKeyPressed(GdkEventKey *event) Gtk::TreeModel::Row row = *(selection->get_selected()); Gtk::TreeIter iter = *(selection->get_selected()); Gtk::TreeModel::Path modelpath = (Gtk::TreeModel::Path)iter; - bool ret = false; + bool ret = false; switch (event->keyval) { case GDK_KEY_Delete: - case GDK_KEY_KP_Delete: - { - // Create new attribute (repeat code, fold into above event!) - Glib::ustring name = row[_attrColumns._attributeName]; - if(name != "content") { - this->_store->erase(row); - this->_repr->setAttribute(name.c_str(), nullptr, false); - this->setUndo(_("Delete attribute")); - } - ret = true; + case GDK_KEY_KP_Delete: { + // Create new attribute (repeat code, fold into above event!) + Glib::ustring name = row[_attrColumns._attributeName]; + if (name != "content") { + this->_store->erase(row); + this->_repr->setAttribute(name.c_str(), nullptr, false); + this->setUndo(_("Delete attribute")); } - break; + ret = true; + } break; case GDK_KEY_plus: case GDK_KEY_Insert: { @@ -355,8 +353,7 @@ bool AttrDialog::onKeyPressed(GdkEventKey *event) this->_treeView.set_cursor(path, *this->_nameCol, true); grab_focus(); ret = true; - } - break; + } break; } } return false; @@ -367,11 +364,11 @@ bool AttrDialog::onNameKeyPressed(GdkEventKey *event, Gtk::Entry *entry) g_debug("StyleDialog::_onNameKeyPressed"); bool ret = false; switch (event->keyval) { - case GDK_KEY_Tab: - case GDK_KEY_KP_Tab: - entry->editing_done(); - ret = true; - break; + case GDK_KEY_Tab: + case GDK_KEY_KP_Tab: + entry->editing_done(); + ret = true; + break; } return ret; } @@ -382,11 +379,11 @@ bool AttrDialog::onValueKeyPressed(GdkEventKey *event, Gtk::Entry *entry) g_debug("StyleDialog::_onValueKeyPressed"); bool ret = false; switch (event->keyval) { - case GDK_KEY_Tab: - case GDK_KEY_KP_Tab: - entry->editing_done(); - ret = true; - break; + case GDK_KEY_Tab: + case GDK_KEY_KP_Tab: + entry->editing_done(); + ret = true; + break; } return ret; } @@ -412,7 +409,7 @@ void AttrDialog::nameEdited (const Glib::ustring& path, const Glib::ustring& nam } if (old_name == "content") { return; - } + } Glib::ustring value = row[_attrColumns._attributeValue]; // Move to editing value, we set the name as a temporary store value if (!old_name.empty()) { @@ -429,7 +426,7 @@ void AttrDialog::nameEdited (const Glib::ustring& path, const Glib::ustring& nam _repr->setAttribute(name.c_str(), value, false); _updating = false; } - + this->setUndo(_("Rename attribute")); } } diff --git a/src/ui/dialog/selectorsdialog.cpp b/src/ui/dialog/selectorsdialog.cpp index e7ca0a8981..ead10eb942 100644 --- a/src/ui/dialog/selectorsdialog.cpp +++ b/src/ui/dialog/selectorsdialog.cpp @@ -19,10 +19,10 @@ #include "inkscape.h" #include "selection.h" #include "style.h" -#include "verbs.h" #include "ui/icon-loader.h" #include "ui/icon-names.h" #include "ui/widget/iconrenderer.h" +#include "verbs.h" #include "xml/attribute-record.h" #include "xml/node-observer.h" @@ -423,7 +423,8 @@ void SelectorsDialog::_showWidgets() _horizontal->set_group(group); _vertical->set_group(group); _vertical->set_active(dir); - _vertical->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &SelectorsDialog::_toggleDirection), _vertical)); + _vertical->signal_toggled().connect( + sigc::bind(sigc::mem_fun(*this, &SelectorsDialog::_toggleDirection), _vertical)); _horizontal->property_draw_indicator() = false; _vertical->property_draw_indicator() = false; _button_box.pack_end(*_horizontal, false, false, 0); @@ -448,7 +449,8 @@ void SelectorsDialog::_showWidgets() set_name("SelectorsAndStyleDialog"); } -void SelectorsDialog::_panedresized(Gtk::Allocation allocation) { +void SelectorsDialog::_panedresized(Gtk::Allocation allocation) +{ g_debug("SelectorsDialog::_panedresized"); _resized(); } diff --git a/src/ui/dialog/selectorsdialog.h b/src/ui/dialog/selectorsdialog.h index 57c579803b..8ca651f186 100644 --- a/src/ui/dialog/selectorsdialog.h +++ b/src/ui/dialog/selectorsdialog.h @@ -15,19 +15,19 @@ #ifndef SELECTORSDIALOG_H #define SELECTORSDIALOG_H -#include "ui/dialog/styledialog.h" #include "ui/dialog/desktop-tracker.h" #include "ui/dialog/dialog-manager.h" +#include "ui/dialog/styledialog.h" #include "ui/widget/panel.h" #include #include +#include #include #include #include #include #include #include -#include #include #include "xml/helper-observer.h" diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index 40034dd146..3b4d0f7f60 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -1168,7 +1168,8 @@ void StyleDialog::_startNameEdit(Gtk::CellEditable *cell, const Glib::ustring &p } Gtk::Entry *entry = dynamic_cast(cell); entry->set_completion(entry_completion); - entry->signal_key_release_event().connect(sigc::bind(sigc::mem_fun(*this, &StyleDialog::_onNameKeyReleased), entry)); + entry->signal_key_release_event().connect( + sigc::bind(sigc::mem_fun(*this, &StyleDialog::_onNameKeyReleased), entry)); entry->signal_key_press_event().connect(sigc::bind(sigc::mem_fun(*this, &StyleDialog::_onNameKeyPressed), entry)); } diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index ef0e508676..719d3cdbab 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -46,28 +46,28 @@ namespace Inkscape { namespace UI { namespace Dialog { -XmlTree::XmlTree() : - UI::Widget::Panel("/dialogs/xml/", SP_VERB_DIALOG_XML_EDITOR), - blocked (0), - _message_stack (nullptr), - _message_context (nullptr), - current_desktop (nullptr), - current_document (nullptr), - selected_attr (0), - selected_repr (nullptr), - tree (nullptr), - status (""), - tree_toolbar(), - xml_element_new_button ( _("New element node")), - xml_text_new_button ( _("New text node")), - xml_node_delete_button ( Q_("nodeAsInXMLdialogTooltip|Delete node")), - xml_node_duplicate_button ( _("Duplicate node")), - unindent_node_button(), - indent_node_button(), - raise_node_button(), - lower_node_button(), - new_window(nullptr), - _updating(false) +XmlTree::XmlTree() + : UI::Widget::Panel("/dialogs/xml/", SP_VERB_DIALOG_XML_EDITOR) + , blocked(0) + , _message_stack(nullptr) + , _message_context(nullptr) + , current_desktop(nullptr) + , current_document(nullptr) + , selected_attr(0) + , selected_repr(nullptr) + , tree(nullptr) + , status("") + , tree_toolbar() + , xml_element_new_button(_("New element node")) + , xml_text_new_button(_("New text node")) + , xml_node_delete_button(Q_("nodeAsInXMLdialogTooltip|Delete node")) + , xml_node_duplicate_button(_("Duplicate node")) + , unindent_node_button() + , indent_node_button() + , raise_node_button() + , lower_node_button() + , new_window(nullptr) + , _updating(false) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; @@ -239,14 +239,9 @@ XmlTree::XmlTree() : } -void XmlTree::_panedresized(Gtk::Allocation allocation) { - _resized(); -} +void XmlTree::_panedresized(Gtk::Allocation allocation) { _resized(); } -void XmlTree::_childresized() -{ - _resized(); -} +void XmlTree::_childresized() { _resized(); } void XmlTree::_resized() { diff --git a/src/ui/dialog/xml-tree.h b/src/ui/dialog/xml-tree.h index d955c14708..ea24ac52bb 100644 --- a/src/ui/dialog/xml-tree.h +++ b/src/ui/dialog/xml-tree.h @@ -19,12 +19,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include "message.h" -- GitLab From 7e19b9191315008654c655e4a630ad754096bd0c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Mon, 19 Aug 2019 00:10:15 +0200 Subject: [PATCH 08/24] Fix compiling issue --- src/ui/dialog/desktop-tracker.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/dialog/desktop-tracker.h b/src/ui/dialog/desktop-tracker.h index b681c9ca16..7b94390068 100644 --- a/src/ui/dialog/desktop-tracker.h +++ b/src/ui/dialog/desktop-tracker.h @@ -46,7 +46,7 @@ private: SPDesktop *base; SPDesktop *desktop; GtkWidget *widget; - gulong hierID; + unsigned long hierID; sigc::connection inkID; bool trackActive; sigc::signal desktopChangedSig; -- GitLab From 40b6f70127755d2b44597e56f5bd965083eda3f2 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Mon, 19 Aug 2019 21:09:30 +0200 Subject: [PATCH 09/24] Remove warnings and fix issue https://gitlab.com/inkscape/inkscape/issues/379 --- src/ui/dialog/attrdialog.cpp | 44 ++++++++++++++++++----------------- src/ui/dialog/attrdialog.h | 3 +-- src/ui/dialog/styledialog.cpp | 27 +++++++++++++++++---- src/ui/dialog/styledialog.h | 5 ++-- 4 files changed, 50 insertions(+), 29 deletions(-) diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp index 0fd8c28c71..3054bc92ce 100644 --- a/src/ui/dialog/attrdialog.cpp +++ b/src/ui/dialog/attrdialog.cpp @@ -72,6 +72,9 @@ AttrDialog::AttrDialog() set_size_request(20, 15); _mainBox.pack_start(_scrolledWindow, Gtk::PACK_EXPAND_WIDGET); _treeView.set_headers_visible(true); + _treeView.set_hover_selection(true); + _treeView.set_activate_on_single_click(true); + _treeView.set_can_focus(false); _scrolledWindow.add(_treeView); _scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); @@ -104,7 +107,6 @@ AttrDialog::AttrDialog() _nameRenderer->property_placeholder_text().set_value(_("Attribute Name")); _nameRenderer->signal_edited().connect(sigc::mem_fun(*this, &AttrDialog::nameEdited)); _nameRenderer->signal_editing_started().connect(sigc::mem_fun(*this, &AttrDialog::startNameEdit)); - _treeView.append_column(_("Name"), *_nameRenderer); _nameCol = _treeView.get_column(1); if (_nameCol) { @@ -138,7 +140,6 @@ AttrDialog::AttrDialog() attr_reset_context(0); _getContents()->pack_start(_mainBox, Gtk::PACK_EXPAND_WIDGET); setDesktop(getDesktop()); - _prev_cell = nullptr; _updating = false; } @@ -157,26 +158,14 @@ AttrDialog::~AttrDialog() void AttrDialog::startNameEdit(Gtk::CellEditable *cell, const Glib::ustring &path) { - if (_prev_cell) { - cell->property_editing_canceled() = true; - _prev_cell = nullptr; - return; - } Gtk::Entry *entry = dynamic_cast(cell); entry->signal_key_press_event().connect(sigc::bind(sigc::mem_fun(*this, &AttrDialog::onNameKeyPressed), entry)); - _prev_cell = cell; } void AttrDialog::startValueEdit(Gtk::CellEditable *cell, const Glib::ustring &path) { - if (_prev_cell) { - cell->property_editing_canceled() = true; - _prev_cell = nullptr; - return; - } Gtk::Entry *entry = dynamic_cast(cell); entry->signal_key_press_event().connect(sigc::bind(sigc::mem_fun(*this, &AttrDialog::onValueKeyPressed), entry)); - _prev_cell = cell; } /** @@ -329,7 +318,6 @@ bool AttrDialog::onKeyPressed(GdkEventKey *event) auto selection = this->_treeView.get_selection(); Gtk::TreeModel::Row row = *(selection->get_selected()); Gtk::TreeIter iter = *(selection->get_selected()); - Gtk::TreeModel::Path modelpath = (Gtk::TreeModel::Path)iter; bool ret = false; switch (event->keyval) { @@ -388,7 +376,21 @@ bool AttrDialog::onValueKeyPressed(GdkEventKey *event, Gtk::Entry *entry) return ret; } +gboolean sp_attrdialog_store_move_to_next(gpointer data) +{ + AttrDialog *attrdialog = reinterpret_cast(data); + auto selection = attrdialog->_treeView.get_selection(); + Gtk::TreeIter iter = *(selection->get_selected()); + Gtk::TreeModel::Path model = (Gtk::TreeModel::Path)iter; + if (model == attrdialog->modelpath ) { + attrdialog->_treeView.set_cursor(attrdialog->modelpath, *attrdialog->_valueCol, true); + } + return FALSE; +} + /** + * + * * @brief AttrDialog::nameEdited * @param event * @return @@ -397,13 +399,12 @@ bool AttrDialog::onValueKeyPressed(GdkEventKey *event, Gtk::Entry *entry) void AttrDialog::nameEdited (const Glib::ustring& path, const Glib::ustring& name) { Gtk::TreeIter iter = *_store->get_iter(path); - Gtk::TreeModel::Path modelpath = (Gtk::TreeModel::Path)iter; + modelpath = (Gtk::TreeModel::Path)iter; Gtk::TreeModel::Row row = *iter; if(row && this->_repr) { - _prev_cell = nullptr; Glib::ustring old_name = row[_attrColumns._attributeName]; if (old_name == name) { - _treeView.set_cursor(modelpath, *_valueCol, true); + g_timeout_add(50, &sp_attrdialog_store_move_to_next, this); grab_focus(); return; } @@ -420,13 +421,12 @@ void AttrDialog::nameEdited (const Glib::ustring& path, const Glib::ustring& nam } if (!name.empty()) { row[_attrColumns._attributeName] = name; - _treeView.set_cursor(modelpath, *_valueCol, true); grab_focus(); _updating = true; _repr->setAttribute(name.c_str(), value, false); _updating = false; + g_timeout_add(50, &sp_attrdialog_store_move_to_next, this); } - this->setUndo(_("Rename attribute")); } } @@ -442,9 +442,11 @@ void AttrDialog::valueEdited (const Glib::ustring& path, const Glib::ustring& va Gtk::TreeModel::Row row = *_store->get_iter(path); if(row && this->_repr) { - _prev_cell = nullptr; Glib::ustring name = row[_attrColumns._attributeName]; Glib::ustring old_value = row[_attrColumns._attributeValue]; + if (old_value == value) { + return; + } if(name.empty()) return; if (name == "content") { _repr->setContent(value.c_str()); diff --git a/src/ui/dialog/attrdialog.h b/src/ui/dialog/attrdialog.h index c7a534d46c..e40159e790 100644 --- a/src/ui/dialog/attrdialog.h +++ b/src/ui/dialog/attrdialog.h @@ -61,6 +61,7 @@ public: Gtk::CellRendererText *_valueRenderer; Gtk::TreeViewColumn *_nameCol; Gtk::TreeViewColumn *_valueCol; + Gtk::TreeModel::Path modelpath; /** * Status bar @@ -78,7 +79,6 @@ public: Inkscape::XML::Node* _repr; Gtk::HBox status_box; Gtk::Label status; - Gtk::CellEditable *_prev_cell; bool _updating; // Helper functions @@ -105,7 +105,6 @@ public: void startValueEdit(Gtk::CellEditable *cell, const Glib::ustring &path); void nameEdited(const Glib::ustring &path, const Glib::ustring &name); void valueEdited(const Glib::ustring &path, const Glib::ustring &value); - }; diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index 3b4d0f7f60..08e5ec69b5 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -1173,6 +1173,19 @@ void StyleDialog::_startNameEdit(Gtk::CellEditable *cell, const Glib::ustring &p entry->signal_key_press_event().connect(sigc::bind(sigc::mem_fun(*this, &StyleDialog::_onNameKeyPressed), entry)); } + +gboolean sp_styledialog_store_move_to_next(gpointer data) +{ + StyleDialog *styledialog = reinterpret_cast(data); + auto selection = styledialog->_current_css_tree->get_selection(); + Gtk::TreeIter iter = *(selection->get_selected()); + Gtk::TreeModel::Path model = (Gtk::TreeModel::Path)iter; + if (model == styledialog->_current_path) { + styledialog->_current_css_tree->set_cursor(styledialog->_current_path, *styledialog->_current_value_col, true); + } + return FALSE; +} + /** * @brief StyleDialog::nameEdited * @param event @@ -1186,9 +1199,10 @@ void StyleDialog::_nameEdited(const Glib::ustring &path, const Glib::ustring &na _scroollock = true; Gtk::TreeModel::Row row = *store->get_iter(path); - Gtk::TreeModel::Path pathel = (Gtk::TreeModel::Path)*store->get_iter(path); + _current_path = (Gtk::TreeModel::Path)*store->get_iter(path); if (row) { + _current_css_tree = css_tree; Glib::ustring finalname = name; auto i = std::min(finalname.find(";"), finalname.find(":")); if (i != std::string::npos) { @@ -1202,7 +1216,7 @@ void StyleDialog::_nameEdited(const Glib::ustring &path, const Glib::ustring &na Glib::ustring selector = row[_mColumns._colSelector]; Glib::ustring value = row[_mColumns._colValue]; bool is_attr = selector == "attributes"; - + Glib::ustring old_name = row[_mColumns._colName]; row[_mColumns._colName] = finalname; if (finalname.empty() && value.empty()) { store->erase(row); @@ -1211,10 +1225,11 @@ void StyleDialog::_nameEdited(const Glib::ustring &path, const Glib::ustring &na if (pos < 1 || is_attr) { col = 2; } - if (write) { + _current_value_col = css_tree->get_column(col); + if (write && old_name != name) { _writeStyleElement(store, selector); } else { - css_tree->set_cursor(pathel, *(css_tree->get_column(col)), true); + g_timeout_add(50, &sp_styledialog_store_move_to_next, this); grab_focus(); } } @@ -1240,6 +1255,10 @@ void StyleDialog::_valueEdited(const Glib::ustring &path, const Glib::ustring &v if (i != std::string::npos) { finalvalue.erase(i, finalvalue.size() - i); } + Glib::ustring old_value = row[_mColumns._colValue]; + if (old_value == finalvalue) { + return; + } row[_mColumns._colValue] = finalvalue; Glib::ustring selector = row[_mColumns._colSelector]; Glib::ustring name = row[_mColumns._colName]; diff --git a/src/ui/dialog/styledialog.h b/src/ui/dialog/styledialog.h index 12ea5dcf04..fd40597cad 100644 --- a/src/ui/dialog/styledialog.h +++ b/src/ui/dialog/styledialog.h @@ -67,7 +67,9 @@ class StyleDialog : public Widget::Panel { static StyleDialog &getInstance() { return *new StyleDialog(); } void setCurrentSelector(Glib::ustring current_selector); - + Gtk::TreeView *_current_css_tree; + Gtk::TreeViewColumn *_current_value_col; + Gtk::TreeModel::Path _current_path; private: // Monitor