Inkscape
Vector Graphics Editor
export-lists.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/* Authors:
3 * Anshudhar Kumar Singh <anshudhar2001@gmail.com>
4 *
5 * Copyright (C) 2021 Authors
6 *
7 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
8 */
9
10#ifndef SP_EXPORT_HELPER_H
11#define SP_EXPORT_HELPER_H
12
13#include <map>
14#include <string>
15#include <2geom/rect.h>
16#include <glibmm/refptr.h>
17#include <gtkmm/comboboxtext.h>
18#include <gtkmm/grid.h>
19
21#include "preferences.h"
22
23namespace Gtk {
24class Builder;
25class MenuButton;
26class Popover;
27class SpinButton;
28class Viewport;
29} // namespace Gtk
30
31class SPDocument;
32class SPItem;
33class SPPage;
34
35namespace Inkscape {
36
37namespace Util {
38class Unit;
39} // namespace Util
40
41namespace Extension {
42class Output;
43} // namespace Extension
44
45namespace UI::Dialog {
46
47inline constexpr auto EXPORT_COORD_PRECISION = 3;
48inline constexpr auto SP_EXPORT_MIN_SIZE = 1.0;
49#define DPI_BASE Inkscape::Util::Quantity::convert(1, "in", "px")
50
51// Class for storing and manipulating extensions
52class ExtensionList : public Gtk::ComboBoxText
53{
54public:
56 ExtensionList(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &refGlade);
57 ~ExtensionList() override;
58
59 void setup();
60 std::string getFileExtension();
61 void setExtensionFromFilename(std::string const &filename);
62 void removeExtension(std::string &filename);
63 void createList();
64 Gtk::MenuButton *getPrefButton() const { return _pref_button; }
66
67private:
68 void init();
69 void on_changed() override;
70
72 std::map<std::string, Inkscape::Extension::Output *> ext_to_mod;
73
75 Glib::RefPtr<Gtk::Builder> _builder;
76 Gtk::MenuButton *_pref_button = nullptr;
77 Gtk::Popover *_pref_popover = nullptr;
78 Gtk::Viewport *_pref_holder = nullptr;
79};
80
81class ExportList : public Gtk::Grid
82{
83public:
84 ExportList() = default;
85 ExportList(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &)
86 : Gtk::Grid(cobject)
87 {
88 }
89 ~ExportList() override = default;
90
91public:
92 void setup();
93 void append_row();
94 void delete_row(Gtk::Widget *widget);
95 std::string get_suffix(int row);
97 void removeExtension(std::string &filename);
98 double get_dpi(int row);
99 int get_rows() { return _num_rows; }
100
101private:
103 double default_dpi = 96.00;
104
105private:
106 bool _initialised = false;
107 int _num_rows = 0;
108 int _suffix_col = 0;
110 int _prefs_col = 2;
111 int _dpi_col = 3;
112 int _delete_col = 4;
113};
114
115} // namespace UI::Dialog
116
117} // namespace Inkscape
118
119#endif // SP_EXPORT_HELPER_H
120
121/*
122 Local Variables:
123 mode:c++
124 c-file-style:"stroustrup"
125 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
126 indent-tabs-mode:nil
127 fill-column:99
128 End:
129*/
130// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Preference storage class.
Definition: preferences.h:63
ExportList(BaseObjectType *cobject, const Glib::RefPtr< Gtk::Builder > &)
Definition: export-lists.h:85
void removeExtension(std::string &filename)
~ExportList() override=default
Inkscape::Preferences * prefs
Definition: export-lists.h:102
std::string get_suffix(int row)
Inkscape::Extension::Output * getExtension(int row)
void delete_row(Gtk::Widget *widget)
Glib::RefPtr< Gtk::Builder > _builder
Definition: export-lists.h:75
Inkscape::Extension::Output * getExtension()
Returns the Output extension currently selected in this dropdown.
void removeExtension(std::string &filename)
Removes the file extension, if it's one of the extensions in the list.
std::map< std::string, Inkscape::Extension::Output * > ext_to_mod
Definition: export-lists.h:72
Gtk::MenuButton * getPrefButton() const
Definition: export-lists.h:64
std::string getFileExtension()
Returns the file extension (file ending) of the currently selected extension.
void setExtensionFromFilename(std::string const &filename)
Typed SVG document implementation.
Definition: document.h:106
Base class for visual SVG elements.
Definition: sp-item.h:107
Definition: sp-page.h:31
Definition: desktop.h:51
constexpr auto SP_EXPORT_MIN_SIZE
Definition: export-lists.h:48
constexpr auto EXPORT_COORD_PRECISION
Definition: export-lists.h:47
Miscellaneous supporting code.
Definition: color-conv.cpp:9
CMYK to sRGB conversion routines.
std::unique_ptr< Preferences::PreferencesObserver > PrefObserver
Definition: preferences.h:700
Singleton class to access the preferences file in a convenient way.
Axis-aligned rectangle.