summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSlagvi Public <JandotDarowskiattgmaildottcom>2013-07-19 18:35:26 +0000
committerSlagvi Public <JandotDarowskiattgmaildottcom>2013-07-19 18:35:26 +0000
commit0fb0f1dd09f4c03a420dd8abf2089b81cd6d30d7 (patch)
tree73ec27229f1ee01078f4a950fa613fe6b6b092f7 /src
parentSearching by words in descriptions, titles etc. Translation support improved (diff)
downloadinkscape-0fb0f1dd09f4c03a420dd8abf2089b81cd6d30d7.tar.gz
inkscape-0fb0f1dd09f4c03a420dd8abf2089b81cd6d30d7.zip
New From Template ui rearrangement
(bzr r12379.2.11)
Diffstat (limited to 'src')
-rw-r--r--src/ui/dialog/Makefile_insert4
-rw-r--r--src/ui/dialog/new-from-template.cpp10
-rw-r--r--src/ui/dialog/new-from-template.h6
-rw-r--r--src/ui/dialog/static-template-load-tab.cpp80
-rw-r--r--src/ui/dialog/template-load-tab.cpp48
-rw-r--r--src/ui/dialog/template-load-tab.h20
-rw-r--r--src/ui/dialog/template-widget.cpp110
-rw-r--r--src/ui/dialog/template-widget.h (renamed from src/ui/dialog/static-template-load-tab.h)26
8 files changed, 160 insertions, 144 deletions
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 <gtkmm/notebook.h>
#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 <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>
-#include <gtkmm/button.h>
-#include <gtkmm/label.h>
-#include <iostream>
-
-#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/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 <gtk/gtk.h>
@@ -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<Gtk::TreeSelection> 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<Glib::ustring>::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<Glib::ustring> 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<Gtk::ListStore> _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 <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-widget.h"
+#include "template-load-tab.h"
+
+#include <gtkmm/alignment.h>
+#include <gtkmm/button.h>
+#include <gtkmm/label.h>
+#include <gtkmm/messagedialog.h>
+#include <iostream>
+
+#include "file.h"
+
+#include <glibmm/convert.h>
+#include <glibmm/i18n.h>
+#include <glibmm/miscutils.h>
+
+
+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<Glib::ustring>::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/static-template-load-tab.h b/src/ui/dialog/template-widget.h
index 9b19c495a..83024e0d8 100644
--- a/src/ui/dialog/static-template-load-tab.h
+++ b/src/ui/dialog/template-widget.h
@@ -1,5 +1,5 @@
/** @file
- * @brief New From Template static templates tab
+ * @brief New From Template - template widget
*/
/* Authors:
* Jan Darowski <jan.darowski@gmail.com>, supervised by Krzysztof Kosiński
@@ -8,34 +8,38 @@
* 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
+#ifndef INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_WIDGET_H
+#define INKSCAPE_SEEN_UI_DIALOG_TEMPLATE_WIDGET_H
#include "template-load-tab.h"
+#include <gtkmm/box.h>
-#include <gtkmm/label.h>
-#include <gtkmm/button.h>
-#include <gtkmm/image.h>
namespace Inkscape {
namespace UI {
+class TemplateLoadTab;
+
-class StaticTemplateLoadTab : public TemplateLoadTab
+class TemplateWidget : public Gtk::VBox
{
public:
- StaticTemplateLoadTab();
- virtual void createTemplate();
+ TemplateWidget ();
+ void create();
+ void display(TemplateLoadTab::TemplateData);
-protected:
- virtual void _displayTemplateInfo();
+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();
+
};
}