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/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 ++++++++++++++++ 7 files changed, 325 insertions(+) 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/ui') 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 -- 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/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 ++++--- 4 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/ui') 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/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 +++++++++++-- 6 files changed, 108 insertions(+), 12 deletions(-) (limited to 'src/ui') 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); }; -- 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/ui') 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/ui') 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/ui') 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/ui') 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/ui') 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/ui/dialog/template-load-tab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') 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/ui') 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/ui') 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/ui') 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/ui') 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/ui/dialog/template-widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') 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/ui/dialog/template-widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') 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 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/ui') 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 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/ui') 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 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/ui') 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/ui') 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/ui/dialog/inkscape-preferences.cpp | 8 ++++++-- src/ui/dialog/inkscape-preferences.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/ui') 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 ba0f4a7717d67ce1a901d07506bdabc7dc72cae1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Sep 2013 06:11:46 +1000 Subject: update cmakefiles (bzr r12493) --- src/ui/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/ui') diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index b592d2527..c95dd35cc 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -54,6 +54,7 @@ set(ui_SRC dialog/livepatheffect-editor.cpp dialog/memory.cpp dialog/messages.cpp + dialog/new-from-template.cpp dialog/object-attributes.cpp dialog/object-properties.cpp dialog/ocaldialogs.cpp @@ -65,6 +66,8 @@ set(ui_SRC dialog/spellcheck.cpp dialog/svg-fonts-dialog.cpp dialog/swatches.cpp + dialog/template-load-tab.cpp + dialog/template-widget.cpp dialog/text-edit.cpp dialog/tile.cpp dialog/tracedialog.cpp @@ -166,16 +169,20 @@ set(ui_SRC dialog/livepatheffect-editor.h dialog/memory.h dialog/messages.h + dialog/new-from-template.h dialog/object-attributes.h dialog/object-properties.h dialog/ocaldialogs.h dialog/panel-dialog.h dialog/print-colors-preview-dialog.h dialog/print.h + dialog/spellcheck.h dialog/svg-fonts-dialog.h dialog/swatches.h dialog/symbols.h + dialog/template-load-tab.h + dialog/template-widget.h dialog/text-edit.h dialog/tile.h dialog/tracedialog.h -- cgit v1.2.3 From c9e56074607678b3c11e381b2462acf66b147789 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 1 Sep 2013 12:46:33 -0400 Subject: Fix PNG export with non-px default unit [Bug #1215104]. (bzr r12495) --- src/ui/dialog/export.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 2c92608d7..0b20c08a2 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -201,11 +201,11 @@ Export::Export (void) : earlier than that */ unit_selector = new Inkscape::UI::Widget::UnitMenu(); unit_selector->setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR); - unitChangedConn = unit_selector->signal_changed().connect(sigc::mem_fun(*this, &Export::onUnitChanged)); SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop) unit_selector->setUnit(sp_desktop_namedview(desktop)->doc_units->abbr); + unitChangedConn = unit_selector->signal_changed().connect(sigc::mem_fun(*this, &Export::onUnitChanged)); unitbox.pack_end(*unit_selector, false, false, 0); unitbox.pack_end(units_label, false, false, 3); -- cgit v1.2.3 From 57154184731bf7d482be5bc2a67a74d11e491e2d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Mon, 2 Sep 2013 02:03:47 +0200 Subject: Allow EMF import from Wine apps on Linux (bzr r12500) --- src/ui/clipboard.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 629960613..22d42d525 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -94,12 +94,6 @@ #ifdef WIN32 #include -// Clipboard Formats: http://msdn.microsoft.com/en-us/library/ms649013(VS.85).aspx -// On Windows, most graphical applications can handle CF_DIB/CF_BITMAP and/or CF_ENHMETAFILE -// GTK automatically presents an "image/bmp" target as CF_DIB/CF_BITMAP -// Presenting "image/x-emf" as CF_ENHMETAFILE must be done by Inkscape ? -#define CLIPBOARD_WIN32_EMF_TARGET "CF_ENHMETAFILE" -#define CLIPBOARD_WIN32_EMF_MIME "image/x-emf" #endif namespace Inkscape { @@ -179,13 +173,18 @@ ClipboardManagerImpl::ClipboardManagerImpl() _text_style(NULL), _clipboard( Gtk::Clipboard::get() ) { + // Clipboard Formats: http://msdn.microsoft.com/en-us/library/ms649013(VS.85).aspx + // On Windows, most graphical applications can handle CF_DIB/CF_BITMAP and/or CF_ENHMETAFILE + // GTK automatically presents an "image/bmp" target as CF_DIB/CF_BITMAP + // Presenting "image/x-emf" as CF_ENHMETAFILE must be done by Inkscape ? + // push supported clipboard targets, in order of preference _preferred_targets.push_back("image/x-inkscape-svg"); _preferred_targets.push_back("image/svg+xml"); _preferred_targets.push_back("image/svg+xml-compressed"); -#ifdef WIN32 - _preferred_targets.push_back(CLIPBOARD_WIN32_EMF_MIME); -#endif + _preferred_targets.push_back("image/x-emf"); + _preferred_targets.push_back("CF_ENHMETAFILE"); + _preferred_targets.push_back("WCF_ENHMETAFILE"); // seen on Wine _preferred_targets.push_back("application/pdf"); _preferred_targets.push_back("image/x-adobe-illustrator"); } @@ -981,7 +980,7 @@ SPDocument *ClipboardManagerImpl::_retrieveClipboard(Glib::ustring required_targ Glib::ustring target = best_target; #ifdef WIN32 - if (best_target == CLIPBOARD_WIN32_EMF_TARGET) + if (best_target == "CF_ENHMETAFILE" || best_target == "WCF_ENHMETAFILE") { // Try to save clipboard data as en emf file (using win32 api) if (OpenClipboard(NULL)) { HGLOBAL hglb = GetClipboardData(CF_ENHMETAFILE); @@ -989,7 +988,7 @@ SPDocument *ClipboardManagerImpl::_retrieveClipboard(Glib::ustring required_targ HENHMETAFILE hemf = CopyEnhMetaFile((HENHMETAFILE) hglb, filename); if (hemf) { file_saved = true; - target = CLIPBOARD_WIN32_EMF_MIME; + target = "image/x-emf"; DeleteEnhMetaFile(hemf); } } @@ -1020,6 +1019,10 @@ SPDocument *ClipboardManagerImpl::_retrieveClipboard(Glib::ustring required_targ if (target == "image/x-inkscape-svg") { target = "image/svg+xml"; } + // Use the EMF extension to import metafiles + if (target == "CF_ENHMETAFILE" || target == "WCF_ENHMETAFILE") { + target = "image/x-emf"; + } Inkscape::Extension::DB::InputList inlist; Inkscape::Extension::db.get_input_list(inlist); @@ -1213,10 +1216,10 @@ Glib::ustring ClipboardManagerImpl::_getBestTarget() // clipboard target debugging snippet /* - g_debug("Begin clipboard targets"); + g_message("Begin clipboard targets"); for ( std::list::iterator x = targets.begin() ; x != targets.end(); ++x ) - g_debug("Clipboard target: %s", (*x).data()); - g_debug("End clipboard targets\n"); + g_message("Clipboard target: %s", (*x).data()); + g_message("End clipboard targets\n"); //*/ for (std::list::iterator i = _preferred_targets.begin() ; -- cgit v1.2.3 From 2bc1f3fc0275dee7b934ab584457fe3e4754816c Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sat, 7 Sep 2013 08:46:37 +0200 Subject: Fix for bug #1219175 (Typing in Layers Dialog searches hidden/unhidden state instead of layer name). Fixed bugs: - https://launchpad.net/bugs/1219175 (bzr r12503) --- src/ui/dialog/layers.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index c41046123..c01903f94 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -838,7 +838,8 @@ LayersPanel::LayersPanel() : _name_column->add_attribute(_text_renderer->property_text(), _model->_colLabel); _tree.set_expander_column( *_tree.get_column(nameColNum) ); - + _tree.set_search_column(nameColNum + 1); + _compositeSettings.setSubject(&_subject); _selectedConnection = _tree.get_selection()->signal_changed().connect( sigc::mem_fun(*this, &LayersPanel::_pushTreeSelectionToCurrent) ); -- cgit v1.2.3 From 69c1405758767e06059f0bfc38b938f7bf069692 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sun, 8 Sep 2013 10:17:05 -0400 Subject: Add a check so objects removed from the document dont crash inkscape, happens on close bc event race condition or misorder of what to destroy Fixed bugs: - https://launchpad.net/bugs/1220143 (bzr r12504) --- src/ui/dialog/filter-effects-dialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 4401d5658..4ce2eafd1 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1310,7 +1310,8 @@ void FilterEffectsDialog::FilterModifier::on_name_edited(const Glib::ustring& pa void FilterEffectsDialog::FilterModifier::on_filter_reorder(const Gtk::TreeModel::Path& path) { for(Gtk::TreeModel::iterator i = _model->children().begin(); i != _model->children().end(); ++i) { SPObject* object = (*i)[_columns.filter]; - object->getRepr()->setPosition(0); + if(object && object->getRepr()) + object->getRepr()->setPosition(0); } } -- cgit v1.2.3 From 294f3f988ad4864d164e90ba68e84795108a3803 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 12 Sep 2013 19:30:14 +0200 Subject: fix Windows build (bzr r12507) --- src/ui/clipboard.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 22d42d525..aeb977078 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -1242,7 +1242,7 @@ Glib::ustring ClipboardManagerImpl::_getBestTarget() CloseClipboard(); if (format == CF_ENHMETAFILE) { - return CLIPBOARD_WIN32_EMF_TARGET; + return "CF_ENHMETAFILE"; } if (format == CF_DIB || format == CF_BITMAP) { return CLIPBOARD_GDK_PIXBUF_TARGET; @@ -1250,7 +1250,7 @@ Glib::ustring ClipboardManagerImpl::_getBestTarget() } if (IsClipboardFormatAvailable(CF_ENHMETAFILE)) { - return CLIPBOARD_WIN32_EMF_TARGET; + return "CF_ENHMETAFILE"; } #endif if (_clipboard->wait_is_image_available()) { @@ -1314,7 +1314,7 @@ void ClipboardManagerImpl::_setClipboardTargets() if (OpenClipboard(NULL)) { if ( _clipboardSPDoc != NULL ) { - const Glib::ustring target = CLIPBOARD_WIN32_EMF_MIME; + const Glib::ustring target = "image/x-emf"; Inkscape::Extension::DB::OutputList outlist; Inkscape::Extension::db.get_output_list(outlist); -- cgit v1.2.3