18#ifndef INK_EXTENSION_H
19#define INK_EXTENSION_H
27#include <glibmm/ustring.h>
28#include <sigc++/signal.h>
43#define SP_MODULE_KEY_AUTODETECT "autodetect"
45#define SP_MODULE_KEY_INPUT_SVG "org.inkscape.input.svg"
46#define SP_MODULE_KEY_INPUT_SVGZ "org.inkscape.input.svgz"
48#define SP_MODULE_KEY_INPUT_DEFAULT SP_MODULE_KEY_AUTODETECT
50#define SP_MODULE_KEY_OUTPUT_SVG "org.inkscape.output.svg.plain"
51#define SP_MODULE_KEY_OUTPUT_SVGZ "org.inkscape.output.svgz.plain"
53#define SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE "org.inkscape.output.svg.inkscape"
54#define SP_MODULE_KEY_OUTPUT_SVGZ_INKSCAPE "org.inkscape.output.svgz.inkscape"
56#define SP_MODULE_KEY_OUTPUT_DEFAULT SP_MODULE_KEY_AUTODETECT
59#define SP_MODULE_KEY_RASTER_PNG "org.inkscape.output.png.inkscape"
62#define SP_MODULE_KEY_PRINT_PS "org.inkscape.print.ps"
63#define SP_MODULE_KEY_PRINT_CAIRO_PS "org.inkscape.print.ps.cairo"
64#define SP_MODULE_KEY_PRINT_CAIRO_EPS "org.inkscape.print.eps.cairo"
66#define SP_MODULE_KEY_PRINT_PDF "org.inkscape.print.pdf"
67#define SP_MODULE_KEY_PRINT_CAIRO_PDF "org.inkscape.print.pdf.cairo"
69#define SP_MODULE_KEY_PRINT_LATEX "org.inkscape.print.latex"
71#define SP_MODULE_KEY_PRINT_GNOME "org.inkscape.print.gnome"
74#define MIME_SVG "image/svg+xml"
77#define EXTENSION_ERROR_LOG_FILENAME "extension-errors.log"
80#define INKSCAPE_EXTENSION_URI "http://www.inkscape.org/namespace/inkscape/extension"
81#define INKSCAPE_EXTENSION_NS_NC "extension"
82#define INKSCAPE_EXTENSION_NS "extension:"
115class ProcessingAction;
116class ExpirationTimer;
117class ExpirationTimer;
121namespace Implementation {
145 std::vector<std::unique_ptr<Dependency>>
_deps;
164 std::unique_ptr<ExpirationTimer>
timer;
181 virtual bool check ();
182 virtual bool prefs();
184 char const *
get_id ()
const;
196 char const *
get_translation(
char const *msgid,
char const *msgctxt =
nullptr)
const;
275 void set_param_any(
char const *name, std::string
const &value);
293 inline static void add_val(Glib::ustring
const &labelstr, Glib::ustring
const &valuestr,
294 Gtk::Grid * table,
int * row);
no valid ID found while parsing XML representation
no valid name found while parsing XML representation
extension is not compatible with the current system and should not be loaded
No implementation could be loaded for the extension.
An error class for when a filename already exists, but the user doesn't want to overwrite it.
An error class for when a parameter is looked for that just simply doesn't exist.
The object that is the basis for the Extension system.
double set_param_float(char const *name, double value)
Sets a parameter identified by name with the double in the parameter value.
state_t get_state()
A getter for the state variable.
int _priority
when sorted, should this come before any others
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.
virtual void deactivate()
This function diactivates the extension (which makes it unusable, but not deleted)
std::string _name
A user friendly name for the Extension.
ExecutionEnv * execution_env
Execution environment of the extension (currently only used by Effects)
int get_param_int(char const *name) const
Gets a parameter identified by name with the integer placed in value.
char const * get_translation(char const *msgid, char const *msgctxt=nullptr) const
Gets a translation within the context of the current extension.
static void error_file_write(Glib::ustring const &text)
A function to write to the error log file.
std::unique_ptr< ExpirationTimer > timer
Timeout to unload after a given time.
std::string _error_reason
Short, textual explanation for the latest error.
state_t
An enumeration to identify if the Extension has been loaded or not.
@ STATE_LOADED
The extension has been loaded successfully.
@ STATE_DEACTIVATED
The extension is missing something which makes it unusable.
@ STATE_UNLOADED
The extension has not been loaded.
unsigned int widget_visible_count() const
A function to get the number of visible parameters of the extension.
char const * get_name() const
Get the name of this extension - not a copy don't delete!
std::string const & getErrorReason()
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.
void paramListString(std::list< std::string > &retlist) const
A function to get the parameters in a string form.
double get_param_float(char const *name) const
Gets a float parameter identified by name with the double placed in value.
bool set_param_bool(char const *name, bool value)
Sets a parameter identified by name with the boolean in the parameter value.
void make_param(Inkscape::XML::Node *paramrepr)
Implementation::Implementation * get_imp()
std::uint32_t get_param_color(char const *name) const
Gets a parameter identified by name with the unsigned int placed in value.
virtual void run_processing_actions(SPDocument *doc)
Runs any pre-processing actions and modifies the document.
Inkscape::XML::Node * repr
The XML description of the Extension.
std::string _id
The unique identifier for the Extension.
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.
std::vector< std::unique_ptr< Dependency > > _deps
Dependencies for this extension.
int set_param_int(char const *name, int value)
Sets a parameter identified by name with the integer in the parameter value.
ImplementationHolder imp
An Implementation object provides the actual implementation of the Extension.
char const * get_id() const
Get the ID of this extension - not a copy don't delete!
static void error_file_open()
A function to open the error log file.
std::vector< std::unique_ptr< InxWidget > > _widgets
A list of widgets for this extension.
ModuleImpType get_implementation_type()
Uses the object's type to figure out what the type is.
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.
ExecutionEnv * get_execution_env()
std::uint32_t set_param_color(char const *name, std::uint32_t color)
virtual bool check()
A function to check the validity of the extension.
int get_sort_priority() const
void set_state(state_t in_state)
A function to set whether the extension should be loaded or unloaded.
auto const & get_base_directory() const
bool _translation_enabled
Attempt translation of strings provided by the extension?
static void add_val(Glib::ustring const &labelstr, Glib::ustring const &valuestr, Gtk::Grid *table, int *row)
Gtk::Box * get_params_widget()
char const * set_param_optiongroup(char const *name, char const *value)
Sets a parameter identified by name with the string in the parameter value.
std::string get_dependency_location(char const *name)
Gets the location of the dependency file as an absolute path.
void set_param_hidden(char const *name, bool hidden)
static void error_file_close()
A function to close the error log file.
Extension(Inkscape::XML::Node *in_repr, ImplementationHolder implementation, std::string *base_directory)
Constructs an Extension from a Inkscape::XML::Node.
std::vector< ProcessingAction > _actions
Processing actions.
void set_base_directory(std::string const &base_directory)
bool loaded()
A quick function to test the state of the extension.
void set_execution_env(ExecutionEnv *env)
Inkscape::XML::Node * get_repr()
A getter for the internal Repr, does not add a reference.
std::string _base_directory
Directory containing the .inx file, relative paths in the extension should usually be relative to it.
void set_sort_priority(int priority)
char const * _translationdomain
Domainname of gettext textdomain that should be used for translation of the extension's strings.
void set_environment(SPDocument const *doc=nullptr)
Sets environment suitable for executing this Extension.
void printFailure(Glib::ustring const &reason)
A quick function to print out a standard start of extension errors in the log.
Gtk::Box * get_info_widget()
char const * set_param_string(char const *name, char const *value)
Sets a parameter identified by name with the string in the parameter value.
bool deactivated()
Find out the status of the extension.
bool get_param_bool(char const *name) const
Gets a parameter identified by name with the bool placed in value.
std::string _gettext_catalog_dir
Directory containing the gettext catalog for _translationdomain.
virtual bool prefs()
Create a dialog for preference for this extension.
state_t _state
Which state the Extension is currently in.
void lookup_translation_catalog()
Searches for a gettext catalog matching the extension's translationdomain.
InxParameter * get_param(char const *name)
Looks up the parameter with the specified name.
void set_param_any(char const *name, std::string const &value)
Parses the given string value and sets a parameter identified by name.
static FILE * error_file
This is the place where errors get reported.
Base class for all implementations of modules.
A class to represent the parameter of an extension.
Interface for refcounted XML nodes.
Typed SVG document implementation.
A helper variant type wrapping either an owning pointer (std::unique_ptr) or a non-owning,...
Inkscape::XML::Node * node
CMYK to sRGB conversion routines.