Code

fix 1432089: stroke is not drawn not only when it's not set but also when it's too...
[inkscape.git] / src / extension / extension.h
1 #ifndef __INK_EXTENSION_H__
2 #define __INK_EXTENSION_H__
4 /** \file
5  * Frontend to certain, possibly pluggable, actions.
6  */
8 /*
9  * Authors:
10  *   Ted Gould <ted@gould.cx>
11  *
12  * Copyright (C) 2002-2005 Authors
13  *
14  * Released under GNU GPL, read the file 'COPYING' for more information
15  */
17 #include <ostream>
18 #include <fstream>
19 #include <vector>
20 #include <gtkmm/widget.h>
21 #include <glibmm/ustring.h>
22 #include "xml/repr.h"
23 #include "extension/extension-forward.h"
25 /** The key that is used to identify that the I/O should be autodetected */
26 #define SP_MODULE_KEY_AUTODETECT "autodetect"
27 /** This is the key for the SVG input module */
28 #define SP_MODULE_KEY_INPUT_SVG "org.inkscape.input.svg"
29 #define SP_MODULE_KEY_INPUT_SVGZ "org.inkscape.input.svgz"
30 /** Specifies the input module that should be used if none are selected */
31 #define SP_MODULE_KEY_INPUT_DEFAULT SP_MODULE_KEY_AUTODETECT
32 /** The key for outputing standard W3C SVG */
33 #define SP_MODULE_KEY_OUTPUT_SVG "org.inkscape.output.svg.plain"
34 #define SP_MODULE_KEY_OUTPUT_SVGZ "org.inkscape.output.svgz.plain"
35 /** This is an output file that has SVG data with the Sodipodi namespace extensions */
36 #define SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE "org.inkscape.output.svg.inkscape"
37 #define SP_MODULE_KEY_OUTPUT_SVGZ_INKSCAPE "org.inkscape.output.svgz.inkscape"
38 /** Which output module should be used? */
39 #define SP_MODULE_KEY_OUTPUT_DEFAULT SP_MODULE_KEY_AUTODETECT
41 /** Defines the key for Postscript printing */
42 #define SP_MODULE_KEY_PRINT_PS    "org.inkscape.print.ps"
43 /** Defines the key for LaTeX printing */
44 #define SP_MODULE_KEY_PRINT_LATEX    "org.inkscape.print.latex"
45 /** Defines the key for printing with GNOME Print */
46 #define SP_MODULE_KEY_PRINT_GNOME "org.inkscape.print.gnome"
47 /** Defines the key for printing under Win32 */
48 #define SP_MODULE_KEY_PRINT_WIN32 "org.inkscape.print.win32"
49 #ifdef WIN32
50 /** Defines the default printing to use */
51 #define SP_MODULE_KEY_PRINT_DEFAULT  SP_MODULE_KEY_PRINT_WIN32
52 #else
53 #ifdef WITH_GNOME_PRINT
54 /** Defines the default printing to use */
55 #define SP_MODULE_KEY_PRINT_DEFAULT  SP_MODULE_KEY_PRINT_GNOME
56 #else
57 /** Defines the default printing to use */
58 #define SP_MODULE_KEY_PRINT_DEFAULT  SP_MODULE_KEY_PRINT_PS
59 #endif
60 #endif
62 /** Mime type for SVG */
63 #define MIME_SVG "image/svg+xml"
65 /** Name of the extension error file */
66 #define EXTENSION_ERROR_LOG_FILENAME  "extension-errors.log"
68 namespace Inkscape {
69 namespace Extension {
71 /** The object that is the basis for the Extension system.  This object
72     contains all of the information that all Extension have.  The
73     individual items are detailed within. This is the interface that
74     those who want to _use_ the extensions system should use.  This
75     is most likely to be those who are inside the Inkscape program. */
76 class Extension {
77 public:
78     /** An enumeration to identify if the Extension has been loaded or not. */
79     typedef enum {
80         STATE_LOADED,      /**< The extension has been loaded successfully */
81         STATE_UNLOADED,    /**< The extension has not been loaded */
82         STATE_DEACTIVATED  /**< The extension is missing something which makes it unusable */
83     } state_t;
84     static std::vector<const gchar *> search_path; /**< A vector of paths to search for extensions */
86 private:
87     gchar     *id;                        /**< The unique identifier for the Extension */
88     gchar     *name;                      /**< A user friendly name for the Extension */
89     state_t    _state;                    /**< Which state the Extension is currently in */
90     std::vector<Dependency *>  _deps;     /**< Dependencies for this extension */
91     static std::ofstream error_file;      /**< This is the place where errors get reported */
93 protected:
94     Inkscape::XML::Node *repr;                         /**< The XML description of the Extension */
95     Implementation::Implementation * imp; /**< An object that holds all the functions for making this work */
96     ExpirationTimer * timer;              /**< Timeout to unload after a given time */
98 public:
99                   Extension    (Inkscape::XML::Node * in_repr,
100                                 Implementation::Implementation * in_imp);
101     virtual      ~Extension    (void);
103     void          set_state    (state_t in_state);
104     state_t       get_state    (void);
105     bool          loaded       (void);
106     virtual bool  check        (void);
107     Inkscape::XML::Node *      get_repr     (void);
108     gchar *       get_id       (void);
109     gchar *       get_name     (void);
110     void          deactivate   (void);
111     bool          deactivated  (void);
112     void          printFailure (Glib::ustring reason);
115 /* Parameter Stuff */
116 private:
117     GSList * parameters; /**< A table to store the parameters for this extension.
118                               This only gets created if there are parameters in this
119                               extension */
121 public:
122     /** An error class for when a parameter is called on a type it is not */
123     class param_wrong_type {};
124     
125     /** An error class for when a parameter is looked for that just 
126      * simply doesn't exist */
127     class param_not_exist {};
128     
129     /** An error class for when a filename already exists, but the user 
130      * doesn't want to overwrite it */
131     class no_overwrite {};
133 private:
134     void             make_param       (Inkscape::XML::Node * paramrepr);
135 #if 0
136     inline param_t * param_shared     (const gchar * name,
137                                        GSList * list);
138 #endif
139 public:
140     bool             get_param_bool   (const gchar * name,
141                                        const Inkscape::XML::Document *   doc = NULL);
142     int              get_param_int    (const gchar * name,
143                                        const Inkscape::XML::Document *   doc = NULL);
144     float            get_param_float  (const gchar * name,
145                                        const Inkscape::XML::Document *   doc = NULL);
146     const gchar *    get_param_string (const gchar * name,
147                                        const Inkscape::XML::Document *   doc = NULL);
148     bool             set_param_bool   (const gchar * name,
149                                        bool          value,
150                                        Inkscape::XML::Document *   doc = NULL);
151     int              set_param_int    (const gchar * name,
152                                        int           value,
153                                        Inkscape::XML::Document *   doc = NULL);
154     float            set_param_float  (const gchar * name,
155                                        float         value,
156                                        Inkscape::XML::Document *   doc = NULL);
157     const gchar *    set_param_string (const gchar * name,
158                                        const gchar * value,
159                                        Inkscape::XML::Document *   doc = NULL);
161     /* Error file handling */
162 public:
163     static void      error_file_open  (void);
164     static void      error_file_close (void);
166 public:
167     Gtk::Widget *    autogui (void);
168     Glib::ustring *  paramString (void);
169 };
173 /*
175 This is a prototype for how collections should work.  Whoever gets
176 around to implementing this gets to decide what a 'folder' and an
177 'item' really is.  That is the joy of implementing it, eh?
179 class Collection : public Extension {
181 public:
182     folder  get_root (void);
183     int     get_count (folder);
184     thumbnail get_thumbnail(item);
185     item[]  get_items(folder);
186     folder[]  get_folders(folder);
187     metadata get_metadata(item);
188     image   get_image(item);
190 };
191 */
193 }  /* namespace Extension */
194 }  /* namespace Inkscape */
196 #endif /* __INK_EXTENSION_H__ */
198 /*
199   Local Variables:
200   mode:c++
201   c-file-style:"stroustrup"
202   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
203   indent-tabs-mode:nil
204   fill-column:99
205   End:
206 */
207 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :