Inkscape
Vector Graphics Editor
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages Concepts
Inkscape::Extension::Effect Class Reference

Effects are extensions that take a document and do something to it in place. More...

#include <effect.h>

Inheritance diagram for Inkscape::Extension::Effect:
Inkscape::Extension::Extension

Public Member Functions

 Effect (Inkscape::XML::Node *in_repr, ImplementationHolder implementation, std::string *base_directory, std::string *file_name)
 
 ~Effect () override
 
bool prefs (SPDesktop *desktop)
 
void effect (SPDesktop *desktop, SPDocument *document=nullptr)
 The function that 'does' the effect itself.
 
void place_menu (Inkscape::XML::Node *menus)
 
Gtk::Box * get_info_widget ()
 
PrefDialogget_pref_dialog ()
 
void set_pref_dialog (PrefDialog *prefdialog)
 
void deactivate () override
 This function diactivates the extension (which makes it unusable, but not deleted)
 
std::string find_icon_file (const std::string &default_dir) const
 
bool takes_input () const
 
bool hidden_from_menu () const
 
bool is_filter_effect () const
 
const Glib::ustring & get_menu_tip () const
 
std::string get_sanitized_id () const
 Sanitizes the id and returns.
 
std::list< Glib::ustring > get_menu_list () const
 
bool apply_filter (SPItem *item)
 
- 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 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!
 
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 Effectget_last_effect ()
 Static function to get the last effect used.
 
static void set_last_effect (Effect *in_effect)
 Sets which effect was called last.
 
static void place_menus ()
 
- 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.
 

Public Attributes

bool _workingDialog = true
 Whether a working dialog should be shown.
 
bool ignore_stderr = false
 If stderr log should be shown, when process return code is 0.
 
bool pipe_diffs = false
 If changesets should be piped in via stdin.
 
bool no_doc
 
bool no_live_preview
 

Private Member Functions

Inkscape::XML::Nodefind_menu (Inkscape::XML::Node *menustruct, const gchar *name)
 
void get_menu (Inkscape::XML::Node *pattern, std::list< Glib::ustring > &sub_menu_list) const
 

Static Private Member Functions

static gchar * remove_ (gchar *instr)
 
static void _sanitizeId (std::string &id)
 

Private Attributes

Inkscape::XML::Node_menu_node
 Menu node created for this effect.
 
PrefDialog_prefDialog
 The preference dialog if it is shown.
 
std::string _file_name
 
bool _hidden_from_menu = false
 
bool _filter_effect = false
 
Glib::ustring _menu_tip
 
Inkscape::XML::Node_local_effects_menu = nullptr
 
std::string _icon_path
 

Static Private Attributes

static Effect_last_effect = nullptr
 This is the last effect that was used.
 

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 >
 
- 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)
 
- 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

Effects are extensions that take a document and do something to it in place.

This class adds the extra functions required to make extensions effects.

Definition at line 39 of file effect.h.

Constructor & Destructor Documentation

◆ Effect()

◆ ~Effect()

Inkscape::Extension::Effect::~Effect ( )
override

Member Function Documentation

◆ _sanitizeId()

static void Inkscape::Extension::Effect::_sanitizeId ( std::string &  id)
staticprivate

◆ apply_filter()

bool Inkscape::Extension::Effect::apply_filter ( SPItem item)

◆ deactivate()

void Inkscape::Extension::Effect::deactivate ( )
overridevirtual

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

Definition at line 174 of file effect.cpp.

References Inkscape::Extension::Extension::deactivate().

◆ effect()

void Inkscape::Extension::Effect::effect ( SPDesktop desktop,
SPDocument document = nullptr 
)

The function that 'does' the effect itself.

Parameters
desktopThe desktop containing the document to do the effect on

This function first insures that the extension is loaded, and if not, loads it. It then calls the implementation to do the actual work. It also resets the last effect pointer to be this effect. Finally, it executes a SPDocumentUndo::done to commit the changes to the undo stack.

Definition at line 233 of file effect.cpp.

References _workingDialog, Inkscape::Extension::ExecutionEnv::cancel(), Inkscape::Extension::ExecutionEnv::commit(), desktop, Inkscape::Extension::Extension::loaded(), Inkscape::Extension::ExecutionEnv::run(), Inkscape::Extension::ExecutionEnv::set_document(), Inkscape::Extension::Extension::set_state(), Inkscape::Extension::Extension::STATE_LOADED, Inkscape::Extension::Extension::timer, and Inkscape::Extension::ExecutionEnv::wait().

Referenced by action_effect(), Inkscape::UI::Dialog::ExtensionsGallery::ExtensionsGallery(), last_effect(), Inkscape::Extension::PrefDialog::on_response(), prefs(), and Inkscape::UI::Dialog::ExtensionsGallery::update_name().

◆ find_icon_file()

std::string Inkscape::Extension::Effect::find_icon_file ( const std::string &  default_dir) const

◆ find_menu()

Inkscape::XML::Node * Inkscape::Extension::Effect::find_menu ( Inkscape::XML::Node menustruct,
const gchar *  name 
)
private

Definition at line 270 of file effect.cpp.

References child, find_menu(), Inkscape::XML::Node::firstChild(), name, and Inkscape::XML::Node::next().

Referenced by find_menu().

◆ get_info_widget()

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

Definition at line 292 of file effect.cpp.

References Inkscape::Extension::Extension::get_info_widget().

◆ get_last_effect()

static Effect * Inkscape::Extension::Effect::get_last_effect ( )
inlinestatic

Static function to get the last effect used.

Definition at line 70 of file effect.h.

References _last_effect.

Referenced by last_effect(), last_effect_pref(), and ~Effect().

◆ get_menu()

void Inkscape::Extension::Effect::get_menu ( Inkscape::XML::Node pattern,
std::list< Glib::ustring > &  sub_menu_list 
) const
private

◆ get_menu_list()

std::list< Glib::ustring > Inkscape::Extension::Effect::get_menu_list ( ) const

Definition at line 363 of file effect.cpp.

References _filter_effect, _local_effects_menu, and get_menu().

Referenced by Inkscape::UI::Dialog::add_effects().

◆ get_menu_tip()

const Glib::ustring & Inkscape::Extension::Effect::get_menu_tip ( ) const

Definition at line 359 of file effect.cpp.

References _menu_tip.

Referenced by Inkscape::UI::Dialog::add_effects().

◆ get_pref_dialog()

PrefDialog * Inkscape::Extension::Effect::get_pref_dialog ( )

Definition at line 298 of file effect.cpp.

References _prefDialog.

Referenced by Inkscape::Extension::ExecutionEnv::createWorkingDialog().

◆ get_sanitized_id()

std::string Inkscape::Extension::Effect::get_sanitized_id ( ) const

Sanitizes the id and returns.

If an invalid character is found in the ID, a warning is printed to stderr. All invalid characters are replaced with an 'X'.

Definition at line 114 of file effect.cpp.

References end, and Inkscape::Extension::Extension::get_id().

Referenced by Inkscape::UI::Dialog::add_effects().

◆ hidden_from_menu()

bool Inkscape::Extension::Effect::hidden_from_menu ( ) const

Definition at line 347 of file effect.cpp.

References _hidden_from_menu.

◆ is_filter_effect()

bool Inkscape::Extension::Effect::is_filter_effect ( ) const

Definition at line 355 of file effect.cpp.

References _filter_effect.

◆ place_menu()

void Inkscape::Extension::Effect::place_menu ( Inkscape::XML::Node menus)

◆ place_menus()

static void Inkscape::Extension::Effect::place_menus ( )
static

◆ prefs()

◆ remove_()

static gchar * Inkscape::Extension::Effect::remove_ ( gchar *  instr)
staticprivate

◆ set_last_effect()

void Inkscape::Extension::Effect::set_last_effect ( Effect in_effect)
static

Sets which effect was called last.

Parameters
in_effectThe effect that has been called

This function sets the static variable _last_effect

Definition at line 261 of file effect.cpp.

References _last_effect, enable_effect_actions(), and InkscapeApplication::instance().

Referenced by Inkscape::Extension::ExecutionEnv::commit(), and ~Effect().

◆ set_pref_dialog()

void Inkscape::Extension::Effect::set_pref_dialog ( PrefDialog prefdialog)

Definition at line 304 of file effect.cpp.

References _prefDialog.

Referenced by Inkscape::Extension::PrefDialog::~PrefDialog().

◆ takes_input()

bool Inkscape::Extension::Effect::takes_input ( ) const

Member Data Documentation

◆ _file_name

std::string Inkscape::Extension::Effect::_file_name
private

Definition at line 113 of file effect.h.

Referenced by Effect(), and find_icon_file().

◆ _filter_effect

bool Inkscape::Extension::Effect::_filter_effect = false
private

Definition at line 115 of file effect.h.

Referenced by Effect(), get_menu_list(), and is_filter_effect().

◆ _hidden_from_menu

bool Inkscape::Extension::Effect::_hidden_from_menu = false
private

Definition at line 114 of file effect.h.

Referenced by Effect(), and hidden_from_menu().

◆ _icon_path

std::string Inkscape::Extension::Effect::_icon_path
private

Definition at line 118 of file effect.h.

Referenced by Effect(), and find_icon_file().

◆ _last_effect

Effect * Inkscape::Extension::Effect::_last_effect = nullptr
staticprivate

This is the last effect that was used.

This is used in a menu item to rapidly recall the same effect.

Definition at line 42 of file effect.h.

Referenced by get_last_effect(), and set_last_effect().

◆ _local_effects_menu

Inkscape::XML::Node* Inkscape::Extension::Effect::_local_effects_menu = nullptr
private

Definition at line 117 of file effect.h.

Referenced by Effect(), and get_menu_list().

◆ _menu_node

Inkscape::XML::Node* Inkscape::Extension::Effect::_menu_node
private

Menu node created for this effect.

Definition at line 48 of file effect.h.

Referenced by ~Effect().

◆ _menu_tip

Glib::ustring Inkscape::Extension::Effect::_menu_tip
private

Definition at line 116 of file effect.h.

Referenced by Effect(), and get_menu_tip().

◆ _prefDialog

PrefDialog* Inkscape::Extension::Effect::_prefDialog
private

The preference dialog if it is shown.

Definition at line 51 of file effect.h.

Referenced by get_pref_dialog(), prefs(), and set_pref_dialog().

◆ _workingDialog

bool Inkscape::Extension::Effect::_workingDialog = true

Whether a working dialog should be shown.

Definition at line 61 of file effect.h.

Referenced by action_effect(), Effect(), and effect().

◆ ignore_stderr

bool Inkscape::Extension::Effect::ignore_stderr = false

If stderr log should be shown, when process return code is 0.

Definition at line 64 of file effect.h.

Referenced by Inkscape::Extension::Implementation::Script::effect(), and Effect().

◆ no_doc

bool Inkscape::Extension::Effect::no_doc

Definition at line 78 of file effect.h.

Referenced by Inkscape::Extension::Implementation::Script::effect(), and Effect().

◆ no_live_preview

bool Inkscape::Extension::Effect::no_live_preview

Definition at line 79 of file effect.h.

Referenced by Effect(), and Inkscape::Extension::PrefDialog::PrefDialog().

◆ pipe_diffs

bool Inkscape::Extension::Effect::pipe_diffs = false

If changesets should be piped in via stdin.

Definition at line 67 of file effect.h.

Referenced by Inkscape::Extension::Implementation::Script::effect(), and Effect().


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