1 /*
2 * Authors:
3 * Ted Gould <ted@gould.cx>
4 *
5 * Copyright (C) 2002-2004 Authors
6 *
7 * Released under GNU GPL, read the file 'COPYING' for more information
8 */
11 #ifndef INKSCAPE_EXTENSION_EFFECT_H__
12 #define INKSCAPE_EXTENSION_EFFECT_H__
14 #include <config.h>
16 #include <glibmm/i18n.h>
17 #include <gtkmm/dialog.h>
18 #include <gtk/gtkdialog.h>
19 #include "verbs.h"
21 #include "prefdialog.h"
22 #include "extension.h"
24 struct Document;
26 namespace Inkscape {
27 namespace UI {
28 namespace View {
29 typedef View View;
30 };
31 };
33 namespace Extension {
35 /** \brief Effects are extensions that take a document and do something
36 to it in place. This class adds the extra functions required
37 to make extensions effects.
38 */
39 class Effect : public Extension {
40 /** \brief This is the last effect that was used. This is used in
41 a menu item to rapidly recall the same effect. */
42 static Effect * _last_effect;
43 /** \brief The location of the Extensions and Filters menus on the menu structure
44 XML file. This is saved so it only has to be discovered
45 once. */
46 static Inkscape::XML::Node * _effects_list;
47 static Inkscape::XML::Node * _filters_list;
48 Inkscape::XML::Node *find_menu (Inkscape::XML::Node * menustruct, const gchar *name);
49 void merge_menu (Inkscape::XML::Node * base, Inkscape::XML::Node * start, Inkscape::XML::Node * patern, Inkscape::XML::Node * mergee);
51 /** \brief This is the verb type that is used for all effect's verbs.
52 It provides convience functions and maintains a pointer
53 back to the effect that created it. */
54 class EffectVerb : public Inkscape::Verb {
55 private:
56 static void perform (SPAction * action, void * mydata, void * otherdata);
57 /** \brief Function to call for specific actions */
58 static SPActionEventVector vector;
60 /** \brief The effect that this verb represents. */
61 Effect * _effect;
62 /** \brief Whether or not to show preferences on display */
63 bool _showPrefs;
64 /** \brief Name with elipses if that makes sense */
65 gchar * _elip_name;
66 protected:
67 virtual SPAction * make_action (Inkscape::UI::View::View * view);
68 public:
69 /** \brief Use the Verb initializer with the same parameters. */
70 EffectVerb(gchar const * id,
71 gchar const * name,
72 gchar const * tip,
73 gchar const * image,
74 Effect * effect,
75 bool showPrefs) :
76 Verb(id, _(name), _(tip), image),
77 _effect(effect),
78 _showPrefs(showPrefs),
79 _elip_name(NULL) {
80 /* No clue why, but this is required */
81 this->set_default_sensitive(true);
82 if (_showPrefs && effect != NULL && effect->param_visible_count() != 0) {
83 _elip_name = g_strdup_printf("%s...", _(name));
84 set_name(_elip_name);
85 }
86 }
88 /** \brief Destructor */
89 ~EffectVerb() {
90 if (_elip_name != NULL) {
91 g_free(_elip_name);
92 }
93 }
94 };
96 /** \brief ID used for the verb without preferences */
97 Glib::ustring _id_noprefs;
98 /** \brief Name used for the verb without preferences */
99 Glib::ustring _name_noprefs;
101 /** \brief The verb representing this effect. */
102 EffectVerb _verb;
103 /** \brief The verb representing this effect. Without preferences. */
104 EffectVerb _verb_nopref;
105 /** \brief Menu node created for this effect */
106 Inkscape::XML::Node * _menu_node;
107 /** \brief Whehter a working dialog should be shown */
108 bool _workingDialog;
110 /** \brief The preference dialog if it is shown */
111 PrefDialog * _prefDialog;
112 public:
113 Effect (Inkscape::XML::Node * in_repr,
114 Implementation::Implementation * in_imp);
115 virtual ~Effect (void);
116 virtual bool check (void);
117 bool prefs (Inkscape::UI::View::View * doc);
118 void effect (Inkscape::UI::View::View * doc);
119 /** \brief Accessor function for a pointer to the verb */
120 Inkscape::Verb * get_verb (void) { return &_verb; };
122 /** \brief Static function to get the last effect used */
123 static Effect * get_last_effect (void) { return _last_effect; };
124 static void set_last_effect (Effect * in_effect);
126 static void place_menus (void);
127 void place_menu (Inkscape::XML::Node * menus);
129 Gtk::VBox * get_info_widget(void);
131 bool no_doc; // if true, the effect does not process SVG document at all, so no need to save, read, and watch for errors
132 bool no_live_preview; // if true, the effect does not need "live preview" checkbox in its dialog
134 void set_pref_dialog (PrefDialog * prefdialog);
135 private:
136 static gchar * remove_ (gchar * instr);
137 };
139 } } /* namespace Inkscape, Extension */
140 #endif /* INKSCAPE_EXTENSION_EFFECT_H__ */
142 /*
143 Local Variables:
144 mode:c++
145 c-file-style:"stroustrup"
146 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
147 indent-tabs-mode:nil
148 fill-column:99
149 End:
150 */
151 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :