19#include <glibmm/miscutils.h>
20#include <glibmm/ustring.h>
47 _prefs[
"filename"] = filename;
48 _name = Glib::path_get_basename(filename);
49 std::replace(
_name.begin(),
_name.end(),
'_',
'-');
55 if (!strcmp(
root->name(),
"svg:svg")) {
68 std::replace(
_key.begin(),
_key.end(),
'/',
'.');
69 std::replace(
_key.begin(),
_key.end(),
'\\',
'.');
85 }
catch(std::exception &
err) {
86 g_warning(
"Template priority malformed number.");
105 g_error(
"Couldn't load filename I expected to exist.");
113 "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI
"\">"
114 "<id>org.inkscape.template.from-file</id>"
115 "<name>" N_(
"Load from User File")
"</name>"
116 "<description>" N_(
"Custom list of templates for a folder")
"</description>"
117 "<category>" NC_(
"TemplateCategory",
"Custom")
"</category>"
119 "<param name='filename' gui-text='" N_(
"Filename")
"' type='string'></param>"
120 "<template icon='custom' priority='-1' visibility='both'>"
123 "</inkscape-extension>",
124 std::make_unique<TemplateFromFile>());
133 if (filename.find(
"icons") != Glib::ustring::npos)
continue;
char const * get_param_string(char const *name, char const *alt) const
Like get_param_string but with a default on param_not_exist error.
std::unique_ptr< SPDocument > new_from_template(Inkscape::Extension::Template *tmod) override
void get_template_presets(const Template *tmod, TemplatePresets &presets) const override
Generate a list of available files as selectable presets.
TemplatePresetFile(Template *mod, std::string const &filename)
A file based template preset.
void _load_data(const Inkscape::XML::Node *root)
std::unique_ptr< SPDocument > get_template_document() const
Get the raw document svg for this template (pre-processing).
Interface for refcounted XML nodes.
virtual Node * root()=0
Get the root node of this node's document.
A way to clear the N_ macro, which is defined as an inline function.
Inkscape::Extension::Extension: Frontend to certain, possibly pluggable, actions.
std::unique_ptr< SPDocument > ink_file_new(std::string const &Template)
Create a blank document, remove any template data.
static void err(const char *fmt,...)
std::vector< std::shared_ptr< TemplatePreset > > TemplatePresets
void build_from_mem(gchar const *buffer, std::unique_ptr< Implementation::Implementation > in_imp)
Create a module from a buffer holding an XML description.
std::vector< std::string > get_filenames(Type type, std::vector< const char * > const &extensions, std::vector< const char * > const &exclusions)
bool file_test(char const *utf8name, GFileTest test)
Document * sp_repr_read_file(const gchar *filename, const gchar *default_ns, bool xinclude)
Reads XML from a file, and returns the Document.
Glib::ustring sp_repr_lookup_content(Inkscape::XML::Node const *repr, gchar const *name, Glib::ustring otherwise)
Inkscape::XML::Node const * sp_repr_lookup_name(Inkscape::XML::Node const *repr, gchar const *name, gint maxdepth)
C facade to Inkscape::XML::Node.
Inkscape::IO::Resource - simple resource API.
Interface for XML documents.
Interface for XML documents.