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

#include <input.h>

Inheritance diagram for Inkscape::Extension::Input:
Inkscape::Extension::Extension

Classes

struct  no_extension_found
 
struct  open_cancelled
 
struct  open_failed
 

Public Member Functions

 Input (Inkscape::XML::Node *in_repr, ImplementationHolder implementation, std::string *base_directory)
 Builds an Input object from a XML description.
 
 ~Input () override
 Destroys an Input extension.
 
bool check () override
 Validate this extension.
 
std::unique_ptr< SPDocumentopen (char const *uri, bool is_importing=false)
 This function creates a document from a file.
 
gchar const * get_mimetype () const
 Get the mime-type that describes this extension.
 
gchar const * get_extension () const
 Get the filename extension for this extension.
 
const char * get_filetypename (bool translated=false) const
 Get the name of the filetype supported.
 
const char * get_filetypetooltip (bool translated=false) const
 Get the tooltip for more information on the filetype.
 
bool can_open_filename (gchar const *filename) const
 Match filename to extension that can open it.
 
- 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 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 Extensionfind_by_mime (char const *mime)
 Get an input extension by mime-type matching.
 
static Extensionfind_by_filename (char const *filename)
 Get an input extension by filename matching.
 
- 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.
 

Private Attributes

gchar * mimetype
 What is the mime type this inputs?
 
gchar * extension
 The extension of the input files.
 
gchar * filetypename
 A userfriendly name for the file type.
 
gchar * filetypetooltip
 A more detailed description of the filetype.
 

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

Definition at line 24 of file input.h.

Constructor & Destructor Documentation

◆ Input()

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

Builds an Input object from a XML description.

Parameters
in_reprThe XML description in a Inkscape::XML::Node tree
implementationThe module to be initialized.

Okay, so you want to build an Input object.

This function first takes and does the build of the parent class, which is SPModule. Then, it looks for the <input> section of the XML description. Under there should be several fields which describe the input module to excruciating detail. Those are parsed, copied, and put into the structure that is passed in as module. Overall, there are many levels of indentation, just to handle the levels of indentation in the XML file.

Definition at line 42 of file input.cpp.

References Inkscape::XML::Node::attributeList(), Inkscape::XML::Node::content(), extension, filetypename, filetypetooltip, Inkscape::XML::Node::firstChild(), mimetype, name, Inkscape::XML::Node::name(), Inkscape::XML::Node::next(), Inkscape::Extension::Extension::repr, and Inkscape::Extension::Extension::set_sort_priority().

◆ ~Input()

Inkscape::Extension::Input::~Input ( )
override

Destroys an Input extension.

Returns
None

Definition at line 108 of file input.cpp.

References extension, filetypename, filetypetooltip, and mimetype.

Member Function Documentation

◆ can_open_filename()

bool Inkscape::Extension::Input::can_open_filename ( gchar const *  filename) const

Match filename to extension that can open it.

Returns
True if the filename matches

Definition at line 185 of file input.cpp.

References extension, and result.

◆ check()

bool Inkscape::Extension::Input::check ( )
overridevirtual

Validate this extension.

Returns
Whether this extension checks out

This function checks to make sure that the input extension has a filename extension and a MIME type. Then it calls the parent class' check function which also checks out the implementation.

Reimplemented from Inkscape::Extension::Extension.

Definition at line 126 of file input.cpp.

References Inkscape::Extension::Extension::check(), extension, and mimetype.

◆ find_by_filename()

Extension * Inkscape::Extension::Input::find_by_filename ( char const *  filename)
static

Get an input extension by filename matching.

Does not look at file contents.

  • filename - The filename to match against.
Returns
the first Input extension found or nullptr

Definition at line 257 of file input.cpp.

References Inkscape::Extension::db, and Inkscape::Extension::DB::get_input_list().

Referenced by file_import(), and Inkscape::Extension::open().

◆ find_by_mime()

Extension * Inkscape::Extension::Input::find_by_mime ( char const *  mime)
static

Get an input extension by mime-type matching.

  • mime - The mime to match against.
Returns
the first Input extension found or nullptr

Definition at line 237 of file input.cpp.

References Inkscape::Extension::db, and Inkscape::Extension::DB::get_input_list().

◆ get_extension()

gchar const * Inkscape::Extension::Input::get_extension ( ) const

Get the filename extension for this extension.

Returns
Filename extension for the extension

Definition at line 175 of file input.cpp.

References extension.

◆ get_filetypename()

const char * Inkscape::Extension::Input::get_filetypename ( bool  translated = false) const

Get the name of the filetype supported.

Returns
The name of the filetype supported

Definition at line 200 of file input.cpp.

References filetypename, Inkscape::Extension::Extension::get_name(), Inkscape::Extension::Extension::get_translation(), and name.

◆ get_filetypetooltip()

const char * Inkscape::Extension::Input::get_filetypetooltip ( bool  translated = false) const

Get the tooltip for more information on the filetype.

Returns
Tooltip giving more information on the filetype

Definition at line 221 of file input.cpp.

References filetypetooltip, and Inkscape::Extension::Extension::get_translation().

◆ get_mimetype()

gchar const * Inkscape::Extension::Input::get_mimetype ( ) const

Get the mime-type that describes this extension.

Returns
IETF mime-type for the extension

Definition at line 165 of file input.cpp.

References mimetype.

◆ open()

std::unique_ptr< SPDocument > Inkscape::Extension::Input::open ( char const *  uri,
bool  is_importing = false 
)

This function creates a document from a file.

Returns
A new document
Parameters
uriThe filename to create the document from
is_importingTrue if the opened file is being imported

This function acts as the first step in creating a new document from a file. The first thing that this does is make sure that the file actually exists. If it doesn't, a NULL is returned. If the file exits, then it is opened using the implementation of this extension.

Definition at line 147 of file input.cpp.

References Inkscape::Extension::Extension::imp, Inkscape::Extension::Extension::loaded(), Inkscape::Extension::Extension::set_state(), Inkscape::Extension::Extension::STATE_LOADED, and Inkscape::Extension::Extension::timer.

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

Member Data Documentation

◆ extension

gchar* Inkscape::Extension::Input::extension
private

The extension of the input files.

Definition at line 26 of file input.h.

Referenced by can_open_filename(), check(), get_extension(), Input(), and ~Input().

◆ filetypename

gchar* Inkscape::Extension::Input::filetypename
private

A userfriendly name for the file type.

Definition at line 27 of file input.h.

Referenced by get_filetypename(), Input(), and ~Input().

◆ filetypetooltip

gchar* Inkscape::Extension::Input::filetypetooltip
private

A more detailed description of the filetype.

Definition at line 28 of file input.h.

Referenced by get_filetypetooltip(), Input(), and ~Input().

◆ mimetype

gchar* Inkscape::Extension::Input::mimetype
private

What is the mime type this inputs?

Definition at line 25 of file input.h.

Referenced by check(), get_mimetype(), Input(), and ~Input().


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