export.cpp revision e09a40ce165febca5e791e93d47e2c7df3de8039
919N/A#ifdef HAVE_CONFIG_H
1319N/A#ifdef WITH_GNOME_VFS
577N/A#include "ui/widget/unit-menu.h"
970N/A#include "inkscape-private.h"
970N/A#include "document.h"
970N/A#include "document-undo.h"
970N/A#include "desktop-handles.h"
970N/A#include "selection.h"
970N/A#include "sp-namedview.h"
970N/A#include "selection-chemistry.h"
1072N/A#include "dialogs/dialog-events.h"
577N/A#include "preferences.h"
577N/A#include "interface.h"
577N/A#include "helper/png-write.h"
1196N/A#include "libgdl/gdl-dock-item.h"
1097N/A#include "message-stack.h"
970N/A#include "../../desktop-handles.h"
970N/A#include "../../document.h"
#include "../../document-undo.h"
#include "verbs.h"
#include "export.h"
class MessageCleaner
namespace Inkscape {
namespace UI {
namespace Dialog {
filename_modified(false),
was_empty(true),
update(false),
togglebox(true, 0),
singleexport_box(false, 0),
unitbox(false, 0),
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!)")),
hide_export(_("Hide a_ll except selected"), _("In the exported image, hide all objects except those that are selected")),
_prog(),
interrupted(false),
deskTrack(),
if (desktop) {
unitChangedConn = unit_selector.signal_changed().connect(sigc::mem_fun(*this, &Export::onUnitChanged));
for (int i = 0; i < SELECTION_NUMBER_OF; i++) {
#if WITH_GTKMM_3_0
#if WITH_GTKMM_3_0
ydpi_adj = createSpinbutton ( "ydpi", prefs->getDouble("/dialogs/export/defaultxdpi/value", DPI_BASE),
desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &Export::setTargetDesktop) );
setExporting(false);
if (this->desktop) {
selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &Export::onSelectionChanged)));
subselChangedConn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &Export::onSelectionChanged)));
selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &Export::onSelectionModified)));
const gchar *text_extension = get_file_save_extension (Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS).c_str();
oextension = dynamic_cast<Inkscape::Extension::Output *>(Inkscape::Extension::db.get(text_extension));
#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> Export::createSpinbutton( gchar const * /*key*/, float val, float min, float max,
#if WITH_GTKMM_3_0
int pos = 0;
#if WITH_GTKMM_3_0
l->set_hexpand();
l->set_vexpand();
pos++;
#if WITH_GTKMM_3_0
pos++;
#if WITH_GTKMM_3_0
l->set_hexpand();
l->set_vexpand();
pos++;
if (cb) {
return adj;
Glib::ustring Export::create_filepath_from_id (Glib::ustring id, const Glib::ustring &file_entry_text)
if (docURI) {
return filename;
batch_export.set_label(g_strdup_printf (ngettext("B_atch export %d selected object","B_atch export %d selected objects",num), num));
//hide_export.set_sensitive (num > 0);
int i = SELECTION_NUMBER_OF;
for (i = 0; i < SELECTION_NUMBER_OF; i++) {
was_empty) {
if ( selection &&
switch (current_key) {
case SELECTION_DRAWING:
if ( SP_ACTIVE_DESKTOP ) {
if (bbox) {
case SELECTION_SELECTION:
if (bbox)
if (update) {
for (int i = 0; i < SELECTION_NUMBER_OF; i++) {
if ( SP_ACTIVE_DESKTOP )
switch (key) {
case SELECTION_SELECTION:
case SELECTION_DRAWING:
if (bbox) {
case SELECTION_PAGE:
case SELECTION_CUSTOM:
switch (key) {
case SELECTION_PAGE:
case SELECTION_DRAWING: {
case SELECTION_SELECTION:
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;