summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/svg-preview.h
blob: 0df897f6dda49e5df2a5dd62a05f830d3aad1026 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// SPDX-License-Identifier: GPL-2.0-or-later
/** @file
 * @brief Implementation of the file dialog interfaces defined in filedialogimpl.h
 */
/* Authors:
 *   Bob Jamison
 *   Johan Engelen <johan@shouraizou.nl>
 *   Joel Holdsworth
 *   Bruno Dilly
 *   Other dudes from The Inkscape Organization
 *
 * Copyright (C) 2004-2008 Authors
 * Copyright (C) 2004-2007 The Inkscape Organization
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#ifndef __SVG_PREVIEW_H__
#define __SVG_PREVIEW_H__

//Gtk includes
#include <gtkmm.h>

//General includes
#include <unistd.h>
#include <sys/stat.h>
#include <cerrno>

#include "filedialog.h"
#include "document.h"

namespace Gtk {
class Expander;
}

namespace Inkscape {
  class URI;

namespace UI {

namespace View {
  class SVGViewWidget;
}

namespace Dialog {

/*#########################################################################
### SVG Preview Widget
#########################################################################*/

/**
 * Simple class for displaying an SVG file in the "preview widget."
 * Currently, this is just a wrapper of the sp_svg_view Gtk widget.
 * Hopefully we will eventually replace with a pure Gtkmm widget.
 */
class SVGPreview : public Gtk::Box
{
public:

    SVGPreview();

    ~SVGPreview() override;

    bool setDocument(SPDocument *doc);

    bool setFileName(Glib::ustring const &fileName);

    bool setFromMem(char const *xmlBuffer);

    bool set(Glib::ustring const &fileName, int dialogType);

    bool setURI(URI &uri);

    /**
     * Show image embedded in SVG
     */
    void showImage(Glib::ustring const &fileName);

    /**
     * Show the "No preview" image
     */
    void showNoPreview();

    /**
     * Show the "Too large" image
     */
    void showTooLarge(long fileLength);

private:
    /**
     * The svg document we are currently showing
     */
    std::unique_ptr<SPDocument> document;

    /**
     * The sp_svg_view widget
     */
    std::unique_ptr<Inkscape::UI::View::SVGViewWidget> viewer;

    /**
     * are we currently showing the "no preview" image?
     */
    bool showingNoPreview;

};


} // namespace Dialog
} // namespace UI
} // namespace Inkscape

#endif /*__SVG_PREVIEW_H__*/

/*
  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 :