summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Lebras <christophe.lebras@gmail.com>2017-07-01 14:28:24 +0000
committerChristophe Lebras <christophe.lebras@gmail.com>2017-07-02 03:11:49 +0000
commitaf269da07f7d7b60c30abfe4f78610f752c27dbb (patch)
treecd3c2227db638f7d5dec5ccb8ad9ffd190a6e9cc /src
parentAdd new verb "save template" (diff)
downloadinkscape-af269da07f7d7b60c30abfe4f78610f752c27dbb.tar.gz
inkscape-af269da07f7d7b60c30abfe4f78610f752c27dbb.zip
Add Save Template Dialog
This add just dialog widget only, don't save template yet.
Diffstat (limited to 'src')
-rw-r--r--src/ui/CMakeLists.txt2
-rw-r--r--src/ui/dialog/save-template-dialog.cpp105
-rw-r--r--src/ui/dialog/save-template-dialog.h51
3 files changed, 158 insertions, 0 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index b6b88e50b..789378e0c 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -115,6 +115,7 @@ set(ui_SRC
dialog/transformation.cpp
dialog/undo-history.cpp
dialog/xml-tree.cpp
+ dialog/save-template-dialog.cpp
widget/addtoicon.cpp
widget/anchor-selector.cpp
@@ -262,6 +263,7 @@ set(ui_SRC
dialog/transformation.h
dialog/undo-history.h
dialog/xml-tree.h
+ dialog/save-template-dialog.h
tool/commit-events.h
tool/control-point-selection.h
diff --git a/src/ui/dialog/save-template-dialog.cpp b/src/ui/dialog/save-template-dialog.cpp
new file mode 100644
index 000000000..a351a9cfa
--- /dev/null
+++ b/src/ui/dialog/save-template-dialog.cpp
@@ -0,0 +1,105 @@
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "save-template-dialog.h"
+#include "file.h"
+
+#include <glibmm/i18n.h>
+
+#include <iostream>
+
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+//TODO: Tooltips
+ //TODO: Save data
+
+SaveTemplate::SaveTemplate() :
+ Gtk::Dialog(_("Save Document as Template")),
+ name_label(_("Name: "), Gtk::ALIGN_START),
+ author_label(_("Author: "), Gtk::ALIGN_START),
+ description_label(_("Description: "), Gtk::ALIGN_START),
+ keywords_label(_("Keywords: "), Gtk::ALIGN_START),
+ is_default_template("Set as default template")
+{
+ resize(400, 200);
+
+ name_text.set_hexpand(true);
+
+ grid.attach(name_label, 0, 0, 1, 1);
+ grid.attach(name_text, 1, 0, 1, 1);
+
+ grid.attach(author_label, 0, 1, 1, 1);
+ grid.attach(author_text, 1, 1, 1, 1);
+
+ grid.attach(description_label, 0, 2, 1, 1);
+ grid.attach(description_text, 1, 2, 1, 1);
+
+ grid.attach(keywords_label, 0, 3, 1, 1);
+ grid.attach(keywords_text, 1, 3, 1, 1);
+
+ auto content_area = get_content_area();
+
+ content_area->set_spacing(5);
+
+ content_area->add(grid);
+ content_area->add(is_default_template);
+
+ name_text.signal_changed().connect( sigc::mem_fun(*this,
+ &SaveTemplate::on_name_changed) );
+
+ add_button("Cancel", Gtk::RESPONSE_CANCEL);
+ add_button("Save", Gtk::RESPONSE_OK);
+
+ set_response_sensitive(Gtk::RESPONSE_OK, false);
+ set_default_response(Gtk::RESPONSE_CANCEL);
+
+ show_all();
+}
+
+void SaveTemplate::on_name_changed() {
+
+ if (name_text.get_text_length() == 0) {
+
+ set_response_sensitive(Gtk::RESPONSE_OK, false);
+ } else {
+
+ set_response_sensitive(Gtk::RESPONSE_OK, true);
+ }
+}
+
+void SaveTemplate::save_template() {
+
+ std::cout
+ << "Save template: "
+ << name_text.get_text() << " "
+ << author_text.get_text() << " "
+ << description_text.get_text() << " "
+ << keywords_text.get_text() << " "
+ << is_default_template.get_active() << std::endl;
+}
+
+void SaveTemplate::save_document_as_template() {
+
+ SaveTemplate dialog;
+
+ auto result = dialog.run();
+
+ switch (result) {
+
+ case Gtk::RESPONSE_OK:
+
+ dialog.save_template();
+ break;
+
+ default:
+ break;
+ }
+
+}
+
+}
+}
+}
diff --git a/src/ui/dialog/save-template-dialog.h b/src/ui/dialog/save-template-dialog.h
new file mode 100644
index 000000000..eba786e96
--- /dev/null
+++ b/src/ui/dialog/save-template-dialog.h
@@ -0,0 +1,51 @@
+#ifndef INKSCAPE_SEEN_UI_DIALOG_SAVE_TEMPLATE_H
+#define INKSCAPE_SEEN_UI_DIALOG_SAVE_TEMPLATE_H
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+#include <gtkmm/box.h>
+#include <gtkmm/grid.h>
+#include <gtkmm/label.h>
+#include <gtkmm/checkbutton.h>
+
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+class SaveTemplate : public Gtk::Dialog
+{
+
+public:
+
+ static void save_document_as_template();
+
+protected:
+
+ void on_name_changed();
+
+private:
+
+ Gtk::Grid grid;
+
+ Gtk::Label name_label;
+ Gtk::Entry name_text;
+
+ Gtk::Label author_label;
+ Gtk::Entry author_text;
+
+ Gtk::Label description_label;
+ Gtk::Entry description_text;
+
+ Gtk::Label keywords_label;
+ Gtk::Entry keywords_text;
+
+ Gtk::CheckButton is_default_template;
+
+ SaveTemplate();
+ void save_template();
+
+};
+}
+}
+}
+#endif