Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
inkscape.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef SEEN_INKSCAPE_H
3#define SEEN_INKSCAPE_H
4
5/*
6 * Interface to main application
7 *
8 * Authors:
9 * Lauris Kaplinski <lauris@kaplinski.com>
10 * Liam P. White <inkscapebrony@gmail.com>
11 *
12 * Copyright (C) 1999-2014 Authors
13 *
14 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
15 */
16
17#include <set>
18#include <string>
19#include <vector>
20
21#include <gdk/gdk.h> // GDK_ALT_MASK
22#include <glib-object.h>
23#include <glib.h>
24#include <sigc++/signal.h>
25
26class SPDesktop;
27class SPDocument;
28
29namespace Inkscape {
30
31class Application;
32class Selection;
33
34namespace UI {
35class ThemeContext;
36namespace Tools {
37
38class ToolBase;
39
40} // namespace Tools
41} // namespace UI
42
43namespace XML {
44class Node;
45struct Document;
46} // namespace XML
47
48} // namespace Inkscape
49
52
53#define INKSCAPE (Inkscape::Application::instance())
54#define SP_ACTIVE_DOCUMENT (INKSCAPE.active_document())
55#define SP_ACTIVE_DESKTOP (INKSCAPE.active_desktop())
56
57namespace Inkscape {
58
60public:
61 static Application& instance();
62 static bool exists();
63 static void create(bool use_gui);
64
65 // returns the mask of the keyboard modifier to map to Alt, zero if no mapping
66 // Needs to be a guint because gdktypes.h does not define a 'no-modifier' value
67 guint mapalt() const { return _mapalt; }
68
69 // Sets the keyboard modifier to map to Alt. Zero switches off mapping, as does '1', which is the default
70 void mapalt(guint maskvalue);
71
72 guint trackalt() const { return _trackalt; }
73 void trackalt(guint trackvalue) { _trackalt = trackvalue; }
74
75 bool use_gui() const { return _use_gui; }
76 void use_gui(gboolean guival) { _use_gui = guival; }
77
78 // no setter for this -- only we can control this variable
79 static bool isCrashing() { return _crashIsHappening; }
80
83
85
86 // Inkscape desktop stuff
92 void get_all_desktops (std::list< SPDesktop* >& listbuf);
94 SPDesktop * find_desktop_by_dkey (unsigned int dkey);
95 unsigned int maximum_dkey();
98 std::vector<SPDesktop *> * get_desktops() { return _desktops; };
99
100 void external_change ();
101
102 // Moved document add/remove functions into public inkscape.h as they are used
103 // (rightly or wrongly) by console-mode functions
104 void add_document(SPDocument *document);
105 void remove_document(SPDocument *document);
106
107 // Fixme: This has to be rethought
108 void exit();
109
110 static void crash_handler(int signum);
111
112 // nobody should be accessing our reference count, so it's made private.
113 friend void ::inkscape_ref (Application & in);
114 friend void ::inkscape_unref(Application & in);
115
116 // signals
117
118 // one of selections changed
120 // one of subselections (text selection, gradient handle, etc) changed
122 // one of selections modified
123 sigc::signal<void (Inkscape::Selection *, guint /*flags*/)> signal_selection_modified;
124 // one of selections set
126 // some desktop got focus
127 sigc::signal<void (SPDesktop *)> signal_activate_desktop;
128 // some desktop lost focus
129 sigc::signal<void (SPDesktop *)> signal_deactivate_desktop;
130
131 // these are orphaned signals (nothing emits them and nothing connects to them)
132 sigc::signal<void (SPDocument *)> signal_destroy_document;
133
134 // a document was changed by some external means (undo or XML editor); this
135 // may not be reflected by a selection change and thus needs a separate signal
136 sigc::signal<void ()> signal_external_change;
137
138 void set_pdf_poppler(bool p) {
139 _pdf_poppler = p;
140 }
142 return _pdf_poppler;
143 }
148 return _pdf_font_strategy;
149 }
150 void set_pdf_convert_colors(bool convert) {
151 _pdf_convert_colors = convert;
152 }
154 return _pdf_convert_colors;
155 }
156 void set_pages(const std::string &pages) {
157 _pages = pages;
158 }
159 const std::string &get_pages() const {
160 return _pages;
161 }
162
163 private:
165
166 Application(bool use_gui);
167 ~Application();
168
169 Application(Application const&) = delete; // no copy
170 Application& operator=(Application const&) = delete; // no assign
171 Application* operator&() const; // no pointer access
172 std::set<SPDocument *> _document_set;
173 std::vector<SPDesktop *> *_desktops = nullptr;
174 std::string _pages;
175
176 unsigned refCount = 1;
177 guint _mapalt = GDK_ALT_MASK;
178 guint _trackalt = false;
179 static bool _crashIsHappening;
180 bool _use_gui = false;
181 bool _pdf_poppler = false;
184};
185
186} // namespace Inkscape
187
188#endif
189
190/*
191 Local Variables:
192 mode:c++
193 c-file-style:"stroustrup"
194 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
195 indent-tabs-mode:nil
196 fill-column:99
197 End:
198*/
199// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
std::vector< SPDesktop * > * get_desktops()
Definition inkscape.h:98
static Inkscape::Application * _S_inst
Definition inkscape.h:164
sigc::signal< void(SPDesktop *)> signal_deactivate_desktop
Definition inkscape.h:129
static bool exists()
Checks whether the current Inkscape::Application global object exists.
Definition inkscape.cpp:142
Inkscape::UI::ThemeContext * themecontext
Definition inkscape.h:84
SPDesktop * prev_desktop()
Definition inkscape.cpp:705
static bool isCrashing()
Definition inkscape.h:79
void activate_desktop(SPDesktop *desktop)
Definition inkscape.cpp:605
sigc::signal< void(SPDocument *)> signal_destroy_document
Definition inkscape.h:132
bool use_gui() const
Definition inkscape.h:75
Application(Application const &)=delete
std::set< SPDocument * > _document_set
Definition inkscape.h:172
sigc::signal< void(Inkscape::Selection *, guint)> signal_selection_modified
Definition inkscape.h:123
void reactivate_desktop(SPDesktop *desktop)
Resends ACTIVATE_DESKTOP for current desktop; needed when a new desktop has got its window that dialo...
Definition inkscape.cpp:636
guint mapalt() const
Definition inkscape.h:67
SPDesktop * next_desktop()
Definition inkscape.cpp:675
bool get_pdf_convert_colors() const
Definition inkscape.h:153
SPDocument * active_document()
Definition inkscape.cpp:769
void add_document(SPDocument *document)
Definition inkscape.cpp:748
void add_desktop(SPDesktop *desktop)
Definition inkscape.cpp:546
void set_pdf_convert_colors(bool convert)
Definition inkscape.h:150
SPDesktop * find_desktop_by_dkey(unsigned int dkey)
Definition inkscape.cpp:648
void use_gui(gboolean guival)
Definition inkscape.h:76
Application & operator=(Application const &)=delete
void set_pages(const std::string &pages)
Definition inkscape.h:156
std::vector< SPDesktop * > * _desktops
Definition inkscape.h:173
sigc::signal< void(SPDesktop *)> signal_activate_desktop
Definition inkscape.h:127
sigc::signal< void(Inkscape::Selection *)> signal_selection_set
Definition inkscape.h:125
Application * operator&() const
Defined only for debugging purposes.
Definition inkscape.cpp:120
sigc::signal< void()> signal_external_change
Definition inkscape.h:136
sigc::signal< void(Inkscape::Selection *)> signal_selection_changed
Definition inkscape.h:119
static Application & instance()
Returns the current Inkscape::Application global object.
Definition inkscape.cpp:152
void get_all_desktops(std::list< SPDesktop * > &listbuf)
Definition inkscape.cpp:796
guint trackalt() const
Definition inkscape.h:72
unsigned int maximum_dkey()
Definition inkscape.cpp:660
static bool _crashIsHappening
Definition inkscape.h:179
const std::string & get_pages() const
Definition inkscape.h:159
void trackalt(guint trackvalue)
Definition inkscape.h:73
void set_pdf_font_strategy(int mode)
Definition inkscape.h:144
std::string _pages
Definition inkscape.h:174
sigc::signal< void(SPDesktop *)> signal_subselection_changed
Definition inkscape.h:121
void exit()
Handler for Inkscape's Exit verb.
Definition inkscape.cpp:790
static void crash_handler(int signum)
Definition inkscape.cpp:305
SPDesktop * active_desktop()
Definition inkscape.cpp:759
void remove_desktop(SPDesktop *desktop)
Definition inkscape.cpp:567
void set_pdf_poppler(bool p)
Definition inkscape.h:138
void remove_document(SPDocument *document)
Definition inkscape.cpp:753
The set of selected SPObjects for a given document and layer model.
Definition selection.h:80
To do: update description of desktop.
Definition desktop.h:149
Typed SVG document implementation.
Definition document.h:101
void inkscape_unref(Inkscape::Application &in)
Definition inkscape.cpp:99
void inkscape_ref(Inkscape::Application &in)
C++ification TODO list.
Definition inkscape.cpp:94
Helper class to stream background task notifications as a series of messages.
int mode
SPDesktop * desktop
std::unique_ptr< Toolbar >(* create)()
Definition toolbars.cpp:56