summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 35c4d9c)
raw | patch | inline | side by side (parent: 35c4d9c)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Fri, 21 Aug 2009 15:26:16 +0000 (15:26 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Fri, 21 Aug 2009 15:26:16 +0000 (15:26 +0000) |
src/dialogs/export.cpp | patch | blob | history |
diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp
index 2e41850edac8f895c55a032325ca2ba1b0706844..ce0786a01f6cab8efc6e95f2f23a28542ad4f873 100644 (file)
--- a/src/dialogs/export.cpp
+++ b/src/dialogs/export.cpp
}
}
+gchar *absolutize_path_from_document_location (SPDocument *doc, const gchar *filename)
+{
+ gchar *path = 0;
+ //Make relative paths go from the document location, if possible:
+ if (!g_path_is_absolute(filename) && doc->uri) {
+ gchar *dirname = g_path_get_dirname(doc->uri);
+ if (dirname) {
+ path = g_build_filename(dirname, filename, NULL);
+ g_free(dirname);
+ }
+ }
+ if (!path) {
+ path = g_strdup(filename);
+ }
+ return path;
+}
+
/// Called when export button is clicked
static void
sp_export_export_clicked (GtkButton */*button*/, GtkObject *base)
if (!filename) {
path = create_filepath_from_id (SP_OBJECT_ID(item), NULL);
} else {
- //Make relative paths go from the document location, if possible:
- if (!g_path_is_absolute(filename) && doc->uri) {
- gchar *dirname = g_path_get_dirname(doc->uri);
- if (dirname) {
- path = g_build_filename(dirname, filename, NULL);
- g_free(dirname);
- }
- }
- if (!path) {
- path = g_strdup(filename);
- }
+ path = absolutize_path_from_document_location(doc, filename);
}
// retrieve export dpi hints
return;
}
- gchar *dirname = g_path_get_dirname(filename);
+ // make sure that .png is the extension of the file:
+ gchar * filename_ext = filename_add_extension(filename, "png");
+ gtk_entry_set_text(GTK_ENTRY(fe), filename_ext);
+
+ gchar *path = absolutize_path_from_document_location(doc, filename_ext);
+
+ gchar *dirname = g_path_get_dirname(path);
if ( dirname == NULL
|| !Inkscape::IO::file_test(dirname, (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) )
{
g_free(safeDir);
g_free(error);
g_free(dirname);
+ g_free(path);
return;
}
g_free(dirname);
- // make sure that .png is the extension of the file:
- gchar * filename_ext = filename_add_extension(filename, "png");
- gtk_entry_set_text(GTK_ENTRY(fe), filename_ext);
-
- gchar *fn = g_path_get_basename (filename_ext);
+ gchar *fn = g_path_get_basename (path);
gchar *progress_text = g_strdup_printf (_("Exporting %s (%lu x %lu)"), fn, width, height);
g_free (fn);
g_free (progress_text);
/* Do export */
- if (!sp_export_png_file (sp_desktop_document (SP_ACTIVE_DESKTOP), filename_ext,
+ if (!sp_export_png_file (sp_desktop_document (SP_ACTIVE_DESKTOP), path,
Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi,
nv->pagecolor,
sp_export_progress_callback, base, FALSE,
hide ? (GSList *) sp_desktop_selection(SP_ACTIVE_DESKTOP)->itemList() : NULL
)) {
gchar * error;
- gchar * safeFile = Inkscape::IO::sanitizeString(filename);
+ gchar * safeFile = Inkscape::IO::sanitizeString(path);
error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile);
sp_ui_error_dialog(error);
g_free(safeFile);
}
g_free (filename_ext);
+ g_free (path);
}