12#include <glibmm/i18n.h>
13#include <glibmm/convert.h>
14#include <glibmm/ustring.h>
15#include <gtkmm/builder.h>
16#include <gtkmm/label.h>
17#include <gtkmm/menubutton.h>
18#include <gtkmm/popover.h>
19#include <gtkmm/spinbutton.h>
20#include <gtkmm/viewport.h>
40 :
Gtk::ComboBoxText{cobject}
57 if (
auto gui = ext->autogui(
nullptr,
nullptr)) {
58 _pref_holder->set_child(*gui);
59 _pref_popover->grab_focus();
67 auto cell_renderer =
dynamic_cast<Gtk::CellRendererText*
>(get_first_cell());
68 cell_renderer->set_fixed_size(125, -1);
69 cell_renderer->property_wrap_mode().set_value(Pango::WrapMode::WORD);
70 cell_renderer->property_wrap_width().set_value(5);
75 bool has_prefs =
false;
77 has_prefs = (ext->widget_visible_count() > 0);
87 bool export_all = prefs->
getBool(
"/dialogs/export/show_all_extensions",
false);
91 for (
auto omod : extensions) {
92 auto oid = Glib::ustring(omod->get_id());
93 if (!export_all && !omod->is_raster() && !omod->is_exported())
96 if (omod->deactivated())
98 this->
append(oid, omod->get_filetypename());
100 auto ext = omod->get_extension();
107 this->set_active_id(SP_MODULE_KEY_RASTER_PNG);
124 return Glib::filename_from_utf8(ext->get_extension());
136 filename.erase(filename.size()-ext.size());
145 this->set_active_id(omod->get_id());
159 auto const add_button = Gtk::make_managed<Gtk::Button>();
160 Glib::ustring label = _(
"Add Export");
161 add_button->set_label(label);
162 this->attach(*add_button, 0, 0, 5, 1);
166 auto const suffix_label = Gtk::make_managed<Gtk::Label>(_(
"Suffix"));
168 suffix_label->set_visible(
true);
170 auto const extension_label = Gtk::make_managed<Gtk::Label>(_(
"Format"));
172 extension_label->set_visible(
true);
174 auto const dpi_label = Gtk::make_managed<Gtk::Label>(_(
"DPI"));
175 this->attach(*dpi_label,
_dpi_col, 0, 1, 1);
176 dpi_label->set_visible(
true);
181 add_button->set_hexpand(
true);
182 add_button->set_visible(
true);
184 this->set_row_spacing(5);
185 this->set_column_spacing(2);
200 this->insert_row(current_row);
202 auto const suffix = Gtk::make_managed<Gtk::Entry>();
203 this->attach(*suffix,
_suffix_col, current_row, 1, 1);
204 suffix->set_width_chars(2);
205 suffix->set_hexpand(
true);
206 suffix->set_placeholder_text(_(
"Suffix"));
207 suffix->set_visible(
true);
209 auto const extension = Gtk::make_managed<ExtensionList>();
210 auto const dpi_sb = Gtk::make_managed<Gtk::SpinButton>();
213 extension->set_visible(
true);
215 this->attach(*extension->getPrefButton(),
_prefs_col, current_row, 1, 1);
218 extension->signal_changed().connect([=]() {
219 if (
auto ext = extension->getExtension()) {
220 dpi_sb->set_sensitive(ext->is_raster());
224 dpi_sb->set_digits(2);
225 dpi_sb->set_increments(0.1, 1.0);
226 dpi_sb->set_range(1.0, 100000.0);
228 dpi_sb->set_sensitive(
true);
229 dpi_sb->set_width_chars(6);
230 dpi_sb->set_max_width_chars(6);
231 dpi_sb->set_visible(
true);
232 this->attach(*dpi_sb,
_dpi_col, current_row, 1, 1);
234 auto const pIcon = Gtk::manage(
sp_get_icon_image(
"window-close", Gtk::IconSize::NORMAL));
235 auto const delete_btn = Gtk::make_managed<Gtk::Button>();
236 delete_btn->set_has_frame(
false);
237 delete_btn->set_child(*pIcon);
238 this->attach(*delete_btn,
_delete_col, current_row, 1, 1);
239 delete_btn->signal_clicked().connect(sigc::bind(sigc::mem_fun(*
this, &
ExportList::delete_row), delete_btn));
246 if (widget ==
nullptr) {
253 query_child(*widget, ignore, row, ignore, ignore);
257 auto const d_button_0 = this->get_child_at(
_delete_col, 1);
259 d_button_0->set_visible(
false);
266 std::string suffix =
"";
267 Gtk::Entry *entry =
dynamic_cast<Gtk::Entry *
>(this->get_child_at(
_suffix_col, row + 1));
268 if (entry ==
nullptr) {
271 suffix = Glib::filename_from_utf8(entry->get_text());
283 auto spin_sb =
dynamic_cast<Gtk::SpinButton *
>(this->get_child_at(
_dpi_col, row + 1));
284 if (spin_sb ==
nullptr) {
287 dpi = spin_sb->get_value();
std::list< Output * > OutputList
OutputList & get_output_list(OutputList &ou_list)
Creates a list of all the Output extensions.
Extension * get(const gchar *key) const
This function looks up a Inkscape::Extension::Extension by using its unique id. It then returns a ref...
Preference storage class.
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
double getDouble(Glib::ustring const &pref_path, double def=0.0, Glib::ustring const &unit="")
Retrieve a floating point value.
static Preferences * get()
Access the singleton Preferences object.
std::unique_ptr< PreferencesObserver > createObserver(Glib::ustring path, std::function< void(const Preferences::Entry &new_value)> callback)
Create an observer watching preference 'path' and calling provided function when preference changes.
void removeExtension(std::string &filename)
Inkscape::Preferences * prefs
std::string get_suffix(int row)
Inkscape::Extension::Output * getExtension(int row)
void delete_row(Gtk::Widget *widget)
Glib::RefPtr< Gtk::Builder > _builder
Inkscape::Extension::Output * getExtension()
Returns the Output extension currently selected in this dropdown.
auto_connection _popover_signal
Gtk::MenuButton * _pref_button
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
~ExtensionList() override
void on_changed() override
std::string getFileExtension()
Returns the file extension (file ending) of the currently selected extension.
Gtk::Popover * _pref_popover
void setExtensionFromFilename(std::string const &filename)
Gtk::Viewport * _pref_holder
Gtk::Image * sp_get_icon_image(Glib::ustring const &icon_name, int size)
DB db
This is the actual database object.
Glib::ustring get_file_extension(Glib::ustring const &path)
Glib::RefPtr< Gtk::Builder > create_builder(const char *filename)
static void append(std::vector< T > &target, std::vector< T > &&source)
Singleton class to access the preferences file in a convenient way.