diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/templates/main.cpp | 6 | ||||
| -rw-r--r-- | src/templates/new-from-template.cpp | 42 | ||||
| -rw-r--r-- | src/templates/new-from-template.h | 31 | ||||
| -rw-r--r-- | src/templates/newfromtemplate.cpp | 35 | ||||
| -rw-r--r-- | src/templates/newfromtemplate.h | 25 | ||||
| -rw-r--r-- | src/templates/static-template-load-tab.cpp | 47 | ||||
| -rw-r--r-- | src/templates/static-template-load-tab.h | 33 | ||||
| -rw-r--r-- | src/templates/statictemplateloadtab.cpp | 42 | ||||
| -rw-r--r-- | src/templates/statictemplateloadtab.h | 27 | ||||
| -rw-r--r-- | src/templates/template-load-tab.cpp | 107 | ||||
| -rw-r--r-- | src/templates/template-load-tab.h | 59 | ||||
| -rw-r--r-- | src/templates/templateloadtab.cpp | 101 | ||||
| -rw-r--r-- | src/templates/templateloadtab.h | 53 |
13 files changed, 323 insertions, 285 deletions
diff --git a/src/templates/main.cpp b/src/templates/main.cpp index 1ff93822c..d7a3f40a4 100644 --- a/src/templates/main.cpp +++ b/src/templates/main.cpp @@ -1,6 +1,8 @@ #include <gtkmm/main.h> -#include "newfromtemplate.h" +#include "new-from-template.h" + +using namespace Inkscape::UI; int main (int argc, char *argv[]) { @@ -11,4 +13,4 @@ int main (int argc, char *argv[]) //Gtk::Main::run(dialog); return 0; -}
\ No newline at end of file +} diff --git a/src/templates/new-from-template.cpp b/src/templates/new-from-template.cpp new file mode 100644 index 000000000..450337aea --- /dev/null +++ b/src/templates/new-from-template.cpp @@ -0,0 +1,42 @@ +#include "new-from-template.h" +#include "gtkmm/alignment.h" + +namespace Inkscape { +namespace UI { + + +NewFromTemplate::NewFromTemplate() : + _createButton("Create from template") +{ + set_title("New From Template"); + resize(400, 250); + + get_vbox()->pack_start(_mainWidget); + _mainWidget.append_page(_tab1, "Static Templates"); + _mainWidget.append_page(_tab2, "Procedural Templates"); + + Gtk::Alignment *align; + align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + get_vbox()->pack_end(*align, Gtk::PACK_SHRINK, 5); + align->add(_createButton); + + _createButton.signal_pressed().connect( + sigc::mem_fun(*this, &NewFromTemplate::_createFromTemplate)); + + show_all(); +} + + +void NewFromTemplate::_createFromTemplate() +{ + if ( _mainWidget.get_current_page() == 0 ) { + _tab1.createTemplate(); + } else { + _tab2.createTemplate(); + } + + response(0); +} + +} +} diff --git a/src/templates/new-from-template.h b/src/templates/new-from-template.h new file mode 100644 index 000000000..869680ae3 --- /dev/null +++ b/src/templates/new-from-template.h @@ -0,0 +1,31 @@ +#ifndef INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H +#define INKSCAPE_SEEN_UI_DIALOG_NEW_FROM_TEMPLATE_H + +#include <gtkmm/button.h> +#include <gtkmm/dialog.h> +#include <gtkmm/notebook.h> + +#include "template-load-tab.h" +#include "static-template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +class NewFromTemplate : public Gtk::Dialog +{ +public: + NewFromTemplate(); + +private: + Gtk::Notebook _mainWidget; + Gtk::Button _createButton; + StaticTemplateLoadTab _tab1; + TemplateLoadTab _tab2; + + void _createFromTemplate(); +}; + +} +} +#endif diff --git a/src/templates/newfromtemplate.cpp b/src/templates/newfromtemplate.cpp deleted file mode 100644 index 3a215889d..000000000 --- a/src/templates/newfromtemplate.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "newfromtemplate.h" -#include "gtkmm/alignment.h" - - -NewFromTemplate::NewFromTemplate() : - createButton("Create from template") -{ - set_title("New From Template"); - resize(400, 250); - - get_vbox()->pack_start(mainWidget); - mainWidget.append_page(tab1, "Static Templates"); - mainWidget.append_page(tab2, "Procedural Templates"); - - Gtk::Alignment *align; - align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); - get_vbox()->pack_end(*align, Gtk::PACK_SHRINK, 5); - align->add(createButton); - - createButton.signal_pressed().connect( - sigc::mem_fun(*this, &NewFromTemplate::createFromTemplate)); - - show_all(); -} - - -void NewFromTemplate::createFromTemplate() -{ - if (mainWidget.get_current_page() == 0) - tab1.createTemplate(); - else - tab2.createTemplate(); - - response(0); -}
\ No newline at end of file diff --git a/src/templates/newfromtemplate.h b/src/templates/newfromtemplate.h deleted file mode 100644 index 1a6ce555d..000000000 --- a/src/templates/newfromtemplate.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef GTKMM_NEW_FROM_TEMPLATE_H -#define GTKMM_TNEW_FROM_TEMPLATE_H - -#include <gtkmm/button.h> -#include <gtkmm/dialog.h> -#include <gtkmm/notebook.h> - -#include "templateloadtab.h" -#include "statictemplateloadtab.h" - - -class NewFromTemplate : public Gtk::Dialog -{ -public: - NewFromTemplate(); - -private: - Gtk::Notebook mainWidget; - Gtk::Button createButton; - StaticTemplateLoadTab tab1; - TemplateLoadTab tab2; - - void createFromTemplate(); -}; -#endif
\ No newline at end of file diff --git a/src/templates/static-template-load-tab.cpp b/src/templates/static-template-load-tab.cpp new file mode 100644 index 000000000..e71b9dede --- /dev/null +++ b/src/templates/static-template-load-tab.cpp @@ -0,0 +1,47 @@ +#include <gtkmm/alignment.h> +#include <gtkmm/button.h> +#include <gtkmm/label.h> +#include <iostream> + +#include "static-template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +StaticTemplateLoadTab::StaticTemplateLoadTab() : + _moreInfoButton("More info"), + _previewImage("preview.png"), + _shortDescriptionLabel("Short description - I like trains. ad asda asd asdweqe gdfg"), + _templateNameLabel("Template_name"), + _templateAuthorLabel("by template_author") +{ + _templateInfoColumn.pack_start(_templateNameLabel, Gtk::PACK_SHRINK, 4); + _templateInfoColumn.pack_start(_templateAuthorLabel, Gtk::PACK_SHRINK, 0); + _templateInfoColumn.pack_start(_previewImage, Gtk::PACK_SHRINK, 15); + _templateInfoColumn.pack_start(_shortDescriptionLabel, Gtk::PACK_SHRINK, 4); + + _shortDescriptionLabel.set_line_wrap(true); + _shortDescriptionLabel.set_size_request(200); + + Gtk::Alignment *align; + align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); + _templateInfoColumn.pack_start(*align, Gtk::PACK_SHRINK, 5); + align->add(_moreInfoButton); +} + + +void StaticTemplateLoadTab::createTemplate() +{ + std::cout << "Static template\n"; +} + + +void StaticTemplateLoadTab::_displayTemplateInfo() +{ + TemplateLoadTab::_displayTemplateInfo(); + _templateNameLabel.set_text(_currentTemplate); +} + +} +} diff --git a/src/templates/static-template-load-tab.h b/src/templates/static-template-load-tab.h new file mode 100644 index 000000000..e6ed17f4c --- /dev/null +++ b/src/templates/static-template-load-tab.h @@ -0,0 +1,33 @@ +#ifndef INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H +#define INKSCAPE_SEEN_UI_DIALOG_STATIC_TEMPLATE_LOAD_TAB_H + +#include <gtkmm/label.h> +#include <gtkmm/button.h> +#include <gtkmm/image.h> + +#include "template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +class StaticTemplateLoadTab : public TemplateLoadTab +{ +public: + StaticTemplateLoadTab(); + virtual void createTemplate(); + +protected: + virtual void _displayTemplateInfo(); + + Gtk::Button _moreInfoButton; + Gtk::Label _shortDescriptionLabel; + Gtk::Label _templateAuthorLabel; + Gtk::Label _templateNameLabel; + Gtk::Image _previewImage; +}; + +} +} + +#endif diff --git a/src/templates/statictemplateloadtab.cpp b/src/templates/statictemplateloadtab.cpp deleted file mode 100644 index b82338f16..000000000 --- a/src/templates/statictemplateloadtab.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include <gtkmm/alignment.h> -#include <gtkmm/button.h> -#include <gtkmm/label.h> -#include <iostream> - -#include "statictemplateloadtab.h" - - -StaticTemplateLoadTab::StaticTemplateLoadTab() : - moreInfoButton("More info"), - previewImage("preview.png"), - shortDescriptionLabel("Short description - I like trains. ad asda asd asdweqe gdfg"), - templateNameLabel("Template_name"), - templateAuthorLabel("by template_author") -{ - templateInfoColumn.pack_start(templateNameLabel, Gtk::PACK_SHRINK, 4); - templateInfoColumn.pack_start(templateAuthorLabel, Gtk::PACK_SHRINK, 0); - templateInfoColumn.pack_start(previewImage, Gtk::PACK_SHRINK, 15); - templateInfoColumn.pack_start(shortDescriptionLabel, Gtk::PACK_SHRINK, 4); - - shortDescriptionLabel.set_line_wrap(true); - shortDescriptionLabel.set_size_request(200); - - Gtk::Alignment *align; - align = manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); - templateInfoColumn.pack_start(*align, Gtk::PACK_SHRINK, 5); - align->add(moreInfoButton); -} - - -void StaticTemplateLoadTab::createTemplate() -{ - std::cout << "Static template\n"; -} - - -void StaticTemplateLoadTab::displayTemplateInfo() -{ - TemplateLoadTab::displayTemplateInfo(); - templateNameLabel.set_text(currentTemplate); -} - diff --git a/src/templates/statictemplateloadtab.h b/src/templates/statictemplateloadtab.h deleted file mode 100644 index 43d640b85..000000000 --- a/src/templates/statictemplateloadtab.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef GTKMM_STATIC_TEMPLATE_LOAD_TAB_H -#define GTKMM_STATIC_TEMPLATE_LOAD_TAB_H - -#include <gtkmm/label.h> -#include <gtkmm/button.h> -#include <gtkmm/image.h> - -#include "templateloadtab.h" - - -class StaticTemplateLoadTab : public TemplateLoadTab -{ -public: - StaticTemplateLoadTab(); - virtual void createTemplate(); - -protected: - virtual void displayTemplateInfo(); - - Gtk::Button moreInfoButton; - Gtk::Label shortDescriptionLabel; - Gtk::Label templateAuthorLabel; - Gtk::Label templateNameLabel; - Gtk::Image previewImage; -}; - -#endif
\ No newline at end of file diff --git a/src/templates/template-load-tab.cpp b/src/templates/template-load-tab.cpp new file mode 100644 index 000000000..d5fcd18ca --- /dev/null +++ b/src/templates/template-load-tab.cpp @@ -0,0 +1,107 @@ +#include <gtkmm/alignment.h> +#include <iostream> + +#include "template-load-tab.h" + +namespace Inkscape { +namespace UI { + + +TemplateLoadTab::TemplateLoadTab() +{ + set_border_width(10); + + Gtk::Label *title; + title = manage(new Gtk::Label("Search Tags:")); + _templatesColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); + + _templatesColumn.pack_start(_keywordsCombo, Gtk::PACK_SHRINK, 0); + + title = manage(new Gtk::Label("Templates")); + _templatesColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); + + title = manage(new Gtk::Label("Selected template")); + _templateInfoColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); + + _initLists(); + + add(_mainBox); + _mainBox.pack_start(_templatesColumn, Gtk::PACK_SHRINK, 20); + _mainBox.pack_start(_templateInfoColumn, Gtk::PACK_EXPAND_WIDGET, 10); + + _templatesColumn.pack_start(_templatesView, Gtk::PACK_SHRINK, 5); + + Glib::RefPtr<Gtk::TreeSelection> templateSelectionRef = + _templatesView.get_selection(); + + templateSelectionRef->signal_changed().connect( + sigc::mem_fun(*this, &TemplateLoadTab::_displayTemplateInfo)); + + _keywordsCombo.signal_changed().connect( + sigc::mem_fun(*this, &TemplateLoadTab::_keywordSelected)); + this->show_all(); +} + + +TemplateLoadTab::~TemplateLoadTab() +{ +} + + +void TemplateLoadTab::createTemplate() +{ + std::cout << "Default Template Tab" << std::endl; +} + + +void TemplateLoadTab::_displayTemplateInfo() +{ + Glib::RefPtr<Gtk::TreeSelection> templateSelectionRef = _templatesView.get_selection(); + if (templateSelectionRef->get_selected()) { + _currentTemplate = (*templateSelectionRef->get_selected())[_templatesColumns.textValue]; + } +} + + +void TemplateLoadTab::_initKeywordsList() +{ + _keywordsCombo.append_text("All"); + _keywordsCombo.set_active_text("All"); + + for (int i = 0 ; i < 10 ; ++i) { + _keywordsCombo.append_text( "Keyword" + Glib::ustring::format(i)); + } +} + + +void TemplateLoadTab::_initLists() +{ + _templatesRef = Gtk::ListStore::create(_templatesColumns); + _templatesView.set_model(_templatesRef); + _templatesView.append_column("", _templatesColumns.textValue); + _templatesView.set_headers_visible(false); + + _initKeywordsList(); + _refreshTemplatesList(); +} + + +void TemplateLoadTab::_keywordSelected() +{ + _currentKeyword = _keywordsCombo.get_active_text(); + _refreshTemplatesList(); +} + + +void TemplateLoadTab::_refreshTemplatesList() +{ + _templatesRef->clear(); + for (int i = 0 ; i < 7 ; ++i) { + Gtk::TreeModel::iterator iter = _templatesRef->append(); + Gtk::TreeModel::Row row = *iter; + row[_templatesColumns.textValue] = "Template" + Glib::ustring::format(i); + } +} + +} +} diff --git a/src/templates/template-load-tab.h b/src/templates/template-load-tab.h new file mode 100644 index 000000000..bb55b384c --- /dev/null +++ b/src/templates/template-load-tab.h @@ -0,0 +1,59 @@ +#ifndef INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_LOAD_TAB_H +#define INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_LOAD_TAB_H + +#include <gtkmm/box.h> +#include <gtkmm/comboboxtext.h> +#include <gtkmm/frame.h> +#include <gtkmm/liststore.h> +#include <gtkmm/treeview.h> + +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<Glib::ustring> textValue; + }; + + Glib::ustring _currentKeyword; + Glib::ustring _currentTemplate; + + virtual void _displayTemplateInfo(); + virtual void _initKeywordsList(); + virtual void _refreshTemplatesList(); + + void _initLists(); + void _keywordSelected(); + + Gtk::HBox _mainBox; + Gtk::VBox _templatesColumn; + Gtk::VBox _templateInfoColumn; + + Gtk::ComboBoxText _keywordsCombo; + + Gtk::TreeView _templatesView; + Glib::RefPtr<Gtk::ListStore> _templatesRef; + StringModelColumns _templatesColumns; + +}; + +} +} + +#endif diff --git a/src/templates/templateloadtab.cpp b/src/templates/templateloadtab.cpp deleted file mode 100644 index 734ac3eec..000000000 --- a/src/templates/templateloadtab.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include <gtkmm/alignment.h> -#include <iostream> - -#include "templateloadtab.h" - - -TemplateLoadTab::TemplateLoadTab() -{ - set_border_width(10); - - Gtk::Label *title; - title = manage(new Gtk::Label("Search Tags:")); - templatesColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); - - templatesColumn.pack_start(keywordsCombo, Gtk::PACK_SHRINK, 0); - - title = manage(new Gtk::Label("Templates")); - templatesColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); - - title = manage(new Gtk::Label("Selected template")); - templateInfoColumn.pack_start(*title, Gtk::PACK_SHRINK, 10); - - initLists(); - - add(mainBox); - mainBox.pack_start(templatesColumn, Gtk::PACK_SHRINK, 20); - mainBox.pack_start(templateInfoColumn, Gtk::PACK_EXPAND_WIDGET, 10); - - templatesColumn.pack_start(templatesView, Gtk::PACK_SHRINK, 5); - - Glib::RefPtr<Gtk::TreeSelection> templateSelectionRef = - templatesView.get_selection(); - - templateSelectionRef->signal_changed().connect( - sigc::mem_fun(*this, &TemplateLoadTab::displayTemplateInfo)); - - keywordsCombo.signal_changed().connect( - sigc::mem_fun(*this, &TemplateLoadTab::keywordSelected)); - this->show_all(); -} - - -TemplateLoadTab::~TemplateLoadTab() -{ -} - - -void TemplateLoadTab::createTemplate() -{ - std::cout << "Default Template Tab" << std::endl; -} - - -void TemplateLoadTab::displayTemplateInfo() -{ - Glib::RefPtr<Gtk::TreeSelection> templateSelectionRef = templatesView.get_selection(); - if (templateSelectionRef->get_selected()) - currentTemplate = (*templateSelectionRef->get_selected())[templatesColumns.textValue]; -} - - -void TemplateLoadTab::initKeywordsList() -{ - keywordsCombo.append_text("All"); - keywordsCombo.set_active_text("All"); - - for (int i=0; i<10; ++i){ - - keywordsCombo.append_text( "Keyword" + Glib::ustring::format(i)); - } -} - - -void TemplateLoadTab::initLists() -{ - templatesRef = Gtk::ListStore::create(templatesColumns); - templatesView.set_model(templatesRef); - templatesView.append_column("", templatesColumns.textValue); - templatesView.set_headers_visible(false); - - initKeywordsList(); - refreshTemplatesList(); -} - - -void TemplateLoadTab::keywordSelected() -{ - currentKeyword = keywordsCombo.get_active_text(); - refreshTemplatesList(); -} - - -void TemplateLoadTab::refreshTemplatesList() -{ - templatesRef->clear(); - for (int i=0; i<7; ++i){ - Gtk::TreeModel::iterator iter = templatesRef->append(); - Gtk::TreeModel::Row row = *iter; - row[templatesColumns.textValue] = "Template" + Glib::ustring::format(i); - } -}
\ No newline at end of file diff --git a/src/templates/templateloadtab.h b/src/templates/templateloadtab.h deleted file mode 100644 index 3947e25fb..000000000 --- a/src/templates/templateloadtab.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef GTKMM_TEMPLATE_LOAD_TAB_H -#define GTKMM_TEMPLATE_LOAD_TAB_H - -#include <gtkmm/box.h> -#include <gtkmm/comboboxtext.h> -#include <gtkmm/frame.h> -#include <gtkmm/liststore.h> -#include <gtkmm/treeview.h> - - -class TemplateLoadTab : public Gtk::Frame -{ - -public: - TemplateLoadTab(); - virtual ~TemplateLoadTab(); - virtual void createTemplate(); - -protected: - class StringModelColumns : public Gtk::TreeModelColumnRecord - { - public: - StringModelColumns() - { - add(textValue); - } - - Gtk::TreeModelColumn<Glib::ustring> textValue; - }; - - Glib::ustring currentKeyword; - Glib::ustring currentTemplate; - - virtual void displayTemplateInfo(); - virtual void initKeywordsList(); - virtual void refreshTemplatesList(); - - void initLists(); - void keywordSelected(); - - Gtk::HBox mainBox; - Gtk::VBox templatesColumn; - Gtk::VBox templateInfoColumn; - - Gtk::ComboBoxText keywordsCombo; - - Gtk::TreeView templatesView; - Glib::RefPtr<Gtk::ListStore> templatesRef; - StringModelColumns templatesColumns; - -}; - -#endif // GTKMM_TEMPLATE_LOAD_TAB_H
\ No newline at end of file |
