From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- src/ui/dialog/template-load-tab.h | 119 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 src/ui/dialog/template-load-tab.h (limited to 'src/ui/dialog/template-load-tab.h') diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h new file mode 100644 index 0000000..ad87aac --- /dev/null +++ b/src/ui/dialog/template-load-tab.h @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * @brief New From Template abstract tab class + */ +/* Authors: + * Jan Darowski , supervised by Krzysztof KosiƄski + * + * Copyright (C) 2013 Authors + * Released under GNU GPL v2+, 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xml/node.h" +#include "io/resource.h" +#include "extension/effect.h" + + +namespace Inkscape { + +namespace Extension { +class Extension; +} + +namespace UI { + +class TemplateWidget; +class NewFromTemplate; + +class TemplateLoadTab : public Gtk::Box +{ + +public: + struct TemplateData + { + bool is_procedural; + std::string path; + Glib::ustring display_name; + Glib::ustring author; + Glib::ustring short_description; + Glib::ustring long_description; // unused + Glib::ustring preview_name; + Glib::ustring creation_date; + std::set keywords; + Inkscape::Extension::Effect *tpl_effect; + }; + + TemplateLoadTab(NewFromTemplate* parent); + ~TemplateLoadTab() override; + virtual void createTemplate(); + +protected: + class StringModelColumns : public Gtk::TreeModelColumnRecord + { + public: + StringModelColumns() + { + add(textValue); + } + + Gtk::TreeModelColumn textValue; + }; + + Glib::ustring _current_keyword; + Glib::ustring _current_template; + std::map _tdata; + std::set _keywords; + + + virtual void _displayTemplateInfo(); + virtual void _initKeywordsList(); + virtual void _refreshTemplatesList(); + void _loadTemplates(); + void _initLists(); + + Gtk::Box _tlist_box; + Gtk::Box _search_box; + TemplateWidget *_info_widget; + + Gtk::ComboBoxText _keywords_combo; + + Gtk::TreeView _tlist_view; + Glib::RefPtr _tlist_store; + StringModelColumns _columns; + +private: + enum SearchType + { + LIST_KEYWORD, + USER_SPECIFIED, + ALL + }; + + SearchType _current_search_type; + NewFromTemplate* _parent_widget; + + void _getDataFromNode(Inkscape::XML::Node *, TemplateData &, Extension::Extension *extension=nullptr); + void _getProceduralTemplates(); + void _getTemplatesFromDomain(Inkscape::IO::Resource::Domain domain); + void _keywordSelected(); + TemplateData _processTemplateFile(const std::string &); + + void _onRowActivated(const Gtk::TreeModel::Path &, Gtk::TreeViewColumn*); +}; + +} +} + +#endif -- cgit v1.2.3