summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabiertxo Arraiza Cenoz <jtx@jtx-desktop.markerlab.es>2017-11-16 10:44:52 +0000
committerJabiertxo Arraiza Cenoz <jtx@jtx-desktop.markerlab.es>2017-11-16 10:44:52 +0000
commite068794cdcfb86203db5ab72f6f1d632b5d900d9 (patch)
treee675f4f455f495af2684bd884521b097d44258c3 /src
parentWorking on fix (diff)
downloadinkscape-e068794cdcfb86203db5ab72f6f1d632b5d900d9.tar.gz
inkscape-e068794cdcfb86203db5ab72f6f1d632b5d900d9.zip
Fix title problems
Diffstat (limited to 'src')
-rw-r--r--src/selection-chemistry.cpp35
-rw-r--r--src/ui/dialog/symbols.cpp32
2 files changed, 41 insertions, 26 deletions
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index e6fa11c4c..b18cea034 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -3150,27 +3150,34 @@ void ObjectSet::toSymbol()
Inkscape::XML::Node *defsrepr = doc->getDefs()->getRepr();
Inkscape::XML::Node *symbol_repr = xml_doc->createElement("svg:symbol");
Inkscape::XML::Node *title_repr = xml_doc->createElement("svg:title");
- Inkscape::XML::Node *desc_repr = xml_doc->createElement("svg:desc");
+
defsrepr->appendChild(symbol_repr);
bool settitle = false;
// For a single group, copy relevant attributes.
if( single_group ) {
+ Glib::ustring id = the_group->getAttribute("id");
symbol_repr->setAttribute("style", the_group->getAttribute("style"));
- symbol_repr->appendChild(title_repr);
gchar * title = the_group->title();
if (title) {
- title_repr->setContent(title);
- } else {
- title_repr->setContent(_("Symbol without title"));
+ symbol_repr->appendChild(title_repr);
+ title_repr->appendChild(xml_doc->createTextNode(title));
+ title_repr->setPosition(0);
+ Inkscape::GC::release(title_repr);
}
+ g_free(title);
+
gchar * desc = the_group->desc();
if (desc) {
+ Inkscape::XML::Node *desc_repr = xml_doc->createElement("svg:desc");
desc_repr->setContent(desc);
+ desc_repr->appendChild(xml_doc->createTextNode(desc));
symbol_repr->appendChild(desc_repr);
+ desc_repr->setPosition(1);
+ Inkscape::GC::release(desc_repr);
}
+ g_free(desc);
symbol_repr->setAttribute("class", the_group->getAttribute("class"));
- Glib::ustring id = the_group->getAttribute("id");
the_group->setAttribute("id", id + "_transform");
symbol_repr->setAttribute("id", id);
@@ -3190,24 +3197,26 @@ void ObjectSet::toSymbol()
gchar* title = (*i)->title();
if (!single_group && !settitle && title) {
symbol_repr->appendChild(title_repr);
- title_repr->setContent(title);
+ title_repr->appendChild(xml_doc->createTextNode(title));
+ title_repr->setPosition(0);
+ Inkscape::GC::release(title_repr);
gchar * desc = (*i)->desc();
if (desc) {
- desc_repr->setContent(desc);
+ Inkscape::XML::Node *desc_repr = xml_doc->createElement("svg:desc");
+ desc_repr->appendChild(xml_doc->createTextNode(desc));
symbol_repr->appendChild(desc_repr);
+ Inkscape::GC::release(desc_repr);
+ desc_repr->setPosition(1);
}
+ g_free(desc);
settitle = true;
}
+ g_free(title);
Inkscape::XML::Node *repr = (*i)->getRepr();
repr->parent()->removeChild(repr);
symbol_repr->addChild(repr, NULL);
}
- if (!settitle) {
- symbol_repr->appendChild(title_repr);
- title_repr->setContent(_("Symbol without title"));
- }
-
if( single_group && transform.isTranslation() ) {
the_group->deleteObject(true);
}
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp
index 4d2315def..3a15813c1 100644
--- a/src/ui/dialog/symbols.cpp
+++ b/src/ui/dialog/symbols.cpp
@@ -886,12 +886,17 @@ void SymbolsDialog::symbolsInDocRecursive (SPObject *r, std::map<Glib::ustring,
return;
}
- if ( dynamic_cast<SPSymbol *>(r) && r->title()) {
- Glib::ustring current = symbol_set->get_active_text();
- if (current == ALLDOCS) {
- l[doc_title + r->title()] = std::make_pair(doc_title,dynamic_cast<SPSymbol *>(r));
+ if ( dynamic_cast<SPSymbol *>(r)) {
+ if(r->title()) {
+ Glib::ustring current = symbol_set->get_active_text();
+ if (current == ALLDOCS) {
+ l[doc_title + r->title()] = std::make_pair(doc_title,dynamic_cast<SPSymbol *>(r));
+ } else {
+ l[r->title()] = std::make_pair(doc_title,dynamic_cast<SPSymbol *>(r));
+ }
} else {
- l[r->title()] = std::make_pair(doc_title,dynamic_cast<SPSymbol *>(r));
+ Glib::ustring id = r->getAttribute("id");
+ l[Glib::ustring(_("Symbol without title ")) + id] = std::make_pair(doc_title,dynamic_cast<SPSymbol *>(r));
}
}
for (auto& child: r->children) {
@@ -1028,7 +1033,7 @@ bool SymbolsDialog::callbackSymbols(){
}
}
}
- if (symbol && (search_str.empty() || found || (search_str.empty() && !symbol_title_char))) {
+ if (symbol && (search_str.empty() || found)) {
addSymbol( symbol, doc_title);
icons_found = true;
}
@@ -1152,16 +1157,17 @@ void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) {
SymbolColumns* columns = getColumns();
gchar const *id = symbol->getRepr()->attribute("id");
- gchar const *title = symbol->title(); // From title element
- if( !title ) {
- title = id;
- }
+ gchar * title = symbol->title(); // From title element
if (doc_title.empty()) {
doc_title = CURRENTDOC;
}
- Glib::ustring symbol_title = Glib::ustring(title) + Glib::ustring(" (") + doc_title + Glib::ustring(")");
+ Glib::ustring symbol_title = "";
+ if(title) {
+ symbol_title = Glib::ustring(title) + Glib::ustring(" (") + doc_title + Glib::ustring(")");
+ } else {
+ symbol_title = Glib::ustring(_("Symbol without title ")) + Glib::ustring(id) + Glib::ustring(" (") + doc_title + Glib::ustring(")");
+ }
Glib::RefPtr<Gdk::Pixbuf> pixbuf = drawSymbol( symbol );
-
if( pixbuf ) {
Gtk::ListStore::iterator row = store->append();
(*row)[columns->symbol_id] = Glib::ustring( id );
@@ -1169,7 +1175,7 @@ void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) {
(*row)[columns->symbol_doc_title] = Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "SymbolDoc", doc_title.c_str()) ));
(*row)[columns->symbol_image] = pixbuf;
}
-
+ g_free(title);
delete columns;
}