From 817e61de278c79c005b3970fe4acaebcda20aabb Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Tue, 28 May 2019 11:13:27 +0200 Subject: working on selector dialog --- src/ui/dialog/attrdialog.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/ui/dialog/attrdialog.cpp') diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp index ce24e3272..974a1189a 100644 --- a/src/ui/dialog/attrdialog.cpp +++ b/src/ui/dialog/attrdialog.cpp @@ -20,6 +20,7 @@ #include "message-stack.h" #include "ui/icon-loader.h" #include "ui/widget/iconrenderer.h" +#include "style.h" #include "xml/node-event-vector.h" #include "xml/attribute-record.h" @@ -280,6 +281,7 @@ void AttrDialog::onAttrDelete(Glib::ustring path) this->_store->erase(row); this->_repr->setAttribute(name.c_str(), nullptr, false); this->setUndo(_("Delete attribute")); + reloadStyles(name); } } } @@ -308,6 +310,7 @@ bool AttrDialog::onKeyPressed(GdkEventKey *event) this->_store->erase(row); this->_repr->setAttribute(name.c_str(), nullptr, false); this->setUndo(_("Delete attribute")); + reloadStyles(name); } return true; } @@ -357,6 +360,28 @@ void AttrDialog::nameEdited (const Glib::ustring& path, const Glib::ustring& nam } } +/** + * @brief AttrDialog::valueEdited + * @param event + * @return + * Called when the value is edited in the TreeView editable column + */ +void AttrDialog::reloadStyles(Glib::ustring name) +{ + SPDocument *document = this->_desktop->doc(); + SPObject *obj = document->getObjectById(_repr->attribute("id")); + if (obj) { + for (auto iter : obj->style->properties()) { + if (iter->style_src != SP_STYLE_SRC_UNSET) { + if( iter->name == name) { + obj->style->readFromObject(obj); + obj->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + } + } + } + } +} + /** * @brief AttrDialog::valueEdited * @param event @@ -377,7 +402,8 @@ void AttrDialog::valueEdited (const Glib::ustring& path, const Glib::ustring& va if(!value.empty()) { row[_attrColumns._attributeValue] = value; } - + reloadStyles(name); + this->setUndo(_("Change attribute value")); } } -- cgit v1.2.3 From a2aa66acf986f27198468ba99e7fa6fd5307372f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 29 May 2019 10:16:32 +0200 Subject: Improvements to hadle whols CSS file --- src/ui/dialog/attrdialog.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/ui/dialog/attrdialog.cpp') diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp index 974a1189a..4e98ca1ef 100644 --- a/src/ui/dialog/attrdialog.cpp +++ b/src/ui/dialog/attrdialog.cpp @@ -235,7 +235,8 @@ void AttrDialog::onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, co } } } - if (new_value) { + std::cout << new_value << "aaa" << new_value << std::endl; + if (new_value && strcmp(new_value, "") != 0) { if ((repr->type() == Inkscape::XML::TEXT_NODE || repr->type() == Inkscape::XML::COMMENT_NODE) && strcmp(name, "content") != 0) { @@ -338,9 +339,16 @@ bool AttrDialog::onKeyPressed(GdkEventKey *event) */ void AttrDialog::nameEdited (const Glib::ustring& path, const Glib::ustring& name) { - Gtk::TreeModel::Row row = *_store->get_iter(path); + Gtk::TreeIter iter = this->_store->append(); + Gtk::TreeModel::Path modelpath = (Gtk::TreeModel::Path)iter; + Gtk::TreeModel::Row row = *iter; if(row && this->_repr) { 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) { @@ -353,8 +361,10 @@ void AttrDialog::nameEdited (const Glib::ustring& path, const Glib::ustring& nam _repr->setAttribute(old_name.c_str(), nullptr, false); } if (!name.empty()) { - _repr->setAttribute(name.c_str(), value, false); row[_attrColumns._attributeName] = name; + _repr->setAttribute(name.c_str(), value, false); + _treeView.set_cursor(modelpath, *_valueCol, true); + grab_focus(); } this->setUndo(_("Rename attribute")); } -- cgit v1.2.3 From 0213907c55de8310db7d0338ad00c5bccd2c08c1 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 29 May 2019 11:16:50 +0200 Subject: Fixed UI issues --- src/ui/dialog/attrdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/dialog/attrdialog.cpp') diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp index 4e98ca1ef..e8a7078c6 100644 --- a/src/ui/dialog/attrdialog.cpp +++ b/src/ui/dialog/attrdialog.cpp @@ -339,7 +339,7 @@ bool AttrDialog::onKeyPressed(GdkEventKey *event) */ void AttrDialog::nameEdited (const Glib::ustring& path, const Glib::ustring& name) { - Gtk::TreeIter iter = this->_store->append(); + Gtk::TreeIter iter = *_store->get_iter(path); Gtk::TreeModel::Path modelpath = (Gtk::TreeModel::Path)iter; Gtk::TreeModel::Row row = *iter; if(row && this->_repr) { -- cgit v1.2.3 From 930ca25606ddefe59afa37f32c823bedcea8ed30 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 29 May 2019 11:20:37 +0200 Subject: Fixing coding style --- src/ui/dialog/attrdialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ui/dialog/attrdialog.cpp') diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp index e8a7078c6..d07623325 100644 --- a/src/ui/dialog/attrdialog.cpp +++ b/src/ui/dialog/attrdialog.cpp @@ -18,9 +18,9 @@ #include "message-context.h" #include "message-stack.h" +#include "style.h" #include "ui/icon-loader.h" #include "ui/widget/iconrenderer.h" -#include "style.h" #include "xml/node-event-vector.h" #include "xml/attribute-record.h" @@ -383,7 +383,7 @@ void AttrDialog::reloadStyles(Glib::ustring name) if (obj) { for (auto iter : obj->style->properties()) { if (iter->style_src != SP_STYLE_SRC_UNSET) { - if( iter->name == name) { + if (iter->name == name) { obj->style->readFromObject(obj); obj->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); } @@ -413,7 +413,7 @@ void AttrDialog::valueEdited (const Glib::ustring& path, const Glib::ustring& va row[_attrColumns._attributeValue] = value; } reloadStyles(name); - + this->setUndo(_("Change attribute value")); } } -- cgit v1.2.3 From 1dcbdd9b9d6f1db457878515fe041bf360ead042 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 29 May 2019 15:44:16 +0200 Subject: Add CSS and remove XML toggler button --- src/ui/dialog/attrdialog.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/ui/dialog/attrdialog.cpp') diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp index d07623325..8d4e74548 100644 --- a/src/ui/dialog/attrdialog.cpp +++ b/src/ui/dialog/attrdialog.cpp @@ -235,7 +235,6 @@ void AttrDialog::onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, co } } } - std::cout << new_value << "aaa" << new_value << std::endl; if (new_value && strcmp(new_value, "") != 0) { if ((repr->type() == Inkscape::XML::TEXT_NODE || repr->type() == Inkscape::XML::COMMENT_NODE) && strcmp(name, "content") != 0) -- cgit v1.2.3