summaryrefslogtreecommitdiffstats
path: root/src/extension/implementation/implementation.cpp
blob: e05dbf3c43276b5917e53dad1956dceedb1809de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
    Author:  Ted Gould <ted@gould.cx>
    Copyright (c) 2003-2005,2007

    This code is licensed under the GNU GPL.  See COPYING for details.

    This file is the backend to the extensions system.  These are
    the parts of the system that most users will never see, but are
    important for implementing the extensions themselves.  This file
    contains the base class for all of that.
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "implementation.h"

#include <extension/output.h>
#include <extension/input.h>
#include <extension/effect.h>

#include "selection.h"
#include "desktop.h"


namespace Inkscape {
namespace Extension {
namespace Implementation {

ImplementationDocumentCache::ImplementationDocumentCache (Inkscape::UI::View::View * view)
     : _view(view)
{
    SPDesktop *desktop = (SPDesktop*)view;
    Inkscape::Selection * selection = NULL;
    if (desktop) {
        selection = desktop->getSelection();
        if (selection && !selection->params.empty()) {
            selection->restoreBackup();
            if (!desktop->on_live_extension) {
                selection->emptyBackup();
            }
        }
    }
    return;
}

Gtk::Widget *
Implementation::prefs_input(Inkscape::Extension::Input *module, gchar const */*filename*/) {
    return module->autogui(NULL, NULL);
}

Gtk::Widget *
Implementation::prefs_output(Inkscape::Extension::Output *module) {
    return module->autogui(NULL, NULL);
}

Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal<void> * changeSignal, ImplementationDocumentCache * /*docCache*/)
{
    if (module->param_visible_count() == 0) {
        return NULL;
    }

    SPDocument * current_document = view->doc();

    auto selected = ((SPDesktop *) view)->getSelection()->items();
    Inkscape::XML::Node const* first_select = NULL;
    if (!selected.empty()) {
        const SPItem * item = selected.front();
        first_select = item->getRepr();
    }

    // TODO deal with this broken const correctness:
    return module->autogui(current_document, const_cast<Inkscape::XML::Node *>(first_select), changeSignal);
} // Implementation::prefs_effect

}  /* namespace Implementation */
}  /* namespace Extension */
}  /* namespace Inkscape */

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :