From 74651351d05898e961941e98ad68043028ce3a87 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Tue, 18 Jun 2013 15:14:09 +0200 Subject: First newFromTemplate commit. Some basic widgets mechanics (bzr r12379.2.1) --- src/templates/main.cpp | 14 +++++ src/templates/newfromtemplate.cpp | 35 +++++++++++ src/templates/newfromtemplate.h | 25 ++++++++ src/templates/preview.png | Bin 0 -> 2426 bytes src/templates/statictemplateloadtab.cpp | 42 +++++++++++++ src/templates/statictemplateloadtab.h | 27 +++++++++ src/templates/templateloadtab.cpp | 101 ++++++++++++++++++++++++++++++++ src/templates/templateloadtab.h | 53 +++++++++++++++++ 8 files changed, 297 insertions(+) create mode 100644 src/templates/main.cpp create mode 100644 src/templates/newfromtemplate.cpp create mode 100644 src/templates/newfromtemplate.h create mode 100644 src/templates/preview.png create mode 100644 src/templates/statictemplateloadtab.cpp create mode 100644 src/templates/statictemplateloadtab.h create mode 100644 src/templates/templateloadtab.cpp create mode 100644 src/templates/templateloadtab.h (limited to 'src') diff --git a/src/templates/main.cpp b/src/templates/main.cpp new file mode 100644 index 000000000..1ff93822c --- /dev/null +++ b/src/templates/main.cpp @@ -0,0 +1,14 @@ +#include + +#include "newfromtemplate.h" + +int main (int argc, char *argv[]) +{ + Gtk::Main kit(argc, argv); + + NewFromTemplate dialog; + dialog.run(); + //Gtk::Main::run(dialog); + + return 0; +} \ No newline at end of file diff --git a/src/templates/newfromtemplate.cpp b/src/templates/newfromtemplate.cpp new file mode 100644 index 000000000..3a215889d --- /dev/null +++ b/src/templates/newfromtemplate.cpp @@ -0,0 +1,35 @@ +#include "newfromtemplate.h" +#include "gtkmm/alignment.h" + + +NewFromTemplate::NewFromTemplate() : + createButton("Create from template") +{ + set_title("New From Template"); + resize(400, 250); + + get_vbox()->pack_start(mainWidget); + mainWidget.append_page(tab1, "Static Templates"); + mainWidget.append_page(tab2, "Procedural Templates"); + + Gtk::Alignment *align; + align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + get_vbox()->pack_end(*align, Gtk::PACK_SHRINK, 5); + align->add(createButton); + + createButton.signal_pressed().connect( + sigc::mem_fun(*this, &NewFromTemplate::createFromTemplate)); + + show_all(); +} + + +void NewFromTemplate::createFromTemplate() +{ + if (mainWidget.get_current_page() == 0) + tab1.createTemplate(); + else + tab2.createTemplate(); + + response(0); +} \ No newline at end of file diff --git a/src/templates/newfromtemplate.h b/src/templates/newfromtemplate.h new file mode 100644 index 000000000..1a6ce555d --- /dev/null +++ b/src/templates/newfromtemplate.h @@ -0,0 +1,25 @@ +#ifndef GTKMM_NEW_FROM_TEMPLATE_H +#define GTKMM_TNEW_FROM_TEMPLATE_H + +#include +#include +#include + +#include "templateloadtab.h" +#include "statictemplateloadtab.h" + + +class NewFromTemplate : public Gtk::Dialog +{ +public: + NewFromTemplate(); + +private: + Gtk::Notebook mainWidget; + Gtk::Button createButton; + StaticTemplateLoadTab tab1; + TemplateLoadTab tab2; + + void createFromTemplate(); +}; +#endif \ No newline at end of file diff --git a/src/templates/preview.png b/src/templates/preview.png new file mode 100644 index 000000000..c56a832a2 Binary files /dev/null and b/src/templates/preview.png differ diff --git a/src/templates/statictemplateloadtab.cpp b/src/templates/statictemplateloadtab.cpp new file mode 100644 index 000000000..b82338f16 --- /dev/null +++ b/src/templates/statictemplateloadtab.cpp @@ -0,0 +1,42 @@ +#include +#include +#include +#include + +#include "statictemplateloadtab.h" + + +StaticTemplateLoadTab::StaticTemplateLoadTab() : + moreInfoButton("More info"), + previewImage("preview.png"), + shortDescriptionLabel("Short description - I like trains. ad asda asd asdweqe gdfg"), + templateNameLabel("Template_name"), + templateAuthorLabel("by template_author") +{ + templateInfoColumn.pack_start(templateNameLabel, Gtk::PACK_SHRINK, 4); + templateInfoColumn.pack_start(templateAuthorLabel, Gtk::PACK_SHRINK, 0); + templateInfoColumn.pack_start(previewImage, Gtk::PACK_SHRINK, 15); + templateInfoColumn.pack_start(shortDescriptionLabel, Gtk::PACK_SHRINK, 4); + + shortDescriptionLabel.set_line_wrap(true); + shortDescriptionLabel.set_size_request(200); + + Gtk::Alignment *align; + align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + templateInfoColumn.pack_start(*align, Gtk::PACK_SHRINK, 5); + align->add(moreInfoButton); +} + + +void StaticTemplateLoadTab::createTemplate() +{ + std::cout << "Static template\n"; +} + + +void StaticTemplateLoadTab::displayTemplateInfo() +{ + TemplateLoadTab::displayTemplateInfo(); + templateNameLabel.set_text(currentTemplate); +} + diff --git a/src/templates/statictemplateloadtab.h b/src/templates/statictemplateloadtab.h new file mode 100644 index 000000000..43d640b85 --- /dev/null +++ b/src/templates/statictemplateloadtab.h @@ -0,0 +1,27 @@ +#ifndef GTKMM_STATIC_TEMPLATE_LOAD_TAB_H +#define GTKMM_STATIC_TEMPLATE_LOAD_TAB_H + +#include +#include +#include + +#include "templateloadtab.h" + + +class StaticTemplateLoadTab : public TemplateLoadTab +{ +public: + StaticTemplateLoadTab(); + virtual void createTemplate(); + +protected: + virtual void displayTemplateInfo(); + + Gtk::Button moreInfoButton; + Gtk::Label shortDescriptionLabel; + Gtk::Label templateAuthorLabel; + Gtk::Label templateNameLabel; + Gtk::Image previewImage; +}; + +#endif \ No newline at end of file diff --git a/src/templates/templateloadtab.cpp b/src/templates/templateloadtab.cpp new file mode 100644 index 000000000..734ac3eec --- /dev/null +++ b/src/templates/templateloadtab.cpp @@ -0,0 +1,101 @@ +#include +#include + +#include "templateloadtab.h" + + +TemplateLoadTab::TemplateLoadTab() +{ + set_border_width(10); + + Gtk::Label *title; + title = manage(new Gtk::Label("Search Tags:")); + templatesColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); + + templatesColumn.pack_start(keywordsCombo, Gtk::PACK_SHRINK, 0); + + title = manage(new Gtk::Label("Templates")); + templatesColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); + + title = manage(new Gtk::Label("Selected template")); + templateInfoColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); + + initLists(); + + add(mainBox); + mainBox.pack_start(templatesColumn, Gtk::PACK_SHRINK, 20); + mainBox.pack_start(templateInfoColumn, Gtk::PACK_EXPAND_WIDGET, 10); + + templatesColumn.pack_start(templatesView, Gtk::PACK_SHRINK, 5); + + Glib::RefPtr templateSelectionRef = + templatesView.get_selection(); + + templateSelectionRef->signal_changed().connect( + sigc::mem_fun(*this, &TemplateLoadTab::displayTemplateInfo)); + + keywordsCombo.signal_changed().connect( + sigc::mem_fun(*this, &TemplateLoadTab::keywordSelected)); + this->show_all(); +} + + +TemplateLoadTab::~TemplateLoadTab() +{ +} + + +void TemplateLoadTab::createTemplate() +{ + std::cout << "Default Template Tab" << std::endl; +} + + +void TemplateLoadTab::displayTemplateInfo() +{ + Glib::RefPtr templateSelectionRef = templatesView.get_selection(); + if (templateSelectionRef->get_selected()) + currentTemplate = (*templateSelectionRef->get_selected())[templatesColumns.textValue]; +} + + +void TemplateLoadTab::initKeywordsList() +{ + keywordsCombo.append_text("All"); + keywordsCombo.set_active_text("All"); + + for (int i=0; i<10; ++i){ + + keywordsCombo.append_text( "Keyword" + Glib::ustring::format(i)); + } +} + + +void TemplateLoadTab::initLists() +{ + templatesRef = Gtk::ListStore::create(templatesColumns); + templatesView.set_model(templatesRef); + templatesView.append_column("", templatesColumns.textValue); + templatesView.set_headers_visible(false); + + initKeywordsList(); + refreshTemplatesList(); +} + + +void TemplateLoadTab::keywordSelected() +{ + currentKeyword = keywordsCombo.get_active_text(); + refreshTemplatesList(); +} + + +void TemplateLoadTab::refreshTemplatesList() +{ + templatesRef->clear(); + for (int i=0; i<7; ++i){ + Gtk::TreeModel::iterator iter = templatesRef->append(); + Gtk::TreeModel::Row row = *iter; + row[templatesColumns.textValue] = "Template" + Glib::ustring::format(i); + } +} \ No newline at end of file diff --git a/src/templates/templateloadtab.h b/src/templates/templateloadtab.h new file mode 100644 index 000000000..3947e25fb --- /dev/null +++ b/src/templates/templateloadtab.h @@ -0,0 +1,53 @@ +#ifndef GTKMM_TEMPLATE_LOAD_TAB_H +#define GTKMM_TEMPLATE_LOAD_TAB_H + +#include +#include +#include +#include +#include + + +class TemplateLoadTab : public Gtk::Frame +{ + +public: + TemplateLoadTab(); + virtual ~TemplateLoadTab(); + virtual void createTemplate(); + +protected: + class StringModelColumns : public Gtk::TreeModelColumnRecord + { + public: + StringModelColumns() + { + add(textValue); + } + + Gtk::TreeModelColumn textValue; + }; + + Glib::ustring currentKeyword; + Glib::ustring currentTemplate; + + virtual void displayTemplateInfo(); + virtual void initKeywordsList(); + virtual void refreshTemplatesList(); + + void initLists(); + void keywordSelected(); + + Gtk::HBox mainBox; + Gtk::VBox templatesColumn; + Gtk::VBox templateInfoColumn; + + Gtk::ComboBoxText keywordsCombo; + + Gtk::TreeView templatesView; + Glib::RefPtr templatesRef; + StringModelColumns templatesColumns; + +}; + +#endif // GTKMM_TEMPLATE_LOAD_TAB_H \ No newline at end of file -- cgit v1.2.3 From 0d0e1eac78d0ae118041022c43e94901cef1b5e8 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 22 Jun 2013 15:22:37 +0200 Subject: Coding style fixes (bzr r12379.2.2) --- src/templates/main.cpp | 6 +- src/templates/new-from-template.cpp | 42 +++++++++++ src/templates/new-from-template.h | 31 +++++++++ src/templates/newfromtemplate.cpp | 35 ---------- src/templates/newfromtemplate.h | 25 ------- src/templates/static-template-load-tab.cpp | 47 +++++++++++++ src/templates/static-template-load-tab.h | 33 +++++++++ src/templates/statictemplateloadtab.cpp | 42 ----------- src/templates/statictemplateloadtab.h | 27 -------- src/templates/template-load-tab.cpp | 107 +++++++++++++++++++++++++++++ src/templates/template-load-tab.h | 59 ++++++++++++++++ src/templates/templateloadtab.cpp | 101 --------------------------- src/templates/templateloadtab.h | 53 -------------- 13 files changed, 323 insertions(+), 285 deletions(-) create mode 100644 src/templates/new-from-template.cpp create mode 100644 src/templates/new-from-template.h delete mode 100644 src/templates/newfromtemplate.cpp delete mode 100644 src/templates/newfromtemplate.h create mode 100644 src/templates/static-template-load-tab.cpp create mode 100644 src/templates/static-template-load-tab.h delete mode 100644 src/templates/statictemplateloadtab.cpp delete mode 100644 src/templates/statictemplateloadtab.h create mode 100644 src/templates/template-load-tab.cpp create mode 100644 src/templates/template-load-tab.h delete mode 100644 src/templates/templateloadtab.cpp delete mode 100644 src/templates/templateloadtab.h (limited to 'src') diff --git a/src/templates/main.cpp b/src/templates/main.cpp index 1ff93822c..d7a3f40a4 100644 --- a/src/templates/main.cpp +++ b/src/templates/main.cpp @@ -1,6 +1,8 @@ #include -#include "newfromtemplate.h" +#include "new-from-template.h" + +using namespace Inkscape::UI; int main (int argc, char *argv[]) { @@ -11,4 +13,4 @@ int main (int argc, char *argv[]) //Gtk::Main::run(dialog); return 0; -} \ No newline at end of file +} diff --git a/src/templates/new-from-template.cpp b/src/templates/new-from-template.cpp new file mode 100644 index 000000000..450337aea --- /dev/null +++ b/src/templates/new-from-template.cpp @@ -0,0 +1,42 @@ +#include "new-from-template.h" +#include "gtkmm/alignment.h" + +namespace Inkscape { +namespace UI { + + +NewFromTemplate::NewFromTemplate() : + _createButton("Create from template") +{ + set_title("New From Template"); + resize(400, 250); + + get_vbox()->pack_start(_mainWidget); + _mainWidget.append_page(_tab1, "Static Templates"); + _mainWidget.append_page(_tab2, "Procedural Templates"); + + Gtk::Alignment *align; + align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + get_vbox()->pack_end(*align, Gtk::PACK_SHRINK, 5); + align->add(_createButton); + + _createButton.signal_pressed().connect( + sigc::mem_fun(*this, &NewFromTemplate::_createFromTemplate)); + + show_all(); +} + + +void NewFromTemplate::_createFromTemplate() +{ + if ( _mainWidget.get_current_page() == 0 ) { + _tab1.createTemplate(); + } else { + _tab2.createTemplate(); + } + + response(0); +} + +} +} diff --git a/src/templates/new-from-template.h b/src/templates/new-from-template.h new file mode 100644 index 000000000..869680ae3 --- /dev/null +++ b/src/templates/new-from-template.h @@ -0,0 +1,31 @@ +#ifndef INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H +#define INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H + +#include +#include +#include + +#include "template-load-tab.h" +#include "static-template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +class NewFromTemplate : public Gtk::Dialog +{ +public: + NewFromTemplate(); + +private: + Gtk::Notebook _mainWidget; + Gtk::Button _createButton; + StaticTemplateLoadTab _tab1; + TemplateLoadTab _tab2; + + void _createFromTemplate(); +}; + +} +} +#endif diff --git a/src/templates/newfromtemplate.cpp b/src/templates/newfromtemplate.cpp deleted file mode 100644 index 3a215889d..000000000 --- a/src/templates/newfromtemplate.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "newfromtemplate.h" -#include "gtkmm/alignment.h" - - -NewFromTemplate::NewFromTemplate() : - createButton("Create from template") -{ - set_title("New From Template"); - resize(400, 250); - - get_vbox()->pack_start(mainWidget); - mainWidget.append_page(tab1, "Static Templates"); - mainWidget.append_page(tab2, "Procedural Templates"); - - Gtk::Alignment *align; - align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); - get_vbox()->pack_end(*align, Gtk::PACK_SHRINK, 5); - align->add(createButton); - - createButton.signal_pressed().connect( - sigc::mem_fun(*this, &NewFromTemplate::createFromTemplate)); - - show_all(); -} - - -void NewFromTemplate::createFromTemplate() -{ - if (mainWidget.get_current_page() == 0) - tab1.createTemplate(); - else - tab2.createTemplate(); - - response(0); -} \ No newline at end of file diff --git a/src/templates/newfromtemplate.h b/src/templates/newfromtemplate.h deleted file mode 100644 index 1a6ce555d..000000000 --- a/src/templates/newfromtemplate.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef GTKMM_NEW_FROM_TEMPLATE_H -#define GTKMM_TNEW_FROM_TEMPLATE_H - -#include -#include -#include - -#include "templateloadtab.h" -#include "statictemplateloadtab.h" - - -class NewFromTemplate : public Gtk::Dialog -{ -public: - NewFromTemplate(); - -private: - Gtk::Notebook mainWidget; - Gtk::Button createButton; - StaticTemplateLoadTab tab1; - TemplateLoadTab tab2; - - void createFromTemplate(); -}; -#endif \ No newline at end of file diff --git a/src/templates/static-template-load-tab.cpp b/src/templates/static-template-load-tab.cpp new file mode 100644 index 000000000..e71b9dede --- /dev/null +++ b/src/templates/static-template-load-tab.cpp @@ -0,0 +1,47 @@ +#include +#include +#include +#include + +#include "static-template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +StaticTemplateLoadTab::StaticTemplateLoadTab() : + _moreInfoButton("More info"), + _previewImage("preview.png"), + _shortDescriptionLabel("Short description - I like trains. ad asda asd asdweqe gdfg"), + _templateNameLabel("Template_name"), + _templateAuthorLabel("by template_author") +{ + _templateInfoColumn.pack_start(_templateNameLabel, Gtk::PACK_SHRINK, 4); + _templateInfoColumn.pack_start(_templateAuthorLabel, Gtk::PACK_SHRINK, 0); + _templateInfoColumn.pack_start(_previewImage, Gtk::PACK_SHRINK, 15); + _templateInfoColumn.pack_start(_shortDescriptionLabel, Gtk::PACK_SHRINK, 4); + + _shortDescriptionLabel.set_line_wrap(true); + _shortDescriptionLabel.set_size_request(200); + + Gtk::Alignment *align; + align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + _templateInfoColumn.pack_start(*align, Gtk::PACK_SHRINK, 5); + align->add(_moreInfoButton); +} + + +void StaticTemplateLoadTab::createTemplate() +{ + std::cout << "Static template\n"; +} + + +void StaticTemplateLoadTab::_displayTemplateInfo() +{ + TemplateLoadTab::_displayTemplateInfo(); + _templateNameLabel.set_text(_currentTemplate); +} + +} +} diff --git a/src/templates/static-template-load-tab.h b/src/templates/static-template-load-tab.h new file mode 100644 index 000000000..e6ed17f4c --- /dev/null +++ b/src/templates/static-template-load-tab.h @@ -0,0 +1,33 @@ +#ifndef INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H +#define INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H + +#include +#include +#include + +#include "template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +class StaticTemplateLoadTab : public TemplateLoadTab +{ +public: + StaticTemplateLoadTab(); + virtual void createTemplate(); + +protected: + virtual void _displayTemplateInfo(); + + Gtk::Button _moreInfoButton; + Gtk::Label _shortDescriptionLabel; + Gtk::Label _templateAuthorLabel; + Gtk::Label _templateNameLabel; + Gtk::Image _previewImage; +}; + +} +} + +#endif diff --git a/src/templates/statictemplateloadtab.cpp b/src/templates/statictemplateloadtab.cpp deleted file mode 100644 index b82338f16..000000000 --- a/src/templates/statictemplateloadtab.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include -#include - -#include "statictemplateloadtab.h" - - -StaticTemplateLoadTab::StaticTemplateLoadTab() : - moreInfoButton("More info"), - previewImage("preview.png"), - shortDescriptionLabel("Short description - I like trains. ad asda asd asdweqe gdfg"), - templateNameLabel("Template_name"), - templateAuthorLabel("by template_author") -{ - templateInfoColumn.pack_start(templateNameLabel, Gtk::PACK_SHRINK, 4); - templateInfoColumn.pack_start(templateAuthorLabel, Gtk::PACK_SHRINK, 0); - templateInfoColumn.pack_start(previewImage, Gtk::PACK_SHRINK, 15); - templateInfoColumn.pack_start(shortDescriptionLabel, Gtk::PACK_SHRINK, 4); - - shortDescriptionLabel.set_line_wrap(true); - shortDescriptionLabel.set_size_request(200); - - Gtk::Alignment *align; - align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); - templateInfoColumn.pack_start(*align, Gtk::PACK_SHRINK, 5); - align->add(moreInfoButton); -} - - -void StaticTemplateLoadTab::createTemplate() -{ - std::cout << "Static template\n"; -} - - -void StaticTemplateLoadTab::displayTemplateInfo() -{ - TemplateLoadTab::displayTemplateInfo(); - templateNameLabel.set_text(currentTemplate); -} - diff --git a/src/templates/statictemplateloadtab.h b/src/templates/statictemplateloadtab.h deleted file mode 100644 index 43d640b85..000000000 --- a/src/templates/statictemplateloadtab.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef GTKMM_STATIC_TEMPLATE_LOAD_TAB_H -#define GTKMM_STATIC_TEMPLATE_LOAD_TAB_H - -#include -#include -#include - -#include "templateloadtab.h" - - -class StaticTemplateLoadTab : public TemplateLoadTab -{ -public: - StaticTemplateLoadTab(); - virtual void createTemplate(); - -protected: - virtual void displayTemplateInfo(); - - Gtk::Button moreInfoButton; - Gtk::Label shortDescriptionLabel; - Gtk::Label templateAuthorLabel; - Gtk::Label templateNameLabel; - Gtk::Image previewImage; -}; - -#endif \ No newline at end of file diff --git a/src/templates/template-load-tab.cpp b/src/templates/template-load-tab.cpp new file mode 100644 index 000000000..d5fcd18ca --- /dev/null +++ b/src/templates/template-load-tab.cpp @@ -0,0 +1,107 @@ +#include +#include + +#include "template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +TemplateLoadTab::TemplateLoadTab() +{ + set_border_width(10); + + Gtk::Label *title; + title = manage(new Gtk::Label("Search Tags:")); + _templatesColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); + + _templatesColumn.pack_start(_keywordsCombo, Gtk::PACK_SHRINK, 0); + + title = manage(new Gtk::Label("Templates")); + _templatesColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); + + title = manage(new Gtk::Label("Selected template")); + _templateInfoColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); + + _initLists(); + + add(_mainBox); + _mainBox.pack_start(_templatesColumn, Gtk::PACK_SHRINK, 20); + _mainBox.pack_start(_templateInfoColumn, Gtk::PACK_EXPAND_WIDGET, 10); + + _templatesColumn.pack_start(_templatesView, Gtk::PACK_SHRINK, 5); + + Glib::RefPtr templateSelectionRef = + _templatesView.get_selection(); + + templateSelectionRef->signal_changed().connect( + sigc::mem_fun(*this, &TemplateLoadTab::_displayTemplateInfo)); + + _keywordsCombo.signal_changed().connect( + sigc::mem_fun(*this, &TemplateLoadTab::_keywordSelected)); + this->show_all(); +} + + +TemplateLoadTab::~TemplateLoadTab() +{ +} + + +void TemplateLoadTab::createTemplate() +{ + std::cout << "Default Template Tab" << std::endl; +} + + +void TemplateLoadTab::_displayTemplateInfo() +{ + Glib::RefPtr templateSelectionRef = _templatesView.get_selection(); + if (templateSelectionRef->get_selected()) { + _currentTemplate = (*templateSelectionRef->get_selected())[_templatesColumns.textValue]; + } +} + + +void TemplateLoadTab::_initKeywordsList() +{ + _keywordsCombo.append_text("All"); + _keywordsCombo.set_active_text("All"); + + for (int i = 0 ; i < 10 ; ++i) { + _keywordsCombo.append_text( "Keyword" + Glib::ustring::format(i)); + } +} + + +void TemplateLoadTab::_initLists() +{ + _templatesRef = Gtk::ListStore::create(_templatesColumns); + _templatesView.set_model(_templatesRef); + _templatesView.append_column("", _templatesColumns.textValue); + _templatesView.set_headers_visible(false); + + _initKeywordsList(); + _refreshTemplatesList(); +} + + +void TemplateLoadTab::_keywordSelected() +{ + _currentKeyword = _keywordsCombo.get_active_text(); + _refreshTemplatesList(); +} + + +void TemplateLoadTab::_refreshTemplatesList() +{ + _templatesRef->clear(); + for (int i = 0 ; i < 7 ; ++i) { + Gtk::TreeModel::iterator iter = _templatesRef->append(); + Gtk::TreeModel::Row row = *iter; + row[_templatesColumns.textValue] = "Template" + Glib::ustring::format(i); + } +} + +} +} diff --git a/src/templates/template-load-tab.h b/src/templates/template-load-tab.h new file mode 100644 index 000000000..bb55b384c --- /dev/null +++ b/src/templates/template-load-tab.h @@ -0,0 +1,59 @@ +#ifndef INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_LOAD_TAB_H +#define INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_LOAD_TAB_H + +#include +#include +#include +#include +#include + +namespace Inkscape { +namespace UI { + + +class TemplateLoadTab : public Gtk::Frame +{ + +public: + TemplateLoadTab(); + virtual ~TemplateLoadTab(); + virtual void createTemplate(); + +protected: + class StringModelColumns : public Gtk::TreeModelColumnRecord + { + public: + StringModelColumns() + { + add(textValue); + } + + Gtk::TreeModelColumn textValue; + }; + + Glib::ustring _currentKeyword; + Glib::ustring _currentTemplate; + + virtual void _displayTemplateInfo(); + virtual void _initKeywordsList(); + virtual void _refreshTemplatesList(); + + void _initLists(); + void _keywordSelected(); + + Gtk::HBox _mainBox; + Gtk::VBox _templatesColumn; + Gtk::VBox _templateInfoColumn; + + Gtk::ComboBoxText _keywordsCombo; + + Gtk::TreeView _templatesView; + Glib::RefPtr _templatesRef; + StringModelColumns _templatesColumns; + +}; + +} +} + +#endif diff --git a/src/templates/templateloadtab.cpp b/src/templates/templateloadtab.cpp deleted file mode 100644 index 734ac3eec..000000000 --- a/src/templates/templateloadtab.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include -#include - -#include "templateloadtab.h" - - -TemplateLoadTab::TemplateLoadTab() -{ - set_border_width(10); - - Gtk::Label *title; - title = manage(new Gtk::Label("Search Tags:")); - templatesColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); - - templatesColumn.pack_start(keywordsCombo, Gtk::PACK_SHRINK, 0); - - title = manage(new Gtk::Label("Templates")); - templatesColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); - - title = manage(new Gtk::Label("Selected template")); - templateInfoColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); - - initLists(); - - add(mainBox); - mainBox.pack_start(templatesColumn, Gtk::PACK_SHRINK, 20); - mainBox.pack_start(templateInfoColumn, Gtk::PACK_EXPAND_WIDGET, 10); - - templatesColumn.pack_start(templatesView, Gtk::PACK_SHRINK, 5); - - Glib::RefPtr templateSelectionRef = - templatesView.get_selection(); - - templateSelectionRef->signal_changed().connect( - sigc::mem_fun(*this, &TemplateLoadTab::displayTemplateInfo)); - - keywordsCombo.signal_changed().connect( - sigc::mem_fun(*this, &TemplateLoadTab::keywordSelected)); - this->show_all(); -} - - -TemplateLoadTab::~TemplateLoadTab() -{ -} - - -void TemplateLoadTab::createTemplate() -{ - std::cout << "Default Template Tab" << std::endl; -} - - -void TemplateLoadTab::displayTemplateInfo() -{ - Glib::RefPtr templateSelectionRef = templatesView.get_selection(); - if (templateSelectionRef->get_selected()) - currentTemplate = (*templateSelectionRef->get_selected())[templatesColumns.textValue]; -} - - -void TemplateLoadTab::initKeywordsList() -{ - keywordsCombo.append_text("All"); - keywordsCombo.set_active_text("All"); - - for (int i=0; i<10; ++i){ - - keywordsCombo.append_text( "Keyword" + Glib::ustring::format(i)); - } -} - - -void TemplateLoadTab::initLists() -{ - templatesRef = Gtk::ListStore::create(templatesColumns); - templatesView.set_model(templatesRef); - templatesView.append_column("", templatesColumns.textValue); - templatesView.set_headers_visible(false); - - initKeywordsList(); - refreshTemplatesList(); -} - - -void TemplateLoadTab::keywordSelected() -{ - currentKeyword = keywordsCombo.get_active_text(); - refreshTemplatesList(); -} - - -void TemplateLoadTab::refreshTemplatesList() -{ - templatesRef->clear(); - for (int i=0; i<7; ++i){ - Gtk::TreeModel::iterator iter = templatesRef->append(); - Gtk::TreeModel::Row row = *iter; - row[templatesColumns.textValue] = "Template" + Glib::ustring::format(i); - } -} \ No newline at end of file diff --git a/src/templates/templateloadtab.h b/src/templates/templateloadtab.h deleted file mode 100644 index 3947e25fb..000000000 --- a/src/templates/templateloadtab.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef GTKMM_TEMPLATE_LOAD_TAB_H -#define GTKMM_TEMPLATE_LOAD_TAB_H - -#include -#include -#include -#include -#include - - -class TemplateLoadTab : public Gtk::Frame -{ - -public: - TemplateLoadTab(); - virtual ~TemplateLoadTab(); - virtual void createTemplate(); - -protected: - class StringModelColumns : public Gtk::TreeModelColumnRecord - { - public: - StringModelColumns() - { - add(textValue); - } - - Gtk::TreeModelColumn textValue; - }; - - Glib::ustring currentKeyword; - Glib::ustring currentTemplate; - - virtual void displayTemplateInfo(); - virtual void initKeywordsList(); - virtual void refreshTemplatesList(); - - void initLists(); - void keywordSelected(); - - Gtk::HBox mainBox; - Gtk::VBox templatesColumn; - Gtk::VBox templateInfoColumn; - - Gtk::ComboBoxText keywordsCombo; - - Gtk::TreeView templatesView; - Glib::RefPtr templatesRef; - StringModelColumns templatesColumns; - -}; - -#endif // GTKMM_TEMPLATE_LOAD_TAB_H \ No newline at end of file -- cgit v1.2.3 From b1f718bfec1daa260ea6417c85c5502954ad1e5e Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 22 Jun 2013 15:47:42 +0200 Subject: Changed comboBox into editable (bzr r12379.2.3) --- src/templates/template-load-tab.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/templates/template-load-tab.cpp b/src/templates/template-load-tab.cpp index d5fcd18ca..febbb3be6 100644 --- a/src/templates/template-load-tab.cpp +++ b/src/templates/template-load-tab.cpp @@ -7,7 +7,8 @@ namespace Inkscape { namespace UI { -TemplateLoadTab::TemplateLoadTab() +TemplateLoadTab::TemplateLoadTab() : + _keywordsCombo(true) { set_border_width(10); @@ -66,7 +67,6 @@ void TemplateLoadTab::_displayTemplateInfo() void TemplateLoadTab::_initKeywordsList() { _keywordsCombo.append_text("All"); - _keywordsCombo.set_active_text("All"); for (int i = 0 ; i < 10 ; ++i) { _keywordsCombo.append_text( "Keyword" + Glib::ustring::format(i)); -- cgit v1.2.3 From 0b13569c400bb2976c5f71cbac687b5e96c2e7a0 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Thu, 27 Jun 2013 11:43:19 +0200 Subject: Coding style fixes (bzr r12379.2.4) --- src/templates/new-from-template.cpp | 16 +++++----- src/templates/new-from-template.h | 4 +-- src/templates/static-template-load-tab.cpp | 30 +++++++++---------- src/templates/static-template-load-tab.h | 10 +++---- src/templates/template-load-tab.cpp | 48 +++++++++++++++--------------- src/templates/template-load-tab.h | 18 +++++------ 6 files changed, 63 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/templates/new-from-template.cpp b/src/templates/new-from-template.cpp index 450337aea..fc590d199 100644 --- a/src/templates/new-from-template.cpp +++ b/src/templates/new-from-template.cpp @@ -5,22 +5,22 @@ namespace Inkscape { namespace UI { -NewFromTemplate::NewFromTemplate() : - _createButton("Create from template") +NewFromTemplate::NewFromTemplate() + : _create_template_button("Create from template") { set_title("New From Template"); resize(400, 250); - get_vbox()->pack_start(_mainWidget); - _mainWidget.append_page(_tab1, "Static Templates"); - _mainWidget.append_page(_tab2, "Procedural Templates"); + get_vbox()->pack_start(_main_widget); + _main_widget.append_page(_tab1, "Static Templates"); + _main_widget.append_page(_tab2, "Procedural Templates"); Gtk::Alignment *align; align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); get_vbox()->pack_end(*align, Gtk::PACK_SHRINK, 5); - align->add(_createButton); + align->add(_create_template_button); - _createButton.signal_pressed().connect( + _create_template_button.signal_pressed().connect( sigc::mem_fun(*this, &NewFromTemplate::_createFromTemplate)); show_all(); @@ -29,7 +29,7 @@ NewFromTemplate::NewFromTemplate() : void NewFromTemplate::_createFromTemplate() { - if ( _mainWidget.get_current_page() == 0 ) { + if ( _main_widget.get_current_page() == 0 ) { _tab1.createTemplate(); } else { _tab2.createTemplate(); diff --git a/src/templates/new-from-template.h b/src/templates/new-from-template.h index 869680ae3..ef3cbce18 100644 --- a/src/templates/new-from-template.h +++ b/src/templates/new-from-template.h @@ -18,8 +18,8 @@ public: NewFromTemplate(); private: - Gtk::Notebook _mainWidget; - Gtk::Button _createButton; + Gtk::Notebook _main_widget; + Gtk::Button _create_template_button; StaticTemplateLoadTab _tab1; TemplateLoadTab _tab2; diff --git a/src/templates/static-template-load-tab.cpp b/src/templates/static-template-load-tab.cpp index e71b9dede..83ff32e52 100644 --- a/src/templates/static-template-load-tab.cpp +++ b/src/templates/static-template-load-tab.cpp @@ -9,25 +9,25 @@ namespace Inkscape { namespace UI { -StaticTemplateLoadTab::StaticTemplateLoadTab() : - _moreInfoButton("More info"), - _previewImage("preview.png"), - _shortDescriptionLabel("Short description - I like trains. ad asda asd asdweqe gdfg"), - _templateNameLabel("Template_name"), - _templateAuthorLabel("by template_author") +StaticTemplateLoadTab::StaticTemplateLoadTab() + : _more_info_button("More info") + , _preview_image("preview.png") + , _short_description_label("Short description - I like trains. ad asda asd asdweqe gdfg") + , _template_name_label("Template_name") + , _template_author_label("by template_author") { - _templateInfoColumn.pack_start(_templateNameLabel, Gtk::PACK_SHRINK, 4); - _templateInfoColumn.pack_start(_templateAuthorLabel, Gtk::PACK_SHRINK, 0); - _templateInfoColumn.pack_start(_previewImage, Gtk::PACK_SHRINK, 15); - _templateInfoColumn.pack_start(_shortDescriptionLabel, Gtk::PACK_SHRINK, 4); + _template_info_column.pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); + _template_info_column.pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); + _template_info_column.pack_start(_preview_image, Gtk::PACK_SHRINK, 15); + _template_info_column.pack_start(_short_description_label, Gtk::PACK_SHRINK, 4); - _shortDescriptionLabel.set_line_wrap(true); - _shortDescriptionLabel.set_size_request(200); + _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)); - _templateInfoColumn.pack_start(*align, Gtk::PACK_SHRINK, 5); - align->add(_moreInfoButton); + _template_info_column.pack_start(*align, Gtk::PACK_SHRINK, 5); + align->add(_more_info_button); } @@ -40,7 +40,7 @@ void StaticTemplateLoadTab::createTemplate() void StaticTemplateLoadTab::_displayTemplateInfo() { TemplateLoadTab::_displayTemplateInfo(); - _templateNameLabel.set_text(_currentTemplate); + _template_name_label.set_text(_current_template); } } diff --git a/src/templates/static-template-load-tab.h b/src/templates/static-template-load-tab.h index e6ed17f4c..651f146a0 100644 --- a/src/templates/static-template-load-tab.h +++ b/src/templates/static-template-load-tab.h @@ -20,11 +20,11 @@ public: protected: virtual void _displayTemplateInfo(); - Gtk::Button _moreInfoButton; - Gtk::Label _shortDescriptionLabel; - Gtk::Label _templateAuthorLabel; - Gtk::Label _templateNameLabel; - Gtk::Image _previewImage; + Gtk::Button _more_info_button; + Gtk::Label _short_description_label; + Gtk::Label _template_author_label; + Gtk::Label _template_name_label; + Gtk::Image _preview_image; }; } diff --git a/src/templates/template-load-tab.cpp b/src/templates/template-load-tab.cpp index febbb3be6..a7b5e63f3 100644 --- a/src/templates/template-load-tab.cpp +++ b/src/templates/template-load-tab.cpp @@ -7,38 +7,38 @@ namespace Inkscape { namespace UI { -TemplateLoadTab::TemplateLoadTab() : - _keywordsCombo(true) +TemplateLoadTab::TemplateLoadTab() + : _keywords_combo(true) { set_border_width(10); Gtk::Label *title; title = manage(new Gtk::Label("Search Tags:")); - _templatesColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); + _templates_column.pack_start(*title, Gtk::PACK_SHRINK, 10); - _templatesColumn.pack_start(_keywordsCombo, Gtk::PACK_SHRINK, 0); + _templates_column.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 0); title = manage(new Gtk::Label("Templates")); - _templatesColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); + _templates_column.pack_start(*title, Gtk::PACK_SHRINK, 10); title = manage(new Gtk::Label("Selected template")); - _templateInfoColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); + _template_info_column.pack_start(*title, Gtk::PACK_SHRINK, 10); _initLists(); - add(_mainBox); - _mainBox.pack_start(_templatesColumn, Gtk::PACK_SHRINK, 20); - _mainBox.pack_start(_templateInfoColumn, Gtk::PACK_EXPAND_WIDGET, 10); + add(_main_box); + _main_box.pack_start(_templates_column, Gtk::PACK_SHRINK, 20); + _main_box.pack_start(_template_info_column, Gtk::PACK_EXPAND_WIDGET, 10); - _templatesColumn.pack_start(_templatesView, Gtk::PACK_SHRINK, 5); + _templates_column.pack_start(_templates_view, Gtk::PACK_SHRINK, 5); Glib::RefPtr templateSelectionRef = - _templatesView.get_selection(); + _templates_view.get_selection(); templateSelectionRef->signal_changed().connect( sigc::mem_fun(*this, &TemplateLoadTab::_displayTemplateInfo)); - _keywordsCombo.signal_changed().connect( + _keywords_combo.signal_changed().connect( sigc::mem_fun(*this, &TemplateLoadTab::_keywordSelected)); this->show_all(); } @@ -57,29 +57,29 @@ void TemplateLoadTab::createTemplate() void TemplateLoadTab::_displayTemplateInfo() { - Glib::RefPtr templateSelectionRef = _templatesView.get_selection(); + Glib::RefPtr templateSelectionRef = _templates_view.get_selection(); if (templateSelectionRef->get_selected()) { - _currentTemplate = (*templateSelectionRef->get_selected())[_templatesColumns.textValue]; + _current_template = (*templateSelectionRef->get_selected())[_templates_columns.textValue]; } } void TemplateLoadTab::_initKeywordsList() { - _keywordsCombo.append_text("All"); + _keywords_combo.append_text("All"); for (int i = 0 ; i < 10 ; ++i) { - _keywordsCombo.append_text( "Keyword" + Glib::ustring::format(i)); + _keywords_combo.append_text( "Keyword" + Glib::ustring::format(i)); } } void TemplateLoadTab::_initLists() { - _templatesRef = Gtk::ListStore::create(_templatesColumns); - _templatesView.set_model(_templatesRef); - _templatesView.append_column("", _templatesColumns.textValue); - _templatesView.set_headers_visible(false); + _templates_ref = Gtk::ListStore::create(_templates_columns); + _templates_view.set_model(_templates_ref); + _templates_view.append_column("", _templates_columns.textValue); + _templates_view.set_headers_visible(false); _initKeywordsList(); _refreshTemplatesList(); @@ -88,18 +88,18 @@ void TemplateLoadTab::_initLists() void TemplateLoadTab::_keywordSelected() { - _currentKeyword = _keywordsCombo.get_active_text(); + _current_keyword = _keywords_combo.get_active_text(); _refreshTemplatesList(); } void TemplateLoadTab::_refreshTemplatesList() { - _templatesRef->clear(); + _templates_ref->clear(); for (int i = 0 ; i < 7 ; ++i) { - Gtk::TreeModel::iterator iter = _templatesRef->append(); + Gtk::TreeModel::iterator iter = _templates_ref->append(); Gtk::TreeModel::Row row = *iter; - row[_templatesColumns.textValue] = "Template" + Glib::ustring::format(i); + row[_templates_columns.textValue] = "Template" + Glib::ustring::format(i); } } diff --git a/src/templates/template-load-tab.h b/src/templates/template-load-tab.h index bb55b384c..a9fa7c313 100644 --- a/src/templates/template-load-tab.h +++ b/src/templates/template-load-tab.h @@ -31,8 +31,8 @@ protected: Gtk::TreeModelColumn textValue; }; - Glib::ustring _currentKeyword; - Glib::ustring _currentTemplate; + Glib::ustring _current_keyword; + Glib::ustring _current_template; virtual void _displayTemplateInfo(); virtual void _initKeywordsList(); @@ -41,15 +41,15 @@ protected: void _initLists(); void _keywordSelected(); - Gtk::HBox _mainBox; - Gtk::VBox _templatesColumn; - Gtk::VBox _templateInfoColumn; + Gtk::HBox _main_box; + Gtk::VBox _templates_column; + Gtk::VBox _template_info_column; - Gtk::ComboBoxText _keywordsCombo; + Gtk::ComboBoxText _keywords_combo; - Gtk::TreeView _templatesView; - Glib::RefPtr _templatesRef; - StringModelColumns _templatesColumns; + Gtk::TreeView _templates_view; + Glib::RefPtr _templates_ref; + StringModelColumns _templates_columns; }; -- cgit v1.2.3 From fdb68963cec5ddbd3eef111f4c95b7e049aa839c Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Tue, 2 Jul 2013 17:37:42 +0200 Subject: Adding NewFromTemplate to the Inkscape menu (bzr r12379.2.5) --- src/file.h | 1 + src/menus-skeleton.h | 1 + src/templates/new-from-template.cpp | 42 ----------- src/templates/new-from-template.h | 31 --------- src/templates/static-template-load-tab.cpp | 47 ------------- src/templates/static-template-load-tab.h | 33 --------- src/templates/template-load-tab.cpp | 107 ----------------------------- src/templates/template-load-tab.h | 59 ---------------- src/ui/dialog/Makefile_insert | 6 ++ src/ui/dialog/new-from-template.cpp | 42 +++++++++++ src/ui/dialog/new-from-template.h | 31 +++++++++ src/ui/dialog/static-template-load-tab.cpp | 47 +++++++++++++ src/ui/dialog/static-template-load-tab.h | 33 +++++++++ src/ui/dialog/template-load-tab.cpp | 107 +++++++++++++++++++++++++++++ src/ui/dialog/template-load-tab.h | 59 ++++++++++++++++ src/verbs.cpp | 6 ++ src/verbs.h | 1 + 17 files changed, 334 insertions(+), 319 deletions(-) delete mode 100644 src/templates/new-from-template.cpp delete mode 100644 src/templates/new-from-template.h delete mode 100644 src/templates/static-template-load-tab.cpp delete mode 100644 src/templates/static-template-load-tab.h delete mode 100644 src/templates/template-load-tab.cpp delete mode 100644 src/templates/template-load-tab.h create mode 100644 src/ui/dialog/new-from-template.cpp create mode 100644 src/ui/dialog/new-from-template.h create mode 100644 src/ui/dialog/static-template-load-tab.cpp create mode 100644 src/ui/dialog/static-template-load-tab.h create mode 100644 src/ui/dialog/template-load-tab.cpp create mode 100644 src/ui/dialog/template-load-tab.h (limited to 'src') diff --git a/src/file.h b/src/file.h index fe8ad9af3..acc6c5c7c 100644 --- a/src/file.h +++ b/src/file.h @@ -45,6 +45,7 @@ Glib::ustring sp_file_default_template_uri(); */ SPDesktop* sp_file_new (const Glib::ustring &templ); SPDesktop* sp_file_new_default (void); +SPDesktop* sp_file_new_from_templatee (); /*###################### ## D E L E T E diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 77e781763..7c412b605 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -17,6 +17,7 @@ static char const menus_skeleton[] = " \n" " \n" " \n" +" \n" " \n" " \n" " \n" diff --git a/src/templates/new-from-template.cpp b/src/templates/new-from-template.cpp deleted file mode 100644 index fc590d199..000000000 --- a/src/templates/new-from-template.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "new-from-template.h" -#include "gtkmm/alignment.h" - -namespace Inkscape { -namespace UI { - - -NewFromTemplate::NewFromTemplate() - : _create_template_button("Create from template") -{ - set_title("New From Template"); - resize(400, 250); - - get_vbox()->pack_start(_main_widget); - _main_widget.append_page(_tab1, "Static Templates"); - _main_widget.append_page(_tab2, "Procedural Templates"); - - Gtk::Alignment *align; - align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); - get_vbox()->pack_end(*align, Gtk::PACK_SHRINK, 5); - align->add(_create_template_button); - - _create_template_button.signal_pressed().connect( - sigc::mem_fun(*this, &NewFromTemplate::_createFromTemplate)); - - show_all(); -} - - -void NewFromTemplate::_createFromTemplate() -{ - if ( _main_widget.get_current_page() == 0 ) { - _tab1.createTemplate(); - } else { - _tab2.createTemplate(); - } - - response(0); -} - -} -} diff --git a/src/templates/new-from-template.h b/src/templates/new-from-template.h deleted file mode 100644 index ef3cbce18..000000000 --- a/src/templates/new-from-template.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H -#define INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H - -#include -#include -#include - -#include "template-load-tab.h" -#include "static-template-load-tab.h" - -namespace Inkscape { -namespace UI { - - -class NewFromTemplate : public Gtk::Dialog -{ -public: - NewFromTemplate(); - -private: - Gtk::Notebook _main_widget; - Gtk::Button _create_template_button; - StaticTemplateLoadTab _tab1; - TemplateLoadTab _tab2; - - void _createFromTemplate(); -}; - -} -} -#endif diff --git a/src/templates/static-template-load-tab.cpp b/src/templates/static-template-load-tab.cpp deleted file mode 100644 index 83ff32e52..000000000 --- a/src/templates/static-template-load-tab.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include -#include -#include - -#include "static-template-load-tab.h" - -namespace Inkscape { -namespace UI { - - -StaticTemplateLoadTab::StaticTemplateLoadTab() - : _more_info_button("More info") - , _preview_image("preview.png") - , _short_description_label("Short description - I like trains. ad asda asd asdweqe gdfg") - , _template_name_label("Template_name") - , _template_author_label("by template_author") -{ - _template_info_column.pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); - _template_info_column.pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); - _template_info_column.pack_start(_preview_image, Gtk::PACK_SHRINK, 15); - _template_info_column.pack_start(_short_description_label, Gtk::PACK_SHRINK, 4); - - _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)); - _template_info_column.pack_start(*align, Gtk::PACK_SHRINK, 5); - align->add(_more_info_button); -} - - -void StaticTemplateLoadTab::createTemplate() -{ - std::cout << "Static template\n"; -} - - -void StaticTemplateLoadTab::_displayTemplateInfo() -{ - TemplateLoadTab::_displayTemplateInfo(); - _template_name_label.set_text(_current_template); -} - -} -} diff --git a/src/templates/static-template-load-tab.h b/src/templates/static-template-load-tab.h deleted file mode 100644 index 651f146a0..000000000 --- a/src/templates/static-template-load-tab.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H -#define INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H - -#include -#include -#include - -#include "template-load-tab.h" - -namespace Inkscape { -namespace UI { - - -class StaticTemplateLoadTab : public TemplateLoadTab -{ -public: - StaticTemplateLoadTab(); - virtual void createTemplate(); - -protected: - virtual void _displayTemplateInfo(); - - Gtk::Button _more_info_button; - Gtk::Label _short_description_label; - Gtk::Label _template_author_label; - Gtk::Label _template_name_label; - Gtk::Image _preview_image; -}; - -} -} - -#endif diff --git a/src/templates/template-load-tab.cpp b/src/templates/template-load-tab.cpp deleted file mode 100644 index a7b5e63f3..000000000 --- a/src/templates/template-load-tab.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include - -#include "template-load-tab.h" - -namespace Inkscape { -namespace UI { - - -TemplateLoadTab::TemplateLoadTab() - : _keywords_combo(true) -{ - set_border_width(10); - - Gtk::Label *title; - title = manage(new Gtk::Label("Search Tags:")); - _templates_column.pack_start(*title, Gtk::PACK_SHRINK, 10); - - _templates_column.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 0); - - title = manage(new Gtk::Label("Templates")); - _templates_column.pack_start(*title, Gtk::PACK_SHRINK, 10); - - title = manage(new Gtk::Label("Selected template")); - _template_info_column.pack_start(*title, Gtk::PACK_SHRINK, 10); - - _initLists(); - - add(_main_box); - _main_box.pack_start(_templates_column, Gtk::PACK_SHRINK, 20); - _main_box.pack_start(_template_info_column, Gtk::PACK_EXPAND_WIDGET, 10); - - _templates_column.pack_start(_templates_view, Gtk::PACK_SHRINK, 5); - - Glib::RefPtr templateSelectionRef = - _templates_view.get_selection(); - - templateSelectionRef->signal_changed().connect( - sigc::mem_fun(*this, &TemplateLoadTab::_displayTemplateInfo)); - - _keywords_combo.signal_changed().connect( - sigc::mem_fun(*this, &TemplateLoadTab::_keywordSelected)); - this->show_all(); -} - - -TemplateLoadTab::~TemplateLoadTab() -{ -} - - -void TemplateLoadTab::createTemplate() -{ - std::cout << "Default Template Tab" << std::endl; -} - - -void TemplateLoadTab::_displayTemplateInfo() -{ - Glib::RefPtr templateSelectionRef = _templates_view.get_selection(); - if (templateSelectionRef->get_selected()) { - _current_template = (*templateSelectionRef->get_selected())[_templates_columns.textValue]; - } -} - - -void TemplateLoadTab::_initKeywordsList() -{ - _keywords_combo.append_text("All"); - - for (int i = 0 ; i < 10 ; ++i) { - _keywords_combo.append_text( "Keyword" + Glib::ustring::format(i)); - } -} - - -void TemplateLoadTab::_initLists() -{ - _templates_ref = Gtk::ListStore::create(_templates_columns); - _templates_view.set_model(_templates_ref); - _templates_view.append_column("", _templates_columns.textValue); - _templates_view.set_headers_visible(false); - - _initKeywordsList(); - _refreshTemplatesList(); -} - - -void TemplateLoadTab::_keywordSelected() -{ - _current_keyword = _keywords_combo.get_active_text(); - _refreshTemplatesList(); -} - - -void TemplateLoadTab::_refreshTemplatesList() -{ - _templates_ref->clear(); - for (int i = 0 ; i < 7 ; ++i) { - Gtk::TreeModel::iterator iter = _templates_ref->append(); - Gtk::TreeModel::Row row = *iter; - row[_templates_columns.textValue] = "Template" + Glib::ustring::format(i); - } -} - -} -} diff --git a/src/templates/template-load-tab.h b/src/templates/template-load-tab.h deleted file mode 100644 index a9fa7c313..000000000 --- a/src/templates/template-load-tab.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_LOAD_TAB_H -#define INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_LOAD_TAB_H - -#include -#include -#include -#include -#include - -namespace Inkscape { -namespace UI { - - -class TemplateLoadTab : public Gtk::Frame -{ - -public: - TemplateLoadTab(); - virtual ~TemplateLoadTab(); - virtual void createTemplate(); - -protected: - class StringModelColumns : public Gtk::TreeModelColumnRecord - { - public: - StringModelColumns() - { - add(textValue); - } - - Gtk::TreeModelColumn textValue; - }; - - Glib::ustring _current_keyword; - Glib::ustring _current_template; - - virtual void _displayTemplateInfo(); - virtual void _initKeywordsList(); - virtual void _refreshTemplatesList(); - - void _initLists(); - void _keywordSelected(); - - Gtk::HBox _main_box; - Gtk::VBox _templates_column; - Gtk::VBox _template_info_column; - - Gtk::ComboBoxText _keywords_combo; - - Gtk::TreeView _templates_view; - Glib::RefPtr _templates_ref; - StringModelColumns _templates_columns; - -}; - -} -} - -#endif diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index 580b47522..4a34cc71c 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -70,6 +70,8 @@ ink_common_sources += \ ui/dialog/memory.h \ ui/dialog/messages.cpp \ ui/dialog/messages.h \ + ui/dialog/new-from-template.cpp \ + ui/dialog/new-from-template.h \ ui/dialog/ocaldialogs.cpp \ ui/dialog/ocaldialogs.h \ ui/dialog/object-attributes.cpp \ @@ -85,12 +87,16 @@ ink_common_sources += \ ui/dialog/scriptdialog.h \ ui/dialog/spellcheck.cpp \ ui/dialog/spellcheck.h \ + ui/dialog/static-template-load-tab.cpp \ + ui/dialog/static-template-load-tab.h \ ui/dialog/svg-fonts-dialog.cpp \ ui/dialog/svg-fonts-dialog.h \ ui/dialog/swatches.cpp \ ui/dialog/swatches.h \ ui/dialog/symbols.cpp \ ui/dialog/symbols.h \ + ui/dialog/template-load-tab.cpp \ + ui/dialog/template-load-tab.h \ ui/dialog/text-edit.cpp \ ui/dialog/text-edit.h \ ui/dialog/tile.cpp \ diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp new file mode 100644 index 000000000..fc590d199 --- /dev/null +++ b/src/ui/dialog/new-from-template.cpp @@ -0,0 +1,42 @@ +#include "new-from-template.h" +#include "gtkmm/alignment.h" + +namespace Inkscape { +namespace UI { + + +NewFromTemplate::NewFromTemplate() + : _create_template_button("Create from template") +{ + set_title("New From Template"); + resize(400, 250); + + get_vbox()->pack_start(_main_widget); + _main_widget.append_page(_tab1, "Static Templates"); + _main_widget.append_page(_tab2, "Procedural Templates"); + + Gtk::Alignment *align; + align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + get_vbox()->pack_end(*align, Gtk::PACK_SHRINK, 5); + align->add(_create_template_button); + + _create_template_button.signal_pressed().connect( + sigc::mem_fun(*this, &NewFromTemplate::_createFromTemplate)); + + show_all(); +} + + +void NewFromTemplate::_createFromTemplate() +{ + if ( _main_widget.get_current_page() == 0 ) { + _tab1.createTemplate(); + } else { + _tab2.createTemplate(); + } + + response(0); +} + +} +} diff --git a/src/ui/dialog/new-from-template.h b/src/ui/dialog/new-from-template.h new file mode 100644 index 000000000..ef3cbce18 --- /dev/null +++ b/src/ui/dialog/new-from-template.h @@ -0,0 +1,31 @@ +#ifndef INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H +#define INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H + +#include +#include +#include + +#include "template-load-tab.h" +#include "static-template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +class NewFromTemplate : public Gtk::Dialog +{ +public: + NewFromTemplate(); + +private: + Gtk::Notebook _main_widget; + Gtk::Button _create_template_button; + StaticTemplateLoadTab _tab1; + TemplateLoadTab _tab2; + + void _createFromTemplate(); +}; + +} +} +#endif diff --git a/src/ui/dialog/static-template-load-tab.cpp b/src/ui/dialog/static-template-load-tab.cpp new file mode 100644 index 000000000..83ff32e52 --- /dev/null +++ b/src/ui/dialog/static-template-load-tab.cpp @@ -0,0 +1,47 @@ +#include +#include +#include +#include + +#include "static-template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +StaticTemplateLoadTab::StaticTemplateLoadTab() + : _more_info_button("More info") + , _preview_image("preview.png") + , _short_description_label("Short description - I like trains. ad asda asd asdweqe gdfg") + , _template_name_label("Template_name") + , _template_author_label("by template_author") +{ + _template_info_column.pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); + _template_info_column.pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); + _template_info_column.pack_start(_preview_image, Gtk::PACK_SHRINK, 15); + _template_info_column.pack_start(_short_description_label, Gtk::PACK_SHRINK, 4); + + _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)); + _template_info_column.pack_start(*align, Gtk::PACK_SHRINK, 5); + align->add(_more_info_button); +} + + +void StaticTemplateLoadTab::createTemplate() +{ + std::cout << "Static template\n"; +} + + +void StaticTemplateLoadTab::_displayTemplateInfo() +{ + TemplateLoadTab::_displayTemplateInfo(); + _template_name_label.set_text(_current_template); +} + +} +} diff --git a/src/ui/dialog/static-template-load-tab.h b/src/ui/dialog/static-template-load-tab.h new file mode 100644 index 000000000..651f146a0 --- /dev/null +++ b/src/ui/dialog/static-template-load-tab.h @@ -0,0 +1,33 @@ +#ifndef INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H +#define INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H + +#include +#include +#include + +#include "template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +class StaticTemplateLoadTab : public TemplateLoadTab +{ +public: + StaticTemplateLoadTab(); + virtual void createTemplate(); + +protected: + virtual void _displayTemplateInfo(); + + Gtk::Button _more_info_button; + Gtk::Label _short_description_label; + Gtk::Label _template_author_label; + Gtk::Label _template_name_label; + Gtk::Image _preview_image; +}; + +} +} + +#endif diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp new file mode 100644 index 000000000..a7b5e63f3 --- /dev/null +++ b/src/ui/dialog/template-load-tab.cpp @@ -0,0 +1,107 @@ +#include +#include + +#include "template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +TemplateLoadTab::TemplateLoadTab() + : _keywords_combo(true) +{ + set_border_width(10); + + Gtk::Label *title; + title = manage(new Gtk::Label("Search Tags:")); + _templates_column.pack_start(*title, Gtk::PACK_SHRINK, 10); + + _templates_column.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 0); + + title = manage(new Gtk::Label("Templates")); + _templates_column.pack_start(*title, Gtk::PACK_SHRINK, 10); + + title = manage(new Gtk::Label("Selected template")); + _template_info_column.pack_start(*title, Gtk::PACK_SHRINK, 10); + + _initLists(); + + add(_main_box); + _main_box.pack_start(_templates_column, Gtk::PACK_SHRINK, 20); + _main_box.pack_start(_template_info_column, Gtk::PACK_EXPAND_WIDGET, 10); + + _templates_column.pack_start(_templates_view, Gtk::PACK_SHRINK, 5); + + Glib::RefPtr templateSelectionRef = + _templates_view.get_selection(); + + templateSelectionRef->signal_changed().connect( + sigc::mem_fun(*this, &TemplateLoadTab::_displayTemplateInfo)); + + _keywords_combo.signal_changed().connect( + sigc::mem_fun(*this, &TemplateLoadTab::_keywordSelected)); + this->show_all(); +} + + +TemplateLoadTab::~TemplateLoadTab() +{ +} + + +void TemplateLoadTab::createTemplate() +{ + std::cout << "Default Template Tab" << std::endl; +} + + +void TemplateLoadTab::_displayTemplateInfo() +{ + Glib::RefPtr templateSelectionRef = _templates_view.get_selection(); + if (templateSelectionRef->get_selected()) { + _current_template = (*templateSelectionRef->get_selected())[_templates_columns.textValue]; + } +} + + +void TemplateLoadTab::_initKeywordsList() +{ + _keywords_combo.append_text("All"); + + for (int i = 0 ; i < 10 ; ++i) { + _keywords_combo.append_text( "Keyword" + Glib::ustring::format(i)); + } +} + + +void TemplateLoadTab::_initLists() +{ + _templates_ref = Gtk::ListStore::create(_templates_columns); + _templates_view.set_model(_templates_ref); + _templates_view.append_column("", _templates_columns.textValue); + _templates_view.set_headers_visible(false); + + _initKeywordsList(); + _refreshTemplatesList(); +} + + +void TemplateLoadTab::_keywordSelected() +{ + _current_keyword = _keywords_combo.get_active_text(); + _refreshTemplatesList(); +} + + +void TemplateLoadTab::_refreshTemplatesList() +{ + _templates_ref->clear(); + for (int i = 0 ; i < 7 ; ++i) { + Gtk::TreeModel::iterator iter = _templates_ref->append(); + Gtk::TreeModel::Row row = *iter; + row[_templates_columns.textValue] = "Template" + Glib::ustring::format(i); + } +} + +} +} diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h new file mode 100644 index 000000000..a9fa7c313 --- /dev/null +++ b/src/ui/dialog/template-load-tab.h @@ -0,0 +1,59 @@ +#ifndef INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_LOAD_TAB_H +#define INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_LOAD_TAB_H + +#include +#include +#include +#include +#include + +namespace Inkscape { +namespace UI { + + +class TemplateLoadTab : public Gtk::Frame +{ + +public: + TemplateLoadTab(); + virtual ~TemplateLoadTab(); + virtual void createTemplate(); + +protected: + class StringModelColumns : public Gtk::TreeModelColumnRecord + { + public: + StringModelColumns() + { + add(textValue); + } + + Gtk::TreeModelColumn textValue; + }; + + Glib::ustring _current_keyword; + Glib::ustring _current_template; + + virtual void _displayTemplateInfo(); + virtual void _initKeywordsList(); + virtual void _refreshTemplatesList(); + + void _initLists(); + void _keywordSelected(); + + Gtk::HBox _main_box; + Gtk::VBox _templates_column; + Gtk::VBox _template_info_column; + + Gtk::ComboBoxText _keywords_combo; + + Gtk::TreeView _templates_view; + Glib::RefPtr _templates_ref; + StringModelColumns _templates_columns; + +}; + +} +} + +#endif diff --git a/src/verbs.cpp b/src/verbs.cpp index 6f83b3dfb..a3d8b07a2 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -79,6 +79,7 @@ #include "ui/dialog/inkscape-preferences.h" #include "ui/dialog/layer-properties.h" #include "ui/dialog/layers.h" +#include "ui/dialog/new-from-template.h" #include "ui/dialog/object-properties.h" #include "ui/dialog/swatches.h" #include "ui/dialog/symbols.h" @@ -860,6 +861,9 @@ void FileVerb::perform(SPAction *action, void *data) case SP_VERB_FILE_QUIT: sp_file_exit(); break; + case SP_VERB_FILE_TEMPLATES: + sp_file_new_from_templatee(); + break; default: break; } @@ -2323,6 +2327,8 @@ Verb *Verb::_base_verbs[] = { new FileVerb(SP_VERB_FILE_CLOSE_VIEW, "FileClose", N_("_Close"), N_("Close this document window"), GTK_STOCK_CLOSE), new FileVerb(SP_VERB_FILE_QUIT, "FileQuit", N_("_Quit"), N_("Quit Inkscape"), GTK_STOCK_QUIT), + new FileVerb(SP_VERB_FILE_TEMPLATES, "FileTemplates", N_("_Templates..."), + N_("Create new project from template"), INKSCAPE_ICON("dialog-templates")), // Edit new EditVerb(SP_VERB_EDIT_UNDO, "EditUndo", N_("_Undo"), N_("Undo last action"), diff --git a/src/verbs.h b/src/verbs.h index dab524d7a..3c1625c84 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -56,6 +56,7 @@ enum { SP_VERB_FILE_PREV_DESKTOP, SP_VERB_FILE_CLOSE_VIEW, SP_VERB_FILE_QUIT, + SP_VERB_FILE_TEMPLATES, /* Edit */ SP_VERB_EDIT_UNDO, SP_VERB_EDIT_REDO, -- cgit v1.2.3 From ec3d3965f0aa7444d42fc8765abbc9c3ed0916ce Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Wed, 3 Jul 2013 13:35:06 +0200 Subject: Templates menu item fixed (bzr r12379.2.6) --- src/file.cpp | 8 ++++++++ src/ui/dialog/new-from-template.h | 2 +- src/ui/dialog/static-template-load-tab.cpp | 3 ++- src/ui/dialog/static-template-load-tab.h | 3 +-- src/ui/dialog/template-load-tab.cpp | 7 ++++--- 5 files changed, 16 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/file.cpp b/src/file.cpp index 5b4110253..7f8bfc8bf 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -66,6 +66,7 @@ #include "verbs.h" #include "event-log.h" #include "ui/dialog/font-substitution.h" +#include "ui/dialog/new-from-template.h" #include @@ -199,6 +200,13 @@ SPDesktop* sp_file_new_default() return desk; } +SPDesktop* sp_file_new_from_templatee() +{ + Inkscape::UI::NewFromTemplate dl; + dl.run(); + return sp_file_new_default(); +} + /*###################### ## D E L E T E ######################*/ diff --git a/src/ui/dialog/new-from-template.h b/src/ui/dialog/new-from-template.h index ef3cbce18..f8c4bbb37 100644 --- a/src/ui/dialog/new-from-template.h +++ b/src/ui/dialog/new-from-template.h @@ -1,8 +1,8 @@ #ifndef INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H #define INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H -#include #include +#include #include #include "template-load-tab.h" diff --git a/src/ui/dialog/static-template-load-tab.cpp b/src/ui/dialog/static-template-load-tab.cpp index 83ff32e52..94298bf1d 100644 --- a/src/ui/dialog/static-template-load-tab.cpp +++ b/src/ui/dialog/static-template-load-tab.cpp @@ -1,9 +1,10 @@ +#include "static-template-load-tab.h" + #include #include #include #include -#include "static-template-load-tab.h" namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/static-template-load-tab.h b/src/ui/dialog/static-template-load-tab.h index 651f146a0..a1a3adf7b 100644 --- a/src/ui/dialog/static-template-load-tab.h +++ b/src/ui/dialog/static-template-load-tab.h @@ -1,12 +1,11 @@ #ifndef INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H #define INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H +#include "template-load-tab.h" #include #include #include -#include "template-load-tab.h" - namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index a7b5e63f3..5d4c3a364 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -1,7 +1,7 @@ +#include "template-load-tab.h" #include #include -#include "template-load-tab.h" namespace Inkscape { namespace UI { @@ -66,10 +66,11 @@ void TemplateLoadTab::_displayTemplateInfo() void TemplateLoadTab::_initKeywordsList() { - _keywords_combo.append_text("All"); + _keywords_combo.append("All"); + // _keywords_combo for (int i = 0 ; i < 10 ; ++i) { - _keywords_combo.append_text( "Keyword" + Glib::ustring::format(i)); + _keywords_combo.append( "Keyword" + Glib::ustring::format(i)); } } -- cgit v1.2.3 From 46211dc227f62c2e71b3edfa1ffb508c9fe8e0ac Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Thu, 4 Jul 2013 16:19:38 +0200 Subject: Added loading templates into NewFromTemplate dialog. (bzr r12379.2.7) --- src/file.cpp | 7 ---- src/file.h | 1 - src/ui/dialog/new-from-template.cpp | 12 ++++++- src/ui/dialog/new-from-template.h | 4 ++- src/ui/dialog/static-template-load-tab.cpp | 20 +++++++++-- src/ui/dialog/static-template-load-tab.h | 2 ++ src/ui/dialog/template-load-tab.cpp | 57 +++++++++++++++++++++++++++--- src/ui/dialog/template-load-tab.h | 25 +++++++++++-- src/verbs.cpp | 2 +- 9 files changed, 109 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/file.cpp b/src/file.cpp index 7f8bfc8bf..9d3c513ab 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -66,7 +66,6 @@ #include "verbs.h" #include "event-log.h" #include "ui/dialog/font-substitution.h" -#include "ui/dialog/new-from-template.h" #include @@ -200,12 +199,6 @@ SPDesktop* sp_file_new_default() return desk; } -SPDesktop* sp_file_new_from_templatee() -{ - Inkscape::UI::NewFromTemplate dl; - dl.run(); - return sp_file_new_default(); -} /*###################### ## D E L E T E diff --git a/src/file.h b/src/file.h index acc6c5c7c..fe8ad9af3 100644 --- a/src/file.h +++ b/src/file.h @@ -45,7 +45,6 @@ Glib::ustring sp_file_default_template_uri(); */ SPDesktop* sp_file_new (const Glib::ustring &templ); SPDesktop* sp_file_new_default (void); -SPDesktop* sp_file_new_from_templatee (); /*###################### ## D E L E T E diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index fc590d199..b210545d1 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -1,5 +1,9 @@ #include "new-from-template.h" -#include "gtkmm/alignment.h" + +#include + +#include "src/file.h" + namespace Inkscape { namespace UI { @@ -38,5 +42,11 @@ void NewFromTemplate::_createFromTemplate() response(0); } +void NewFromTemplate::load_new_from_template() +{ + NewFromTemplate dl; + dl.run(); +} + } } diff --git a/src/ui/dialog/new-from-template.h b/src/ui/dialog/new-from-template.h index f8c4bbb37..e7976d685 100644 --- a/src/ui/dialog/new-from-template.h +++ b/src/ui/dialog/new-from-template.h @@ -8,6 +8,7 @@ #include "template-load-tab.h" #include "static-template-load-tab.h" + namespace Inkscape { namespace UI { @@ -15,9 +16,10 @@ namespace UI { class NewFromTemplate : public Gtk::Dialog { public: - NewFromTemplate(); + static void load_new_from_template(); private: + NewFromTemplate(); Gtk::Notebook _main_widget; Gtk::Button _create_template_button; StaticTemplateLoadTab _tab1; diff --git a/src/ui/dialog/static-template-load-tab.cpp b/src/ui/dialog/static-template-load-tab.cpp index 94298bf1d..47c7c00b9 100644 --- a/src/ui/dialog/static-template-load-tab.cpp +++ b/src/ui/dialog/static-template-load-tab.cpp @@ -5,18 +5,25 @@ #include #include +#include "src/file.h" + namespace Inkscape { namespace UI { StaticTemplateLoadTab::StaticTemplateLoadTab() - : _more_info_button("More info") + : TemplateLoadTab() + , _more_info_button("More info") , _preview_image("preview.png") , _short_description_label("Short description - I like trains. ad asda asd asdweqe gdfg") , _template_name_label("Template_name") , _template_author_label("by template_author") { + _loading_path = "/static"; + _loadTemplates(); + _initLists(); + _template_info_column.pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); _template_info_column.pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); _template_info_column.pack_start(_preview_image, Gtk::PACK_SHRINK, 15); @@ -34,7 +41,14 @@ StaticTemplateLoadTab::StaticTemplateLoadTab() void StaticTemplateLoadTab::createTemplate() { - std::cout << "Static template\n"; + Glib::ustring path; + if (_templates.find(_current_template) != _templates.end()){ + path = _templates[_current_template].path; + } + else + path = ""; + + sp_file_new(path); } @@ -42,6 +56,8 @@ void StaticTemplateLoadTab::_displayTemplateInfo() { TemplateLoadTab::_displayTemplateInfo(); _template_name_label.set_text(_current_template); + _template_author_label.set_text(_templates[_current_template].author); + _short_description_label.set_text(_templates[_current_template].short_description); } } diff --git a/src/ui/dialog/static-template-load-tab.h b/src/ui/dialog/static-template-load-tab.h index a1a3adf7b..a5411296d 100644 --- a/src/ui/dialog/static-template-load-tab.h +++ b/src/ui/dialog/static-template-load-tab.h @@ -2,10 +2,12 @@ #define INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H #include "template-load-tab.h" + #include #include #include + namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 5d4c3a364..5e3a16a3f 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -1,7 +1,14 @@ #include "template-load-tab.h" + #include #include +#include "src/interface.h" +#include "src/file.h" +#include "src/path-prefix.h" +#include "src/preferences.h" +#include "src/inkscape.h" + namespace Inkscape { namespace UI { @@ -9,6 +16,7 @@ namespace UI { TemplateLoadTab::TemplateLoadTab() : _keywords_combo(true) + , _current_keyword("") { set_border_width(10); @@ -24,8 +32,6 @@ TemplateLoadTab::TemplateLoadTab() title = manage(new Gtk::Label("Selected template")); _template_info_column.pack_start(*title, Gtk::PACK_SHRINK, 10); - _initLists(); - add(_main_box); _main_box.pack_start(_templates_column, Gtk::PACK_SHRINK, 20); _main_box.pack_start(_template_info_column, Gtk::PACK_EXPAND_WIDGET, 10); @@ -67,7 +73,6 @@ void TemplateLoadTab::_displayTemplateInfo() void TemplateLoadTab::_initKeywordsList() { _keywords_combo.append("All"); - // _keywords_combo for (int i = 0 ; i < 10 ; ++i) { _keywords_combo.append( "Keyword" + Glib::ustring::format(i)); @@ -97,12 +102,54 @@ void TemplateLoadTab::_keywordSelected() void TemplateLoadTab::_refreshTemplatesList() { _templates_ref->clear(); - for (int i = 0 ; i < 7 ; ++i) { + + for (std::map::iterator it = _templates.begin() ; it != _templates.end() ; ++it) { Gtk::TreeModel::iterator iter = _templates_ref->append(); Gtk::TreeModel::Row row = *iter; - row[_templates_columns.textValue] = "Template" + Glib::ustring::format(i); + row[_templates_columns.textValue] = it->first; } } + +void TemplateLoadTab::_loadTemplates() +{ + // user's local dir + _getTemplatesFromDir(profile_path("templates") + _loading_path); + + // system templates dir + _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); +} + + +TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(Glib::ustring path) +{ + TemplateData result; + result.path = path; + result.display_name = Glib::path_get_basename(path); + result.short_description = "LaLaLaLa"; + result.author = "JAASDASD"; + + return result; +} + + +void TemplateLoadTab::_getTemplatesFromDir(Glib::ustring path) +{ + if ( !Glib::file_test(path, Glib::FILE_TEST_EXISTS) || + !Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) + return; + + Glib::Dir dir(path); + path += "/"; + Glib::ustring file = path + dir.read_name(); + while (file != path){ + if (Glib::str_has_suffix(file, ".svg")){ + TemplateData tmp = _processTemplateFile(file); + _templates[Glib::path_get_basename(file)] = tmp; + } + file = path + dir.read_name(); + } +} + } } diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index a9fa7c313..3edcf15eb 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -6,6 +6,9 @@ #include #include #include +#include +#include + namespace Inkscape { namespace UI { @@ -20,6 +23,15 @@ public: virtual void createTemplate(); protected: + struct TemplateData + { + Glib::ustring path; + Glib::ustring display_name; + Glib::ustring author; + Glib::ustring short_description; + std::set keywords; + }; + class StringModelColumns : public Gtk::TreeModelColumnRecord { public: @@ -33,14 +45,16 @@ protected: Glib::ustring _current_keyword; Glib::ustring _current_template; + Glib::ustring _loading_path; + std::map _templates; + virtual void _displayTemplateInfo(); virtual void _initKeywordsList(); virtual void _refreshTemplatesList(); - + void _loadTemplates(); void _initLists(); - void _keywordSelected(); - + Gtk::HBox _main_box; Gtk::VBox _templates_column; Gtk::VBox _template_info_column; @@ -50,6 +64,11 @@ protected: Gtk::TreeView _templates_view; Glib::RefPtr _templates_ref; StringModelColumns _templates_columns; + +private: + void _getTemplatesFromDir(Glib::ustring); + void _keywordSelected(); + TemplateData _processTemplateFile(Glib::ustring); }; diff --git a/src/verbs.cpp b/src/verbs.cpp index a3d8b07a2..8b8a7e6af 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -862,7 +862,7 @@ void FileVerb::perform(SPAction *action, void *data) sp_file_exit(); break; case SP_VERB_FILE_TEMPLATES: - sp_file_new_from_templatee(); + Inkscape::UI::NewFromTemplate::load_new_from_template(); break; default: break; -- cgit v1.2.3 From cbdafaae927348aa8ef5396474535571fe989bf8 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Mon, 8 Jul 2013 18:02:38 +0200 Subject: Coding style improvements and display bug fixes (bzr r12379.2.8) --- src/ui/dialog/new-from-template.cpp | 15 ++++- src/ui/dialog/new-from-template.h | 10 ++++ src/ui/dialog/static-template-load-tab.cpp | 36 +++++++----- src/ui/dialog/static-template-load-tab.h | 10 ++++ src/ui/dialog/template-load-tab.cpp | 91 +++++++++++++++++------------- src/ui/dialog/template-load-tab.h | 26 ++++++--- 6 files changed, 126 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index b210545d1..765ec0bce 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -1,8 +1,19 @@ +/** @file + * @brief New From Template main dialog - implementation + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof KosiƄski + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + + #include "new-from-template.h" #include -#include "src/file.h" +#include "file.h" namespace Inkscape { @@ -13,7 +24,7 @@ NewFromTemplate::NewFromTemplate() : _create_template_button("Create from template") { set_title("New From Template"); - resize(400, 250); + resize(400, 400); get_vbox()->pack_start(_main_widget); _main_widget.append_page(_tab1, "Static Templates"); diff --git a/src/ui/dialog/new-from-template.h b/src/ui/dialog/new-from-template.h index e7976d685..59b61a015 100644 --- a/src/ui/dialog/new-from-template.h +++ b/src/ui/dialog/new-from-template.h @@ -1,3 +1,13 @@ +/** @file + * @brief New From Template main dialog + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof KosiƄski + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + #ifndef INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H #define INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H diff --git a/src/ui/dialog/static-template-load-tab.cpp b/src/ui/dialog/static-template-load-tab.cpp index 47c7c00b9..26b999aec 100644 --- a/src/ui/dialog/static-template-load-tab.cpp +++ b/src/ui/dialog/static-template-load-tab.cpp @@ -1,3 +1,13 @@ +/** @file + * @brief New From Template static templates tab - implementation + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof KosiƄski + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + #include "static-template-load-tab.h" #include @@ -5,7 +15,7 @@ #include #include -#include "src/file.h" +#include "file.h" namespace Inkscape { @@ -15,26 +25,26 @@ namespace UI { StaticTemplateLoadTab::StaticTemplateLoadTab() : TemplateLoadTab() , _more_info_button("More info") - , _preview_image("preview.png") , _short_description_label("Short description - I like trains. ad asda asd asdweqe gdfg") - , _template_name_label("Template_name") , _template_author_label("by template_author") + , _template_name_label("Template_name") + , _preview_image("preview.png") { - _loading_path = "/static"; + _loading_path = ""; _loadTemplates(); _initLists(); - _template_info_column.pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); - _template_info_column.pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); - _template_info_column.pack_start(_preview_image, Gtk::PACK_SHRINK, 15); - _template_info_column.pack_start(_short_description_label, Gtk::PACK_SHRINK, 4); + _info_box.pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); + _info_box.pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); + _info_box.pack_start(_preview_image, Gtk::PACK_SHRINK, 15); + _info_box.pack_start(_short_description_label, Gtk::PACK_SHRINK, 4); _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)); - _template_info_column.pack_start(*align, Gtk::PACK_SHRINK, 5); + _info_box.pack_start(*align, Gtk::PACK_SHRINK, 5); align->add(_more_info_button); } @@ -42,8 +52,8 @@ StaticTemplateLoadTab::StaticTemplateLoadTab() void StaticTemplateLoadTab::createTemplate() { Glib::ustring path; - if (_templates.find(_current_template) != _templates.end()){ - path = _templates[_current_template].path; + if (_tdata.find(_current_template) != _tdata.end()){ + path = _tdata[_current_template].path; } else path = ""; @@ -56,8 +66,8 @@ void StaticTemplateLoadTab::_displayTemplateInfo() { TemplateLoadTab::_displayTemplateInfo(); _template_name_label.set_text(_current_template); - _template_author_label.set_text(_templates[_current_template].author); - _short_description_label.set_text(_templates[_current_template].short_description); + _template_author_label.set_text(_tdata[_current_template].author); + _short_description_label.set_text(_tdata[_current_template].short_description); } } diff --git a/src/ui/dialog/static-template-load-tab.h b/src/ui/dialog/static-template-load-tab.h index a5411296d..9b19c495a 100644 --- a/src/ui/dialog/static-template-load-tab.h +++ b/src/ui/dialog/static-template-load-tab.h @@ -1,3 +1,13 @@ +/** @file + * @brief New From Template static templates tab + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof KosiƄski + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + #ifndef INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H #define INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 5e3a16a3f..95baccc75 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -1,13 +1,23 @@ +/** @file + * @brief New From Template abstract tab implementation + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof KosiƄski + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + #include "template-load-tab.h" -#include +#include #include -#include "src/interface.h" -#include "src/file.h" -#include "src/path-prefix.h" -#include "src/preferences.h" -#include "src/inkscape.h" +#include "interface.h" +#include "file.h" +#include "path-prefix.h" +#include "preferences.h" +#include "inkscape.h" namespace Inkscape { @@ -15,34 +25,32 @@ namespace UI { TemplateLoadTab::TemplateLoadTab() - : _keywords_combo(true) - , _current_keyword("") + : _current_keyword("") + , _keywords_combo(true) { set_border_width(10); Gtk::Label *title; - title = manage(new Gtk::Label("Search Tags:")); - _templates_column.pack_start(*title, Gtk::PACK_SHRINK, 10); + title = manage(new Gtk::Label("Search:")); + _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); - _templates_column.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 0); + _tlist_box.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 0); title = manage(new Gtk::Label("Templates")); - _templates_column.pack_start(*title, Gtk::PACK_SHRINK, 10); + _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); title = manage(new Gtk::Label("Selected template")); - _template_info_column.pack_start(*title, Gtk::PACK_SHRINK, 10); + _info_box.pack_start(*title, Gtk::PACK_SHRINK, 10); add(_main_box); - _main_box.pack_start(_templates_column, Gtk::PACK_SHRINK, 20); - _main_box.pack_start(_template_info_column, Gtk::PACK_EXPAND_WIDGET, 10); + _main_box.pack_start(_tlist_box, Gtk::PACK_SHRINK, 20); + _main_box.pack_start(_info_box, Gtk::PACK_EXPAND_WIDGET, 10); - _templates_column.pack_start(_templates_view, Gtk::PACK_SHRINK, 5); - - Glib::RefPtr templateSelectionRef = - _templates_view.get_selection(); - - templateSelectionRef->signal_changed().connect( - sigc::mem_fun(*this, &TemplateLoadTab::_displayTemplateInfo)); + Gtk::ScrolledWindow *scrolled; + scrolled = manage(new Gtk::ScrolledWindow()); + scrolled->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); + scrolled->add(_tlist_view); + _tlist_box.pack_start(*scrolled, Gtk::PACK_EXPAND_WIDGET, 5); _keywords_combo.signal_changed().connect( sigc::mem_fun(*this, &TemplateLoadTab::_keywordSelected)); @@ -63,9 +71,9 @@ void TemplateLoadTab::createTemplate() void TemplateLoadTab::_displayTemplateInfo() { - Glib::RefPtr templateSelectionRef = _templates_view.get_selection(); + Glib::RefPtr templateSelectionRef = _tlist_view.get_selection(); if (templateSelectionRef->get_selected()) { - _current_template = (*templateSelectionRef->get_selected())[_templates_columns.textValue]; + _current_template = (*templateSelectionRef->get_selected())[_columns.textValue]; } } @@ -82,13 +90,18 @@ void TemplateLoadTab::_initKeywordsList() void TemplateLoadTab::_initLists() { - _templates_ref = Gtk::ListStore::create(_templates_columns); - _templates_view.set_model(_templates_ref); - _templates_view.append_column("", _templates_columns.textValue); - _templates_view.set_headers_visible(false); + _tlist_store = Gtk::ListStore::create(_columns); + _tlist_view.set_model(_tlist_store); + _tlist_view.append_column("", _columns.textValue); + _tlist_view.set_headers_visible(false); _initKeywordsList(); _refreshTemplatesList(); + + Glib::RefPtr templateSelectionRef = + _tlist_view.get_selection(); + templateSelectionRef->signal_changed().connect( + sigc::mem_fun(*this, &TemplateLoadTab::_displayTemplateInfo)); } @@ -101,12 +114,12 @@ void TemplateLoadTab::_keywordSelected() void TemplateLoadTab::_refreshTemplatesList() { - _templates_ref->clear(); + _tlist_store->clear(); - for (std::map::iterator it = _templates.begin() ; it != _templates.end() ; ++it) { - Gtk::TreeModel::iterator iter = _templates_ref->append(); + for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { + Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; - row[_templates_columns.textValue] = it->first; + row[_columns.textValue] = it->first; } } @@ -121,7 +134,7 @@ void TemplateLoadTab::_loadTemplates() } -TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(Glib::ustring path) +TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib::ustring &path) { TemplateData result; result.path = path; @@ -133,21 +146,21 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(Glib::ustrin } -void TemplateLoadTab::_getTemplatesFromDir(Glib::ustring path) +void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) { if ( !Glib::file_test(path, Glib::FILE_TEST_EXISTS) || !Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) return; Glib::Dir dir(path); - path += "/"; - Glib::ustring file = path + dir.read_name(); + + Glib::ustring file = Glib::build_filename(path, dir.read_name()); while (file != path){ - if (Glib::str_has_suffix(file, ".svg")){ + if (Glib::str_has_suffix(file, ".svg") && !Glib::str_has_prefix(Glib::path_get_basename(file), "default")){ TemplateData tmp = _processTemplateFile(file); - _templates[Glib::path_get_basename(file)] = tmp; + _tdata[Glib::path_get_basename(file)] = tmp; } - file = path + dir.read_name(); + file = Glib::build_filename(path, dir.read_name()); } } diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 3edcf15eb..7d1e25d6d 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -1,3 +1,13 @@ +/** @file + * @brief New From Template abstract tab class + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof KosiƄski + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + #ifndef INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_LOAD_TAB_H #define INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_LOAD_TAB_H @@ -46,7 +56,7 @@ protected: Glib::ustring _current_keyword; Glib::ustring _current_template; Glib::ustring _loading_path; - std::map _templates; + std::map _tdata; virtual void _displayTemplateInfo(); @@ -56,19 +66,19 @@ protected: void _initLists(); Gtk::HBox _main_box; - Gtk::VBox _templates_column; - Gtk::VBox _template_info_column; + Gtk::VBox _tlist_box; + Gtk::VBox _info_box; Gtk::ComboBoxText _keywords_combo; - Gtk::TreeView _templates_view; - Glib::RefPtr _templates_ref; - StringModelColumns _templates_columns; + Gtk::TreeView _tlist_view; + Glib::RefPtr _tlist_store; + StringModelColumns _columns; private: - void _getTemplatesFromDir(Glib::ustring); + void _getTemplatesFromDir(const Glib::ustring &); void _keywordSelected(); - TemplateData _processTemplateFile(Glib::ustring); + TemplateData _processTemplateFile(const Glib::ustring &); }; -- cgit v1.2.3 From 5977386b97689dfd12335f7444217634c66b5930 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 13 Jul 2013 00:24:56 +0200 Subject: Template info loading + searching by keywords added. (bzr r12379.2.9) --- src/ui/dialog/static-template-load-tab.cpp | 6 ++ src/ui/dialog/template-load-tab.cpp | 108 ++++++++++++++++++++++++++--- src/ui/dialog/template-load-tab.h | 5 ++ 3 files changed, 109 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/static-template-load-tab.cpp b/src/ui/dialog/static-template-load-tab.cpp index 26b999aec..35f3430fb 100644 --- a/src/ui/dialog/static-template-load-tab.cpp +++ b/src/ui/dialog/static-template-load-tab.cpp @@ -46,6 +46,9 @@ StaticTemplateLoadTab::StaticTemplateLoadTab() align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); _info_box.pack_start(*align, Gtk::PACK_SHRINK, 5); align->add(_more_info_button); + + _more_info_button.signal_pressed().connect( + sigc::mem_fun(*this, &StaticTemplateLoadTab::_displayTemplateDetails)); } @@ -68,6 +71,9 @@ void StaticTemplateLoadTab::_displayTemplateInfo() _template_name_label.set_text(_current_template); _template_author_label.set_text(_tdata[_current_template].author); _short_description_label.set_text(_tdata[_current_template].short_description); + + Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_tdata[_current_template].path), _tdata[_current_template].preview_name); + _preview_image.set(imagePath); } } diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 95baccc75..6d9c61078 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -10,6 +10,7 @@ #include "template-load-tab.h" +#include #include #include @@ -18,6 +19,17 @@ #include "path-prefix.h" #include "preferences.h" #include "inkscape.h" +#include "xml/repr.h" +#include "xml/document.h" +#include "xml/node.h" + +// +#include + +#include +#include +#include +// namespace Inkscape { @@ -80,10 +92,10 @@ void TemplateLoadTab::_displayTemplateInfo() void TemplateLoadTab::_initKeywordsList() { - _keywords_combo.append("All"); + _keywords_combo.append(_("All")); - for (int i = 0 ; i < 10 ; ++i) { - _keywords_combo.append( "Keyword" + Glib::ustring::format(i)); + for (std::set::iterator it = _keywords.begin() ; it != _keywords.end() ; ++it){ + _keywords_combo.append(*it); } } @@ -108,6 +120,8 @@ void TemplateLoadTab::_initLists() void TemplateLoadTab::_keywordSelected() { _current_keyword = _keywords_combo.get_active_text(); + if (_current_keyword == "" && _keywords_combo.get_entry_text().size() > 0) + _current_keyword = _keywords_combo.get_entry_text(); _refreshTemplatesList(); } @@ -117,9 +131,11 @@ void TemplateLoadTab::_refreshTemplatesList() _tlist_store->clear(); for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { - Gtk::TreeModel::iterator iter = _tlist_store->append(); - Gtk::TreeModel::Row row = *iter; - row[_columns.textValue] = it->first; + if (it->second.keywords.count(_current_keyword) > 0 || _current_keyword == _("All") || _current_keyword == ""){ + Gtk::TreeModel::iterator iter = _tlist_store->append(); + Gtk::TreeModel::Row row = *iter; + row[_columns.textValue] = it->first; + } } } @@ -130,7 +146,7 @@ void TemplateLoadTab::_loadTemplates() _getTemplatesFromDir(profile_path("templates") + _loading_path); // system templates dir - _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); + // _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); } @@ -138,9 +154,54 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: { TemplateData result; result.path = path; - result.display_name = Glib::path_get_basename(path); + result.display_name = Glib::path_get_basename(path);/* result.short_description = "LaLaLaLa"; - result.author = "JAASDASD"; + result.author = "JAASDASD";*/ + + 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(); + if (strcmp(myRoot->name(), "svg:svg") != 0){ // Wrong file format + return result; + } + + myRoot = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); + + if (myRoot == NULL) // No template info + return result; + + if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_name")) != NULL) + result.display_name = dgettext(NULL, 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(NULL, dataNode->firstChild()->content()); + if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_long") )!= NULL) + result.long_description = dgettext(NULL, 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()){ + int pos = data.find_first_of(" "); + Glib::ustring keyword = dgettext(NULL, data.substr(0, pos).data()); + result.keywords.insert(keyword); + std::cout< 0){ + message += "Keywords: "; + for (std::set::iterator it = tmpl.keywords.begin(); it != tmpl.keywords.end(); ++it) + message += *it + " "; + message += "\n\n"; + } + + if (tmpl.author != "") + message += "By: " + _tdata[_current_template].author + " " + tmpl.creation_date + "\n\n"; + + Gtk::MessageDialog dl(message, false, Gtk::MESSAGE_OTHER); + dl.run(); +} + } } diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 7d1e25d6d..55893eed0 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -39,6 +39,9 @@ protected: Glib::ustring display_name; Glib::ustring author; Glib::ustring short_description; + Glib::ustring long_description; + Glib::ustring preview_name; + Glib::ustring creation_date; std::set keywords; }; @@ -57,6 +60,7 @@ protected: Glib::ustring _current_template; Glib::ustring _loading_path; std::map _tdata; + std::set _keywords; virtual void _displayTemplateInfo(); @@ -64,6 +68,7 @@ protected: virtual void _refreshTemplatesList(); void _loadTemplates(); void _initLists(); + void _displayTemplateDetails(); Gtk::HBox _main_box; Gtk::VBox _tlist_box; -- cgit v1.2.3 From 76ce8f0dae07598af9b0369473db64c38fa309a4 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Wed, 17 Jul 2013 12:17:23 +0200 Subject: Searching by words in descriptions, titles etc. Translation support improved (bzr r12379.2.10) --- src/ui/dialog/template-load-tab.cpp | 64 +++++++++++++++++++++++++++++-------- src/ui/dialog/template-load-tab.h | 9 ++++++ 2 files changed, 60 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 6d9c61078..90980dc39 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -39,6 +39,7 @@ namespace UI { TemplateLoadTab::TemplateLoadTab() : _current_keyword("") , _keywords_combo(true) + ,_current_search_type(ALL) { set_border_width(10); @@ -120,8 +121,16 @@ void TemplateLoadTab::_initLists() void TemplateLoadTab::_keywordSelected() { _current_keyword = _keywords_combo.get_active_text(); - if (_current_keyword == "" && _keywords_combo.get_entry_text().size() > 0) + if (_current_keyword == ""){ _current_keyword = _keywords_combo.get_entry_text(); + _current_search_type = USER_SPECIFIED; + } + else + _current_search_type = LIST_KEYWORD; + + if (_current_keyword == "" || _current_keyword == "All") + _current_search_type = ALL; + _refreshTemplatesList(); } @@ -130,12 +139,43 @@ void TemplateLoadTab::_refreshTemplatesList() { _tlist_store->clear(); - for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { - if (it->second.keywords.count(_current_keyword) > 0 || _current_keyword == _("All") || _current_keyword == ""){ + switch (_current_search_type){ + case ALL :{ + + for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; row[_columns.textValue] = it->first; } + break; + } + + case LIST_KEYWORD: { + for (std::map::iterator it = _tdata.begin() ; it != _tdata.end() ; ++it) { + if (it->second.keywords.count(_current_keyword) != 0){ + Gtk::TreeModel::iterator iter = _tlist_store->append(); + Gtk::TreeModel::Row row = *iter; + row[_columns.textValue] = it->first; + } + } + break; + } + + 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 ) + { + Gtk::TreeModel::iterator iter = _tlist_store->append(); + Gtk::TreeModel::Row row = *iter; + row[_columns.textValue] = it->first; + } + } + break; + } } } @@ -174,13 +214,13 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: return result; if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_name")) != NULL) - result.display_name = dgettext(NULL, dataNode->firstChild()->content()); + 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(NULL, dataNode->firstChild()->content()); + 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(NULL, dataNode->firstChild()->content()); + 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){ @@ -191,10 +231,8 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: Glib::ustring data = dataNode->firstChild()->content(); while (!data.empty()){ int pos = data.find_first_of(" "); - Glib::ustring keyword = dgettext(NULL, data.substr(0, pos).data()); + Glib::ustring keyword = dgettext("Document template keyword", data.substr(0, pos).data()); result.keywords.insert(keyword); - std::cout< 0){ - message += "Keywords: "; + message += _("Keywords: "); for (std::set::iterator it = tmpl.keywords.begin(); it != tmpl.keywords.end(); ++it) message += *it + " "; message += "\n\n"; } if (tmpl.author != "") - message += "By: " + _tdata[_current_template].author + " " + tmpl.creation_date + "\n\n"; + message += _("By: ") + _tdata[_current_template].author + " " + tmpl.creation_date + "\n\n"; Gtk::MessageDialog dl(message, false, Gtk::MESSAGE_OTHER); dl.run(); diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 55893eed0..8290f1b3f 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -81,6 +81,15 @@ protected: StringModelColumns _columns; private: + enum SearchType + { + LIST_KEYWORD, + USER_SPECIFIED, + ALL + }; + + SearchType _current_search_type; + void _getTemplatesFromDir(const Glib::ustring &); void _keywordSelected(); TemplateData _processTemplateFile(const Glib::ustring &); -- cgit v1.2.3 From 0fb0f1dd09f4c03a420dd8abf2089b81cd6d30d7 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Fri, 19 Jul 2013 20:35:26 +0200 Subject: New From Template ui rearrangement (bzr r12379.2.11) --- src/ui/dialog/Makefile_insert | 4 +- src/ui/dialog/new-from-template.cpp | 10 +-- src/ui/dialog/new-from-template.h | 6 +- src/ui/dialog/static-template-load-tab.cpp | 80 --------------------- src/ui/dialog/static-template-load-tab.h | 44 ------------ src/ui/dialog/template-load-tab.cpp | 48 +++++-------- src/ui/dialog/template-load-tab.h | 20 +++--- src/ui/dialog/template-widget.cpp | 110 +++++++++++++++++++++++++++++ src/ui/dialog/template-widget.h | 48 +++++++++++++ 9 files changed, 193 insertions(+), 177 deletions(-) delete mode 100644 src/ui/dialog/static-template-load-tab.cpp delete mode 100644 src/ui/dialog/static-template-load-tab.h create mode 100644 src/ui/dialog/template-widget.cpp create mode 100644 src/ui/dialog/template-widget.h (limited to 'src') diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index 4a34cc71c..41e3ecbf8 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -87,8 +87,6 @@ ink_common_sources += \ ui/dialog/scriptdialog.h \ ui/dialog/spellcheck.cpp \ ui/dialog/spellcheck.h \ - ui/dialog/static-template-load-tab.cpp \ - ui/dialog/static-template-load-tab.h \ ui/dialog/svg-fonts-dialog.cpp \ ui/dialog/svg-fonts-dialog.h \ ui/dialog/swatches.cpp \ @@ -97,6 +95,8 @@ ink_common_sources += \ ui/dialog/symbols.h \ ui/dialog/template-load-tab.cpp \ ui/dialog/template-load-tab.h \ + ui/dialog/template-widget.cpp \ + ui/dialog/template-widget.h \ ui/dialog/text-edit.cpp \ ui/dialog/text-edit.h \ ui/dialog/tile.cpp \ diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index 765ec0bce..241da3f43 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -27,9 +27,7 @@ NewFromTemplate::NewFromTemplate() resize(400, 400); get_vbox()->pack_start(_main_widget); - _main_widget.append_page(_tab1, "Static Templates"); - _main_widget.append_page(_tab2, "Procedural Templates"); - + Gtk::Alignment *align; align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); get_vbox()->pack_end(*align, Gtk::PACK_SHRINK, 5); @@ -44,11 +42,7 @@ NewFromTemplate::NewFromTemplate() void NewFromTemplate::_createFromTemplate() { - if ( _main_widget.get_current_page() == 0 ) { - _tab1.createTemplate(); - } else { - _tab2.createTemplate(); - } + _main_widget.createTemplate(); response(0); } diff --git a/src/ui/dialog/new-from-template.h b/src/ui/dialog/new-from-template.h index 59b61a015..05af98a50 100644 --- a/src/ui/dialog/new-from-template.h +++ b/src/ui/dialog/new-from-template.h @@ -16,7 +16,6 @@ #include #include "template-load-tab.h" -#include "static-template-load-tab.h" namespace Inkscape { @@ -30,10 +29,9 @@ public: private: NewFromTemplate(); - Gtk::Notebook _main_widget; Gtk::Button _create_template_button; - StaticTemplateLoadTab _tab1; - TemplateLoadTab _tab2; + //StaticTemplateLoadTab _tab1; + TemplateLoadTab _main_widget; void _createFromTemplate(); }; diff --git a/src/ui/dialog/static-template-load-tab.cpp b/src/ui/dialog/static-template-load-tab.cpp deleted file mode 100644 index 35f3430fb..000000000 --- a/src/ui/dialog/static-template-load-tab.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/** @file - * @brief New From Template static templates tab - implementation - */ -/* Authors: - * Jan Darowski , supervised by Krzysztof KosiƄski - * - * Copyright (C) 2013 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "static-template-load-tab.h" - -#include -#include -#include -#include - -#include "file.h" - - -namespace Inkscape { -namespace UI { - - -StaticTemplateLoadTab::StaticTemplateLoadTab() - : TemplateLoadTab() - , _more_info_button("More info") - , _short_description_label("Short description - I like trains. ad asda asd asdweqe gdfg") - , _template_author_label("by template_author") - , _template_name_label("Template_name") - , _preview_image("preview.png") -{ - _loading_path = ""; - _loadTemplates(); - _initLists(); - - _info_box.pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); - _info_box.pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); - _info_box.pack_start(_preview_image, Gtk::PACK_SHRINK, 15); - _info_box.pack_start(_short_description_label, Gtk::PACK_SHRINK, 4); - - _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)); - _info_box.pack_start(*align, Gtk::PACK_SHRINK, 5); - align->add(_more_info_button); - - _more_info_button.signal_pressed().connect( - sigc::mem_fun(*this, &StaticTemplateLoadTab::_displayTemplateDetails)); -} - - -void StaticTemplateLoadTab::createTemplate() -{ - Glib::ustring path; - if (_tdata.find(_current_template) != _tdata.end()){ - path = _tdata[_current_template].path; - } - else - path = ""; - - sp_file_new(path); -} - - -void StaticTemplateLoadTab::_displayTemplateInfo() -{ - TemplateLoadTab::_displayTemplateInfo(); - _template_name_label.set_text(_current_template); - _template_author_label.set_text(_tdata[_current_template].author); - _short_description_label.set_text(_tdata[_current_template].short_description); - - Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_tdata[_current_template].path), _tdata[_current_template].preview_name); - _preview_image.set(imagePath); -} - -} -} diff --git a/src/ui/dialog/static-template-load-tab.h b/src/ui/dialog/static-template-load-tab.h deleted file mode 100644 index 9b19c495a..000000000 --- a/src/ui/dialog/static-template-load-tab.h +++ /dev/null @@ -1,44 +0,0 @@ -/** @file - * @brief New From Template static templates tab - */ -/* Authors: - * Jan Darowski , supervised by Krzysztof KosiƄski - * - * Copyright (C) 2013 Authors - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H -#define INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H - -#include "template-load-tab.h" - -#include -#include -#include - - -namespace Inkscape { -namespace UI { - - -class StaticTemplateLoadTab : public TemplateLoadTab -{ -public: - StaticTemplateLoadTab(); - virtual void createTemplate(); - -protected: - virtual void _displayTemplateInfo(); - - Gtk::Button _more_info_button; - Gtk::Label _short_description_label; - Gtk::Label _template_author_label; - Gtk::Label _template_name_label; - Gtk::Image _preview_image; -}; - -} -} - -#endif diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 90980dc39..70dadfc52 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -23,6 +23,8 @@ #include "xml/document.h" #include "xml/node.h" +#include "template-widget.h" + // #include @@ -39,10 +41,11 @@ namespace UI { TemplateLoadTab::TemplateLoadTab() : _current_keyword("") , _keywords_combo(true) - ,_current_search_type(ALL) + , _current_search_type(ALL) { set_border_width(10); + _info_widget = manage(new TemplateWidget()); Gtk::Label *title; title = manage(new Gtk::Label("Search:")); _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); @@ -53,11 +56,11 @@ TemplateLoadTab::TemplateLoadTab() _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); title = manage(new Gtk::Label("Selected template")); - _info_box.pack_start(*title, Gtk::PACK_SHRINK, 10); + _info_widget->pack_start(*title, Gtk::PACK_SHRINK, 10); add(_main_box); _main_box.pack_start(_tlist_box, Gtk::PACK_SHRINK, 20); - _main_box.pack_start(_info_box, Gtk::PACK_EXPAND_WIDGET, 10); + _main_box.pack_start(*_info_widget, Gtk::PACK_EXPAND_WIDGET, 10); Gtk::ScrolledWindow *scrolled; scrolled = manage(new Gtk::ScrolledWindow()); @@ -68,6 +71,11 @@ TemplateLoadTab::TemplateLoadTab() _keywords_combo.signal_changed().connect( sigc::mem_fun(*this, &TemplateLoadTab::_keywordSelected)); this->show_all(); + + + _loading_path = ""; + _loadTemplates(); + _initLists(); } @@ -78,7 +86,7 @@ TemplateLoadTab::~TemplateLoadTab() void TemplateLoadTab::createTemplate() { - std::cout << "Default Template Tab" << std::endl; + _info_widget->create(); } @@ -87,7 +95,10 @@ void TemplateLoadTab::_displayTemplateInfo() Glib::RefPtr templateSelectionRef = _tlist_view.get_selection(); if (templateSelectionRef->get_selected()) { _current_template = (*templateSelectionRef->get_selected())[_columns.textValue]; + + _info_widget->display(_tdata[_current_template]); } + } @@ -194,7 +205,8 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: { TemplateData result; result.path = path; - result.display_name = Glib::path_get_basename(path);/* + result.display_name = Glib::path_get_basename(path); + result.is_procedural = false;/* result.short_description = "LaLaLaLa"; result.author = "JAASDASD";*/ @@ -264,31 +276,5 @@ void TemplateLoadTab::_getTemplatesFromDir(const Glib::ustring &path) } } -void TemplateLoadTab::_displayTemplateDetails() -{ - if (_current_template == "") - return; - - TemplateData &tmpl = _tdata[_current_template]; - - Glib::ustring message = tmpl.display_name + "\n\n" + - _("Path: ") + tmpl.path + "\n\n"; - - if (tmpl.long_description != "") - message += _("Description: ") + _tdata[_current_template].long_description + "\n\n"; - if (tmpl.keywords.size() > 0){ - message += _("Keywords: "); - for (std::set::iterator it = tmpl.keywords.begin(); it != tmpl.keywords.end(); ++it) - message += *it + " "; - message += "\n\n"; - } - - if (tmpl.author != "") - message += _("By: ") + _tdata[_current_template].author + " " + tmpl.creation_date + "\n\n"; - - Gtk::MessageDialog dl(message, false, Gtk::MESSAGE_OTHER); - dl.run(); -} - } } diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 8290f1b3f..48ad23ae9 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -22,19 +22,16 @@ namespace Inkscape { namespace UI { - + +class TemplateWidget; class TemplateLoadTab : public Gtk::Frame { public: - TemplateLoadTab(); - virtual ~TemplateLoadTab(); - virtual void createTemplate(); - -protected: struct TemplateData { + bool is_procedural; Glib::ustring path; Glib::ustring display_name; Glib::ustring author; @@ -45,6 +42,12 @@ protected: std::set keywords; }; + TemplateLoadTab(); + virtual ~TemplateLoadTab(); + virtual void createTemplate(); + +protected: + class StringModelColumns : public Gtk::TreeModelColumnRecord { public: @@ -68,11 +71,10 @@ protected: virtual void _refreshTemplatesList(); void _loadTemplates(); void _initLists(); - void _displayTemplateDetails(); Gtk::HBox _main_box; Gtk::VBox _tlist_box; - Gtk::VBox _info_box; + TemplateWidget *_info_widget; Gtk::ComboBoxText _keywords_combo; @@ -80,6 +82,8 @@ protected: Glib::RefPtr _tlist_store; StringModelColumns _columns; + + private: enum SearchType { diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp new file mode 100644 index 000000000..dd066c90b --- /dev/null +++ b/src/ui/dialog/template-widget.cpp @@ -0,0 +1,110 @@ + + +/** @file + * @brief New From Template - templates widget - implementation + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof KosiƄski + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "template-widget.h" +#include "template-load-tab.h" + +#include +#include +#include +#include +#include + +#include "file.h" + +#include +#include +#include + + +namespace Inkscape { +namespace UI { + + +TemplateWidget::TemplateWidget() + : _more_info_button("More info") + , _short_description_label("Short description - I like trains. ad asda asd asdweqe gdfg") + , _template_author_label("by template_author") + , _template_name_label("Template_name") + , _preview_image("preview.png") +{ + pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); + pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); + pack_start(_preview_image, Gtk::PACK_SHRINK, 15); + pack_start(_short_description_label, Gtk::PACK_SHRINK, 4); + + _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)); + pack_start(*align, Gtk::PACK_SHRINK, 5); + align->add(_more_info_button); + + _more_info_button.signal_pressed().connect( + sigc::mem_fun(*this, &TemplateWidget::_displayTemplateDetails)); +} + + +void TemplateWidget::create() +{ + if (_current_template.path == "") + return; + if (_current_template.is_procedural){ + + } + else { + sp_file_new(_current_template.path); + } +} + + +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); + + Glib::ustring imagePath = Glib::build_filename(Glib::path_get_dirname(_current_template.path), _current_template.preview_name); + _preview_image.set(imagePath); + } +} + +void TemplateWidget::_displayTemplateDetails() +{ + if (_current_template.path == "") + return; + + Glib::ustring message = _current_template.display_name + "\n\n" + + _("Path: ") + _current_template.path + "\n\n"; + + if (_current_template.long_description != "") + message += _("Description: ") + _current_template.long_description + "\n\n"; + if (_current_template.keywords.size() > 0){ + message += _("Keywords: "); + for (std::set::iterator it = _current_template.keywords.begin(); it != _current_template.keywords.end(); ++it) + message += *it + " "; + message += "\n\n"; + } + + if (_current_template.author != "") + message += _("By: ") + _current_template.author + " " + _current_template.creation_date + "\n\n"; + + Gtk::MessageDialog dl(message, false, Gtk::MESSAGE_OTHER); + dl.run(); +} + +} +} diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h new file mode 100644 index 000000000..83024e0d8 --- /dev/null +++ b/src/ui/dialog/template-widget.h @@ -0,0 +1,48 @@ +/** @file + * @brief New From Template - template widget + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof KosiƄski + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_WIDGET_H +#define INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_WIDGET_H + +#include "template-load-tab.h" +#include + + + +namespace Inkscape { +namespace UI { + +class TemplateLoadTab; + + +class TemplateWidget : public Gtk::VBox +{ +public: + TemplateWidget (); + void create(); + void display(TemplateLoadTab::TemplateData); + +private: + TemplateLoadTab::TemplateData _current_template; + + Gtk::Button _more_info_button; + Gtk::Label _short_description_label; + Gtk::Label _template_author_label; + Gtk::Label _template_name_label; + Gtk::Image _preview_image; + + void _displayTemplateDetails(); + +}; + +} +} + +#endif -- cgit v1.2.3 From bd2265c6e8a1496f40692752f9d710f36a24fada Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Fri, 19 Jul 2013 20:57:07 +0200 Subject: Minor code fixes (bzr r12379.2.12) --- src/ui/dialog/new-from-template.cpp | 9 +++++---- src/ui/dialog/new-from-template.h | 2 -- src/ui/dialog/template-load-tab.cpp | 26 ++++++-------------------- src/ui/dialog/template-load-tab.h | 8 ++------ src/ui/dialog/template-widget.cpp | 23 ++++++++++------------- src/ui/dialog/template-widget.h | 4 ---- 6 files changed, 23 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index 241da3f43..6598aecdf 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -10,10 +10,10 @@ #include "new-from-template.h" +#include "file.h" #include - -#include "file.h" +#include namespace Inkscape { @@ -21,9 +21,9 @@ namespace UI { NewFromTemplate::NewFromTemplate() - : _create_template_button("Create from template") + : _create_template_button(_("Create from template")) { - set_title("New From Template"); + set_title(_("New From Template")); resize(400, 400); get_vbox()->pack_start(_main_widget); @@ -47,6 +47,7 @@ void NewFromTemplate::_createFromTemplate() response(0); } + void NewFromTemplate::load_new_from_template() { NewFromTemplate dl; diff --git a/src/ui/dialog/new-from-template.h b/src/ui/dialog/new-from-template.h index 05af98a50..8ebcb2863 100644 --- a/src/ui/dialog/new-from-template.h +++ b/src/ui/dialog/new-from-template.h @@ -13,7 +13,6 @@ #include #include -#include #include "template-load-tab.h" @@ -30,7 +29,6 @@ public: private: NewFromTemplate(); Gtk::Button _create_template_button; - //StaticTemplateLoadTab _tab1; TemplateLoadTab _main_widget; void _createFromTemplate(); diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 70dadfc52..ded4fc6fd 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -9,9 +9,11 @@ */ #include "template-load-tab.h" +#include "template-widget.h" #include #include +#include #include #include "interface.h" @@ -23,16 +25,6 @@ #include "xml/document.h" #include "xml/node.h" -#include "template-widget.h" - -// -#include - -#include -#include -#include -// - namespace Inkscape { namespace UI { @@ -47,17 +39,14 @@ TemplateLoadTab::TemplateLoadTab() _info_widget = manage(new TemplateWidget()); Gtk::Label *title; - title = manage(new Gtk::Label("Search:")); + title = manage(new Gtk::Label(_("Search:"))); _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); _tlist_box.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 0); - title = manage(new Gtk::Label("Templates")); + title = manage(new Gtk::Label(_("Templates"))); _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); - title = manage(new Gtk::Label("Selected template")); - _info_widget->pack_start(*title, Gtk::PACK_SHRINK, 10); - add(_main_box); _main_box.pack_start(_tlist_box, Gtk::PACK_SHRINK, 20); _main_box.pack_start(*_info_widget, Gtk::PACK_EXPAND_WIDGET, 10); @@ -72,7 +61,6 @@ TemplateLoadTab::TemplateLoadTab() sigc::mem_fun(*this, &TemplateLoadTab::_keywordSelected)); this->show_all(); - _loading_path = ""; _loadTemplates(); _initLists(); @@ -139,7 +127,7 @@ void TemplateLoadTab::_keywordSelected() else _current_search_type = LIST_KEYWORD; - if (_current_keyword == "" || _current_keyword == "All") + if (_current_keyword == "" || _current_keyword == _("All")) _current_search_type = ALL; _refreshTemplatesList(); @@ -206,9 +194,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: TemplateData result; result.path = path; result.display_name = Glib::path_get_basename(path); - result.is_procedural = false;/* - result.short_description = "LaLaLaLa"; - result.author = "JAASDASD";*/ + result.is_procedural = false; Inkscape::XML::Document *rdoc; rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 48ad23ae9..cc5229c95 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -46,8 +46,7 @@ public: virtual ~TemplateLoadTab(); virtual void createTemplate(); -protected: - +protected: class StringModelColumns : public Gtk::TreeModelColumnRecord { public: @@ -80,9 +79,7 @@ protected: Gtk::TreeView _tlist_view; Glib::RefPtr _tlist_store; - StringModelColumns _columns; - - + StringModelColumns _columns; private: enum SearchType @@ -97,7 +94,6 @@ private: void _getTemplatesFromDir(const Glib::ustring &); void _keywordSelected(); TemplateData _processTemplateFile(const Glib::ustring &); - }; } diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index dd066c90b..bb2c4a683 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -12,18 +12,13 @@ #include "template-widget.h" #include "template-load-tab.h" +#include "file.h" #include #include #include #include -#include - -#include "file.h" - -#include #include -#include namespace Inkscape { @@ -31,12 +26,14 @@ namespace UI { TemplateWidget::TemplateWidget() - : _more_info_button("More info") - , _short_description_label("Short description - I like trains. ad asda asd asdweqe gdfg") - , _template_author_label("by template_author") - , _template_name_label("Template_name") + : _more_info_button(_("More info")) + , _short_description_label(_("Short description")) + , _template_author_label(_("by template_author")) + , _template_name_label(_("Template_name")) , _preview_image("preview.png") { + Gtk::Label *title = manage(new Gtk::Label(_("Selected template"))); + pack_start(*title, Gtk::PACK_SHRINK, 10); pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); pack_start(_preview_image, Gtk::PACK_SHRINK, 15); @@ -59,9 +56,8 @@ void TemplateWidget::create() { if (_current_template.path == "") return; - if (_current_template.is_procedural){ - - } + + if (_current_template.is_procedural) {} else { sp_file_new(_current_template.path); } @@ -82,6 +78,7 @@ void TemplateWidget::display(TemplateLoadTab::TemplateData data) } } + void TemplateWidget::_displayTemplateDetails() { if (_current_template.path == "") diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index 83024e0d8..743fb524d 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -15,13 +15,10 @@ #include - namespace Inkscape { namespace UI { -class TemplateLoadTab; - class TemplateWidget : public Gtk::VBox { public: @@ -39,7 +36,6 @@ private: Gtk::Image _preview_image; void _displayTemplateDetails(); - }; } -- cgit v1.2.3 From 6b78e29d0a6b0a5df82b1d8779689ec41718b258 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Wed, 24 Jul 2013 09:25:52 +0200 Subject: Old templates support removed (bzr r12379.2.13) --- src/interface.cpp | 97 +----------------------------------- src/menus-skeleton.h | 1 - src/templates/main.cpp | 16 ------ src/templates/preview.png | Bin 2426 -> 0 bytes src/ui/dialog/template-load-tab.cpp | 2 +- 5 files changed, 2 insertions(+), 114 deletions(-) delete mode 100644 src/templates/main.cpp delete mode 100644 src/templates/preview.png (limited to 'src') diff --git a/src/interface.cpp b/src/interface.cpp index 986d3107f..f9e720494 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -716,13 +716,6 @@ sp_recent_open(GtkRecentChooser *recent_menu, gpointer /*user_data*/) g_free(uri); } -static void -sp_file_new_from_template(GtkWidget */*widget*/, gchar const *uri) -{ - sp_file_new(uri); -} - - static bool compare_file_basenames(gchar const *a, gchar const *b) { bool rc; @@ -750,91 +743,6 @@ compare_file_basenames(gchar const *a, gchar const *b) { return rc; } -static void -sp_menu_get_svg_filenames_from_dir(gchar const *dirname, std::list *files) -{ - if ( Inkscape::IO::file_test( dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) ) ) { - GError *err = 0; - GDir *dir = g_dir_open(dirname, 0, &err); - - if (dir) { - for (gchar const *file = g_dir_read_name(dir); file != NULL; file = g_dir_read_name(dir)) { - if (!g_str_has_suffix(file, ".svg") && !g_str_has_suffix(file, ".svgz")) { - continue; // skip non-svg files - } - - { - gchar *basename = g_path_get_basename(file); - if (g_str_has_suffix(basename, ".svg") && g_str_has_prefix(basename, "default.")) { - g_free(basename); - basename = 0; - continue; // skip default.*.svg (i.e. default.svg and translations) - it's in the menu already - } - g_free(basename); - basename = 0; - } - - gchar const *filepath = g_build_filename(dirname, file, NULL); - files->push_front(filepath); - } - g_dir_close(dir); - } - } - - files->sort(compare_file_basenames); -} - -static void -sp_menu_add_filenames_to_menu(GtkWidget *menu, Inkscape::UI::View::View *view, std::list *files) -{ - if (!files->empty()) { - GtkWidget *sep = gtk_separator_menu_item_new(); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep); - } - - for(std::list::iterator it=files->begin(); it != files->end(); ++it) { - gchar const *filepath = *it; - gchar const *file = g_path_get_basename(filepath); - gchar *dupfile = g_strndup(file, strlen(file) - 4); - gchar *filename = g_filename_to_utf8(dupfile, -1, NULL, NULL, NULL); - g_free(dupfile); - - GtkWidget *item = gtk_menu_item_new_with_label(filename); - g_free(filename); - - gtk_widget_show(item); - // how does "filepath" ever get freed? - g_signal_connect(G_OBJECT(item), - "activate", - G_CALLBACK(sp_file_new_from_template), - (gpointer) filepath); - - if (view) { - // set null tip for now; later use a description from the template file - g_object_set_data(G_OBJECT(item), "view", (gpointer) view); - g_signal_connect( G_OBJECT(item), "select", G_CALLBACK(sp_ui_menu_select), (gpointer) NULL ); - g_signal_connect( G_OBJECT(item), "deselect", G_CALLBACK(sp_ui_menu_deselect), NULL); - } - - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - } - -} -static void -sp_menu_append_new_templates(GtkWidget *menu, Inkscape::UI::View::View *view) -{ - // user's local dir - std::list userfiles; - sp_menu_get_svg_filenames_from_dir(profile_path("templates"), &userfiles); - sp_menu_add_filenames_to_menu(menu, view, &userfiles); - - // system templates dir - std::list templatefiles; - sp_menu_get_svg_filenames_from_dir(INKSCAPE_TEMPLATESDIR, &templatefiles); - sp_menu_add_filenames_to_menu(menu, view, &templatefiles); - -} - static void sp_ui_checkboxes_menus(GtkMenu *m, Inkscape::UI::View::View *view) { @@ -995,10 +903,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); continue; } - if (!strcmp(menu_pntr->name(), "template-list")) { - sp_menu_append_new_templates(menu, view); - continue; - } + if (!strcmp(menu_pntr->name(), "recent-file-list")) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 7c412b605..9dcd4a80b 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -16,7 +16,6 @@ static char const menus_skeleton[] = " \n" " \n" " \n" -" \n" " \n" " \n" " \n" diff --git a/src/templates/main.cpp b/src/templates/main.cpp deleted file mode 100644 index d7a3f40a4..000000000 --- a/src/templates/main.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include - -#include "new-from-template.h" - -using namespace Inkscape::UI; - -int main (int argc, char *argv[]) -{ - Gtk::Main kit(argc, argv); - - NewFromTemplate dialog; - dialog.run(); - //Gtk::Main::run(dialog); - - return 0; -} diff --git a/src/templates/preview.png b/src/templates/preview.png deleted file mode 100644 index c56a832a2..000000000 Binary files a/src/templates/preview.png and /dev/null differ diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index ded4fc6fd..58219f8f2 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -185,7 +185,7 @@ void TemplateLoadTab::_loadTemplates() _getTemplatesFromDir(profile_path("templates") + _loading_path); // system templates dir - // _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); + _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path); } -- cgit v1.2.3 From badc78fc17340975af12905bc7a0e0c4d7ab62b4 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Wed, 24 Jul 2013 10:22:37 +0200 Subject: Templates gui fixes (bzr r12379.2.14) --- src/ui/dialog/new-from-template.cpp | 3 ++- src/ui/dialog/template-load-tab.cpp | 14 ++++++-------- src/ui/dialog/template-load-tab.h | 5 +++-- src/ui/dialog/template-widget.cpp | 17 ++++++++--------- 4 files changed, 19 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index 6598aecdf..2595e2cf5 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -30,7 +30,8 @@ NewFromTemplate::NewFromTemplate() Gtk::Alignment *align; align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); - get_vbox()->pack_end(*align, Gtk::PACK_SHRINK, 5); + get_vbox()->pack_end(*align, Gtk::PACK_SHRINK); + align->set_padding(0, 0, 0, 15); align->add(_create_template_button); _create_template_button.signal_pressed().connect( diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 58219f8f2..65d5e6447 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -38,18 +38,16 @@ TemplateLoadTab::TemplateLoadTab() set_border_width(10); _info_widget = manage(new TemplateWidget()); + Gtk::Label *title; title = manage(new Gtk::Label(_("Search:"))); - _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); - - _tlist_box.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 0); + _search_box.pack_start(*title, Gtk::PACK_SHRINK); + _search_box.pack_start(_keywords_combo, Gtk::PACK_SHRINK, 5); - title = manage(new Gtk::Label(_("Templates"))); - _tlist_box.pack_start(*title, Gtk::PACK_SHRINK, 10); + _tlist_box.pack_start(_search_box, Gtk::PACK_SHRINK, 10); - add(_main_box); - _main_box.pack_start(_tlist_box, Gtk::PACK_SHRINK, 20); - _main_box.pack_start(*_info_widget, Gtk::PACK_EXPAND_WIDGET, 10); + pack_start(_tlist_box, Gtk::PACK_SHRINK); + pack_start(*_info_widget, Gtk::PACK_EXPAND_WIDGET, 5); Gtk::ScrolledWindow *scrolled; scrolled = manage(new Gtk::ScrolledWindow()); diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index cc5229c95..c3c512374 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -25,7 +25,7 @@ namespace UI { class TemplateWidget; -class TemplateLoadTab : public Gtk::Frame +class TemplateLoadTab : public Gtk::HBox { public: @@ -71,8 +71,9 @@ protected: void _loadTemplates(); void _initLists(); - Gtk::HBox _main_box; + // Gtk::HBox _main_box; Gtk::VBox _tlist_box; + Gtk::HBox _search_box; TemplateWidget *_info_widget; Gtk::ComboBoxText _keywords_combo; diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index bb2c4a683..56346403e 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -27,26 +27,25 @@ namespace UI { TemplateWidget::TemplateWidget() : _more_info_button(_("More info")) - , _short_description_label(_("Short description")) - , _template_author_label(_("by template_author")) - , _template_name_label(_("Template_name")) - , _preview_image("preview.png") + , _short_description_label(_(" ")) + , _template_author_label(_(" ")) + , _template_name_label(_("no template selected")) + , _preview_image(" ") { - Gtk::Label *title = manage(new Gtk::Label(_("Selected template"))); - pack_start(*title, Gtk::PACK_SHRINK, 10); - pack_start(_template_name_label, Gtk::PACK_SHRINK, 4); + pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); pack_start(_preview_image, Gtk::PACK_SHRINK, 15); - pack_start(_short_description_label, Gtk::PACK_SHRINK, 4); _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)); - pack_start(*align, Gtk::PACK_SHRINK, 5); + pack_end(*align, Gtk::PACK_SHRINK); align->add(_more_info_button); + pack_end(_short_description_label, Gtk::PACK_SHRINK, 5); + _more_info_button.signal_pressed().connect( sigc::mem_fun(*this, &TemplateWidget::_displayTemplateDetails)); } -- cgit v1.2.3 From 6967bad3f32f3cf9e660f6009be63adf62f94058 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 27 Jul 2013 22:14:29 +0200 Subject: Templates related bug fixes (bzr r12379.2.15) --- src/ui/dialog/template-load-tab.cpp | 10 +++++++++- src/ui/dialog/template-widget.cpp | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 65d5e6447..d993e0233 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -191,9 +191,17 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: { TemplateData result; result.path = path; - result.display_name = Glib::path_get_basename(path); result.is_procedural = false; + // convert path into valid template name + result.display_name = Glib::path_get_basename(path); + gsize n = 0; + while ((n = result.display_name.find_first_of("_", 0)) < Glib::ustring::npos){ + result.display_name.replace(n, 1, 1, ' '); + } + n = result.display_name.rfind(".svg"); + result.display_name.replace(n, 4, 1, ' '); + Inkscape::XML::Document *rdoc; rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); Inkscape::XML::Node *myRoot; diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 56346403e..1efa790ab 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -58,7 +58,7 @@ void TemplateWidget::create() if (_current_template.is_procedural) {} else { - sp_file_new(_current_template.path); + sp_file_open(_current_template.path, NULL); } } -- cgit v1.2.3 From d11c156518710f49dc3fc8ec3408388a1a2b1ddb Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 27 Jul 2013 22:39:28 +0200 Subject: New preview rendering option in New From Template (bzr r12379.2.16) --- src/ui/dialog/template-load-tab.cpp | 1 + src/ui/dialog/template-widget.cpp | 13 ++++++++++++- src/ui/dialog/template-widget.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index d993e0233..ade595eaa 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -192,6 +192,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: TemplateData result; result.path = path; result.is_procedural = false; + result.preview_name = ""; // convert path into valid template name result.display_name = Glib::path_get_basename(path); diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 1efa790ab..c15d234ab 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -31,10 +31,12 @@ TemplateWidget::TemplateWidget() , _template_author_label(_(" ")) , _template_name_label(_("no template selected")) , _preview_image(" ") + , _preview_render() { pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); pack_start(_preview_image, Gtk::PACK_SHRINK, 15); + pack_start(_preview_render, Gtk::PACK_SHRINK, 10); _short_description_label.set_line_wrap(true); _short_description_label.set_size_request(200); @@ -73,7 +75,16 @@ void TemplateWidget::display(TemplateLoadTab::TemplateData data) _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); - _preview_image.set(imagePath); + 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(); + } } } diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index 743fb524d..b9d03415c 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -12,6 +12,7 @@ #define INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_WIDGET_H #include "template-load-tab.h" +#include "filedialogimpl-gtkmm.h" #include @@ -34,6 +35,7 @@ private: Gtk::Label _template_author_label; Gtk::Label _template_name_label; Gtk::Image _preview_image; + Dialog::SVGPreview _preview_render; void _displayTemplateDetails(); }; -- cgit v1.2.3 From 2b49305a582432378732c9f26456e1ada464edbd Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 27 Jul 2013 22:51:06 +0200 Subject: Template preview size fixed (bzr r12379.2.17) --- src/ui/dialog/template-widget.cpp | 6 ++++-- src/ui/dialog/template-widget.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index c15d234ab..4b64c1c73 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -35,8 +35,10 @@ TemplateWidget::TemplateWidget() { pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); - pack_start(_preview_image, Gtk::PACK_SHRINK, 15); - pack_start(_preview_render, Gtk::PACK_SHRINK, 10); + 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); diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index b9d03415c..3c95208de 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -34,6 +34,7 @@ private: Gtk::Label _short_description_label; Gtk::Label _template_author_label; Gtk::Label _template_name_label; + Gtk::HBox _preview_box; Gtk::Image _preview_image; Dialog::SVGPreview _preview_render; -- cgit v1.2.3 From 3d59db609dcae34444b45348c57ac203886576b6 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sun, 4 Aug 2013 14:37:48 +0200 Subject: Removing template data from XML tree added (bzr r12379.2.18) --- src/extension/dbus/document-interface.cpp | 2 +- src/file.cpp | 18 ++++++++++++++---- src/file.h | 10 ++++++++-- src/help.cpp | 2 +- src/ui/dialog/template-widget.cpp | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 56d1dfdbd..85c92b098 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -918,7 +918,7 @@ gboolean document_interface_load(DocumentInterface *object, { desktop_ensure_active(object->desk); const Glib::ustring file(filename); - sp_file_open(file, NULL, TRUE, TRUE); + sp_file_open(file, NULL); if (object->updates) { Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), SP_VERB_FILE_OPEN, "Opened File"); } diff --git a/src/file.cpp b/src/file.cpp index 9d3c513ab..ee205b035 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -227,7 +227,7 @@ sp_file_exit() */ bool sp_file_open(const Glib::ustring &uri, Inkscape::Extension::Extension *key, - bool add_to_recent, bool replace_empty) + int flags) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop) { @@ -252,9 +252,19 @@ bool sp_file_open(const Glib::ustring &uri, } if (doc) { + if (flags & IS_FROM_TEMPLATE){ + Inkscape::XML::Node *myRoot = doc->getReprRoot(); + Inkscape::XML::Node *nodeToRemove = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); + if (nodeToRemove != NULL){ + sp_repr_unparent(nodeToRemove); + delete nodeToRemove; + DocumentUndo::clearUndo(doc); + } + } + SPDocument *existing = desktop ? sp_desktop_document(desktop) : NULL; - if (existing && existing->virgin && replace_empty) { + if (existing && existing->virgin && (flags & REPLACE_EMPTY)) { // If the current desktop is empty, open the document there doc->ensureUpToDate(); // TODO this will trigger broken link warnings, etc. desktop->change_document(doc); @@ -268,14 +278,14 @@ bool sp_file_open(const Glib::ustring &uri, doc->virgin = FALSE; - // everyone who cares now has a reference, get rid of ours + // everyone who cares now has a reference, get rid of our`s doc->doUnref(); // resize the window to match the document properties sp_namedview_window_from_document(desktop); sp_namedview_update_layers_from_document(desktop); - if (add_to_recent) { + if (flags & ADD_TO_RECENT) { sp_file_add_recent( doc->getURI() ); } diff --git a/src/file.h b/src/file.h index fe8ad9af3..e94a3c598 100644 --- a/src/file.h +++ b/src/file.h @@ -62,11 +62,17 @@ void sp_file_exit (void); /** * Opens a new file and window from the given URI */ +enum SPFileOpenFlags +{ + ADD_TO_RECENT = 1, + REPLACE_EMPTY = 2, + IS_FROM_TEMPLATE = 4 +}; + bool sp_file_open( const Glib::ustring &uri, Inkscape::Extension::Extension *key, - bool add_to_recent = true, - bool replace_empty = true + int flags = ADD_TO_RECENT | REPLACE_EMPTY ); /** diff --git a/src/help.cpp b/src/help.cpp index 02a1930f4..f14fdf487 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -34,7 +34,7 @@ sp_help_open_tutorial(GtkMenuItem *, gpointer data) { gchar const *name = static_cast(data); gchar *c = g_build_filename(INKSCAPE_TUTORIALSDIR, name, NULL); - sp_file_open(c, NULL, false, false); + sp_file_open(c, NULL, 0); g_free(c); } diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 4b64c1c73..66121a73a 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -62,7 +62,7 @@ void TemplateWidget::create() if (_current_template.is_procedural) {} else { - sp_file_open(_current_template.path, NULL); + sp_file_open(_current_template.path, NULL, REPLACE_EMPTY | ADD_TO_RECENT | IS_FROM_TEMPLATE); } } -- cgit v1.2.3 From 625d70be1e222b3cfbbf6527b2829b645f369cd2 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Tue, 6 Aug 2013 22:48:28 +0200 Subject: Adapted sp_file_new for use with templates (bzr r12379.2.19) --- src/file.cpp | 50 ++++++++++++++++++++++++++------------- src/file.h | 3 +-- src/ui/dialog/template-widget.cpp | 2 +- 3 files changed, 35 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/file.cpp b/src/file.cpp index ee205b035..258628d32 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -127,21 +127,46 @@ SPDesktop *sp_file_new(const Glib::ustring &templ) { SPDocument *doc = SPDocument::createNewDoc( !templ.empty() ? templ.c_str() : 0 , TRUE, true ); g_return_val_if_fail(doc != NULL, NULL); + + // Remove all the template info from xml tree + Inkscape::XML::Node *myRoot = doc->getReprRoot(); + Inkscape::XML::Node *nodeToRemove = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); + if (nodeToRemove != NULL){ + sp_repr_unparent(nodeToRemove); + delete nodeToRemove; + DocumentUndo::clearUndo(doc); + } + + SPDesktop *desktop = SP_ACTIVE_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)); - g_return_val_if_fail(dtw != NULL, NULL); doc->doUnref(); - sp_create_window(dtw, TRUE); - SPDesktop *dt = static_cast(dtw->view); - sp_namedview_window_from_document(dt); - sp_namedview_update_layers_from_document(dt); + sp_namedview_window_from_document(desktop); + sp_namedview_update_layers_from_document(desktop); #ifdef WITH_DBUS Inkscape::Extension::Dbus::dbus_init_desktop_interface(dt); #endif - return dt; + return desktop; } Glib::ustring sp_file_default_template_uri() @@ -252,16 +277,7 @@ bool sp_file_open(const Glib::ustring &uri, } if (doc) { - if (flags & IS_FROM_TEMPLATE){ - Inkscape::XML::Node *myRoot = doc->getReprRoot(); - Inkscape::XML::Node *nodeToRemove = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); - if (nodeToRemove != NULL){ - sp_repr_unparent(nodeToRemove); - delete nodeToRemove; - DocumentUndo::clearUndo(doc); - } - } - + SPDocument *existing = desktop ? sp_desktop_document(desktop) : NULL; if (existing && existing->virgin && (flags & REPLACE_EMPTY)) { diff --git a/src/file.h b/src/file.h index e94a3c598..4d55825c4 100644 --- a/src/file.h +++ b/src/file.h @@ -65,8 +65,7 @@ void sp_file_exit (void); enum SPFileOpenFlags { ADD_TO_RECENT = 1, - REPLACE_EMPTY = 2, - IS_FROM_TEMPLATE = 4 + REPLACE_EMPTY = 2 }; bool sp_file_open( diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 66121a73a..7e0599049 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -62,7 +62,7 @@ void TemplateWidget::create() if (_current_template.is_procedural) {} else { - sp_file_open(_current_template.path, NULL, REPLACE_EMPTY | ADD_TO_RECENT | IS_FROM_TEMPLATE); + sp_file_new(_current_template.path); } } -- cgit v1.2.3 From 2f7ea8f8ae067cbb3406169d22a84426cabd43f6 Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Thu, 8 Aug 2013 17:01:03 +0100 Subject: Fix to do the "right thing" for difference/intersection boolean ops when one or more input paths are truncated to zero-size by the quantization step (coordinate rounding). Previously this had only been fixed for union ops (which happened to work for exclusion (XOR) ops as well). (bzr r12472.1.1) --- src/splivarot.cpp | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 356cf0161..6423129b9 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -277,11 +277,37 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool theShapeB->ConvertToShape(theShape, origWind[curOrig]); - if (theShapeA->numberOfEdges() == 0) { - Shape *swap = theShapeB; - theShapeB = theShapeA; - theShapeA = swap; - } else if (theShapeB->numberOfEdges() > 0) { + // Due to quantization of the input shape coordinates, we may end up with A or B being empty. + // If this is a union or symdiff operation, we just use the non-empty shape as the result: + // A=0 => (0 or B) == B + // B=0 => (A or 0) == A + // A=0 => (0 xor B) == B + // B=0 => (A xor 0) == A + // If this is an intersection operation, we just use the empty shape as the result: + // A=0 => (0 and B) == 0 == A + // B=0 => (A and 0) == 0 == B + // If this a difference operation, and the upper shape (A) is empty, we keep B. + // If the lower shape (B) is empty, we still keep B, as it's empty: + // A=0 => (B - 0) == B + // B=0 => (0 - A) == 0 == B + // + // In any case, the output from this operation is stored in shape A, so we may apply + // the above rules simply by judicious use of swapping A and B where necessary. + bool zeroA = theShapeA->numberOfEdges() == 0; + bool zeroB = theShapeB->numberOfEdges() == 0; + if (zeroA || zeroB) { + // We might need to do a swap. Apply the above rules depending on operation type. + bool resultIsB = ((bop == bool_op_union || bop == bool_op_symdiff) && zeroA) + || ((bop == bool_op_inters) && zeroB) + || (bop == bool_op_diff); + if (resultIsB) { + // Swap A and B to use B as the result + Shape *swap = theShapeB; + theShapeB = theShapeA; + theShapeA = swap; + } + } else { + // Just do the Boolean operation as usual // les elements arrivent en ordre inverse dans la liste theShape->Booleen(theShapeB, theShapeA, bop); Shape *swap = theShape; -- cgit v1.2.3 From c9946d39f8b2d37991be9a02e3b0f133f48bdb22 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Sat, 10 Aug 2013 15:23:01 +0200 Subject: Existing templates metadata added. Small keywords processing fix. (bzr r12379.2.20) --- src/ui/dialog/template-load-tab.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index ade595eaa..b37b68ae3 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -207,6 +207,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); Inkscape::XML::Node *myRoot; Inkscape::XML::Node *dataNode; + std::cerr << path.c_str(); if (rdoc){ myRoot = rdoc->root(); if (strcmp(myRoot->name(), "svg:svg") != 0){ // Wrong file format @@ -236,9 +237,13 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: Glib::ustring data = dataNode->firstChild()->content(); while (!data.empty()){ int 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); -- cgit v1.2.3 From 05f008356889de30ff55df1f73030003ed7cc312 Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Mon, 12 Aug 2013 16:39:48 +0100 Subject: Allow Object to Path verb from non-GUI (DBus) interface (bzr r12473.1.1) --- src/extension/internal/bluredge.cpp | 2 +- src/path-chemistry.cpp | 10 ++++------ src/path-chemistry.h | 4 +++- src/ui/dialog/livepatheffect-editor.cpp | 2 +- src/verbs.cpp | 23 +++++++++++++++++------ 5 files changed, 26 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index a3d2fd6e5..3ce537d9f 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -94,7 +94,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View new_group->appendChild(new_items[i]); selection->add(new_items[i]); - sp_selected_path_to_curves(static_cast(desktop)); + sp_selected_path_to_curves(selection, static_cast(desktop)); if (offset < 0.0) { /* Doing an inset here folks */ diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index b192904ce..e1924664b 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -294,18 +294,16 @@ sp_selected_path_break_apart(SPDesktop *desktop) /* This function is an entry point from GUI */ void -sp_selected_path_to_curves(SPDesktop *desktop, bool interactive) +sp_selected_path_to_curves(Inkscape::Selection *selection, SPDesktop *desktop, bool interactive) { - Inkscape::Selection *selection = sp_desktop_selection(desktop); - if (selection->isEmpty()) { - if (interactive) + if (interactive && desktop) sp_desktop_message_stack(desktop)->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to convert to path.")); return; } bool did = false; - if (interactive) { + if (interactive && desktop) { desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Converting objects to paths...")); // set "busy" cursor desktop->setWaitingCursor(); @@ -324,7 +322,7 @@ sp_selected_path_to_curves(SPDesktop *desktop, bool interactive) g_slist_free (to_select); g_slist_free (selected); - if (interactive) { + if (interactive && desktop) { desktop->clearWaitingCursor(); if (did) { DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_OBJECT_TO_CURVE, diff --git a/src/path-chemistry.h b/src/path-chemistry.h index b88b84087..efc687b44 100644 --- a/src/path-chemistry.h +++ b/src/path-chemistry.h @@ -19,6 +19,7 @@ class SPDesktop; class SPItem; namespace Inkscape { +class Selection; namespace XML { class Node; } // namespace XML @@ -26,7 +27,8 @@ class Node; void sp_selected_path_combine (SPDesktop *desktop); void sp_selected_path_break_apart (SPDesktop *desktop); -void sp_selected_path_to_curves (SPDesktop *desktop, bool interactive = true); +// interactive=true only has an effect if desktop != NULL, i.e. if a GUI is available +void sp_selected_path_to_curves (Inkscape::Selection *selection, SPDesktop *desktop, bool interactive = true); void sp_selected_to_lpeitems(SPDesktop *desktop); Inkscape::XML::Node *sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy); void sp_selected_path_reverse (SPDesktop *desktop); diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 6c6f3a582..6dc9c1ee3 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -416,7 +416,7 @@ LivePathEffectEditor::onAdd() // If item is a SPRect, convert it to path first: if ( SP_IS_RECT(item) ) { - sp_selected_path_to_curves(current_desktop, false); + sp_selected_path_to_curves(sel, current_desktop, false); item = sel->singleItem(); // get new item } diff --git a/src/verbs.cpp b/src/verbs.cpp index 06e59be38..baac07d60 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1446,12 +1446,26 @@ void LayerVerb::perform(SPAction *action, void *data) */ void ObjectVerb::perform( SPAction *action, void *data) { - g_return_if_fail(ensure_desktop_valid(action)); SPDesktop *dt = sp_action_get_desktop(action); + Inkscape::Selection *sel = sp_action_get_selection(action); - SPEventContext *ec = dt->event_context; + // We can perform some actions without a desktop + bool handled = true; + switch (reinterpret_cast(data)) { + case SP_VERB_OBJECT_TO_CURVE: + sp_selected_path_to_curves(sel, dt); + break; + default: + handled = false; + break; + } + if (handled) { + return; + } - Inkscape::Selection *sel = sp_desktop_selection(dt); + g_return_if_fail(ensure_desktop_valid(action)); + + SPEventContext *ec = dt->event_context; if (sel->isEmpty()) return; @@ -1478,9 +1492,6 @@ void ObjectVerb::perform( SPAction *action, void *data) case SP_VERB_OBJECT_FLATTEN: sp_selection_remove_transform(dt); break; - case SP_VERB_OBJECT_TO_CURVE: - sp_selected_path_to_curves(dt); - break; case SP_VERB_OBJECT_FLOW_TEXT: text_flow_into_shape(); break; -- cgit v1.2.3 From ca6b42152e492dc4e1a4554aae7ae1712eeecab7 Mon Sep 17 00:00:00 2001 From: Slagvi Public Date: Tue, 13 Aug 2013 12:10:07 +0200 Subject: Cleanups before merge (bzr r12379.2.21) --- src/ui/dialog/template-load-tab.cpp | 3 +-- src/ui/dialog/template-load-tab.h | 1 - src/ui/dialog/template-widget.cpp | 4 ++-- src/ui/dialog/template-widget.h | 6 +++--- 4 files changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index b37b68ae3..4fee4c5e7 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include "interface.h" #include "file.h" @@ -207,7 +206,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); Inkscape::XML::Node *myRoot; Inkscape::XML::Node *dataNode; - std::cerr << path.c_str(); + if (rdoc){ myRoot = rdoc->root(); if (strcmp(myRoot->name(), "svg:svg") != 0){ // Wrong file format diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index c3c512374..50f3e0be2 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -71,7 +71,6 @@ protected: void _loadTemplates(); void _initLists(); - // Gtk::HBox _main_box; Gtk::VBox _tlist_box; Gtk::HBox _search_box; TemplateWidget *_info_widget; diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 7e0599049..0e05f292c 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -30,7 +30,7 @@ TemplateWidget::TemplateWidget() , _short_description_label(_(" ")) , _template_author_label(_(" ")) , _template_name_label(_("no template selected")) - , _preview_image(" ") + , _preview_image() , _preview_render() { pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); @@ -41,7 +41,7 @@ TemplateWidget::TemplateWidget() _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); + //_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)); diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index 3c95208de..c7847460f 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -31,12 +31,12 @@ private: TemplateLoadTab::TemplateData _current_template; Gtk::Button _more_info_button; - Gtk::Label _short_description_label; - Gtk::Label _template_author_label; - Gtk::Label _template_name_label; Gtk::HBox _preview_box; Gtk::Image _preview_image; Dialog::SVGPreview _preview_render; + Gtk::Label _short_description_label; + Gtk::Label _template_author_label; + Gtk::Label _template_name_label; void _displayTemplateDetails(); }; -- cgit v1.2.3 From 7f43184f78f3ab203d6c597639805bf65cd22387 Mon Sep 17 00:00:00 2001 From: su_v Date: Wed, 14 Aug 2013 20:52:42 +0200 Subject: fix build with dbusapi enabled Fixed bugs: - https://launchpad.net/bugs/1212355 (bzr r12477) --- src/file.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/file.cpp b/src/file.cpp index eb917f169..68e229e62 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -164,7 +164,7 @@ SPDesktop *sp_file_new(const Glib::ustring &templ) sp_namedview_update_layers_from_document(desktop); #ifdef WITH_DBUS - Inkscape::Extension::Dbus::dbus_init_desktop_interface(dt); + Inkscape::Extension::Dbus::dbus_init_desktop_interface(desktop); #endif return desktop; -- cgit v1.2.3 From 0167937d063bb0e313aba987cbc69b59e18d2ed4 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 15 Aug 2013 01:15:59 +0200 Subject: Fix warning and hopefully fix build failures on Launchpad (bzr r12478) --- src/ui/dialog/template-load-tab.cpp | 5 ++++- src/ui/dialog/template-widget.cpp | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 4fee4c5e7..0123f663f 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -14,6 +14,9 @@ #include #include #include +#include +#include +#include #include "interface.h" #include "file.h" @@ -235,7 +238,7 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const Glib:: if ((dataNode = sp_repr_lookup_name(myRoot, "inkscape:_keywords")) != NULL){ Glib::ustring data = dataNode->firstChild()->content(); while (!data.empty()){ - int pos = data.find_first_of(" "); + std::size_t pos = data.find_first_of(" "); if (pos == Glib::ustring::npos) pos = data.size(); diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 0e05f292c..dfc26913f 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -30,8 +30,6 @@ TemplateWidget::TemplateWidget() , _short_description_label(_(" ")) , _template_author_label(_(" ")) , _template_name_label(_("no template selected")) - , _preview_image() - , _preview_render() { pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); pack_start(_template_author_label, Gtk::PACK_SHRINK, 0); -- cgit v1.2.3 From 0be39e335f73b5b7770f1580871f48ca1791ced4 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 15 Aug 2013 10:07:55 +0100 Subject: Fix Gtk+ 3 build failure and make check (bzr r12479) --- src/ui/dialog/template-load-tab.cpp | 3 ++- src/ui/dialog/template-widget.cpp | 8 ++++---- src/ui/dialog/template-widget.h | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 0123f663f..265ee8026 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -8,9 +8,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "template-load-tab.h" #include "template-widget.h" +#include "template-load-tab.h" + #include #include #include diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index dfc26913f..be7e2b515 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -1,5 +1,3 @@ - - /** @file * @brief New From Template - templates widget - implementation */ @@ -11,15 +9,17 @@ */ #include "template-widget.h" -#include "template-load-tab.h" -#include "file.h" #include #include #include #include + #include +#include +#include "template-load-tab.h" +#include "file.h" namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/template-widget.h b/src/ui/dialog/template-widget.h index c7847460f..f7e1267ce 100644 --- a/src/ui/dialog/template-widget.h +++ b/src/ui/dialog/template-widget.h @@ -11,10 +11,11 @@ #ifndef INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_WIDGET_H #define INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_WIDGET_H -#include "template-load-tab.h" #include "filedialogimpl-gtkmm.h" + #include +#include "template-load-tab.h" namespace Inkscape { namespace UI { -- cgit v1.2.3 From 69ac4cffff595c46b3f8dd2bcceab6bccf6e4581 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 15 Aug 2013 21:10:29 +0200 Subject: Add option to write out path data using only relative coordinates (in addition to using only absolute coordinates or using a mixture of absolute and relative coordinates optimized for length). (bzr r12480) --- src/preferences-skeleton.h | 2 +- src/svg/path-string.cpp | 72 ++++++++++++++++++++++------------ src/svg/path-string.h | 24 +++++++++--- src/ui/dialog/inkscape-preferences.cpp | 8 +++- src/ui/dialog/inkscape-preferences.h | 2 +- 5 files changed, 73 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index c5d972966..17b912d33 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -326,7 +326,7 @@ static char const preferences_skeleton[] = " minimumexponent=\"-8\" " " inlineattrs=\"0\" " " indent=\"2\" " -" allowrelativecoordinates=\"1\" " +" pathstring_format=\"2\" " " forcerepeatcommands=\"0\" " " incorrect_attributes_warn=\"1\" " " incorrect_attributes_remove=\"0\" " diff --git a/src/svg/path-string.cpp b/src/svg/path-string.cpp index 61e9c90a2..6dddeadff 100644 --- a/src/svg/path-string.cpp +++ b/src/svg/path-string.cpp @@ -2,6 +2,7 @@ * Inkscape::SVG::PathString - builder for SVG path strings * * Copyright 2008 Jasper van de Gronde + * Copyright 2013 Tavmjong Bah * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -25,44 +26,65 @@ static int const maxprec = 16; int Inkscape::SVG::PathString::numericprecision; int Inkscape::SVG::PathString::minimumexponent; +Inkscape::SVG::PATHSTRING_FORMAT Inkscape::SVG::PathString::format; Inkscape::SVG::PathString::PathString() : - allow_relative_coordinates(Inkscape::Preferences::get()->getBool("/options/svgoutput/allowrelativecoordinates", true)), force_repeat_commands(Inkscape::Preferences::get()->getBool("/options/svgoutput/forcerepeatcommands")) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + format = (PATHSTRING_FORMAT)prefs->getIntLimited("/options/svgoutput/pathstring_format", 1, 0, PATHSTRING_FORMAT_SIZE - 1 ); numericprecision = std::max(minprec,std::min(maxprec, prefs->getInt("/options/svgoutput/numericprecision", 8))); minimumexponent = prefs->getInt("/options/svgoutput/minimumexponent", -8); } +// For absolute and relative paths... the entire path is kept in the "tail". +// For optimized path, at a switch between absolute and relative, add tail to commonbase. void Inkscape::SVG::PathString::_appendOp(char abs_op, char rel_op) { bool abs_op_repeated = _abs_state.prevop == abs_op && !force_repeat_commands; bool rel_op_repeated = _rel_state.prevop == rel_op && !force_repeat_commands; - unsigned int const abs_added_size = abs_op_repeated ? 0 : 2; - unsigned int const rel_added_size = rel_op_repeated ? 0 : 2; - if ( _rel_state.str.size()+2 < _abs_state.str.size()+abs_added_size && allow_relative_coordinates ) { - // Store common prefix - commonbase += _rel_state.str; - _rel_state.str.clear(); - // Copy rel to abs - _abs_state = _rel_state; - _abs_state.switches++; - abs_op_repeated = false; - // We do not have to copy abs to rel: - // _rel_state.str.size()+2 < _abs_state.str.size()+abs_added_size - // _rel_state.str.size()+rel_added_size < _abs_state.str.size()+2 - // _abs_state.str.size()+2 > _rel_state.str.size()+rel_added_size - } else if ( _abs_state.str.size()+2 < _rel_state.str.size()+rel_added_size ) { - // Store common prefix - commonbase += _abs_state.str; - _abs_state.str.clear(); - // Copy abs to rel - _rel_state = _abs_state; - _abs_state.switches++; - rel_op_repeated = false; + + // For absolute and relative paths... do nothing. + switch (format) { + case PATHSTRING_ABSOLUTE: + if ( !abs_op_repeated ) _abs_state.appendOp(abs_op); + break; + case PATHSTRING_RELATIVE: + if ( !rel_op_repeated ) _rel_state.appendOp(rel_op); + break; + case PATHSTRING_OPTIMIZE: + { + unsigned int const abs_added_size = abs_op_repeated ? 0 : 2; + unsigned int const rel_added_size = rel_op_repeated ? 0 : 2; + if ( _rel_state.str.size()+2 < _abs_state.str.size()+abs_added_size ) { + + // Store common prefix + commonbase += _rel_state.str; + _rel_state.str.clear(); + // Copy rel to abs + _abs_state = _rel_state; + _abs_state.switches++; + abs_op_repeated = false; + // We do not have to copy abs to rel: + // _rel_state.str.size()+2 < _abs_state.str.size()+abs_added_size + // _rel_state.str.size()+rel_added_size < _abs_state.str.size()+2 + // _abs_state.str.size()+2 > _rel_state.str.size()+rel_added_size + } else if ( _abs_state.str.size()+2 < _rel_state.str.size()+rel_added_size ) { + + // Store common prefix + commonbase += _abs_state.str; + _abs_state.str.clear(); + // Copy abs to rel + _rel_state = _abs_state; + _abs_state.switches++; + rel_op_repeated = false; + } + if ( !abs_op_repeated ) _abs_state.appendOp(abs_op); + if ( !rel_op_repeated ) _rel_state.appendOp(rel_op); + } + break; + default: + std::cout << "Better not be here!" << std::endl; } - if ( !abs_op_repeated ) _abs_state.appendOp(abs_op); - if ( !rel_op_repeated ) _rel_state.appendOp(rel_op); } void Inkscape::SVG::PathString::State::append(Geom::Coord v) { diff --git a/src/svg/path-string.h b/src/svg/path-string.h index 11018e65c..3a891873d 100644 --- a/src/svg/path-string.h +++ b/src/svg/path-string.h @@ -1,6 +1,7 @@ /* * Copyright 2007 MenTaLguY * Copyright 2008 Jasper van de Gronde + * Copyright 2013 Tavmjong Bah * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -23,6 +24,14 @@ namespace Inkscape { namespace SVG { +// Relative vs. absolute coordinates +enum PATHSTRING_FORMAT { + PATHSTRING_ABSOLUTE, // Use only absolute coordinates + PATHSTRING_RELATIVE, // Use only relative coordinates + PATHSTRING_OPTIMIZE, // Optimize for path string length + PATHSTRING_FORMAT_SIZE +}; + /** * Builder for SVG path strings. */ @@ -38,6 +47,7 @@ public: final.reserve(commonbase.size()+t.size()); final = commonbase; final += tail(); + // std::cout << " final: " << final << std::endl; return final; } @@ -130,12 +140,10 @@ public: } PathString &closePath() { - commonbase += _abs_state.str; - _abs_state.str.clear(); - _rel_state = _abs_state; + _abs_state.appendOp('Z'); _rel_state.appendOp('z'); - _rel_state.switches++; + _current_point = _initial_point; return *this; } @@ -229,9 +237,13 @@ private: // to cause a quadratic time complexity (in the number of characters/operators) std::string commonbase; std::string final; - std::string const &tail() const { return ((_abs_state <= _rel_state || !allow_relative_coordinates) ? _abs_state.str : _rel_state.str); } + std::string const &tail() const { + return ( (format == PATHSTRING_ABSOLUTE) || + (format == PATHSTRING_OPTIMIZE && _abs_state <= _rel_state ) ? + _abs_state.str : _rel_state.str ); + } - bool const allow_relative_coordinates; + static PATHSTRING_FORMAT format; bool const force_repeat_commands; static int numericprecision; static int minimumexponent; diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 7890b0b4c..b06c1fd1f 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -879,8 +879,12 @@ void InkscapePreferences::initPageIO() _page_svgoutput.add_group_header( _("Path data")); - _svgoutput_allowrelativecoordinates.init( _("Allow relative coordinates"), "/options/svgoutput/allowrelativecoordinates", true); - _page_svgoutput.add_line( true, "", _svgoutput_allowrelativecoordinates, "", _("If set, relative coordinates may be used in path data"), false); + int const numPathstringFormat = 3; + Glib::ustring pathstringFormatLabels[numPathstringFormat] = {_("Absolute"), _("Relative"), _("Optimized")}; + int pathstringFormatValues[numPathstringFormat] = {0, 1, 2}; + + _svgoutput_pathformat.init("/options/svgoutput/pathstring_format", pathstringFormatLabels, pathstringFormatValues, numPathstringFormat, 2); + _page_svgoutput.add_line( true, _("Path string format"), _svgoutput_pathformat, "", _("Path data should be written: only with absolute coordinates, only with relative coordinates, or optimized for string length (mixed absolute and relative coordinates)"), false); _svgoutput_forcerepeatcommands.init( _("Force repeat commands"), "/options/svgoutput/forcerepeatcommands", false); _page_svgoutput.add_line( true, "", _svgoutput_forcerepeatcommands, "", _("Force repeating of the same path command (for example, 'L 1,2 L 3,4' instead of 'L 1,2 3,4')"), false); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 37c05df05..56222fb22 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -426,7 +426,7 @@ protected: UI::Widget::PrefSpinButton _svgoutput_minimumexponent; UI::Widget::PrefCheckButton _svgoutput_inlineattrs; UI::Widget::PrefSpinButton _svgoutput_indent; - UI::Widget::PrefCheckButton _svgoutput_allowrelativecoordinates; + UI::Widget::PrefCombo _svgoutput_pathformat; UI::Widget::PrefCheckButton _svgoutput_forcerepeatcommands; // Attribute Checking controls for SVG Output page: -- cgit v1.2.3 From 451210ce988fb6e6964bd4869f74ffa7fb2c462d Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 15 Aug 2013 21:13:44 +0200 Subject: Prevent writing out empty style strings. (bzr r12481) --- src/attribute-rel-util.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/attribute-rel-util.cpp b/src/attribute-rel-util.cpp index 933339632..15c71daa7 100644 --- a/src/attribute-rel-util.cpp +++ b/src/attribute-rel-util.cpp @@ -141,7 +141,11 @@ void sp_attribute_clean_style(Node *repr, unsigned int flags) { // sp_repr_css_set( repr, css, "style"); // Don't use as it will cause loop. Glib::ustring value; sp_repr_css_write_string(css, value); - repr->setAttribute("style", value.c_str()); + if( value.empty() ) { + repr->setAttribute("style", NULL ); + } else { + repr->setAttribute("style", value.c_str()); + } sp_repr_css_attr_unref( css ); } -- cgit v1.2.3