blob: ad87aac91366a7efa43b056551c4780839016ced (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
// SPDX-License-Identifier: GPL-2.0-or-later
/** @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 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 <gtkmm/box.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/frame.h>
#include <gtkmm/liststore.h>
#include <gtkmm/treeview.h>
#include <map>
#include <set>
#include <string>
#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<Glib::ustring> 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<Glib::ustring> textValue;
};
Glib::ustring _current_keyword;
Glib::ustring _current_template;
std::map<Glib::ustring, TemplateData> _tdata;
std::set<Glib::ustring> _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<Gtk::ListStore> _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
|