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

The object that is the basis for the Extension system. More...

#include <extension.h>

Inheritance diagram for Inkscape::Extension::Extension:
Inkscape::Extension::Effect Inkscape::Extension::Input Inkscape::Extension::Output Inkscape::Extension::PathEffect Inkscape::Extension::Print Inkscape::Extension::Template

Classes

class  extension_no_id
 no valid ID found while parsing XML representation More...
 
class  extension_no_name
 no valid name found while parsing XML representation More...
 
class  extension_not_compatible
 extension is not compatible with the current system and should not be loaded More...
 
class  no_implementation_for_extension
 No implementation could be loaded for the extension. More...
 
class  no_overwrite
 An error class for when a filename already exists, but the user doesn't want to overwrite it. More...
 
class  param_not_exist
 An error class for when a parameter is looked for that just simply doesn't exist. More...
 

Public Types

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 >
 

Public Member Functions

 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 check ()
 A function to check the validity 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 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 void add_val (Glib::ustring const &labelstr, Glib::ustring const &valuestr, Gtk::Grid *table, int *row)
 

Protected Attributes

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?
 

Private Member Functions

void lookup_translation_catalog ()
 Searches for a gettext catalog matching the extension's translationdomain.
 
void make_param (Inkscape::XML::Node *paramrepr)
 
InxParameterget_param (char const *name)
 Looks up the parameter with the specified name.
 
InxParameter const * get_param (char const *name) const
 Looks up the parameter with the specified name.
 

Private Attributes

std::string _id
 The unique identifier for the Extension.
 
std::string _name
 A user friendly name for the Extension.
 
state_t _state = STATE_UNLOADED
 Which state the Extension is currently in.
 
int _priority = 0
 when sorted, should this come before any others
 
std::vector< std::unique_ptr< Dependency > > _deps
 Dependencies for this extension.
 
std::string _error_reason
 Short, textual explanation for the latest error.
 
bool _gui = true
 
std::vector< ProcessingAction_actions
 Processing actions.
 
char const * _translationdomain = nullptr
 Domainname of gettext textdomain that should be used for translation of the extension's strings.
 
std::string _gettext_catalog_dir
 Directory containing the gettext catalog for _translationdomain.
 
std::vector< std::unique_ptr< InxWidget > > _widgets
 A list of widgets for this extension.
 

Static Private Attributes

static FILE * error_file = nullptr
 This is the place where errors get reported.
 

Detailed Description

The object that is the basis for the Extension system.

This object contains all of the information that all Extension have. The individual items are detailed within. This is the interface that those who want to use the extensions system should use. This is most likely to be those who are inside the Inkscape program.

Definition at line 133 of file extension.h.

Member Typedef Documentation

◆ ImplementationHolder

Member Enumeration Documentation

◆ state_t

An enumeration to identify if the Extension has been loaded or not.

Enumerator
STATE_LOADED 

The extension has been loaded successfully.

STATE_UNLOADED 

The extension has not been loaded.

STATE_DEACTIVATED 

The extension is missing something which makes it unusable.

Definition at line 136 of file extension.h.

Constructor & Destructor Documentation

◆ Extension()

Inkscape::Extension::Extension::Extension ( Inkscape::XML::Node in_repr,
ImplementationHolder  implementation,
std::string *  base_directory 
)

Constructs an Extension from a Inkscape::XML::Node.

Returns
none
Parameters
in_reprThe repr that should be used to build it
base_directoryBase directory of extensions that were loaded from a file (.inx file's location)

This function is the basis of building an extension for Inkscape. It currently extracts the fields from the Repr that are used in the extension. The Repr will likely include other children that are not related to the module directly. If the Repr does not include a name and an ID the module will be left in an errored state.

Definition at line 66 of file extension.cpp.

References _actions, _base_directory, _deps, _gettext_catalog_dir, _id, _name, _translation_enabled, _translationdomain, _widgets, Inkscape::GC::anchor(), Inkscape::XML::Node::attribute(), child, Inkscape::XML::Node::content(), Inkscape::XML::ELEMENT_NODE, Inkscape::XML::Node::firstChild(), imp, Inkscape::Extension::InxWidget::is_valid_widget_name(), lookup_translation_catalog(), Inkscape::Extension::InxWidget::make(), name, Inkscape::XML::Node::name(), Inkscape::XML::Node::next(), repr, Inkscape::Extension::Dependency::TYPE_EXECUTABLE, and Inkscape::Extension::Dependency::TYPE_FILE.

◆ ~Extension()

Inkscape::Extension::Extension::~Extension ( )
virtual

Definition at line 173 of file extension.cpp.

References Inkscape::GC::release(), and repr.

Member Function Documentation

◆ add_val()

void Inkscape::Extension::Extension::add_val ( Glib::ustring const &  labelstr,
Glib::ustring const &  valuestr,
Gtk::Grid *  table,
int *  row 
)
inlinestaticprotected

Definition at line 1024 of file extension.cpp.

References label.

Referenced by get_info_widget().

◆ autogui()

Gtk::Widget * Inkscape::Extension::Extension::autogui ( SPDocument doc,
Inkscape::XML::Node node,
sigc::signal< void()> *  changeSignal = nullptr 
)

A function to automatically generate a GUI from the extensions' widgets.

Returns
Generated widget

This function just goes through each widget, and calls it's 'get_widget'. Then, each of those is placed into a Gtk::VBox, which is then returned to the calling function.

If there are no visible parameters, this function just returns NULL.

Definition at line 975 of file extension.cpp.

References _gui, _widgets, Inkscape::Extension::InxWidget::GUI_BOX_MARGIN, Inkscape::Extension::InxWidget::GUI_BOX_SPACING, and widget_visible_count().

Referenced by prefs().

◆ check()

bool Inkscape::Extension::Extension::check ( )
virtual

A function to check the validity of the extension.

Returns
A boolean saying whether the extension passed the checks

This function chekcs to make sure that there is an id, a name, a repr and an implementation for this extension. Then it checks all of the dependencies to see if they pass. Finally, it asks the implementation to do a check of itself.

On each check, if there is a failure, it will print a message to the error log for that failure. It is important to note that the function keeps executing if it finds an error, to try and get as many of them into the error log as possible. This should help people debug installations, and figure out what they need to get for the full functionality of Inkscape to be available.

Reimplemented in Inkscape::Extension::Input, Inkscape::Extension::Output, and Inkscape::Extension::Template.

Definition at line 257 of file extension.cpp.

References _deps, error_file_write(), imp, printFailure(), and repr.

Referenced by Inkscape::Extension::Input::check(), Inkscape::Extension::Output::check(), and Inkscape::Extension::Template::check().

◆ deactivate()

void Inkscape::Extension::Extension::deactivate ( )
virtual

This function diactivates the extension (which makes it unusable, but not deleted)

Returns
None

This function is used to removed an extension from functioning, but not delete it completely. It sets the state to STATE_DEACTIVATED to mark to the world that it has been deactivated. It also removes the current implementation and replaces it with a standard one. This makes it so that we don't have to continually check if there is an implementation, but we are guaranteed to have a benign one.

Warning
It is important to note that there is no 'activate' function. Running this function is irreversible.

Reimplemented in Inkscape::Extension::Effect.

Definition at line 347 of file extension.cpp.

References imp, set_state(), and STATE_DEACTIVATED.

Referenced by Inkscape::Extension::Effect::deactivate().

◆ deactivated()

bool Inkscape::Extension::Extension::deactivated ( )

Find out the status of the extension.

Returns
Whether the extension has been deactivated

Definition at line 361 of file extension.cpp.

References get_state(), and STATE_DEACTIVATED.

◆ error_file_close()

void Inkscape::Extension::Extension::error_file_close ( )
static

A function to close the error log file.

Definition at line 919 of file extension.cpp.

References error_file.

Referenced by Inkscape::Extension::check_extensions().

◆ error_file_open()

void Inkscape::Extension::Extension::error_file_open ( )
static

A function to open the error log file.

Definition at line 908 of file extension.cpp.

References error_file, Inkscape::IO::fopen_utf8name(), and Inkscape::IO::Resource::log_path().

Referenced by Inkscape::Extension::check_extensions().

◆ error_file_write()

void Inkscape::Extension::Extension::error_file_write ( Glib::ustring const &  text)
static

A function to write to the error log file.

Definition at line 928 of file extension.cpp.

References error_file.

Referenced by check(), and printFailure().

◆ get_base_directory()

◆ get_dependency_location()

std::string Inkscape::Extension::Extension::get_dependency_location ( char const *  name)

Gets the location of the dependency file as an absolute path.

Iterates over all dependencies of this extension and finds the one with matching name, then returns the absolute path to this dependency file as determined previously.

TODO: This function should not be necessary, but we parse script dependencies twice:

  • Once here in the Extension::Extension() constructor
  • A second time in Script::load() in "script.cpp" when determining the script location Theoretically we could return the wrong path if an extension depends on two files with the same name in different relative locations. In practice this risk should be close to zero, though.
Returns
Absolute path of the dependency file

Definition at line 379 of file extension.cpp.

References _deps, and name.

◆ get_gui()

bool Inkscape::Extension::Extension::get_gui ( ) const
inline

Definition at line 286 of file extension.h.

References _gui.

◆ get_id()

char const * Inkscape::Extension::Extension::get_id ( ) const

Get the ID of this extension - not a copy don't delete!

Returns
The textual id of this extension

Definition at line 316 of file extension.cpp.

References _id.

Referenced by Inkscape::Extension::Dependency::check(), InkFileExportCmd::do_export_extension(), Inkscape::Extension::Implementation::Script::effect(), Inkscape::Extension::Effect::Effect(), Inkscape::Extension::Effect::find_icon_file(), Inkscape::Extension::Effect::get_sanitized_id(), Inkscape::Extension::InxWidget::get_widget(), Inkscape::Extension::InxParameter::InxParameter(), Inkscape::Extension::InxWidget::InxWidget(), Inkscape::Extension::InxParameter::make(), Inkscape::Extension::InxWidget::make(), Inkscape::Extension::open(), Inkscape::Extension::ParamColor::ParamColor(), Inkscape::Extension::ParamFloat::ParamFloat(), Inkscape::Extension::ParamInt::ParamInt(), Inkscape::Extension::ParamNotebook::ParamNotebook(), Inkscape::Extension::ParamNotebook::ParamNotebookPage::ParamNotebookPage(), Inkscape::Extension::ParamOptionGroup::ParamOptionGroup(), Inkscape::Extension::ParamOptionGroup::ParamOptionGroupOption::ParamOptionGroupOption(), Inkscape::Extension::ParamPath::ParamPath(), Inkscape::Extension::ParamString::ParamString(), Inkscape::Extension::InxParameter::pref_name(), Inkscape::UI::Dialog::render_icon(), Inkscape::Extension::save(), Inkscape::Extension::ParamOptionGroup::set(), Inkscape::Extension::InxParameter::string_to_value(), Inkscape::Extension::ParamBool::string_to_value(), Inkscape::Extension::InxParameter::value_to_string(), Inkscape::Extension::WidgetBox::WidgetBox(), Inkscape::Extension::WidgetImage::WidgetImage(), Inkscape::Extension::WidgetLabel::WidgetLabel(), and Inkscape::Extension::WidgetSpacer::WidgetSpacer().

◆ get_imp()

◆ get_implementation_type()

ModuleImpType Inkscape::Extension::Extension::get_implementation_type ( )

Uses the object's type to figure out what the type is.

Returns
Returns the type of extension that this object is.

Definition at line 553 of file extension.cpp.

References Inkscape::Util::HybridPointer< T >::get(), imp, MODULE_EXTENSION, MODULE_PLUGIN, and MODULE_XSLT.

◆ get_info_widget()

Gtk::Box * Inkscape::Extension::Extension::get_info_widget ( )

◆ get_name()

char const * Inkscape::Extension::Extension::get_name ( ) const

◆ get_param() [1/2]

InxParameter * Inkscape::Extension::Extension::get_param ( char const *  name)
private

Looks up the parameter with the specified name.

Searches the list of parameters attached to this extension, looking for a parameter with a matching name.

This function can throw a 'param_not_exist' exception if the name is not found.

Parameters
nameName of the parameter to search for.
Returns
Parameter with matching name.

Definition at line 597 of file extension.cpp.

References _widgets, Inkscape::Extension::InxParameter::name(), and name.

Referenced by get_param(), get_param_bool(), get_param_color(), get_param_float(), get_param_int(), get_param_optiongroup(), get_param_optiongroup_contains(), get_param_string(), set_param_any(), set_param_bool(), set_param_color(), set_param_float(), set_param_hidden(), set_param_int(), set_param_optiongroup(), and set_param_string().

◆ get_param() [2/2]

InxParameter const * Inkscape::Extension::Extension::get_param ( char const *  name) const
private

Looks up the parameter with the specified name.

Searches the list of parameters attached to this extension, looking for a parameter with a matching name.

This function can throw a 'param_not_exist' exception if the name is not found.

Parameters
nameName of the parameter to search for.
Returns
Parameter with matching name.

Definition at line 621 of file extension.cpp.

References get_param(), and name.

◆ get_param_bool() [1/2]

bool Inkscape::Extension::Extension::get_param_bool ( char const *  name) const

Gets a parameter identified by name with the bool placed in value.

Returns
The value of the parameter identified by the name
Parameters
nameThe name of the parameter to get

Look up in the parameters list, const then execute the function on that found parameter.

Definition at line 634 of file extension.cpp.

References Inkscape::Extension::InxParameter::get_bool(), get_param(), and name.

Referenced by Inkscape::UI::Dialog::Export::exportRaster(), Inkscape::Extension::Internal::Filter::Blur::get_filter_text(), Inkscape::Extension::Internal::Filter::ImageBlur::get_filter_text(), Inkscape::Extension::Internal::Filter::Bump::get_filter_text(), Inkscape::Extension::Internal::Filter::WaxBump::get_filter_text(), Inkscape::Extension::Internal::Filter::Brilliance::get_filter_text(), Inkscape::Extension::Internal::Filter::ChannelPaint::get_filter_text(), Inkscape::Extension::Internal::Filter::Colorize::get_filter_text(), Inkscape::Extension::Internal::Filter::ExtractChannel::get_filter_text(), Inkscape::Extension::Internal::Filter::Greyscale::get_filter_text(), Inkscape::Extension::Internal::Filter::Invert::get_filter_text(), Inkscape::Extension::Internal::Filter::EdgeDetect::get_filter_text(), Inkscape::Extension::Internal::Filter::Crosssmooth::get_filter_text(), Inkscape::Extension::Internal::Filter::Outline::get_filter_text(), Inkscape::Extension::Internal::Filter::NoiseFill::get_filter_text(), Inkscape::Extension::Internal::Filter::Chromolitho::get_filter_text(), Inkscape::Extension::Internal::Filter::CrossEngraving::get_filter_text(), Inkscape::Extension::Internal::Filter::Drawing::get_filter_text(), Inkscape::Extension::Internal::Filter::Electrize::get_filter_text(), Inkscape::Extension::Internal::Filter::PointEngraving::get_filter_text(), Inkscape::Extension::Internal::Filter::Posterize::get_filter_text(), Inkscape::Extension::Internal::Filter::ColorizableDropShadow::get_filter_text(), Inkscape::Extension::Internal::Filter::ChannelTransparency::get_filter_text(), Inkscape::Extension::Internal::Filter::LightEraser::get_filter_text(), Inkscape::Extension::Internal::Filter::Silhouette::get_filter_text(), get_param_bool(), Inkscape::Extension::Internal::CairoPsOutput::textToPath(), Inkscape::Extension::Internal::CairoEpsOutput::textToPath(), Inkscape::Extension::Internal::PrintLatex::textToPath(), and Inkscape::Extension::Internal::PrintMetafile::textToPath().

◆ get_param_bool() [2/2]

bool Inkscape::Extension::Extension::get_param_bool ( char const *  name,
bool  alt 
) const

Like get_param_bool but with a default on param_not_exist error.

Returns
The value of the param or the alternate if the param doesn't exist.

Definition at line 645 of file extension.cpp.

References get_param_bool(), and name.

◆ get_param_color()

Colors::Color Inkscape::Extension::Extension::get_param_color ( char const *  name) const

Gets a parameter identified by name with the unsigned int placed in value.

Returns
The unsigned integer RGBA value for the parameter specified
Parameters
nameThe name of the parameter to get

Look up in the parameters list, const then execute the function on that found parameter.

Definition at line 788 of file extension.cpp.

References Inkscape::Extension::InxParameter::get_color(), get_param(), and name.

Referenced by Inkscape::Extension::Internal::Filter::DiffuseLight::get_filter_text(), Inkscape::Extension::Internal::Filter::MatteJelly::get_filter_text(), Inkscape::Extension::Internal::Filter::SpecularLight::get_filter_text(), Inkscape::Extension::Internal::Filter::ImageBlur::get_filter_text(), Inkscape::Extension::Internal::Filter::Bump::get_filter_text(), Inkscape::Extension::Internal::Filter::WaxBump::get_filter_text(), Inkscape::Extension::Internal::Filter::ChannelPaint::get_filter_text(), Inkscape::Extension::Internal::Filter::Colorize::get_filter_text(), Inkscape::Extension::Internal::Filter::Duochrome::get_filter_text(), Inkscape::Extension::Internal::Filter::NudgeRGB::get_filter_text(), Inkscape::Extension::Internal::Filter::NudgeCMY::get_filter_text(), Inkscape::Extension::Internal::Filter::SimpleBlend::get_filter_text(), Inkscape::Extension::Internal::Filter::Tritone::get_filter_text(), Inkscape::Extension::Internal::Filter::Outline::get_filter_text(), Inkscape::Extension::Internal::Filter::NoiseFill::get_filter_text(), Inkscape::Extension::Internal::Filter::Drawing::get_filter_text(), Inkscape::Extension::Internal::Filter::PointEngraving::get_filter_text(), Inkscape::Extension::Internal::Filter::ColorizableDropShadow::get_filter_text(), and Inkscape::Extension::Internal::Filter::Silhouette::get_filter_text().

◆ get_param_float() [1/2]

double Inkscape::Extension::Extension::get_param_float ( char const *  name) const

Gets a float parameter identified by name with the double placed in value.

Returns
The double value for the float parameter specified
Parameters
nameThe name of the parameter to get

Look up in the parameters list, const then execute the function on that found parameter.

Definition at line 690 of file extension.cpp.

References Inkscape::Extension::InxParameter::get_float(), get_param(), and name.

Referenced by Inkscape::Extension::Internal::Grid::effect(), Inkscape::Extension::Internal::Grid::effect(), Inkscape::UI::Dialog::Export::exportRaster(), Inkscape::Extension::Internal::Filter::DiffuseLight::get_filter_text(), Inkscape::Extension::Internal::Filter::MatteJelly::get_filter_text(), Inkscape::Extension::Internal::Filter::SpecularLight::get_filter_text(), Inkscape::Extension::Internal::Filter::Blur::get_filter_text(), Inkscape::Extension::Internal::Filter::CleanEdges::get_filter_text(), Inkscape::Extension::Internal::Filter::CrossBlur::get_filter_text(), Inkscape::Extension::Internal::Filter::Feather::get_filter_text(), Inkscape::Extension::Internal::Filter::ImageBlur::get_filter_text(), Inkscape::Extension::Internal::Filter::Bump::get_filter_text(), Inkscape::Extension::Internal::Filter::WaxBump::get_filter_text(), Inkscape::Extension::Internal::Filter::Brilliance::get_filter_text(), Inkscape::Extension::Internal::Filter::ChannelPaint::get_filter_text(), Inkscape::Extension::Internal::Filter::ColorShift::get_filter_text(), Inkscape::Extension::Internal::Filter::Colorize::get_filter_text(), Inkscape::Extension::Internal::Filter::Duochrome::get_filter_text(), Inkscape::Extension::Internal::Filter::FadeToBW::get_filter_text(), Inkscape::Extension::Internal::Filter::Greyscale::get_filter_text(), Inkscape::Extension::Internal::Filter::Invert::get_filter_text(), Inkscape::Extension::Internal::Filter::Lighting::get_filter_text(), Inkscape::Extension::Internal::Filter::LightnessContrast::get_filter_text(), Inkscape::Extension::Internal::Filter::NudgeRGB::get_filter_text(), Inkscape::Extension::Internal::Filter::NudgeCMY::get_filter_text(), Inkscape::Extension::Internal::Filter::Quadritone::get_filter_text(), Inkscape::Extension::Internal::Filter::Tritone::get_filter_text(), Inkscape::Extension::Internal::Filter::FeltFeather::get_filter_text(), Inkscape::Extension::Internal::Filter::Roughen::get_filter_text(), Inkscape::Extension::Internal::Filter::EdgeDetect::get_filter_text(), Inkscape::Extension::Internal::Filter::Crosssmooth::get_filter_text(), Inkscape::Extension::Internal::Filter::Outline::get_filter_text(), Inkscape::Extension::Internal::Filter::NoiseFill::get_filter_text(), Inkscape::Extension::Internal::Filter::Chromolitho::get_filter_text(), Inkscape::Extension::Internal::Filter::CrossEngraving::get_filter_text(), Inkscape::Extension::Internal::Filter::Drawing::get_filter_text(), Inkscape::Extension::Internal::Filter::Electrize::get_filter_text(), Inkscape::Extension::Internal::Filter::NeonDraw::get_filter_text(), Inkscape::Extension::Internal::Filter::PointEngraving::get_filter_text(), Inkscape::Extension::Internal::Filter::Posterize::get_filter_text(), Inkscape::Extension::Internal::Filter::PosterizeBasic::get_filter_text(), Inkscape::Extension::Internal::Filter::Snow::get_filter_text(), Inkscape::Extension::Internal::Filter::ColorizableDropShadow::get_filter_text(), Inkscape::Extension::Internal::Filter::InkBlot::get_filter_text(), Inkscape::Extension::Internal::Filter::ChannelTransparency::get_filter_text(), Inkscape::Extension::Internal::Filter::LightEraser::get_filter_text(), Inkscape::Extension::Internal::Filter::Opacity::get_filter_text(), Inkscape::Extension::Internal::Filter::Silhouette::get_filter_text(), get_param_float(), Inkscape::Extension::Internal::TemplateBase::get_template_size(), Inkscape::Extension::Internal::TemplateOther::get_template_size(), and Inkscape::Extension::Internal::TemplatePaper::get_template_size().

◆ get_param_float() [2/2]

double Inkscape::Extension::Extension::get_param_float ( char const *  name,
double  alt 
) const

Like get_param_float but with a default on param_not_exist error.

Returns
The value of the param or the alternate if the param doesn't exist.

Definition at line 701 of file extension.cpp.

References get_param_float(), and name.

◆ get_param_int() [1/2]

int Inkscape::Extension::Extension::get_param_int ( char const *  name) const

Gets a parameter identified by name with the integer placed in value.

Returns
The integer value for the parameter specified
Parameters
nameThe name of the parameter to get

Look up in the parameters list, const then execute the function on that found parameter.

Definition at line 662 of file extension.cpp.

References Inkscape::Extension::InxParameter::get_int(), get_param(), and name.

Referenced by Inkscape::UI::Dialog::Export::exportRaster(), Inkscape::Extension::Internal::Filter::DiffuseLight::get_filter_text(), Inkscape::Extension::Internal::Filter::MatteJelly::get_filter_text(), Inkscape::Extension::Internal::Filter::SpecularLight::get_filter_text(), Inkscape::Extension::Internal::Filter::Bump::get_filter_text(), Inkscape::Extension::Internal::Filter::WaxBump::get_filter_text(), Inkscape::Extension::Internal::Filter::ColorShift::get_filter_text(), Inkscape::Extension::Internal::Filter::Quadritone::get_filter_text(), Inkscape::Extension::Internal::Filter::Solarize::get_filter_text(), Inkscape::Extension::Internal::Filter::Tritone::get_filter_text(), Inkscape::Extension::Internal::Filter::FeltFeather::get_filter_text(), Inkscape::Extension::Internal::Filter::Roughen::get_filter_text(), Inkscape::Extension::Internal::Filter::NoiseFill::get_filter_text(), Inkscape::Extension::Internal::Filter::Chromolitho::get_filter_text(), Inkscape::Extension::Internal::Filter::CrossEngraving::get_filter_text(), Inkscape::Extension::Internal::Filter::Drawing::get_filter_text(), Inkscape::Extension::Internal::Filter::Electrize::get_filter_text(), Inkscape::Extension::Internal::Filter::PointEngraving::get_filter_text(), Inkscape::Extension::Internal::Filter::Posterize::get_filter_text(), Inkscape::Extension::Internal::Filter::PosterizeBasic::get_filter_text(), Inkscape::Extension::Internal::Filter::InkBlot::get_filter_text(), and get_param_int().

◆ get_param_int() [2/2]

int Inkscape::Extension::Extension::get_param_int ( char const *  name,
int  alt 
) const

Like get_param_int but with a default on param_not_exist error.

Returns
The value of the param or the alternate if the param doesn't exist.

Definition at line 673 of file extension.cpp.

References get_param_int(), and name.

◆ get_param_optiongroup() [1/2]

char const * Inkscape::Extension::Extension::get_param_optiongroup ( char const *  name) const

Gets a parameter identified by name with the string placed in value.

Returns
The string value for the parameter specified
Parameters
nameThe name of the parameter to get

Look up in the parameters list, const then execute the function on that found parameter.

Definition at line 746 of file extension.cpp.

References Inkscape::Extension::InxParameter::get_optiongroup(), get_param(), and name.

◆ get_param_optiongroup() [2/2]

char const * Inkscape::Extension::Extension::get_param_optiongroup ( char const *  name,
char const *  alt 
) const

Like get_param_optiongroup but with a default on param_not_exist error.

Returns
The value of the param or the alternate if the param doesn't exist.

Definition at line 757 of file extension.cpp.

References get_param_optiongroup(), and name.

Referenced by Inkscape::Extension::Internal::Filter::CrossBlur::get_filter_text(), Inkscape::Extension::Internal::Filter::ImageBlur::get_filter_text(), Inkscape::Extension::Internal::Filter::Bump::get_filter_text(), Inkscape::Extension::Internal::Filter::WaxBump::get_filter_text(), Inkscape::Extension::Internal::Filter::ColorBlindness::get_filter_text(), Inkscape::Extension::Internal::Filter::Colorize::get_filter_text(), Inkscape::Extension::Internal::Filter::ComponentTransfer::get_filter_text(), Inkscape::Extension::Internal::Filter::Duochrome::get_filter_text(), Inkscape::Extension::Internal::Filter::ExtractChannel::get_filter_text(), Inkscape::Extension::Internal::Filter::FadeToBW::get_filter_text(), Inkscape::Extension::Internal::Filter::Invert::get_filter_text(), Inkscape::Extension::Internal::Filter::Quadritone::get_filter_text(), Inkscape::Extension::Internal::Filter::SimpleBlend::get_filter_text(), Inkscape::Extension::Internal::Filter::Solarize::get_filter_text(), Inkscape::Extension::Internal::Filter::Tritone::get_filter_text(), Inkscape::Extension::Internal::Filter::FeltFeather::get_filter_text(), Inkscape::Extension::Internal::Filter::Roughen::get_filter_text(), Inkscape::Extension::Internal::Filter::EdgeDetect::get_filter_text(), Inkscape::Extension::Internal::Filter::Crosssmooth::get_filter_text(), Inkscape::Extension::Internal::Filter::Outline::get_filter_text(), Inkscape::Extension::Internal::Filter::NoiseFill::get_filter_text(), Inkscape::Extension::Internal::Filter::Chromolitho::get_filter_text(), Inkscape::Extension::Internal::Filter::Electrize::get_filter_text(), Inkscape::Extension::Internal::Filter::NeonDraw::get_filter_text(), Inkscape::Extension::Internal::Filter::PointEngraving::get_filter_text(), Inkscape::Extension::Internal::Filter::Posterize::get_filter_text(), Inkscape::Extension::Internal::Filter::ColorizableDropShadow::get_filter_text(), Inkscape::Extension::Internal::Filter::InkBlot::get_filter_text(), Inkscape::Extension::Internal::Filter::Blend::get_filter_text(), get_param_optiongroup(), Inkscape::Extension::Internal::TemplatePaper::get_template_size(), Inkscape::Extension::Internal::TemplateBase::get_template_unit(), and Inkscape::Extension::Internal::CairoRendererPdfOutput::save().

◆ get_param_optiongroup_contains()

bool Inkscape::Extension::Extension::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.

Parameters
nameThe name of the optiongroup parameter to get.
Returns
true if value exists, false if not

Definition at line 773 of file extension.cpp.

References Inkscape::Extension::InxParameter::get_optiongroup_contains(), get_param(), and name.

Referenced by InkFileExportCmd::do_export_ps_pdf().

◆ get_param_string() [1/2]

char const * Inkscape::Extension::Extension::get_param_string ( char const *  name) const

Gets a parameter identified by name with the string placed in value.

Returns
The string value for the parameter specified
Parameters
nameThe name of the parameter to get

Look up in the parameters list, const then execute the function on that found parameter.

Definition at line 718 of file extension.cpp.

References get_param(), Inkscape::Extension::InxParameter::get_string(), and name.

◆ get_param_string() [2/2]

char const * Inkscape::Extension::Extension::get_param_string ( char const *  name,
char const *  alt 
) const

Like get_param_string but with a default on param_not_exist error.

Returns
The value of the param or the alternate if the param doesn't exist.

Definition at line 729 of file extension.cpp.

References get_param_string(), and name.

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

◆ get_params_widget()

Gtk::Box * Inkscape::Extension::Extension::get_params_widget ( )

Definition at line 1036 of file extension.cpp.

References Inkscape::UI::pack_start().

◆ get_repr()

Inkscape::XML::Node * Inkscape::Extension::Extension::get_repr ( )

A getter for the internal Repr, does not add a reference.

Returns
The XML tree that is used to define the extension

Definition at line 306 of file extension.cpp.

References repr.

◆ get_sort_priority()

int Inkscape::Extension::Extension::get_sort_priority ( ) const
inline

Definition at line 199 of file extension.h.

References _priority.

Referenced by Inkscape::Extension::Template::Template().

◆ get_state()

Extension::state_t Inkscape::Extension::Extension::get_state ( )

A getter for the state variable.

Returns
The state the extension is in

Definition at line 225 of file extension.cpp.

References _state.

Referenced by deactivated(), and loaded().

◆ get_translation()

char const * Inkscape::Extension::Extension::get_translation ( char const *  msgid,
char const *  msgctxt = nullptr 
) const

Gets a translation within the context of the current extension.

Query gettext for the translated version of the input string, handling the preferred translation domain of the extension internally.

Parameters
msgidString to translate
msgctxtContext for the translation
Returns
Translated string (or original string if extension is not supposed to be translated)

Definition at line 498 of file extension.cpp.

References _id, _translation_enabled, and _translationdomain.

Referenced by Inkscape::Extension::Input::get_filetypename(), Inkscape::Extension::Output::get_filetypename(), Inkscape::Extension::Input::get_filetypetooltip(), Inkscape::Extension::Output::get_filetypetooltip(), get_info_widget(), Inkscape::Extension::Effect::get_menu(), get_name(), and Inkscape::Extension::InxWidget::get_translation().

◆ getErrorReason()

std::string const & Inkscape::Extension::Extension::getErrorReason ( )
inline

Definition at line 190 of file extension.h.

References _error_reason.

◆ loaded()

◆ lookup_translation_catalog()

void Inkscape::Extension::Extension::lookup_translation_catalog ( )
private

Searches for a gettext catalog matching the extension's translationdomain.

This function will attempt to find the correct gettext catalog for the translationdomain requested by the extension.

For this the following three locations are recursively searched for "${translationdomain}.mo":

  • the 'locale' directory in the .inx file's folder
  • the 'locale' directory in the "extensions" folder containing the .inx
  • the system location for gettext catalogs, i.e. where Inkscape's own catalog is located

If one matching file is found, the directory is assumed to be the correct location and registered with gettext

Definition at line 424 of file extension.cpp.

References _base_directory, Inkscape::Extension::_find_filename_recursive(), _gettext_catalog_dir, _translation_enabled, and _translationdomain.

Referenced by Extension().

◆ make_param()

void Inkscape::Extension::Extension::make_param ( Inkscape::XML::Node paramrepr)
private

◆ paramListString()

void Inkscape::Extension::Extension::paramListString ( std::list< std::string > &  retlist) const

A function to get the parameters in a string form.

Returns
An array with all the parameters in it.

Definition at line 570 of file extension.cpp.

References _widgets, Inkscape::Extension::InxParameter::name(), name, and Inkscape::Extension::InxParameter::value_to_string().

◆ prefs()

bool Inkscape::Extension::Extension::prefs ( )
virtual

Create a dialog for preference for this extension.

Will skip if not using GUI.

Returns
True if preferences have been shown or not using GUI, False is canceled.

Definition at line 1061 of file extension.cpp.

References autogui(), Inkscape::UI::dialog_run(), get_name(), loaded(), set_state(), and STATE_LOADED.

Referenced by Inkscape::Extension::open(), Inkscape::Extension::PathEffect::processPathEffects(), Inkscape::Extension::save(), Inkscape::Extension::TemplatePreset::setup_prefs(), and Inkscape::Extension::Template::Template().

◆ printFailure()

void Inkscape::Extension::Extension::printFailure ( Glib::ustring const &  reason)

A quick function to print out a standard start of extension errors in the log.

Parameters
reasonA string explaining why this failed

Real simple, just put everything into error_file.

Definition at line 295 of file extension.cpp.

References _error_reason, _name, and error_file_write().

Referenced by check().

◆ run_processing_actions()

void Inkscape::Extension::Extension::run_processing_actions ( SPDocument doc)
virtual

Runs any pre-processing actions and modifies the document.

Definition at line 1085 of file extension.cpp.

References _actions.

Referenced by Inkscape::Extension::Output::save().

◆ set_base_directory()

void Inkscape::Extension::Extension::set_base_directory ( std::string const &  base_directory)
inline

Definition at line 193 of file extension.h.

References _base_directory.

◆ set_environment()

void Inkscape::Extension::Extension::set_environment ( SPDocument const *  doc = nullptr)

Sets environment suitable for executing this Extension.

Currently sets the environment variables INKEX_GETTEXT_DOMAIN and INKEX_GETTEXT_DIRECTORY to make the "translationdomain" accessible to child processes spawned by this extension's Implementation.

Parameters
docOptional document, if provided sets the DOCUMENT_PATH from the document's save location.

Definition at line 522 of file extension.cpp.

References _gettext_catalog_dir, _translationdomain, SPDocument::getDocumentFilename(), and Inkscape::IO::Resource::profile_path().

◆ set_gui()

void Inkscape::Extension::Extension::set_gui ( bool  s)
inline

◆ set_param_any()

void Inkscape::Extension::Extension::set_param_any ( char const *  name,
std::string const &  value 
)

Parses the given string value and sets a parameter identified by name.

Parameters
nameThe name of the parameter to set
valueThe value to set the parameter to

Definition at line 896 of file extension.cpp.

References get_param(), name, and Inkscape::Extension::InxParameter::set().

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

◆ set_param_bool()

bool Inkscape::Extension::Extension::set_param_bool ( char const *  name,
bool  value 
)

Sets a parameter identified by name with the boolean in the parameter value.

Returns
The passed in value
Parameters
nameThe name of the parameter to set
valueThe value to set the parameter to

Look up in the parameters list, const then execute the function on that found parameter.

Definition at line 804 of file extension.cpp.

References get_param(), name, and Inkscape::Extension::InxParameter::set_bool().

Referenced by InkFileExportCmd::do_export_ps_pdf(), Inkscape::Extension::Internal::Emf::save(), and Inkscape::Extension::Internal::Wmf::save().

◆ set_param_color()

void Inkscape::Extension::Extension::set_param_color ( char const *  name,
Colors::Color const &  color 
)
\return   The passed in value
\brief    Sets a parameter identified by name with the unsigned integer RGBA value in the parameter value.
\param    name   The name of the parameter to set
\param    value  The value to set the parameter to

Look up in the parameters list, const then execute the function on that found parameter.

Definition at line 884 of file extension.cpp.

References get_param(), name, and Inkscape::Extension::InxParameter::set_color().

◆ set_param_float()

double Inkscape::Extension::Extension::set_param_float ( char const *  name,
double  value 
)

Sets a parameter identified by name with the double in the parameter value.

Returns
The passed in value
Parameters
nameThe name of the parameter to set
valueThe value to set the parameter to

Look up in the parameters list, const then execute the function on that found parameter.

Definition at line 836 of file extension.cpp.

References get_param(), name, and Inkscape::Extension::InxParameter::set_float().

◆ set_param_hidden()

void Inkscape::Extension::Extension::set_param_hidden ( char const *  name,
bool  hidden 
)

◆ set_param_int()

int Inkscape::Extension::Extension::set_param_int ( char const *  name,
int  value 
)

Sets a parameter identified by name with the integer in the parameter value.

Returns
The passed in value
Parameters
nameThe name of the parameter to set
valueThe value to set the parameter to

Look up in the parameters list, const then execute the function on that found parameter.

Definition at line 820 of file extension.cpp.

References get_param(), name, and Inkscape::Extension::InxParameter::set_int().

Referenced by InkFileExportCmd::do_export_ps_pdf().

◆ set_param_optiongroup()

char const * Inkscape::Extension::Extension::set_param_optiongroup ( char const *  name,
char const *  value 
)

Sets a parameter identified by name with the string in the parameter value.

Returns
The passed in value
Parameters
nameThe name of the parameter to set
valueThe value to set the parameter to

Look up in the parameters list, const then execute the function on that found parameter.

Definition at line 868 of file extension.cpp.

References get_param(), name, and Inkscape::Extension::InxParameter::set_optiongroup().

Referenced by InkFileExportCmd::do_export_ps_pdf().

◆ set_param_string()

char const * Inkscape::Extension::Extension::set_param_string ( char const *  name,
char const *  value 
)

Sets a parameter identified by name with the string in the parameter value.

Returns
The passed in value
Parameters
nameThe name of the parameter to set
valueThe value to set the parameter to

Look up in the parameters list, const then execute the function on that found parameter.

Definition at line 852 of file extension.cpp.

References get_param(), name, and Inkscape::Extension::InxParameter::set_string().

◆ set_sort_priority()

void Inkscape::Extension::Extension::set_sort_priority ( int  priority)
inline

◆ set_state()

void Inkscape::Extension::Extension::set_state ( state_t  in_state)

A function to set whether the extension should be loaded or unloaded.

Returns
none
Parameters
in_stateWhich state should the extension be in?

It checks to see if this is a state change or not. If we're changing states it will call the appropriate function in the implementation, load or unload. Currently, there is no error checking in this function. There should be.

Todo:
Need some more error checking here!

Definition at line 190 of file extension.cpp.

References _state, imp, STATE_DEACTIVATED, STATE_LOADED, STATE_UNLOADED, and timer.

Referenced by deactivate(), InkFileExportCmd::do_export_extension(), Inkscape::Extension::Effect::effect(), Inkscape::Extension::Output::export_raster(), Inkscape::Extension::ExpirationTimer::idle_func(), Inkscape::Extension::Template::new_from_template(), Inkscape::Extension::Input::open(), Inkscape::Extension::open(), Inkscape::Extension::PrefDialog::param_change(), prefs(), Inkscape::Extension::Effect::prefs(), Inkscape::Extension::Template::resize_to_template(), Inkscape::Extension::save(), and Inkscape::Extension::Output::save().

◆ widget_visible_count()

unsigned int Inkscape::Extension::Extension::widget_visible_count ( ) const

A function to get the number of visible parameters of the extension.

Returns
The number of visible parameters.

Definition at line 1044 of file extension.cpp.

References _widgets.

Referenced by autogui(), Inkscape::Extension::Effect::prefs(), Inkscape::Extension::Implementation::Implementation::prefs_effect(), and Inkscape::Extension::Effect::takes_input().

Member Data Documentation

◆ _actions

std::vector<ProcessingAction> Inkscape::Extension::Extension::_actions
private

Processing actions.

Definition at line 153 of file extension.h.

Referenced by Extension(), and run_processing_actions().

◆ _base_directory

std::string Inkscape::Extension::Extension::_base_directory
protected

Directory containing the .inx file, relative paths in the extension should usually be relative to it.

Definition at line 163 of file extension.h.

Referenced by Extension(), Inkscape::Extension::Effect::find_icon_file(), get_base_directory(), lookup_translation_catalog(), and set_base_directory().

◆ _deps

std::vector<std::unique_ptr<Dependency> > Inkscape::Extension::Extension::_deps
private

Dependencies for this extension.

Definition at line 148 of file extension.h.

Referenced by check(), Extension(), and get_dependency_location().

◆ _error_reason

std::string Inkscape::Extension::Extension::_error_reason
private

Short, textual explanation for the latest error.

Definition at line 150 of file extension.h.

Referenced by getErrorReason(), and printFailure().

◆ _gettext_catalog_dir

std::string Inkscape::Extension::Extension::_gettext_catalog_dir
private

Directory containing the gettext catalog for _translationdomain.

Definition at line 171 of file extension.h.

Referenced by Extension(), lookup_translation_catalog(), and set_environment().

◆ _gui

bool Inkscape::Extension::Extension::_gui = true
private

Definition at line 151 of file extension.h.

Referenced by autogui(), get_gui(), and set_gui().

◆ _id

std::string Inkscape::Extension::Extension::_id
private

The unique identifier for the Extension.

Definition at line 144 of file extension.h.

Referenced by Extension(), get_id(), get_info_widget(), and get_translation().

◆ _name

std::string Inkscape::Extension::Extension::_name
private

A user friendly name for the Extension.

Definition at line 145 of file extension.h.

Referenced by Extension(), get_info_widget(), get_name(), and printFailure().

◆ _priority

int Inkscape::Extension::Extension::_priority = 0
private

when sorted, should this come before any others

Definition at line 147 of file extension.h.

Referenced by get_sort_priority(), and set_sort_priority().

◆ _state

state_t Inkscape::Extension::Extension::_state = STATE_UNLOADED
private

Which state the Extension is currently in.

Definition at line 146 of file extension.h.

Referenced by get_info_widget(), get_state(), and set_state().

◆ _translation_enabled

bool Inkscape::Extension::Extension::_translation_enabled = true
protected

Attempt translation of strings provided by the extension?

Definition at line 166 of file extension.h.

Referenced by Extension(), Inkscape::Extension::Effect::get_menu(), get_translation(), and lookup_translation_catalog().

◆ _translationdomain

char const* Inkscape::Extension::Extension::_translationdomain = nullptr
private

Domainname of gettext textdomain that should be used for translation of the extension's strings.

Definition at line 169 of file extension.h.

Referenced by Extension(), get_translation(), lookup_translation_catalog(), and set_environment().

◆ _widgets

std::vector<std::unique_ptr<InxWidget> > Inkscape::Extension::Extension::_widgets
private

A list of widgets for this extension.

Definition at line 206 of file extension.h.

Referenced by autogui(), Extension(), get_param(), paramListString(), and widget_visible_count().

◆ error_file

FILE * Inkscape::Extension::Extension::error_file = nullptr
staticprivate

This is the place where errors get reported.

Definition at line 149 of file extension.h.

Referenced by error_file_close(), error_file_open(), and error_file_write().

◆ imp

◆ repr

◆ timer

std::unique_ptr<ExpirationTimer> Inkscape::Extension::Extension::timer
protected

Timeout to unload after a given time.

Definition at line 165 of file extension.h.

Referenced by Inkscape::Extension::Effect::effect(), Inkscape::Extension::Input::open(), and set_state().


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