diff options
| author | Alexander Valavanis <valavanisalex@gmail.com> | 2019-01-19 13:58:54 +0000 |
|---|---|---|
| committer | Alexander Valavanis <valavanisalex@gmail.com> | 2019-01-19 13:58:54 +0000 |
| commit | 199c3dd0acac8c7a7cc835067e07ad6c4c069015 (patch) | |
| tree | cf6f24a57943858136ffc41366de6502d28c9d65 /src/ui | |
| parent | derive all toolbars from Inkscape::Toolbar (diff) | |
| parent | Disable app menu (deprecated in GTK 3.32). (diff) | |
| download | inkscape-199c3dd0acac8c7a7cc835067e07ad6c4c069015.tar.gz inkscape-199c3dd0acac8c7a7cc835067e07ad6c4c069015.zip | |
Merge branch 'master' of gitlab.com:inkscape/inkscape
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/dialog/aboutbox.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/attrdialog.cpp | 79 | ||||
| -rw-r--r-- | src/ui/dialog/objects.cpp | 9 | ||||
| -rw-r--r-- | src/ui/dialog/xml-tree.cpp | 6 |
4 files changed, 67 insertions, 29 deletions
diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index d79a14861..3db65411a 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -133,8 +133,6 @@ void AboutBox::build_splash_widget() { double height=doc->getHeight().value("px") / 2.0; viewer->setResize(width, height); - doc->doUnref(); - _splash_widget = new Gtk::AspectFrame(); _splash_widget->unset_label(); _splash_widget->set_shadow_type(Gtk::SHADOW_NONE); diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp index 21e92f600..4ccb037ef 100644 --- a/src/ui/dialog/attrdialog.cpp +++ b/src/ui/dialog/attrdialog.cpp @@ -36,11 +36,20 @@ static void on_attr_changed (Inkscape::XML::Node * repr, { ATTR_DIALOG(data)->onAttrChanged(repr, name, new_value); } + +static void on_content_changed (Inkscape::XML::Node * repr, + gchar const * oldcontent, + gchar const * newcontent, + gpointer data) +{ + ATTR_DIALOG(data)->onAttrChanged(repr, "content", repr->content()); +} + Inkscape::XML::NodeEventVector _repr_events = { nullptr, /* child_added */ nullptr, /* child_removed */ on_attr_changed, - nullptr, /* content_changed */ + on_content_changed, /* content_changed */ nullptr /* order_changed */ }; @@ -127,7 +136,6 @@ AttrDialog::AttrDialog(): setDesktop(getDesktop()); } - /** * @brief AttrDialog::~AttrDialog * Class destructor @@ -226,10 +234,16 @@ void AttrDialog::onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, co } } } - if(new_value) { - Gtk::TreeModel::Row row = *(_store->append()); - row[_attrColumns._attributeName] = name; - row[_attrColumns._attributeValue] = new_value; + if (new_value) { + if ((repr->type() == Inkscape::XML::TEXT_NODE || repr->type() == Inkscape::XML::COMMENT_NODE) && + name != "content") + { + return; + } else { + Gtk::TreeModel::Row row = *(_store->append()); + row[_attrColumns._attributeName] = name; + row[_attrColumns._attributeValue] = new_value; + } } } @@ -260,8 +274,13 @@ void AttrDialog::onAttrDelete(Glib::ustring path) Gtk::TreeModel::Row row = *_store->get_iter(path); if (row) { Glib::ustring name = row[_attrColumns._attributeName]; - this->_repr->setAttribute(name.c_str(), nullptr, false); - this->setUndo(_("Delete attribute")); + if (name == "content") { + return; + } else { + this->_store->erase(row); + this->_repr->setAttribute(name.c_str(), nullptr, false); + this->setUndo(_("Delete attribute")); + } } } @@ -283,8 +302,13 @@ bool AttrDialog::onKeyPressed(GdkEventKey *event) { // Create new attribute (repeat code, fold into above event!) Glib::ustring name = row[_attrColumns._attributeName]; - this->_repr->setAttribute(name.c_str(), nullptr, false); - this->setUndo(_("Delete attribute")); + if(name == "content") { + return true; + } else { + this->_store->erase(row); + this->_repr->setAttribute(name.c_str(), nullptr, false); + this->setUndo(_("Delete attribute")); + } return true; } case GDK_KEY_plus: @@ -314,21 +338,22 @@ void AttrDialog::nameEdited (const Glib::ustring& path, const Glib::ustring& nam Gtk::TreeModel::Row row = *_store->get_iter(path); if(row && this->_repr) { Glib::ustring old_name = row[_attrColumns._attributeName]; + if (old_name == "content" || + old_name == name) + { + return; + } Glib::ustring value = row[_attrColumns._attributeValue]; - if(!old_name.empty()) { - // Remove named value - _repr->setAttribute(old_name, nullptr, false); - _repr->setAttribute(name, value, false); - this->setUndo(_("Rename attribute")); - } else { - // Move to editing value, we set the name as a temporary store value + // Move to editing value, we set the name as a temporary store value + if (!old_name.empty()) { + // Remove old named value + _repr->setAttribute(old_name.c_str(), nullptr, false); + } + if (!name.empty()) { + _repr->setAttribute(name.c_str(), value, false); row[_attrColumns._attributeName] = name; - // This would be nice to have, but it causes a crash when treeview looses focus - // because signaling vs. focus is in some sort of conflict. - //Gtk::TreeModel::Path _path = (Gtk::TreeModel::Path)row; - //_treeView.set_cursor(_path, *_valueCol, true); - //grab_focus(); } + this->setUndo(_("Rename attribute")); } } @@ -344,7 +369,15 @@ void AttrDialog::valueEdited (const Glib::ustring& path, const Glib::ustring& va if(row && this->_repr) { Glib::ustring name = row[_attrColumns._attributeName]; if(name.empty()) return; - _repr->setAttribute(name, value, false); + if (name == "content") { + _repr->setContent(value.c_str()); + } else { + _repr->setAttribute(name.c_str(), value, false); + } + if(!value.empty()) { + row[_attrColumns._attributeValue] = value; + } + this->setUndo(_("Change attribute value")); } } diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 9e115a2d6..f02df8042 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -422,13 +422,16 @@ void ObjectsPanel::_updateObject( SPObject *obj, bool recurse ) { bool ObjectsPanel::_checkForUpdated(const Gtk::TreeIter& iter, SPObject* obj) { Gtk::TreeModel::Row row = *iter; - if ( obj == row[_model->_colObject] ) + if (obj && *iter && obj == row[_model->_colObject] ) { //We found our item in the tree!! Update it! SPItem * item = SP_IS_ITEM(obj) ? SP_ITEM(obj) : nullptr; SPGroup * group = SP_IS_GROUP(obj) ? SP_GROUP(obj) : nullptr; - - row[_model->_colLabel] = obj->label() ? obj->label() : obj->getId(); + gchar const * id = obj->getId(); + if (!id) { + id = _("no-id"); + } + row[_model->_colLabel] = obj->label() ? obj->label() : id; row[_model->_colVisible] = item ? !item->isHidden() : false; row[_model->_colLocked] = item ? !item->isSensitive() : false; row[_model->_colType] = group ? (group->layerMode() == SPGroup::LAYER ? 2 : 1) : 0; diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index c6058945f..7d8f0a296 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -353,7 +353,11 @@ void XmlTree::set_tree_select(Inkscape::XML::Node *repr) void XmlTree::propagate_tree_select(Inkscape::XML::Node *repr) { - if (repr && (repr->type() == Inkscape::XML::ELEMENT_NODE)) { + if (repr && + (repr->type() == Inkscape::XML::ELEMENT_NODE || + repr->type() == Inkscape::XML::TEXT_NODE || + repr->type() == Inkscape::XML::COMMENT_NODE)) + { attributes->setRepr(repr); } else { attributes->setRepr(nullptr); |
