summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorShlomi Fish <shlomif@shlomifish.org>2019-05-23 08:06:12 +0000
committerShlomi Fish <shlomif@shlomifish.org>2019-06-06 12:57:27 +0000
commitcb8c36249e983866378e7915e6605ef92d247923 (patch)
tree53ec0a0745250375aaeb4b5a52f821380ccb614a /src/ui
parentCI: Avoid failure due to sorting issue (diff)
downloadinkscape-cb8c36249e983866378e7915e6605ef92d247923.tar.gz
inkscape-cb8c36249e983866378e7915e6605ef92d247923.zip
Refactoring: call setAttribute() directly.
Call this->setAttribute(...) directly instead of this->getRepr()->setAttribute(...). This avoids clutter and mental indirection. See http://wiki.inkscape.org/wiki/index.php?title=Refactoring_projects&oldid=112116 and https://en.wikipedia.org/wiki/Law_of_Demeter . --- I hereby disclaim any implicit or explicit ownership of my changes in this changeset, and put them under a multiple licence consisting of your choice of one of more of: - The CC0 / Public Domain - https://creativecommons.org/choose/zero/ . - The MIT / Expat license - https://en.wikipedia.org/wiki/MIT_License - The default licence of your project - The https://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License - version 2.1 or higher - The https://en.wikipedia.org/wiki/GNU_General_Public_License - version 2 or higher - Any licence in the 2018-Aug-27 popular licenses list of https://opensource.org/licenses - The https://en.wikipedia.org/wiki/Apache_License version 2.0 or later - The https://en.wikipedia.org/wiki/Artistic_License version 2.0 or later - The https://en.wikipedia.org/wiki/ISC_license - The https://opensource.org/licenses/BSD-2-Clause Crediting me will be nice, but not mandatory, and you can change the licence of the project without needing my permission.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp14
-rw-r--r--src/ui/dialog/find.cpp8
-rw-r--r--src/ui/dialog/livepatheffect-editor.cpp4
-rw-r--r--src/ui/dialog/selectordialog.cpp6
-rw-r--r--src/ui/dialog/svg-fonts-dialog.cpp22
-rw-r--r--src/ui/toolbar/rect-toolbar.cpp2
-rw-r--r--src/ui/tools/tweak-tool.cpp4
7 files changed, 30 insertions, 30 deletions
diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp
index 6259c822c..23f0acb9f 100644
--- a/src/ui/dialog/filter-effects-dialog.cpp
+++ b/src/ui/dialog/filter-effects-dialog.cpp
@@ -1116,7 +1116,7 @@ private:
SPFilterPrimitive* prim = _dialog._primitive_list.get_selected();
if(prim) {
- _funcNode->getRepr()->setAttribute( "type", _type.get_as_attribute().c_str() );
+ _funcNode->setAttribute( "type", _type.get_as_attribute() );
SPFilter* filter = _dialog._filter_modifier.get_selected_filter();
filter->requestModified(SP_OBJECT_MODIFIED_FLAG);
@@ -2494,20 +2494,20 @@ static void check_single_connection(SPFilterPrimitive* prim, const int result)
{
if (prim && (result >= 0)) {
if (prim->image_in == result) {
- prim->getRepr()->setAttribute("in", nullptr);
+ prim->setAttribute("in", nullptr);
}
if (SP_IS_FEBLEND(prim)) {
if (SP_FEBLEND(prim)->in2 == result) {
- prim->getRepr()->setAttribute("in2", nullptr);
+ prim->setAttribute("in2", nullptr);
}
} else if (SP_IS_FECOMPOSITE(prim)) {
if (SP_FECOMPOSITE(prim)->in2 == result) {
- prim->getRepr()->setAttribute("in2", nullptr);
+ prim->setAttribute("in2", nullptr);
}
} else if (SP_IS_FEDISPLACEMENTMAP(prim)) {
if (SP_FEDISPLACEMENTMAP(prim)->in2 == result) {
- prim->getRepr()->setAttribute("in2", nullptr);
+ prim->setAttribute("in2", nullptr);
}
}
}
@@ -2990,7 +2990,7 @@ void FilterEffectsDialog::set_filternode_attr(const AttrWidget* input)
SPFilter *filter = _filter_modifier.get_selected_filter();
const gchar* name = (const gchar*)sp_attribute_name(input->get_attribute());
if (filter && name && filter->getRepr()){
- filter->getRepr()->setAttribute(name, input->get_as_attribute().c_str());
+ filter->setAttribute(name, input->get_as_attribute());
filter->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
_attr_lock = false;
@@ -3012,7 +3012,7 @@ void FilterEffectsDialog::set_attr(SPObject* o, const SPAttributeEnum attr, cons
if(filter && name && o) {
update_settings_sensitivity();
- o->getRepr()->setAttribute(name, val);
+ o->setAttribute(name, val);
filter->requestModified(SP_OBJECT_MODIFIED_FLAG);
Glib::ustring undokey = "filtereffects:";
diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp
index 402ccd46d..8c43befd7 100644
--- a/src/ui/dialog/find.cpp
+++ b/src/ui/dialog/find.cpp
@@ -496,7 +496,7 @@ bool Find::item_id_match (SPItem *item, const gchar *id, bool exact, bool casema
gchar * replace_text = g_strdup(entry_replace.getEntry()->get_text().c_str());
Glib::ustring new_item_style = find_replace(item_id, id, replace_text , exact, casematch, true);
if (new_item_style != item_id) {
- item->getRepr()->setAttribute("id", new_item_style.data());
+ item->setAttribute("id", new_item_style.data());
}
g_free(replace_text);
}
@@ -521,7 +521,7 @@ bool Find::item_style_match (SPItem *item, const gchar *text, bool exact, bool c
gchar * replace_text = g_strdup(entry_replace.getEntry()->get_text().c_str());
Glib::ustring new_item_style = find_replace(item_style, text, replace_text , exact, casematch, true);
if (new_item_style != item_style) {
- item->getRepr()->setAttribute("style", new_item_style.data());
+ item->setAttribute("style", new_item_style.data());
}
g_free(replace_text);
}
@@ -575,7 +575,7 @@ bool Find::item_attrvalue_match(SPItem *item, const gchar *text, bool exact, boo
gchar * replace_text = g_strdup(entry_replace.getEntry()->get_text().c_str());
Glib::ustring new_item_style = find_replace(attr_value, text, replace_text , exact, casematch, true);
if (new_item_style != attr_value) {
- item->getRepr()->setAttribute(key, new_item_style.data());
+ item->setAttribute(key, new_item_style.data());
}
}
@@ -634,7 +634,7 @@ bool Find::item_font_match(SPItem *item, const gchar *text, bool exact, bool cas
new_item_style.append(vStyleToken).append(";");
}
new_item_style.erase(new_item_style.size()-1);
- item->getRepr()->setAttribute("style", new_item_style.data());
+ item->setAttribute("style", new_item_style.data());
}
return ret;
diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp
index 8767a109f..8eea0895f 100644
--- a/src/ui/dialog/livepatheffect-editor.cpp
+++ b/src/ui/dialog/livepatheffect-editor.cpp
@@ -468,8 +468,8 @@ LivePathEffectEditor::onAdd()
SPItem *new_item = sel->singleItem();
// Check that the cloning was successful. We don't want to change the ID of the original referenced path!
if (new_item && (new_item != orig)) {
- new_item->getRepr()->setAttribute("id", id);
- new_item->getRepr()->setAttribute("transform", transform);
+ new_item->setAttribute("id", id);
+ new_item->setAttribute("transform", transform);
}
g_free(id);
g_free(transform);
diff --git a/src/ui/dialog/selectordialog.cpp b/src/ui/dialog/selectordialog.cpp
index fefd23e51..e99f35df2 100644
--- a/src/ui/dialog/selectordialog.cpp
+++ b/src/ui/dialog/selectordialog.cpp
@@ -750,7 +750,7 @@ void SelectorDialog::_removeFromSelector(Gtk::TreeModel::Row row)
classAttr.erase(i, 1);
}
_store->erase(row);
- objVec[0]->getRepr()->setAttribute("class", classAttr);
+ objVec[0]->setAttribute("class", classAttr);
parent[_mColumns._colExpand] = true;
} else {
// Do nothing for element selectors.
@@ -823,7 +823,7 @@ void SelectorDialog::_insertClass(const std::vector<SPObject *>& objVec, const G
if (!obj->getRepr()->attribute("class")) {
// 'class' attribute does not exist, create it.
- obj->getRepr()->setAttribute("class", className);
+ obj->setAttribute("class", className);
} else {
// 'class' attribute exists, append.
Glib::ustring classAttr = obj->getRepr()->attribute("class");
@@ -838,7 +838,7 @@ void SelectorDialog::_insertClass(const std::vector<SPObject *>& objVec, const G
}
}
if (add) {
- obj->getRepr()->setAttribute("class", classAttr + " " + className );
+ obj->setAttribute("class", classAttr + " " + className );
}
}
}
diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp
index 2d9331818..ad6bc25a4 100644
--- a/src/ui/dialog/svg-fonts-dialog.cpp
+++ b/src/ui/dialog/svg-fonts-dialog.cpp
@@ -137,7 +137,7 @@ void SvgFontsDialog::AttrEntry::on_attr_changed(){
const gchar* name = (const gchar*)sp_attribute_name(this->attr);
if(name && o) {
- o->getRepr()->setAttribute((const gchar*) name, this->entry.get_text().c_str());
+ o->setAttribute((const gchar*) name, this->entry.get_text());
o->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
Glib::ustring undokey = "svgfonts:";
@@ -209,7 +209,7 @@ void SvgFontsDialog::AttrSpin::on_attr_changed(){
if(name && o) {
std::ostringstream temp;
temp << this->spin.get_value();
- o->getRepr()->setAttribute((const gchar*) name, temp.str().c_str() );
+ o->setAttribute((const gchar*) name, temp.str() );
o->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
Glib::ustring undokey = "svgfonts:";
@@ -269,7 +269,7 @@ void SvgFontsDialog::on_kerning_value_changed(){
//slider values increase from right to left so that they match the kerning pair preview
//XML Tree being directly used here while it shouldn't be.
- this->kerning_pair->getRepr()->setAttribute("k", Glib::Ascii::dtostr(get_selected_spfont()->horiz_adv_x - kerning_slider->get_value()).c_str());
+ this->kerning_pair->setAttribute("k", Glib::Ascii::dtostr(get_selected_spfont()->horiz_adv_x - kerning_slider->get_value()));
DocumentUndo::maybeDone(document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, _("Adjust kerning value"));
//populate_kerning_pairs_box();
@@ -626,7 +626,7 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){
//XML Tree being directly used here while it shouldn't be.
gchar *str = sp_svg_write_path (flip_coordinate_system(pathv));
- glyph->getRepr()->setAttribute("d", str);
+ glyph->setAttribute("d", str);
g_free(str);
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves"));
@@ -664,7 +664,7 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){
//XML Tree being directly used here while it shouldn't be.
gchar *str = sp_svg_write_path (flip_coordinate_system(pathv));
- obj.getRepr()->setAttribute("d", str);
+ obj.setAttribute("d", str);
g_free(str);
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves"));
}
@@ -684,7 +684,7 @@ void SvgFontsDialog::reset_missing_glyph_description(){
for (auto& obj: get_selected_spfont()->children) {
if (SP_IS_MISSING_GLYPH(&obj)){
//XML Tree being directly used here while it shouldn't be.
- obj.getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z");
+ obj.setAttribute("d", "M0,0h1000v1024h-1000z");
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Reset missing-glyph"));
}
}
@@ -698,7 +698,7 @@ void SvgFontsDialog::glyph_name_edit(const Glib::ustring&, const Glib::ustring&
SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node];
//XML Tree being directly used here while it shouldn't be.
- glyph->getRepr()->setAttribute("glyph-name", str.c_str());
+ glyph->setAttribute("glyph-name", str);
SPDocument* doc = this->getDesktop()->getDocument();
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Edit glyph name"));
@@ -712,7 +712,7 @@ void SvgFontsDialog::glyph_unicode_edit(const Glib::ustring&, const Glib::ustrin
SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node];
//XML Tree being directly used here while it shouldn't be.
- glyph->getRepr()->setAttribute("unicode", str.c_str());
+ glyph->setAttribute("unicode", str);
SPDocument* doc = this->getDesktop()->getDocument();
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph unicode"));
@@ -730,7 +730,7 @@ void SvgFontsDialog::glyph_advance_edit(const Glib::ustring&, const Glib::ustrin
double value;
// Check if input valid
if ((is >> value)) {
- glyph->getRepr()->setAttribute("horiz-adv-x", str.c_str());
+ glyph->setAttribute("horiz-adv-x", str);
SPDocument* doc = this->getDesktop()->getDocument();
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph advance"));
@@ -966,7 +966,7 @@ void set_font_family(SPFont* font, char* str){
for (auto& obj: font->children) {
if (SP_IS_FONTFACE(&obj)){
//XML Tree being directly used here while it shouldn't be.
- obj.getRepr()->setAttribute("font-family", str);
+ obj.setAttribute("font-family", str);
}
}
@@ -986,7 +986,7 @@ void SvgFontsDialog::add_font(){
for (auto& obj: font->children) {
if (SP_IS_FONTFACE(&obj)){
//XML Tree being directly used here while it shouldn't be.
- obj.getRepr()->setAttribute("font-family", os2.str().c_str());
+ obj.setAttribute("font-family", os2.str());
}
}
diff --git a/src/ui/toolbar/rect-toolbar.cpp b/src/ui/toolbar/rect-toolbar.cpp
index 44a53c8fc..bfcc14e47 100644
--- a/src/ui/toolbar/rect-toolbar.cpp
+++ b/src/ui/toolbar/rect-toolbar.cpp
@@ -232,7 +232,7 @@ RectToolbar::value_changed(Glib::RefPtr<Gtk::Adjustment>& adj,
if (adj->get_value() != 0) {
(SP_RECT(*i)->*setter)(Quantity::convert(adj->get_value(), unit, "px"));
} else {
- (*i)->getRepr()->setAttribute(value_name, nullptr);
+ (*i)->setAttribute(value_name, nullptr);
}
modmade = true;
}
diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp
index 42e3520a0..1cb757bfd 100644
--- a/src/ui/tools/tweak-tool.cpp
+++ b/src/ui/tools/tweak-tool.cpp
@@ -616,9 +616,9 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
} else {
SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
if (lpeitem && lpeitem->hasPathEffectRecursive()) {
- item->getRepr()->setAttribute("inkscape:original-d", str);
+ item->setAttribute("inkscape:original-d", str);
} else {
- item->getRepr()->setAttribute("d", str);
+ item->setAttribute("d", str);
}
}
g_free(str);