Code

Remove warnings
[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 <gtkmm/box.h>
22 #include <gtkmm/table.h>
23 #include <glibmm/ustring.h>
24 #include "xml/repr.h"
25 #include "extension/extension-forward.h"
27 /** The key that is used to identify that the I/O should be autodetected */
28 #define SP_MODULE_KEY_AUTODETECT "autodetect"
29 /** This is the key for the SVG input module */
30 #define SP_MODULE_KEY_INPUT_SVG "org.inkscape.input.svg"
31 #define SP_MODULE_KEY_INPUT_SVGZ "org.inkscape.input.svgz"
32 /** Specifies the input module that should be used if none are selected */
33 #define SP_MODULE_KEY_INPUT_DEFAULT SP_MODULE_KEY_AUTODETECT
34 /** The key for outputing standard W3C SVG */
35 #define SP_MODULE_KEY_OUTPUT_SVG "org.inkscape.output.svg.plain"
36 #define SP_MODULE_KEY_OUTPUT_SVGZ "org.inkscape.output.svgz.plain"
37 /** This is an output file that has SVG data with the Sodipodi namespace extensions */
38 #define SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE "org.inkscape.output.svg.inkscape"
39 #define SP_MODULE_KEY_OUTPUT_SVGZ_INKSCAPE "org.inkscape.output.svgz.inkscape"
40 /** Which output module should be used? */
41 #define SP_MODULE_KEY_OUTPUT_DEFAULT SP_MODULE_KEY_AUTODETECT
43 /** Defines the key for Postscript printing */
44 #define SP_MODULE_KEY_PRINT_PS    "org.inkscape.print.ps"
45 /** Defines the key for LaTeX printing */
46 #define SP_MODULE_KEY_PRINT_LATEX    "org.inkscape.print.latex"
47 /** Defines the key for printing with GNOME Print */
48 #define SP_MODULE_KEY_PRINT_GNOME "org.inkscape.print.gnome"
49 /** Defines the key for printing under Win32 */
50 #define SP_MODULE_KEY_PRINT_WIN32 "org.inkscape.print.win32"
51 #ifdef WIN32
52 /** Defines the default printing to use */
53 #define SP_MODULE_KEY_PRINT_DEFAULT  SP_MODULE_KEY_PRINT_WIN32
54 #else
55 #ifdef WITH_GNOME_PRINT
56 /** Defines the default printing to use */
57 #define SP_MODULE_KEY_PRINT_DEFAULT  SP_MODULE_KEY_PRINT_GNOME
58 #else
59 /** Defines the default printing to use */
60 #define SP_MODULE_KEY_PRINT_DEFAULT  SP_MODULE_KEY_PRINT_PS
61 #endif
62 #endif
64 /** Mime type for SVG */
65 #define MIME_SVG "image/svg+xml"
67 /** Name of the extension error file */
68 #define EXTENSION_ERROR_LOG_FILENAME  "extension-errors.log"
70 namespace Inkscape {
71 namespace Extension {
73 /** The object that is the basis for the Extension system.  This object
74     contains all of the information that all Extension have.  The
75     individual items are detailed within. This is the interface that
76     those who want to _use_ the extensions system should use.  This
77     is most likely to be those who are inside the Inkscape program. */
78 class Extension {
79 public:
80     /** An enumeration to identify if the Extension has been loaded or not. */
81     typedef enum {
82         STATE_LOADED,      /**< The extension has been loaded successfully */
83         STATE_UNLOADED,    /**< The extension has not been loaded */
84         STATE_DEACTIVATED  /**< The extension is missing something which makes it unusable */
85     } state_t;
86     static std::vector<const gchar *> search_path; /**< A vector of paths to search for extensions */
88 private:
89     gchar     *id;                        /**< The unique identifier for the Extension */
90     gchar     *name;                      /**< A user friendly name for the Extension */
91     gchar     *_help;                     /**< A string that contains a help text for the user */
92     state_t    _state;                    /**< Which state the Extension is currently in */
93     std::vector<Dependency *>  _deps;     /**< Dependencies for this extension */
94     static std::ofstream error_file;      /**< This is the place where errors get reported */
96 protected:
97     Inkscape::XML::Node *repr;                         /**< The XML description of the Extension */
98     Implementation::Implementation * imp; /**< An object that holds all the functions for making this work */
99     ExpirationTimer * timer;              /**< Timeout to unload after a given time */
101 public:
102                   Extension    (Inkscape::XML::Node * in_repr,
103                                 Implementation::Implementation * in_imp);
104     virtual      ~Extension    (void);
106     void          set_state    (state_t in_state);
107     state_t       get_state    (void);
108     bool          loaded       (void);
109     virtual bool  check        (void);
110     Inkscape::XML::Node *      get_repr     (void);
111     gchar *       get_id       (void);
112     gchar *       get_name     (void);
113     /** \brief  Gets the help string for this extension */
114     gchar const * get_help     (void) { return _help; }
115     void          deactivate   (void);
116     bool          deactivated  (void);
117     void          printFailure (Glib::ustring reason);
120 /* Parameter Stuff */
121 private:
122     GSList * parameters; /**< A table to store the parameters for this extension.
123                               This only gets created if there are parameters in this
124                               extension */
126 public:
127     /** An error class for when a parameter is called on a type it is not */
128     class param_wrong_type {};
129     
130     /** An error class for when a parameter is looked for that just 
131      * simply doesn't exist */
132     class param_not_exist {};
133     
134     /** An error class for when a filename already exists, but the user 
135      * doesn't want to overwrite it */
136     class no_overwrite {};
138 private:
139     void             make_param       (Inkscape::XML::Node * paramrepr);
140 #if 0
141     inline param_t * param_shared     (const gchar * name,
142                                        GSList * list);
143 #endif
144 public:
145     bool             get_param_bool   (const gchar * name,
146                                        const Inkscape::XML::Document *   doc = NULL);
147     int              get_param_int    (const gchar * name,
148                                        const Inkscape::XML::Document *   doc = NULL);
149     float            get_param_float  (const gchar * name,
150                                        const Inkscape::XML::Document *   doc = NULL);
151     const gchar *    get_param_string (const gchar * name,
152                                        const Inkscape::XML::Document *   doc = NULL);
153     bool             set_param_bool   (const gchar * name,
154                                        bool          value,
155                                        Inkscape::XML::Document *   doc = NULL);
156     int              set_param_int    (const gchar * name,
157                                        int           value,
158                                        Inkscape::XML::Document *   doc = NULL);
159     float            set_param_float  (const gchar * name,
160                                        float         value,
161                                        Inkscape::XML::Document *   doc = NULL);
162     const gchar *    set_param_string (const gchar * name,
163                                        const gchar * value,
164                                        Inkscape::XML::Document *   doc = NULL);
166     /* Error file handling */
167 public:
168     static void      error_file_open  (void);
169     static void      error_file_close (void);
171 public:
172     Gtk::Widget *    autogui (void);
173     Glib::ustring *  paramString (void);
175     /* Extension editor dialog stuff */
176 public:
177     Gtk::VBox *    get_info_widget(void);
178     Gtk::VBox *    get_help_widget(void);
179     Gtk::VBox *    get_params_widget(void);
180 protected:
181     inline static void add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Table * table, int * row);
183 };
187 /*
189 This is a prototype for how collections should work.  Whoever gets
190 around to implementing this gets to decide what a 'folder' and an
191 'item' really is.  That is the joy of implementing it, eh?
193 class Collection : public Extension {
195 public:
196     folder  get_root (void);
197     int     get_count (folder);
198     thumbnail get_thumbnail(item);
199     item[]  get_items(folder);
200     folder[]  get_folders(folder);
201     metadata get_metadata(item);
202     image   get_image(item);
204 };
205 */
207 }  /* namespace Extension */
208 }  /* namespace Inkscape */
210 #endif /* __INK_EXTENSION_H__ */
212 /*
213   Local Variables:
214   mode:c++
215   c-file-style:"stroustrup"
216   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
217   indent-tabs-mode:nil
218   fill-column:99
219   End:
220 */
221 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :