diff options
| author | Slagvi Public <JandotDarowskiattgmaildottcom> | 2013-07-08 16:02:38 +0000 |
|---|---|---|
| committer | Slagvi Public <JandotDarowskiattgmaildottcom> | 2013-07-08 16:02:38 +0000 |
| commit | cbdafaae927348aa8ef5396474535571fe989bf8 (patch) | |
| tree | f6043cb991d9b848e8c073d8c9f9704d6de33df1 /src/ui | |
| parent | Added loading templates into NewFromTemplate dialog. (diff) | |
| download | inkscape-cbdafaae927348aa8ef5396474535571fe989bf8.tar.gz inkscape-cbdafaae927348aa8ef5396474535571fe989bf8.zip | |
Coding style improvements and display bug fixes
(bzr r12379.2.8)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/dialog/new-from-template.cpp | 15 | ||||
| -rw-r--r-- | src/ui/dialog/new-from-template.h | 10 | ||||
| -rw-r--r-- | src/ui/dialog/static-template-load-tab.cpp | 36 | ||||
| -rw-r--r-- | src/ui/dialog/static-template-load-tab.h | 10 | ||||
| -rw-r--r-- | src/ui/dialog/template-load-tab.cpp | 91 | ||||
| -rw-r--r-- | src/ui/dialog/template-load-tab.h | 26 |
6 files changed, 126 insertions, 62 deletions
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 <jan.darowski@gmail.com>, 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 <gtkmm/alignment.h> -#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 <jan.darowski@gmail.com>, 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 <jan.darowski@gmail.com>, 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 <gtkmm/alignment.h> @@ -5,7 +15,7 @@ #include <gtkmm/label.h> #include <iostream> -#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 <jan.darowski@gmail.com>, 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 <jan.darowski@gmail.com>, 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 <gtkmm/alignment.h> +#include <gtkmm/scrolledwindow.h> #include <iostream> -#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<Gtk::TreeSelection> 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<Gtk::TreeSelection> templateSelectionRef = _templates_view.get_selection(); + Glib::RefPtr<Gtk::TreeSelection> 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<Gtk::TreeSelection> 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<Glib::ustring, TemplateData>::iterator it = _templates.begin() ; it != _templates.end() ; ++it) { - Gtk::TreeModel::iterator iter = _templates_ref->append(); + for (std::map<Glib::ustring, TemplateData>::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 <jan.darowski@gmail.com>, 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<Glib::ustring, TemplateData> _templates; + std::map<Glib::ustring, TemplateData> _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<Gtk::ListStore> _templates_ref; - StringModelColumns _templates_columns; + Gtk::TreeView _tlist_view; + Glib::RefPtr<Gtk::ListStore> _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 &); }; |
