From e9468d5c8bc974ee96dc7537e0d13fe2def0e615 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 24 Aug 2013 23:36:04 +0200 Subject: Add listing procedural templates in NewFromTemplate dialog. (bzr r12481.1.1) --- src/ui/dialog/template-load-tab.cpp | 100 ++++++++++++++++++++++++------------ src/ui/dialog/template-load-tab.h | 4 ++ 2 files changed, 72 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 265ee8026..280b3b073 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include "interface.h" #include "file.h" @@ -27,6 +29,8 @@ #include "xml/repr.h" #include "xml/document.h" #include "xml/node.h" +#include "extension/db.h" +#include "extension/effect.h" namespace Inkscape { @@ -187,6 +191,10 @@ void TemplateLoadTab::_loadTemplates() // system templates dir _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); + + + // procedural templates + _getProceduralTemplates(); } @@ -209,7 +217,6 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: Inkscape::XML::Document *rdoc; rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); Inkscape::XML::Node *myRoot; - Inkscape::XML::Node *dataNode; if (rdoc){ myRoot = rdoc->root(); @@ -221,37 +228,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: if (myRoot == NULL) // No template info return result; - - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_name")) != NULL) - result.display_name = dgettext("Document template name", dataNode->firstChild()->content()); - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:author")) != NULL) - result.author = dataNode->firstChild()->content(); - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_short")) != NULL) - result.short_description = dgettext("Document template short description", dataNode->firstChild()->content()); - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_long") )!= NULL) - result.long_description = dgettext("Document template long description", dataNode->firstChild()->content()); - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:preview")) != NULL) - result.preview_name = dataNode->firstChild()->content(); - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:date")) != NULL){ - result.creation_date = dataNode->firstChild()->content(); - } - - if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_keywords")) != NULL){ - Glib::ustring data = dataNode->firstChild()->content(); - while (!data.empty()){ - std::size_t pos = data.find_first_of(" "); - if (pos == Glib::ustring::npos) - pos = data.size(); - - Glib::ustring keyword = dgettext("Document template keyword", data.substr(0, pos).data()); - result.keywords.insert(keyword); - _keywords.insert(keyword); - - if (pos == data.size()) - break; - data.erase(0, pos+1); - } - } + _getDataFromNode(myRoot, result); } return result; @@ -277,5 +254,64 @@ void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) } } + +void TemplateLoadTab::_getProceduralTemplates() +{ + std::list effects; + Inkscape::Extension::db.get_effect_list(effects); + + std::list::iterator it = effects.begin(); + while (it != effects.end()){ + Inkscape::XML::Node *myRoot; + myRoot = (*it)->get_repr(); + myRoot = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); + + if (myRoot){ + TemplateData result; + result.display_name = (*it)->get_name(); + result.is_procedural = true; + result.path = ""; + _getDataFromNode(myRoot, result); + _tdata[result.display_name] = result; + } + ++it; + } +} + + +void TemplateLoadTab::_getDataFromNode(Inkscape::XML::Node *dataNode, TemplateData &data) +{ + Inkscape::XML::Node *currentData; + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_name")) != NULL) + data.display_name = dgettext("Document template name", currentData->firstChild()->content()); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:author")) != NULL) + data.author = currentData->firstChild()->content(); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_short")) != NULL) + data.short_description = dgettext("Document template short description", currentData->firstChild()->content()); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_long") )!= NULL) + data.long_description = dgettext("Document template long description", currentData->firstChild()->content()); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:preview")) != NULL) + data.preview_name = currentData->firstChild()->content(); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:date")) != NULL) + data.creation_date = currentData->firstChild()->content(); + + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_keywords")) != NULL){ + Glib::ustring tplKeywords = currentData->firstChild()->content(); + while (!tplKeywords.empty()){ + std::size_t pos = tplKeywords.find_first_of(" "); + if (pos == Glib::ustring::npos) + pos = tplKeywords.size(); + + Glib::ustring keyword = dgettext("Document template keyword", tplKeywords.substr(0, pos).data()); + data.keywords.insert(keyword); + _keywords.insert(keyword); + + if (pos == tplKeywords.size()) + break; + tplKeywords.erase(0, pos+1); + } + } +} + } } diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 50f3e0be2..c3817cf1b 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -19,6 +19,8 @@ #include #include +#include "xml/node.h" + namespace Inkscape { namespace UI { @@ -91,6 +93,8 @@ private: SearchType _current_search_type; + void _getDataFromNode(Inkscape::XML::Node *, TemplateData &); + void _getProceduralTemplates(); void _getTemplatesFromDir(const Glib::ustring &); void _keywordSelected(); TemplateData _processTemplateFile(const Glib::ustring &); -- cgit v1.2.3 From 100be92caf253e8743126da4264e84a060c82182 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Wed, 4 Sep 2013 11:50:07 +0200 Subject: Creating documents from procedural templates added. (bzr r12481.1.2) --- src/ui/dialog/template-load-tab.cpp | 2 ++ src/ui/dialog/template-load-tab.h | 2 ++ src/ui/dialog/template-widget.cpp | 59 +++++++++++++++++++++++-------------- src/ui/dialog/template-widget.h | 1 + 4 files changed, 42 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 280b3b073..11511d7fc 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -271,6 +271,8 @@ void TemplateLoadTab::_getProceduralTemplates() result.display_name = (*it)->get_name(); result.is_procedural = true; result.path = ""; + result.tpl_effect = *it; + _getDataFromNode(myRoot, result); _tdata[result.display_name] = result; } diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index c3817cf1b..cdf8a0ade 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -20,6 +20,7 @@ #include #include "xml/node.h" +#include "extension/effect.h" namespace Inkscape { @@ -42,6 +43,7 @@ public: Glib::ustring preview_name; Glib::ustring creation_date; std::set keywords; + Inkscape::Extension::Effect *tpl_effect; }; TemplateLoadTab(); diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index be7e2b515..21ea709f2 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -20,6 +20,10 @@ #include "template-load-tab.h" #include "file.h" +#include "extension/implementation/implementation.h" + +#include "inkscape.h" +#include "desktop.h" namespace Inkscape { namespace UI { @@ -30,6 +34,7 @@ TemplateWidget::TemplateWidget() , _short_description_label(_(" ")) , _template_author_label(_(" ")) , _template_name_label(_("no template selected")) + , _effect_prefs(NULL) { pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); @@ -55,10 +60,13 @@ TemplateWidget::TemplateWidget() void TemplateWidget::create() { - if (_current_template.path == "") + if (_current_template.display_name == "") return; - if (_current_template.is_procedural) {} + if (_current_template.is_procedural){ + SPDesktop *desc = sp_file_new_default(); + _current_template.tpl_effect->effect(desc); + } else { sp_file_new(_current_template.path); } @@ -68,34 +76,41 @@ void TemplateWidget::create() void TemplateWidget::display(TemplateLoadTab::TemplateData data) { _current_template = data; - if (data.is_procedural){} - else{ - _template_name_label.set_text(_current_template.display_name); - _template_author_label.set_text(_current_template.author); - _short_description_label.set_text(_current_template.short_description); + + _template_name_label.set_text(_current_template.display_name); + // _template_author_label.set_text(_current_template.author); + _short_description_label.set_text(_current_template.short_description); - Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name); - if (data.preview_name != ""){ - _preview_image.set(imagePath); - _preview_image.show(); - _preview_render.hide(); - } - else{ - _preview_render.showImage(data.path); - _preview_render.show(); - _preview_image.hide(); - } + _preview_render.hide(); + _preview_image.hide(); + + Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name); + if (data.preview_name != ""){ + _preview_image.set(imagePath); + _preview_image.show(); + } + else if (!data.is_procedural){ + _preview_render.showImage(data.path); + _preview_render.show(); + } + + if (_effect_prefs != NULL){ + remove (*_effect_prefs); + _effect_prefs = NULL; + } + if (data.is_procedural){ + _effect_prefs = data.tpl_effect->get_imp()->prefs_effect(data.tpl_effect, SP_ACTIVE_DESKTOP, NULL, NULL); // SP_ACTIVE_DESKTOP? + pack_start(*_effect_prefs); } } void TemplateWidget::_displayTemplateDetails() { - if (_current_template.path == "") - return; + Glib::ustring message = _current_template.display_name + "\n\n"; - Glib::ustring message = _current_template.display_name + "\n\n" + - _("Path: ") + _current_template.path + "\n\n"; + if (_current_template.path != "") + message += _("Path: ") + _current_template.path + "\n\n"; if (_current_template.long_description != "") message += _("Description: ") + _current_template.long_description + "\n\n"; diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index f7e1267ce..a41a14a38 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -38,6 +38,7 @@ private: Gtk::Label _short_description_label; Gtk::Label _template_author_label; Gtk::Label _template_name_label; + Gtk::Widget *_effect_prefs; void _displayTemplateDetails(); }; -- cgit v1.2.3 From 5dc7ab56d1f8bf9b51367702e13788f8eea00aaf Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sun, 15 Sep 2013 21:58:27 +0200 Subject: Removed search templates case sensitivity (bzr r12481.1.4) --- src/ui/dialog/template-load-tab.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 11511d7fc..ababd4ca3 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -156,7 +156,7 @@ void TemplateLoadTab::_refreshTemplatesList() case LIST_KEYWORD: { for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { - if (it->second.keywords.count(_current_keyword) != 0){ + if (it->second.keywords.count(_current_keyword.lowercase()) != 0){ Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; row[_columns.textValue] = it->first; @@ -167,11 +167,11 @@ void TemplateLoadTab::_refreshTemplatesList() case USER_SPECIFIED : { for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { - if (it->second.keywords.count(_current_keyword) != 0 || - it->second.display_name.find(_current_keyword) != Glib::ustring::npos || - it->second.author.find(_current_keyword) != Glib::ustring::npos || - it->second.short_description.find(_current_keyword) != Glib::ustring::npos || - it->second.long_description.find(_current_keyword) != Glib::ustring::npos ) + if (it->second.keywords.count(_current_keyword.lowercase()) != 0 || + it->second.display_name.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || + it->second.author.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || + it->second.short_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || + it->second.long_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos ) { Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; @@ -192,7 +192,6 @@ void TemplateLoadTab::_loadTemplates() // system templates dir _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); - // procedural templates _getProceduralTemplates(); } @@ -305,8 +304,8 @@ void TemplateLoadTab::_getDataFromNode(Inkscape::XML::Node *dataNode, TemplateDa pos = tplKeywords.size(); Glib::ustring keyword = dgettext("Document template keyword", tplKeywords.substr(0, pos).data()); - data.keywords.insert(keyword); - _keywords.insert(keyword); + data.keywords.insert(keyword.lowercase()); + _keywords.insert(keyword.lowercase()); if (pos == tplKeywords.size()) break; -- cgit v1.2.3 From fbaf8db2eb5c15ac84348f9e9de3303c78860f62 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sun, 15 Sep 2013 22:36:28 +0200 Subject: Fixed available undo after new template creation. (bzr r12481.1.6) --- src/ui/dialog/template-widget.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 21ea709f2..6ead7ef8d 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -24,6 +24,9 @@ #include "inkscape.h" #include "desktop.h" +#include "desktop-handles.h" +#include "document.h" +#include "document-undo.h" namespace Inkscape { namespace UI { @@ -66,6 +69,7 @@ void TemplateWidget::create() if (_current_template.is_procedural){ SPDesktop *desc = sp_file_new_default(); _current_template.tpl_effect->effect(desc); + DocumentUndo::clearUndo(sp_desktop_document(desc)); } else { sp_file_new(_current_template.path); -- cgit v1.2.3 From bd94128f84bc367d11815c53347eb8d5b5557c5e Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sun, 15 Sep 2013 23:18:47 +0200 Subject: Fix procedural templates "modified" status. (bzr r12481.1.7) --- src/ui/dialog/template-widget.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 6ead7ef8d..1e0900a07 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -70,6 +70,7 @@ void TemplateWidget::create() SPDesktop *desc = sp_file_new_default(); _current_template.tpl_effect->effect(desc); DocumentUndo::clearUndo(sp_desktop_document(desc)); + sp_desktop_document(desc)->setModifiedSinceSave(false); } else { sp_file_new(_current_template.path); -- cgit v1.2.3 From c549b2977183241cecc95d40839d31d99eb76699 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Wed, 18 Sep 2013 17:04:03 +0200 Subject: Fix "default_*" template names treatment. (bzr r12481.1.8) --- src/ui/dialog/template-load-tab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index ababd4ca3..c884df2b1 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -244,7 +244,7 @@ void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) Glib::ustring file = Glib::build_filename(path, dir.read_name()); while (file != path){ - if (Glib::str_has_suffix(file, ".svg") && !Glib::str_has_prefix(Glib::path_get_basename(file), "default")){ + if (Glib::str_has_suffix(file, ".svg") && !Glib::str_has_prefix(Glib::path_get_basename(file), "default.")){ TemplateData tmp = _processTemplateFile(file); if (tmp.display_name != "") _tdata[tmp.display_name] = tmp; -- cgit v1.2.3 From 4eb731d194e43b55a97ad1c9d4f5d095d4b759a0 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Wed, 18 Sep 2013 17:15:17 +0200 Subject: Opening new documents behaviour fixed. (bzr r12481.1.9) --- src/file.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/file.cpp b/src/file.cpp index 68e229e62..12373a2e5 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -139,24 +139,14 @@ SPDesktop *sp_file_new(const Glib::ustring &templ) } SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop) { + if (desktop) desktop->setWaitingCursor(); - } - SPDocument *existing = desktop ? sp_desktop_document(desktop) : NULL; - if (existing && existing->virgin) { - // If the current desktop is empty, open the document there - doc->ensureUpToDate(); // TODO this will trigger broken link warnings, etc. - desktop->change_document(doc); - doc->emitResizedSignal(doc->getWidth(), doc->getHeight()); - } else { - // create a whole new desktop and window - SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); // TODO this will trigger broken link warnings, etc. - g_return_val_if_fail(dtw != NULL, NULL); - sp_create_window(dtw, TRUE); - desktop = static_cast(dtw->view); - } + SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); // TODO this will trigger broken link warnings, etc. + g_return_val_if_fail(dtw != NULL, NULL); + sp_create_window(dtw, TRUE); + desktop = static_cast(dtw->view); doc->doUnref(); @@ -166,6 +156,9 @@ SPDesktop *sp_file_new(const Glib::ustring &templ) #ifdef WITH_DBUS Inkscape::Extension::Dbus::dbus_init_desktop_interface(desktop); #endif + + if (desktop) + desktop->clearWaitingCursor(); return desktop; } @@ -220,7 +213,7 @@ SPDesktop* sp_file_new_default() { Glib::ustring templateUri = sp_file_default_template_uri(); SPDesktop* desk = sp_file_new(sp_file_default_template_uri()); - rdf_add_from_preferences( SP_ACTIVE_DOCUMENT ); + //rdf_add_from_preferences( SP_ACTIVE_DOCUMENT ); return desk; } -- cgit v1.2.3 From 074dfbc9661c5d2b1d2b29b0eb3dabb632b676a4 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Fri, 20 Sep 2013 16:20:17 +0200 Subject: Small style fixes. (bzr r12481.1.10) --- src/ui/dialog/template-widget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 1e0900a07..64be57a45 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -19,14 +19,14 @@ #include #include "template-load-tab.h" -#include "file.h" -#include "extension/implementation/implementation.h" - -#include "inkscape.h" #include "desktop.h" #include "desktop-handles.h" #include "document.h" #include "document-undo.h" +#include "file.h" +#include "extension/implementation/implementation.h" +#include "inkscape.h" + namespace Inkscape { namespace UI { -- cgit v1.2.3 From 18bc66ea42cb3e7ad8d2b77ba70bd06d1b88cc7c Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Fri, 20 Sep 2013 16:48:10 +0200 Subject: Change paths storage to std::string. (bzr r12481.1.12) --- src/file.cpp | 4 +++- src/file.h | 3 ++- src/ui/dialog/template-load-tab.cpp | 6 +++--- src/ui/dialog/template-load-tab.h | 9 +++++---- src/ui/dialog/template-widget.cpp | 5 +++-- 5 files changed, 16 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/file.cpp b/src/file.cpp index 12373a2e5..b6063e5cd 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -74,6 +74,8 @@ #include #include +#include + using Inkscape::DocumentUndo; #ifdef WITH_GNOME_VFS @@ -124,7 +126,7 @@ static void sp_file_add_recent(gchar const *uri) /** * Create a blank document and add it to the desktop */ -SPDesktop *sp_file_new(const Glib::ustring &templ) +SPDesktop *sp_file_new(const std::string &templ) { SPDocument *doc = SPDocument::createNewDoc( !templ.empty() ? templ.c_str() : 0 , TRUE, true ); g_return_val_if_fail(doc != NULL, NULL); diff --git a/src/file.h b/src/file.h index 682ca422e..7f80f3645 100644 --- a/src/file.h +++ b/src/file.h @@ -16,6 +16,7 @@ */ #include +#include #include "extension/system.h" class SPDesktop; @@ -43,7 +44,7 @@ Glib::ustring sp_file_default_template_uri(); * Creates a new Inkscape document and window. * Return value is a pointer to the newly created desktop. */ -SPDesktop* sp_file_new (const Glib::ustring &templ); +SPDesktop* sp_file_new (const std::string &templ); SPDesktop* sp_file_new_default (void); /*###################### diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index c884df2b1..127a7e4f5 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -197,7 +197,7 @@ void TemplateLoadTab::_loadTemplates() } -TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib::ustring &path) +TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const std::string &path) { TemplateData result; result.path = path; @@ -234,7 +234,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: } -void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) +void TemplateLoadTab::_getTemplatesFromDir(const std::string &path) { if ( !Glib::file_test(path, Glib::FILE_TEST_EXISTS) || !Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) @@ -242,7 +242,7 @@ void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) Glib::Dir dir(path); - Glib::ustring file = Glib::build_filename(path, dir.read_name()); + std::string file = Glib::build_filename(path, dir.read_name()); while (file != path){ if (Glib::str_has_suffix(file, ".svg") && !Glib::str_has_prefix(Glib::path_get_basename(file), "default.")){ TemplateData tmp = _processTemplateFile(file); diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index cdf8a0ade..744a2a9fb 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -18,6 +18,7 @@ #include #include #include +#include #include "xml/node.h" #include "extension/effect.h" @@ -35,7 +36,7 @@ public: struct TemplateData { bool is_procedural; - Glib::ustring path; + std::string path; Glib::ustring display_name; Glib::ustring author; Glib::ustring short_description; @@ -64,7 +65,7 @@ protected: Glib::ustring _current_keyword; Glib::ustring _current_template; - Glib::ustring _loading_path; + std::string _loading_path; std::map _tdata; std::set _keywords; @@ -97,9 +98,9 @@ private: void _getDataFromNode(Inkscape::XML::Node *, TemplateData &); void _getProceduralTemplates(); - void _getTemplatesFromDir(const Glib::ustring &); + void _getTemplatesFromDir(const std::string &); void _keywordSelected(); - TemplateData _processTemplateFile(const Glib::ustring &); + TemplateData _processTemplateFile(const std::string &); }; } diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 64be57a45..916d968ec 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -89,13 +89,14 @@ void TemplateWidget::display(TemplateLoadTab::TemplateData data) _preview_render.hide(); _preview_image.hide(); - Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name); + std::string imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name); if (data.preview_name != ""){ _preview_image.set(imagePath); _preview_image.show(); } else if (!data.is_procedural){ - _preview_render.showImage(data.path); + Glib::ustring gPath = data.path.c_str(); + _preview_render.showImage(gPath); _preview_render.show(); } -- cgit v1.2.3 From 9ba75e8a819b3fa9e266f6bd46ccee65322f89b0 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 21 Sep 2013 22:30:40 +0200 Subject: Fix templates parameters names. (bzr r12481.1.13) --- src/ui/dialog/template-load-tab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 127a7e4f5..4517c4472 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -287,7 +287,7 @@ void TemplateLoadTab::_getDataFromNode(Inkscape::XML::Node *dataNode, TemplateDa data.display_name = dgettext("Document template name", currentData->firstChild()->content()); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:author")) != NULL) data.author = currentData->firstChild()->content(); - if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_short")) != NULL) + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_shortdesc")) != NULL) data.short_description = dgettext("Document template short description", currentData->firstChild()->content()); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_long") )!= NULL) data.long_description = dgettext("Document template long description", currentData->firstChild()->content()); -- cgit v1.2.3 From 8921f8000318d636ae8ce2a1198f92161f1dba9f Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 21 Sep 2013 23:32:09 +0200 Subject: Small style fixes. (bzr r12481.1.15) --- src/ui/dialog/template-load-tab.cpp | 8 ++++---- src/ui/dialog/template-widget.cpp | 6 +----- src/ui/dialog/template-widget.h | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 4517c4472..8e33cf503 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -18,19 +18,19 @@ #include #include #include -#include #include +#include +#include "extension/db.h" +#include "extension/effect.h" +#include "inkscape.h" #include "interface.h" #include "file.h" #include "path-prefix.h" #include "preferences.h" -#include "inkscape.h" #include "xml/repr.h" #include "xml/document.h" #include "xml/node.h" -#include "extension/db.h" -#include "extension/effect.h" namespace Inkscape { diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 916d968ec..ef022c421 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -35,19 +35,16 @@ namespace UI { TemplateWidget::TemplateWidget() : _more_info_button(_("More info")) , _short_description_label(_(" ")) - , _template_author_label(_(" ")) , _template_name_label(_("no template selected")) , _effect_prefs(NULL) { pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); - pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); pack_start(_preview_box, Gtk::PACK_SHRINK, 0); _preview_box.pack_start(_preview_image, Gtk::PACK_EXPAND_PADDING, 15); _preview_box.pack_start(_preview_render, Gtk::PACK_EXPAND_PADDING, 10); _short_description_label.set_line_wrap(true); - //_short_description_label.set_size_request(200); Gtk::Alignment *align; align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); @@ -83,7 +80,6 @@ void TemplateWidget::display(TemplateLoadTab::TemplateData data) _current_template = data; _template_name_label.set_text(_current_template.display_name); - // _template_author_label.set_text(_current_template.author); _short_description_label.set_text(_current_template.short_description); _preview_render.hide(); @@ -105,7 +101,7 @@ void TemplateWidget::display(TemplateLoadTab::TemplateData data) _effect_prefs = NULL; } if (data.is_procedural){ - _effect_prefs = data.tpl_effect->get_imp()->prefs_effect(data.tpl_effect, SP_ACTIVE_DESKTOP, NULL, NULL); // SP_ACTIVE_DESKTOP? + _effect_prefs = data.tpl_effect->get_imp()->prefs_effect(data.tpl_effect, SP_ACTIVE_DESKTOP, NULL, NULL); pack_start(*_effect_prefs); } } diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index a41a14a38..bb35d26a0 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -17,6 +17,7 @@ #include "template-load-tab.h" + namespace Inkscape { namespace UI { @@ -36,7 +37,6 @@ private: Gtk::Image _preview_image; Dialog::SVGPreview _preview_render; Gtk::Label _short_description_label; - Gtk::Label _template_author_label; Gtk::Label _template_name_label; Gtk::Widget *_effect_prefs; -- cgit v1.2.3