Inkscape
Vector Graphics Editor
|
Effects are extensions that take a document and do something to it in place. More...
#include <effect.h>
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 () |
PrefDialog * | get_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) |
![]() | |
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::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! | |
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 Effect * | get_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 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::Node * | find_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 | |
![]() | |
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 void | add_val (Glib::ustring const &labelstr, Glib::ustring const &valuestr, Gtk::Grid *table, int *row) |
![]() | |
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? | |
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.
Inkscape::Extension::Effect::Effect | ( | Inkscape::XML::Node * | in_repr, |
ImplementationHolder | implementation, | ||
std::string * | base_directory, | ||
std::string * | file_name | ||
) |
Definition at line 41 of file effect.cpp.
References _file_name, _filter_effect, _hidden_from_menu, _icon_path, _local_effects_menu, _menu_tip, _workingDialog, child, Inkscape::XML::Node::content(), Inkscape::Application::exists(), Inkscape::XML::Node::firstChild(), Inkscape::Util::HybridPointer< T >::get(), Inkscape::Extension::Extension::get_id(), ignore_stderr, Inkscape::Extension::Extension::imp, InkscapeApplication::instance(), no_doc, no_live_preview, pipe_diffs, Inkscape::Extension::Extension::repr, and streq().
|
override |
Definition at line 186 of file effect.cpp.
References _menu_node, get_last_effect(), Inkscape::XML::Node::parent(), Inkscape::GC::release(), Inkscape::XML::Node::removeChild(), and set_last_effect().
|
staticprivate |
bool Inkscape::Extension::Effect::apply_filter | ( | SPItem * | item | ) |
Definition at line 374 of file effect.cpp.
References Inkscape::Extension::Implementation::Implementation::apply_filter(), Inkscape::Extension::Extension::get_imp(), and item.
Referenced by Inkscape::UI::Dialog::render_icon().
|
overridevirtual |
This function diactivates the extension (which makes it unusable, but not deleted)
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.
Reimplemented from Inkscape::Extension::Extension.
Definition at line 174 of file effect.cpp.
References Inkscape::Extension::Extension::deactivate().
void Inkscape::Extension::Effect::effect | ( | SPDesktop * | desktop, |
SPDocument * | document = nullptr |
||
) |
The function that 'does' the effect itself.
desktop | The 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().
std::string Inkscape::Extension::Effect::find_icon_file | ( | const std::string & | default_dir | ) | const |
Definition at line 314 of file effect.cpp.
References Inkscape::Extension::Extension::_base_directory, _file_name, _icon_path, Inkscape::IO::get_file_extension(), and Inkscape::Extension::Extension::get_id().
Referenced by Inkscape::UI::Dialog::add_effects().
|
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().
Gtk::Box * Inkscape::Extension::Effect::get_info_widget | ( | ) |
Definition at line 292 of file effect.cpp.
References Inkscape::Extension::Extension::get_info_widget().
|
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().
|
private |
Definition at line 145 of file effect.cpp.
References Inkscape::Extension::Extension::_translation_enabled, Inkscape::XML::Node::attribute(), Inkscape::XML::Node::firstChild(), get_menu(), and Inkscape::Extension::Extension::get_translation().
Referenced by get_menu(), and 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().
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().
PrefDialog * Inkscape::Extension::Effect::get_pref_dialog | ( | ) |
Definition at line 298 of file effect.cpp.
References _prefDialog.
Referenced by Inkscape::Extension::ExecutionEnv::createWorkingDialog().
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().
bool Inkscape::Extension::Effect::hidden_from_menu | ( | ) | const |
Definition at line 347 of file effect.cpp.
References _hidden_from_menu.
bool Inkscape::Extension::Effect::is_filter_effect | ( | ) | const |
Definition at line 355 of file effect.cpp.
References _filter_effect.
void Inkscape::Extension::Effect::place_menu | ( | Inkscape::XML::Node * | menus | ) |
|
static |
bool Inkscape::Extension::Effect::prefs | ( | SPDesktop * | desktop | ) |
Definition at line 200 of file effect.cpp.
References _prefDialog, desktop, effect(), Inkscape::Extension::Extension::get_name(), Inkscape::Extension::Extension::loaded(), name, Inkscape::Extension::Extension::set_state(), Inkscape::Extension::Extension::STATE_LOADED, and Inkscape::Extension::Extension::widget_visible_count().
Referenced by action_effect(), and last_effect_pref().
|
staticprivate |
|
static |
Sets which effect was called last.
in_effect | The 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().
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().
bool Inkscape::Extension::Effect::takes_input | ( | ) | const |
Definition at line 351 of file effect.cpp.
References Inkscape::Extension::Extension::widget_visible_count().
|
private |
Definition at line 113 of file effect.h.
Referenced by Effect(), and find_icon_file().
|
private |
Definition at line 115 of file effect.h.
Referenced by Effect(), get_menu_list(), and is_filter_effect().
|
private |
Definition at line 114 of file effect.h.
Referenced by Effect(), and hidden_from_menu().
|
private |
Definition at line 118 of file effect.h.
Referenced by Effect(), and find_icon_file().
|
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().
|
private |
Definition at line 117 of file effect.h.
Referenced by Effect(), and get_menu_list().
|
private |
|
private |
Definition at line 116 of file effect.h.
Referenced by Effect(), and get_menu_tip().
|
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().
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().
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().
bool Inkscape::Extension::Effect::no_doc |
Definition at line 78 of file effect.h.
Referenced by Inkscape::Extension::Implementation::Script::effect(), and Effect().
bool Inkscape::Extension::Effect::no_live_preview |
Definition at line 79 of file effect.h.
Referenced by Effect(), and Inkscape::Extension::PrefDialog::PrefDialog().
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().