summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/attrdialog.cpp
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2019-06-02 12:49:26 +0000
committerMarc Jeanmougin <marc@jeanmougin.fr>2019-06-02 12:49:26 +0000
commit114a38206233122984b134e5d33bae494a5ba7e9 (patch)
tree881dae040e601c85dc6d0153a2397ee4ff8ef50b /src/ui/dialog/attrdialog.cpp
parentCache bounding box of shapes (diff)
parentadd stylesheet popup (diff)
downloadinkscape-114a38206233122984b134e5d33bae494a5ba7e9.tar.gz
inkscape-114a38206233122984b134e5d33bae494a5ba7e9.zip
Merge branch 'CSSDialogSimplify'
Diffstat (limited to 'src/ui/dialog/attrdialog.cpp')
-rw-r--r--src/ui/dialog/attrdialog.cpp41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp
index ce24e3272..8d4e74548 100644
--- a/src/ui/dialog/attrdialog.cpp
+++ b/src/ui/dialog/attrdialog.cpp
@@ -18,6 +18,7 @@
#include "message-context.h"
#include "message-stack.h"
+#include "style.h"
#include "ui/icon-loader.h"
#include "ui/widget/iconrenderer.h"
@@ -234,7 +235,7 @@ void AttrDialog::onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, co
}
}
}
- if (new_value) {
+ if (new_value && strcmp(new_value, "") != 0) {
if ((repr->type() == Inkscape::XML::TEXT_NODE || repr->type() == Inkscape::XML::COMMENT_NODE) &&
strcmp(name, "content") != 0)
{
@@ -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;
}
@@ -335,9 +338,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 = *_store->get_iter(path);
+ 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)
{
@@ -350,8 +360,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"));
}
@@ -363,6 +375,28 @@ void AttrDialog::nameEdited (const Glib::ustring& path, const Glib::ustring& nam
* @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
+ * @return
+ * Called when the value is edited in the TreeView editable column
+ */
void AttrDialog::valueEdited (const Glib::ustring& path, const Glib::ustring& value)
{
Gtk::TreeModel::Row row = *_store->get_iter(path);
@@ -377,6 +411,7 @@ 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"));
}