Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::Extension::Template Class Reference

#include <template.h>

Inheritance diagram for Inkscape::Extension::Template:
Inkscape::Extension::Extension

Classes

struct  create_cancelled
 

Public Member Functions

 Template (Inkscape::XML::Node *in_repr, ImplementationHolder implementation, std::string *base_directory)
 Builds a Template object from a XML description.
 
 ~Template () override=default
 
bool check () override
 Validate this extension.
 
std::unique_ptr< SPDocumentnew_from_template ()
 This function creates a document from a template.
 
void resize_to_template (SPDocument *doc, SPPage *page)
 Takes an existing page and resizes it to the required dimentions.
 
std::string get_icon () const
 
std::string get_description () const
 
std::string get_category () const
 
bool can_resize () const
 
int get_visibility () const
 
TemplatePresets get_presets (TemplateShow visibility=TEMPLATE_ANY) const
 Return a list of all template presets.
 
std::shared_ptr< TemplatePresetget_preset (const std::string &key)
 Return the template preset based on the key from this template class.
 
std::shared_ptr< TemplatePresetget_preset (double width, double height)
 Matches the given page against the given page.
 
Glib::RefPtr< Gio::File > get_template_filename () const
 Get the template filename, or return the default template.
 
std::unique_ptr< SPDocumentget_template_document () const
 Get the raw document svg for this template (pre-processing).
 
- Public Member Functions inherited from Inkscape::Extension::Extension
 Extension (Inkscape::XML::Node *in_repr, ImplementationHolder implementation, std::string *base_directory)
 Constructs an Extension from a Inkscape::XML::Node.
 
virtual ~Extension ()
 
void set_state (state_t in_state)
 A function to set whether the extension should be loaded or unloaded.
 
state_t get_state ()
 A getter for the state variable.
 
bool loaded ()
 A quick function to test the state of the extension.
 
virtual bool prefs ()
 Create a dialog for preference for this extension.
 
Inkscape::XML::Nodeget_repr ()
 A getter for the internal Repr, does not add a reference.
 
char const * get_id () const
 Get the ID of this extension - not a copy don't delete!
 
char const * get_name () const
 Get the name of this extension - not a copy don't delete!
 
virtual void deactivate ()
 This function diactivates the extension (which makes it unusable, but not deleted)
 
bool deactivated ()
 Find out the status of the extension.
 
void printFailure (Glib::ustring const &reason)
 A quick function to print out a standard start of extension errors in the log.
 
std::string const & getErrorReason ()
 
Implementation::Implementationget_imp ()
 
auto const & get_base_directory () const
 
void set_base_directory (std::string const &base_directory)
 
std::string get_dependency_location (char const *name)
 Gets the location of the dependency file as an absolute path.
 
char const * get_translation (char const *msgid, char const *msgctxt=nullptr) const
 Gets a translation within the context of the current extension.
 
void set_environment (SPDocument const *doc=nullptr)
 Sets environment suitable for executing this Extension.
 
ModuleImpType get_implementation_type ()
 Uses the object's type to figure out what the type is.
 
int get_sort_priority () const
 
void set_sort_priority (int priority)
 
virtual void run_processing_actions (SPDocument *doc)
 Runs any pre-processing actions and modifies the document.
 
unsigned int widget_visible_count () const
 A function to get the number of visible parameters of the extension.
 
bool get_param_bool (char const *name) const
 Gets a parameter identified by name with the bool placed in value.
 
bool get_param_bool (char const *name, bool alt) const
 Like get_param_bool but with a default on param_not_exist error.
 
int get_param_int (char const *name) const
 Gets a parameter identified by name with the integer placed in value.
 
int get_param_int (char const *name, int alt) const
 Like get_param_int but with a default on param_not_exist error.
 
double get_param_float (char const *name) const
 Gets a float parameter identified by name with the double placed in value.
 
double get_param_float (char const *name, double alt) const
 Like get_param_float but with a default on param_not_exist error.
 
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.
 
char const * get_param_string (char const *name) const
 Gets a parameter identified by name with the string placed in value.
 
char const * get_param_optiongroup (char const *name, char const *alt) const
 Like get_param_optiongroup but with a default on param_not_exist error.
 
char const * get_param_optiongroup (char const *name) const
 Gets a parameter identified by name with the string placed in value.
 
Colors::Color get_param_color (char const *name) const
 Gets a parameter identified by name with the unsigned int placed in value.
 
bool get_param_optiongroup_contains (char const *name, char const *value) const
 This is useful to find out, if a given string value is selectable in a optiongroup named \cname.
 
bool set_param_bool (char const *name, bool value)
 Sets a parameter identified by name with the boolean in the parameter value.
 
int set_param_int (char const *name, int value)
 Sets a parameter identified by name with the integer in the parameter value.
 
double set_param_float (char const *name, double value)
 Sets a parameter identified by name with the double in the parameter value.
 
char const * set_param_string (char const *name, char const *value)
 Sets a parameter identified by name with the string in the parameter value.
 
char const * set_param_optiongroup (char const *name, char const *value)
 Sets a parameter identified by name with the string in the parameter value.
 
void set_param_color (char const *name, Colors::Color const &color)
 
void set_param_any (char const *name, std::string const &value)
 Parses the given string value and sets a parameter identified by name.
 
void set_param_hidden (char const *name, bool hidden)
 
Gtk::Widget * autogui (SPDocument *doc, Inkscape::XML::Node *node, sigc::signal< void()> *changeSignal=nullptr)
 A function to automatically generate a GUI from the extensions' widgets.
 
void paramListString (std::list< std::string > &retlist) const
 A function to get the parameters in a string form.
 
void set_gui (bool s)
 
bool get_gui () const
 
Gtk::Box * get_info_widget ()
 
Gtk::Box * get_params_widget ()
 

Static Public Member Functions

static std::shared_ptr< TemplatePresetget_any_preset (const std::string &key)
 Return the template preset based on the key from any template class (static method).
 
static std::shared_ptr< TemplatePresetget_any_preset (double width, double height)
 Return the template preset based on the key from any template class (static method).
 
- Static Public Member Functions inherited from Inkscape::Extension::Extension
static void error_file_open ()
 A function to open the error log file.
 
static void error_file_close ()
 A function to close the error log file.
 
static void error_file_write (Glib::ustring const &text)
 A function to write to the error log file.
 

Static Protected Member Functions

static int parse_visibility (const std::string &value)
 Parse the expected value for the visibility value, turn into enum.
 
- Static Protected Member Functions inherited from Inkscape::Extension::Extension
static void add_val (Glib::ustring const &labelstr, Glib::ustring const &valuestr, Gtk::Grid *table, int *row)
 

Private Attributes

std::string _source
 
std::string _icon
 
std::string _desc
 
std::string _category
 
bool _can_resize = false
 
int _visibility = TEMPLATE_SIZE_SEARCH
 
TemplatePresets _presets
 

Friends

class TemplatePreset
 

Additional Inherited Members

- Public Types inherited from Inkscape::Extension::Extension
enum  state_t { STATE_LOADED , STATE_UNLOADED , STATE_DEACTIVATED }
 An enumeration to identify if the Extension has been loaded or not. More...
 
using ImplementationHolder = Util::HybridPointer< Implementation::Implementation >
 
- Protected Attributes inherited from Inkscape::Extension::Extension
Inkscape::XML::Noderepr
 The XML description of the Extension.
 
ImplementationHolder imp
 An Implementation object provides the actual implementation of the Extension.
 
std::string _base_directory
 Directory containing the .inx file, relative paths in the extension should usually be relative to it.
 
std::unique_ptr< ExpirationTimertimer
 Timeout to unload after a given time.
 
bool _translation_enabled = true
 Attempt translation of strings provided by the extension?
 

Detailed Description

Definition at line 96 of file template.h.

Constructor & Destructor Documentation

◆ Template()

◆ ~Template()

Inkscape::Extension::Template::~Template ( )
overridedefault

Member Function Documentation

◆ can_resize()

bool Inkscape::Extension::Template::can_resize ( ) const
inline

Definition at line 117 of file template.h.

References _can_resize.

Referenced by Inkscape::Extension::TemplatePreset::resize_to_template().

◆ check()

bool Inkscape::Extension::Template::check ( )
overridevirtual

Validate this extension.

Returns
Whether this extension checks out

This function checks to make sure that the template extension has a filename extension and a MIME type. Then it calls the parent class' check function which also checks out the implementation.

Reimplemented from Inkscape::Extension::Extension.

Definition at line 260 of file template.cpp.

References _category, and Inkscape::Extension::Extension::check().

◆ get_any_preset() [1/2]

std::shared_ptr< TemplatePreset > Inkscape::Extension::Template::get_any_preset ( const std::string &  key)
static

Return the template preset based on the key from any template class (static method).

Definition at line 352 of file template.cpp.

References Inkscape::Extension::db, Inkscape::Extension::DB::get_template_list(), and key.

Referenced by Inkscape::UI::Widget::TemplateList::get_selected_preset(), Inkscape::PageManager::getSizeLabel(), and Inkscape::UI::Toolbar::PageToolbar::sizeChoose().

◆ get_any_preset() [2/2]

std::shared_ptr< TemplatePreset > Inkscape::Extension::Template::get_any_preset ( double  width,
double  height 
)
static

Return the template preset based on the key from any template class (static method).

Definition at line 367 of file template.cpp.

References Inkscape::Extension::db, Inkscape::Extension::DB::get_template_list(), height, and width.

◆ get_category()

std::string Inkscape::Extension::Template::get_category ( ) const
inline

Definition at line 115 of file template.h.

References _category.

◆ get_description()

std::string Inkscape::Extension::Template::get_description ( ) const
inline

Definition at line 114 of file template.h.

References _desc.

◆ get_icon()

std::string Inkscape::Extension::Template::get_icon ( ) const
inline

Definition at line 113 of file template.h.

References _icon.

◆ get_preset() [1/2]

std::shared_ptr< TemplatePreset > Inkscape::Extension::Template::get_preset ( const std::string &  key)

Return the template preset based on the key from this template class.

Definition at line 326 of file template.cpp.

References get_presets(), and key.

◆ get_preset() [2/2]

std::shared_ptr< TemplatePreset > Inkscape::Extension::Template::get_preset ( double  width,
double  height 
)

Matches the given page against the given page.

Definition at line 339 of file template.cpp.

References get_presets(), height, and width.

◆ get_presets()

TemplatePresets Inkscape::Extension::Template::get_presets ( TemplateShow  visibility = TEMPLATE_ANY) const

Return a list of all template presets.

Definition at line 309 of file template.cpp.

References _presets, and Inkscape::Extension::Extension::imp.

Referenced by get_preset(), and get_preset().

◆ get_template_document()

std::unique_ptr< SPDocument > Inkscape::Extension::Template::get_template_document ( ) const

Get the raw document svg for this template (pre-processing).

Definition at line 407 of file template.cpp.

References get_template_filename(), and ink_file_new().

Referenced by Inkscape::Extension::Internal::TemplateBase::new_from_template(), and Inkscape::Extension::Internal::TemplateFromFile::new_from_template().

◆ get_template_filename()

Glib::RefPtr< Gio::File > Inkscape::Extension::Template::get_template_filename ( ) const

Get the template filename, or return the default template.

Definition at line 384 of file template.cpp.

References _source, Inkscape::IO::Resource::get_filename(), and Inkscape::IO::Resource::TEMPLATES.

Referenced by get_template_document(), and Inkscape::Extension::Implementation::Script::new_from_template().

◆ get_visibility()

int Inkscape::Extension::Template::get_visibility ( ) const
inline

Definition at line 118 of file template.h.

References _visibility.

◆ new_from_template()

std::unique_ptr< SPDocument > Inkscape::Extension::Template::new_from_template ( )

This function creates a document from a template.

Returns
A new document

This function acts as the first step in creating a new document.

Definition at line 274 of file template.cpp.

References Inkscape::DocumentUndo::clearUndo(), Inkscape::Extension::Extension::imp, Inkscape::Extension::Extension::loaded(), Inkscape::Extension::Extension::set_state(), and Inkscape::Extension::Extension::STATE_LOADED.

Referenced by Inkscape::Extension::TemplatePreset::new_from_template().

◆ parse_visibility()

int Inkscape::Extension::Template::parse_visibility ( const std::string &  value)
staticprotected

Parse the expected value for the visibility value, turn into enum.

Definition at line 239 of file template.cpp.

References Inkscape::Extension::TEMPLATE_ALL, Inkscape::Extension::TEMPLATE_NEW_ICON, Inkscape::Extension::TEMPLATE_SIZE_LIST, and Inkscape::Extension::TEMPLATE_SIZE_SEARCH.

Referenced by Template().

◆ resize_to_template()

void Inkscape::Extension::Template::resize_to_template ( SPDocument doc,
SPPage page 
)

Takes an existing page and resizes it to the required dimentions.

Parameters
doc- The active document to change
page- The select page to resize, or nullptr if not multipage.

Definition at line 295 of file template.cpp.

References Inkscape::Extension::Extension::imp, Inkscape::Extension::Extension::loaded(), page, Inkscape::Extension::Extension::set_state(), and Inkscape::Extension::Extension::STATE_LOADED.

Referenced by Inkscape::Extension::TemplatePreset::resize_to_template().

Friends And Related Symbol Documentation

◆ TemplatePreset

friend class TemplatePreset
friend

Definition at line 131 of file template.h.

Referenced by Template().

Member Data Documentation

◆ _can_resize

bool Inkscape::Extension::Template::_can_resize = false
private

Definition at line 140 of file template.h.

Referenced by can_resize(), and Template().

◆ _category

std::string Inkscape::Extension::Template::_category
private

Definition at line 138 of file template.h.

Referenced by check(), get_category(), and Template().

◆ _desc

std::string Inkscape::Extension::Template::_desc
private

Definition at line 137 of file template.h.

Referenced by get_description(), and Template().

◆ _icon

std::string Inkscape::Extension::Template::_icon
private

Definition at line 136 of file template.h.

Referenced by get_icon(), and Template().

◆ _presets

TemplatePresets Inkscape::Extension::Template::_presets
private

Definition at line 143 of file template.h.

Referenced by get_presets(), and Template().

◆ _source

std::string Inkscape::Extension::Template::_source
private

Definition at line 135 of file template.h.

Referenced by get_template_filename(), and Template().

◆ _visibility

int Inkscape::Extension::Template::_visibility = TEMPLATE_SIZE_SEARCH
private

Definition at line 141 of file template.h.

Referenced by get_visibility(), and Template().


The documentation for this class was generated from the following files: