Inkscape
Vector Graphics Editor
|
#include <template.h>
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< SPDocument > | new_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< TemplatePreset > | get_preset (const std::string &key) |
Return the template preset based on the key from this template class. | |
std::shared_ptr< TemplatePreset > | get_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< SPDocument > | get_template_document () const |
Get the raw document svg for this template (pre-processing). | |
![]() | |
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::Node * | get_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::Implementation * | get_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< TemplatePreset > | get_any_preset (const std::string &key) |
Return the template preset based on the key from any template class (static method). | |
static std::shared_ptr< TemplatePreset > | get_any_preset (double width, double height) |
Return the template preset based on the key from any template class (static method). | |
![]() | |
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 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 | |
![]() | |
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 > |
![]() | |
Inkscape::XML::Node * | repr |
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< ExpirationTimer > | timer |
Timeout to unload after a given time. | |
bool | _translation_enabled = true |
Attempt translation of strings provided by the extension? | |
Definition at line 96 of file template.h.
Inkscape::Extension::Template::Template | ( | Inkscape::XML::Node * | in_repr, |
ImplementationHolder | implementation, | ||
std::string * | base_directory | ||
) |
Builds a Template object from a XML description.
in_repr | The XML description in a Inkscape::XML::Node tree |
implementation | The implementation of the extension |
Definition at line 186 of file template.cpp.
References _can_resize, _category, _desc, _icon, _presets, _source, _visibility, Inkscape::Extension::Extension::get_sort_priority(), name, parse_visibility(), Inkscape::Extension::Extension::prefs(), Inkscape::Extension::Extension::repr, Inkscape::Extension::Extension::set_sort_priority(), sp_repr_lookup_content(), sp_repr_lookup_name(), sp_repr_lookup_name_many(), Inkscape::Extension::TEMPLATE_SIZE_LIST, Inkscape::Extension::TEMPLATE_SIZE_SEARCH, and TemplatePreset.
|
overridedefault |
|
inline |
Definition at line 117 of file template.h.
References _can_resize.
Referenced by Inkscape::Extension::TemplatePreset::resize_to_template().
|
overridevirtual |
Validate this extension.
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().
|
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().
|
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.
|
inline |
Definition at line 115 of file template.h.
References _category.
|
inline |
Definition at line 114 of file template.h.
References _desc.
|
inline |
Definition at line 113 of file template.h.
References _icon.
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.
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.
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().
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().
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().
|
inline |
Definition at line 118 of file template.h.
References _visibility.
std::unique_ptr< SPDocument > Inkscape::Extension::Template::new_from_template | ( | ) |
This function creates a document from a template.
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().
|
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().
void Inkscape::Extension::Template::resize_to_template | ( | SPDocument * | doc, |
SPPage * | page | ||
) |
Takes an existing page and resizes it to the required dimentions.
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().
|
friend |
Definition at line 131 of file template.h.
Referenced by Template().
|
private |
Definition at line 140 of file template.h.
Referenced by can_resize(), and Template().
|
private |
Definition at line 138 of file template.h.
Referenced by check(), get_category(), and Template().
|
private |
Definition at line 137 of file template.h.
Referenced by get_description(), and Template().
|
private |
Definition at line 136 of file template.h.
Referenced by get_icon(), and Template().
|
private |
Definition at line 143 of file template.h.
Referenced by get_presets(), and Template().
|
private |
Definition at line 135 of file template.h.
Referenced by get_template_filename(), and Template().
|
private |
Definition at line 141 of file template.h.
Referenced by get_visibility(), and Template().