export.cpp revision a4f5285714e41e9b1a29422b6fa5b520c3d5624a
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Lauris Kaplinski <lauris@kaplinski.com>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * bulia byak <buliabyak@users.sf.net>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Peter Bostrom
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Jon A. Cruz <jon@joncruz.org>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Abhishek Sharma
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Kris De Gussem <Kris.DeGussem@gmail.com>
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Copyright (C) 1999-2007, 2012 Authors
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib * Copyright (C) 2001-2002 Ximian, Inc.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * Released under GNU GPL, read the file 'COPYING' for more information
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh// This has to be included prior to anything that includes setjmp.h, it croaks otherwise
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh#if GLIBMM_DISABLE_DEPRECATED && HAVE_GLIBMM_THREADS_H
54e660c4de9d37185e3953165d053526632ef4f0johanengelen# include <libgnomevfs/gnome-vfs-init.h> // gnome_vfs_initialized
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh// required to set status message after export
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh#define DPI_BASE Inkscape::Util::Quantity::convert(1, "in", "px")
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh#include "../../desktop-handles.h"
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh#include "../../document.h"
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh#include "../../document-undo.h"
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh MessageCleaner(Inkscape::MessageId messageId, SPDesktop *desktop) :
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh MessageCleaner &operator=(MessageCleaner const &other);
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen} // namespace
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh/** A list of strings that is used both in the preferences, and in the
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh data fields to describe the various values of \c selection_type. */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshstatic const char * selection_names[SELECTION_NUMBER_OF] = {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh/** The names on the buttons for the various selection types. */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshstatic const char * selection_labels[SELECTION_NUMBER_OF] = {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh N_("_Page"), N_("_Drawing"), N_("_Selection"), N_("_Custom")
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh UI::Widget::Panel ("", "/dialogs/export/", SP_VERB_DIALOG_EXPORT),
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh browse_image(Gtk::StockID(Gtk::Stock::INDEX), Gtk::ICON_SIZE_BUTTON),
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh batch_export(_("B_atch export all selected objects"), _("Export each selected object into its own PNG file, using export hints if any (caution, overwrites without asking!)")),
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh hide_export(_("Hide a_ll except selected"), _("In the exported image, hide all objects except those that are selected")),
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen closeWhenDone(_("Close when complete"), _("Once the export completes, close this dialog")),
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh export_image(Gtk::StockID(Gtk::Stock::APPLY), Gtk::ICON_SIZE_BUTTON),
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen /* Export area frame */
54e660c4de9d37185e3953165d053526632ef4f0johanengelen Gtk::Label* lbl = new Gtk::Label(_("<b>Export area</b>"), Gtk::ALIGN_START);
54e660c4de9d37185e3953165d053526632ef4f0johanengelen /* Units box */
54e660c4de9d37185e3953165d053526632ef4f0johanengelen /* gets added to the vbox later, but the unit selector is needed
54e660c4de9d37185e3953165d053526632ef4f0johanengelen earlier than that */
54e660c4de9d37185e3953165d053526632ef4f0johanengelen unit_selector.setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR);
54e660c4de9d37185e3953165d053526632ef4f0johanengelen unit_selector.setUnit(sp_desktop_namedview(desktop)->doc_units->abbr);
54e660c4de9d37185e3953165d053526632ef4f0johanengelen unitChangedConn = unit_selector.signal_changed().connect(sigc::mem_fun(*this, &Export::onUnitChanged));
54e660c4de9d37185e3953165d053526632ef4f0johanengelen unitbox.pack_end(unit_selector, false, false, 0);
54e660c4de9d37185e3953165d053526632ef4f0johanengelen unitbox.pack_end(units_label, false, false, 3);
54e660c4de9d37185e3953165d053526632ef4f0johanengelen for (int i = 0; i < SELECTION_NUMBER_OF; i++) {
54e660c4de9d37185e3953165d053526632ef4f0johanengelen selectiontype_buttons[i] = new Gtk::RadioButton(_(selection_labels[i]), true);
54e660c4de9d37185e3953165d053526632ef4f0johanengelen if (i > 0) {
54e660c4de9d37185e3953165d053526632ef4f0johanengelen Gtk::RadioButton::Group group = selectiontype_buttons[0]->get_group();
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen togglebox.pack_start(*selectiontype_buttons[i], false, true, 0);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh selectiontype_buttons[i]->signal_clicked().connect(sigc::mem_fun(*this, &Export::onAreaToggled));
54e660c4de9d37185e3953165d053526632ef4f0johanengelen x0_adj = createSpinbutton ( "x0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0,
54e660c4de9d37185e3953165d053526632ef4f0johanengelen t, 0, 0, _("_x0:"), "", EXPORT_COORD_PRECISION, 1,
54e660c4de9d37185e3953165d053526632ef4f0johanengelen x1_adj = createSpinbutton ( "x1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0,
e21d4ac16bee82a55fd227660aa14af10ecac9b1johanengelen t, 0, 1, _("x_1:"), "", EXPORT_COORD_PRECISION, 1,
e21d4ac16bee82a55fd227660aa14af10ecac9b1johanengelen width_adj = createSpinbutton ( "width", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0,
e21d4ac16bee82a55fd227660aa14af10ecac9b1johanengelen t, 0, 2, _("Wid_th:"), "", EXPORT_COORD_PRECISION, 1,
e21d4ac16bee82a55fd227660aa14af10ecac9b1johanengelen y0_adj = createSpinbutton ( "y0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0,
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen t, 2, 0, _("_y0:"), "", EXPORT_COORD_PRECISION, 1,
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen y1_adj = createSpinbutton ( "y1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0,
54e660c4de9d37185e3953165d053526632ef4f0johanengelen t, 2, 1, _("y_1:"), "", EXPORT_COORD_PRECISION, 1,
54e660c4de9d37185e3953165d053526632ef4f0johanengelen height_adj = createSpinbutton ( "height", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0,
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen t, 2, 2, _("Hei_ght:"), "", EXPORT_COORD_PRECISION, 1,
54e660c4de9d37185e3953165d053526632ef4f0johanengelen area_box.pack_start(togglebox, false, false, 3);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh singleexport_box.pack_start(area_box, false, false, 0);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh } // end of area box
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /* Bitmap size frame */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh bm_label = new Gtk::Label(_("<b>Image size</b>"), Gtk::ALIGN_START);
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen bmwidth_adj = createSpinbutton ( "bmwidth", 16.0, 1.0, 1000000.0, 1.0, 10.0,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh prefs->getDouble("/dialogs/export/defaultxdpi/value", DPI_BASE),
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh bmheight_adj = createSpinbutton ( "bmheight", 16.0, 1.0, 1000000.0, 1.0, 10.0,
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * There's no way to set ydpi currently, so we use the defaultxdpi value here, too...
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh ydpi_adj = createSpinbutton ( "ydpi", prefs->getDouble("/dialogs/export/defaultxdpi/value", DPI_BASE),
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /* File entry */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh flabel = new Gtk::Label(_("<b>_Filename</b>"), Gtk::ALIGN_START, Gtk::ALIGN_CENTER, true);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh filename_box.pack_start (filename_entry, true, true, 0);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Gtk::HBox* browser_im_label = new Gtk::HBox(false, 3);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh filename_box.pack_end (browse_button, false, false, 4);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // focus is in the filename initially:
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // mnemonic in frame label moves focus to filename:
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen batch_box.pack_start(batch_export, false, false);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh hide_export.set_active (prefs->getBool("/dialogs/export/hideexceptselected/value", false));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /* Export Button row */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Gtk::HBox* export_image_label = new Gtk::HBox(false, 3);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh export_button.set_tooltip_text (_("Export the bitmap file with these settings"));
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib button_box.pack_start(closeWhenDone, true, true, 0 );
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh button_box.pack_end(export_button, false, false, 0);
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen /* Main dialog */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /* Signal handlers */
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib filename_entry.signal_changed().connect( sigc::mem_fun(*this, &Export::onFilenameModified) );
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // pressing enter in the filename field is the same as clicking export:
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh filename_entry.signal_activate().connect(sigc::mem_fun(*this, &Export::onExport) );
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh browse_button.signal_clicked().connect(sigc::mem_fun(*this, &Export::onBrowse));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh batch_export.signal_clicked().connect(sigc::mem_fun(*this, &Export::onBatchClicked));
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen export_button.signal_clicked().connect(sigc::mem_fun(*this, &Export::onExport));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh hide_export.signal_clicked().connect(sigc::mem_fun(*this, &Export::onHideExceptSelected));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &Export::setTargetDesktop) );
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib if (this->desktop) {
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &Export::onSelectionChanged)));
17d87f5698f5c2958d38c6a6207c7b322a7adaf9johanengelen subselChangedConn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &Export::onSelectionChanged)));
26b62dfb088a00b6debad350538a64c2af145f50johanengelen //// Must check flags, so can't call widget_setup() directly.
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &Export::onSelectionModified)));
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * set the default filename to be that of the current path + document
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * with .png extension
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * One thing to notice here is that this filename may get
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * overwritten, but it won't happen here. The filename gets
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * written into the text field, but then the button to select
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * the area gets set. In that code the filename can be changed
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * if there are some with presidence in the document. So, while
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib * this code sets the name first, it may not be the one users
861fa436e7a6d6ff3eaa889b2298e0b82a0b238ctheadib * really see.
861fa436e7a6d6ff3eaa889b2298e0b82a0b238ctheadib if ( SP_ACTIVE_DOCUMENT && SP_ACTIVE_DOCUMENT->getURI() )
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib const gchar *text_extension = get_file_save_extension (Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS).c_str();
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib oextension = dynamic_cast<Inkscape::Extension::Output *>(Inkscape::Extension::db.get(text_extension));
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib gchar * old_extension = oextension->get_extension();
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib extension_point = g_strrstr(uri_copy, old_extension);
45d0b0d0dc24df8e321cbe8a085ab9b1f60b4a42theadibGlib::RefPtr<Gtk::Adjustment> Export::createSpinbutton( gchar const * /*key*/, float val, float min, float max,
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadibGtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, float min, float max,
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib Glib::RefPtr<Gtk::Adjustment> adj = Gtk::Adjustment::create(val, min, max, step, page, 0);
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib Gtk::Adjustment *adj = new Gtk::Adjustment ( val, min, max, step, page, 0 );
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib t->attach (*l, x + pos, x + pos + 1, y, y + 1, Gtk::EXPAND, Gtk::EXPAND, 0, 0 );
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib Gtk::SpinButton *sb = new Gtk::SpinButton(adj, 1.0, digits);
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib Gtk::SpinButton *sb = new Gtk::SpinButton(*adj, 1.0, digits);
5c45c5153b0415f7573f69f4ee3e946b5872a8d1theadib t->attach (*sb, x + pos, x + pos + 1, y, y + 1, Gtk::EXPAND, Gtk::EXPAND, 0, 0 );
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh t->attach (*l, x + pos, x + pos + 1, y, y + 1, Gtk::EXPAND, Gtk::EXPAND, 0, 0 );
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh adj->signal_value_changed().connect( sigc::mem_fun(*this, cb) );
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh} // end of createSpinbutton()
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6mikloshGlib::ustring Export::create_filepath_from_id (Glib::ustring id, const Glib::ustring &file_entry_text)
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh { /* This should never happen */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh directory = Glib::path_get_dirname(file_entry_text);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /* Grab document directory */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Glib::ustring filename = Glib::build_filename(directory, id+".png");
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh gint num = g_slist_length((GSList *) sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList());
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh batch_export.set_label(g_strdup_printf (ngettext("B_atch export %d selected object","B_atch export %d selected objects",num), num));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh //hide_export.set_sensitive (num > 0);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /* Try using the preferences */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Glib::ustring what = prefs->getString("/dialogs/export/exportarea/value");
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh for (i = 0; i < SELECTION_NUMBER_OF; i++) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh selectiontype_buttons[current_key]->set_active(true);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * If selection changed or a different document activated, we must
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * recalculate any chosen areas.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Inkscape::Selection *selection = sp_desktop_selection (SP_ACTIVE_DESKTOP);
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib if ((current_key == SELECTION_DRAWING || current_key == SELECTION_PAGE) &&
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh (sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false &&
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh selectiontype_buttons[current_key]->set_active(true);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh was_empty = (sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty();
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Geom::OptRect bbox = doc->getRoot()->desktopVisualBounds();
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /* Do nothing for page or for custom */
3955580a5a68a873b098921626f5b9d841b964ecjaspervdg/// Called when one of the selection buttons was toggled.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /* Find which button is active */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh for (int i = 0; i < SELECTION_NUMBER_OF; i++) {
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh bbox = Geom::Rect(Geom::Point(0.0, 0.0),Geom::Point(0.0, 0.0));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /* Notice how the switch is used to 'fall through' here to get
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh various backups. If you modify this without noticing you'll
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh probabaly screw something up. */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false)
4b1c2be41ce8c1a88502c1b1885ad1468646fbfftheadib bbox = sp_desktop_selection (SP_ACTIVE_DESKTOP)->visualBounds();
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /* Only if there is a selection that we can set
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh do we break, otherwise we fall through to the
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // std::cout << "Using selection: SELECTION" << std::endl;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh * This returns wrong values if the document has a viewBox.
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh /* If the drawing is valid, then we'll use it and break
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh otherwise we drop through to the page settings */
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // std::cout << "Using selection: DRAWING" << std::endl;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh Geom::Point(doc->getWidth().value("px"), doc->getHeight().value("px")));
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // std::cout << "Using selection: PAGE" << std::endl;
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh } // switch
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh // remember area setting
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh prefs->setString("/dialogs/export/exportarea/value", selection_names[current_key]);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh } // end of if ( SP_ACTIVE_DESKTOP )
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh sp_document_get_export_hints (doc, filename, &xdpi, &ydpi);
b7f07692f95074fdcf74c7350fbf5f3099ffc1b6miklosh if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) {
case SELECTION_CUSTOM:
interrupted = true;
return TRUE;
interrupted = true;
return FALSE;
if (total > 0) {
if (self) {
int evtcount = 0;
return TRUE;
if (exporting) {
return dlg;
if ( !dot )
return filename;
Glib::ustring Export::absolutize_path_from_document_location (SPDocument *doc, const Glib::ustring &filename)
return path;
if (!desktop) return;
bool exportSuccessful = false;
gint n = 0;
for (GSList *i = const_cast<GSList *>(sp_desktop_selection(desktop)->itemList()); i && !interrupted; i = i->next) {
if (!filename) {
const gchar *dpi_hint = item->getRepr()->attribute("inkscape:export-xdpi"); // only xdpi, ydpi is always the same now
if (dpi_hint) {
if (area) {
setExporting(false);
delete prog_dlg;
interrupted = false;
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The chosen area to be exported is invalid."));
|| !Inkscape::IO::file_test(dirname.c_str(), (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) )
safeDir);
prog_dlg = create_progress_dialog (Glib::ustring::compose(_("Exporting %1 (%2 x %3)"), fn, width, height));
exportSuccessful = true;
desktop->messageStack()->flashF(Inkscape::INFORMATION_MESSAGE, _("Drawing exported to <b>%s</b>."), safeFile);
filename_modified = false;
setExporting(false);
delete prog_dlg;
interrupted = false;
switch (current_key) {
case SELECTION_PAGE:
case SELECTION_DRAWING: {
bool modified = false;
modified = true;
modified = true;
modified = true;
if (modified) {
case SELECTION_SELECTION: {
bool modified = false;
if (docURI)
( !docURI ||
modified = true;
modified = true;
modified = true;
if (modified) {
if (item) {
/// @todo refactor this code to use ui/dialogs/filedialog.cpp
NULL );
#ifdef WITH_GNOME_VFS
if (gnome_vfs_initialized()) {
#ifdef WIN32
// code in this section is borrowed from ui/dialogs/filedialogimpl-win32.cpp
WCHAR* title_string = (WCHAR*)g_utf8_to_utf16(_("Select a filename for exporting"), -1, NULL, NULL, NULL);
#if WITH_GTKMM_3_0
// TODO: Move this to nr-rect-fns.h.
static const selection_type test_order[SELECTION_NUMBER_OF] = {SELECTION_SELECTION, SELECTION_DRAWING, SELECTION_PAGE, SELECTION_CUSTOM};
for (int i = 0; i < SELECTION_NUMBER_OF; i++) {
switch (this_test[i]) {
case SELECTION_SELECTION:
case SELECTION_DRAWING: {
case SELECTION_PAGE: {
#if WITH_GTKMM_3_0
if (update) {
update = true;
detectSize();
update = false;
#if WITH_GTKMM_3_0
if (update) {
update = true;
detectSize();
update = false;
if (update) {
update = true;
update = false;
if (update) {
update = true;
update = false;
if (update) {
update = true;
setImageY ();
update = false;
if (update) {
update = true;
setImageX ();
update = false;
if (update) {
update = true;
setImageY ();
update = false;
update = true;
update = false;
#if WITH_GTKMM_3_0
if (adj) {
#if WITH_GTKMM_3_0
#if WITH_GTKMM_3_0
if (!adj) {
#if WITH_GTKMM_3_0
filename_modified = false;
filename_modified = true;