Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
export-single.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/* Authors:
3 * Lauris Kaplinski <lauris@kaplinski.com>
4 * bulia byak <buliabyak@users.sf.net>
5 * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
6 * Anshudhar Kumar Singh <anshudhar2001@gmail.com>
7 *
8 * Copyright (C) 1999-2007, 2021 Authors
9 * Copyright (C) 2001-2002 Ximian, Inc.
10 *
11 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
12 */
13
14#ifndef SP_EXPORT_SINGLE_H
15#define SP_EXPORT_SINGLE_H
16
18
19namespace Gtk {
20class Builder;
21class Button;
22class CheckButton;
23class FlowBox;
24class Grid;
25class Label;
26class ProgressBar;
27class ToggleButton;
28class ScrolledWindow;
29class SpinButton;
30} // namespace Gtk
31
33class SPDesktop;
34class SPDocument;
35class SPObject;
36class SPPage;
37
38namespace Inkscape {
39
40class Selection;
41class Preferences;
42
43namespace UI {
44
45namespace Widget {
46class UnitMenu;
47class ColorPicker;
48} // namespace Widget
49
50namespace Dialog {
51
52class PreviewDrawing;
53class ExportPreview;
54class ExtensionList;
55
56class SingleExport : public Gtk::Box
57{
58public:
59 SingleExport(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &refGlade);
60 ~SingleExport() override;
61
62 void setApp(InkscapeApplication *app) { _app = app; }
63 void setDocument(SPDocument *document);
66 void selectionModified(Inkscape::Selection *selection, guint flags);
67 void refresh()
68 {
72 };
73
74private:
87
89 {
90 SELECTION_PAGE = 0, // Default is alaways placed first
94 };
95
97 SPDesktop *_desktop = nullptr;
99 std::shared_ptr<PreviewDrawing> _preview_drawing;
100
101 bool setupDone = false; // To prevent setup() call add connections again.
102
103 std::map<sb_type, Gtk::SpinButton *> spin_buttons;
104 std::map<sb_type, Gtk::Label *> spin_labels;
105 std::map<selection_mode, Gtk::ToggleButton *> selection_buttons;
106
107 Gtk::CheckButton *show_export_area = nullptr;
108
110
111 // In order of intialization
112 Gtk::FlowBox &pages_list;
113 Gtk::ScrolledWindow &pages_list_box;
114 Gtk::Grid &size_box;
116 Gtk::Box &si_units_row;
117 Gtk::CheckButton &si_hide_all;
118 Gtk::CheckButton &si_show_preview;
119
121 Gtk::Box &preview_box;
122
124
125 Gtk::Entry &si_filename_entry;
126 Gtk::Button &si_filename_button;
127 Gtk::Button &si_export;
128 Gtk::ProgressBar &progress_bar;
129 Gtk::Widget &progress_box;
130 Gtk::Button &cancel_button;
132
138
139 Glib::ustring doc_export_name;
142 std::string filepath_native;
143
145 std::map<selection_mode, Glib::ustring> selection_names;
147
148 void setup();
149 void setupUnits();
150 void setupSpinButtons();
152 void refreshPreview();
153
154 // change range and callbacks to spinbuttons
155 template <typename T>
156 void setupSpinButton(Gtk::SpinButton *sb, double val, double min, double max, double step, double page, int digits,
157 bool sensitive, void (SingleExport::*cb)(T), T param);
158
160 void onAreaXChange(sb_type type);
161 void onAreaYChange(sb_type type);
162 void onDpiChange(sb_type type);
164 void onUnitChanged();
165 void onFilenameModified();
166 void onExtensionChanged();
167 void onExport();
168 void onCancel();
169 void onBrowse();
170
171 void refreshArea();
172 void refreshPage();
173 void loadExportHints();
174 void setFilename(std::string filename, bool modified_by_user);
175 void saveExportHints(SPObject *target);
176 void areaXChange(sb_type type);
177 void areaYChange(sb_type type);
178 void dpiChange(sb_type type);
179 void setArea(double x0, double y0, double x1, double y1);
180 void blockSpinConns(bool status);
181
182 void setExporting(bool exporting, Glib::ustring const &text = "");
188 static unsigned int onProgressCallback(float value, void *data);
189
193 void onPagesChanged();
196 void setPagesMode(bool multi);
197 void selectPage(SPPage *page);
198 std::vector<SPPage const *> getSelectedPages() const;
199
201
202 // Gtk Signals
203 std::vector<sigc::scoped_connection> spinButtonConns;
204 sigc::scoped_connection filenameConn;
205 sigc::scoped_connection extensionConn;
206 sigc::scoped_connection exportConn;
207 sigc::scoped_connection cancelConn;
208 sigc::scoped_connection browseConn;
209 sigc::scoped_connection _pages_list_changed;
210 // Document Signals
211 sigc::scoped_connection _page_selected_connection;
212 sigc::scoped_connection _page_modified_connection;
213 sigc::scoped_connection _page_changed_connection;
214};
215
216} // namespace Dialog
217} // namespace UI
218} // namespace Inkscape
219
220#endif // SP_EXPORT_SINGLE_H
221
222/*
223 Local Variables:
224 mode:c++
225 c-file-style:"stroustrup"
226 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
227 indent-tabs-mode:nil
228 fill-column:99
229 End:
230*/
231// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
uint64_t page
Definition canvas.cpp:171
Preference storage class.
Definition preferences.h:61
The set of selected SPObjects for a given document and layer model.
Definition selection.h:80
sigc::scoped_connection _page_selected_connection
void setupSpinButton(Gtk::SpinButton *sb, double val, double min, double max, double step, double page, int digits, bool sensitive, void(SingleExport::*cb)(T), T param)
void onAreaTypeToggle(selection_mode key)
void selectionChanged(Inkscape::Selection *selection)
void setDesktop(SPDesktop *desktop)
sigc::scoped_connection _page_modified_connection
void setArea(double x0, double y0, double x1, double y1)
Gtk::ScrolledWindow & pages_list_box
Inkscape::UI::Widget::UnitMenu & units
void onFilenameModified()
Filename in filename entry field was changed.
std::string filepath_native
File path as returned by the file chooser.
Glib::ustring filename_entry_original_value
Last value of filename entry field that was set programmatically. Used to detect modification by the ...
std::map< selection_mode, Gtk::ToggleButton * > selection_buttons
void setFilename(std::string filename, bool modified_by_user)
Set filename and update filename entry box.
sigc::scoped_connection extensionConn
void loadExportHints()
Update suggested DPI and filename when the selection has changed.
Inkscape::Preferences * prefs
sigc::scoped_connection exportConn
static unsigned int onProgressCallback(float value, void *data)
Callback to be used in for loop to update the progress bar.
void selectionModified(Inkscape::Selection *selection, guint flags)
sigc::scoped_connection cancelConn
std::shared_ptr< PreviewDrawing > _preview_drawing
bool filename_modified_by_user
True if the value of the selected filename was changed by the user since the last export.
void setExporting(bool exporting, Glib::ustring const &text="")
std::vector< sigc::scoped_connection > spinButtonConns
sigc::scoped_connection filenameConn
std::map< sb_type, Gtk::SpinButton * > spin_buttons
sigc::scoped_connection browseConn
std::map< sb_type, Gtk::Label * > spin_labels
sigc::scoped_connection _pages_list_changed
std::map< selection_mode, Glib::ustring > selection_names
UI::Widget::ColorPicker & _background_color
void setDocument(SPDocument *document)
void setApp(InkscapeApplication *app)
sigc::scoped_connection _page_changed_connection
void saveExportHints(SPObject *target)
std::vector< SPPage const * > getSelectedPages() const
A drop down menu for choosing unit types.
Definition unit-menu.h:31
To do: update description of desktop.
Definition desktop.h:149
Typed SVG document implementation.
Definition document.h:101
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
Definition desktop.h:50
std::map< std::string, std::unique_ptr< BatchItem > > BatchItems
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
static const Point data[]
SPDesktop * desktop