summaryrefslogtreecommitdiffstats
path: root/src/file.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-01-09 16:47:29 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-01-09 16:47:29 +0000
commit13abf3e6f87b4bc85708bfd8d8fe93deb76facdc (patch)
tree8f5021ba5ae6123d242f5740c45611266a317071 /src/file.cpp
parentFix a bug whith oposite handles on node move,and a little cleanup (diff)
parentFix for bug #1266113 (xcf export only allows 90 dpi). (diff)
downloadinkscape-13abf3e6f87b4bc85708bfd8d8fe93deb76facdc.tar.gz
inkscape-13abf3e6f87b4bc85708bfd8d8fe93deb76facdc.zip
update to trunk
(bzr r11950.1.233)
Diffstat (limited to 'src/file.cpp')
-rw-r--r--src/file.cpp35
1 files changed, 13 insertions, 22 deletions
diff --git a/src/file.cpp b/src/file.cpp
index cec634c9b..babc4df99 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -843,38 +843,30 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens
if (extension)
filename_extension = extension->get_extension();
- Glib::ustring save_path;
- Glib::ustring save_loc;
-
- save_path = Inkscape::Extension::get_file_save_path(doc, save_method);
+ Glib::ustring save_path = Inkscape::Extension::get_file_save_path(doc, save_method);
if (!Inkscape::IO::file_test(save_path.c_str(),
(GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
- save_path = "";
+ save_path.clear();
- if (save_path.size()<1)
+ if (save_path.empty())
save_path = g_get_home_dir();
- save_loc = save_path;
+ Glib::ustring save_loc = save_path;
save_loc.append(G_DIR_SEPARATOR_S);
- // TODO fixed buffer is bad:
- char formatBuf[256];
int i = 1;
if ( !doc->getURI() ) {
// We are saving for the first time; create a unique default filename
- snprintf(formatBuf, 255, _("drawing%s"), filename_extension.c_str());
- save_loc.append(formatBuf);
+ save_loc = save_loc + Glib::ustring(_("drawing")) + filename_extension;
while (Inkscape::IO::file_test(save_loc.c_str(), G_FILE_TEST_EXISTS)) {
save_loc = save_path;
save_loc.append(G_DIR_SEPARATOR_S);
- snprintf(formatBuf, 255, _("drawing-%d%s"), i++, filename_extension.c_str());
- save_loc.append(formatBuf);
+ save_loc = save_loc + Glib::ustring::compose(_("drawing-%1"), i++) + filename_extension;
}
} else {
- snprintf(formatBuf, 255, _("%s"), Glib::path_get_basename(doc->getURI()).c_str());
- save_loc.append(formatBuf);
+ save_loc.append(Glib::path_get_basename(doc->getURI()));
}
// convert save_loc from utf-8 to locale
@@ -882,7 +874,7 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens
// Inkscape::IO?
Glib::ustring save_loc_local = Glib::filename_from_utf8(save_loc);
- if ( save_loc_local.size() > 0)
+ if (!save_loc_local.empty())
save_loc = save_loc_local;
//# Show the SaveAs dialog
@@ -909,28 +901,27 @@ sp_file_save_dialog(Gtk::Window &parentWindow, SPDocument *doc, Inkscape::Extens
bool success = saveDialog->show();
if (!success) {
delete saveDialog;
+ if(doc_title) g_free(doc_title);
return success;
}
// set new title here (call RDF to ensure metadata and title element are updated)
rdf_set_work_entity(doc, rdf_find_entity("title"), saveDialog->getDocTitle().c_str());
- // free up old string
- if(doc_title) g_free(doc_title);
Glib::ustring fileName = saveDialog->getFilename();
Inkscape::Extension::Extension *selectionType = saveDialog->getSelectionType();
delete saveDialog;
-
saveDialog = 0;
+ if(doc_title) g_free(doc_title);
- if (fileName.size() > 0) {
+ if (!fileName.empty()) {
Glib::ustring newFileName = Glib::filename_to_utf8(fileName);
- if ( newFileName.size()>0 )
+ if (!newFileName.empty())
fileName = newFileName;
else
- g_warning( "Error converting save filename to UTF-8." );
+ g_warning( "Error converting filename for saving to UTF-8." );
Inkscape::Extension::Output *omod = dynamic_cast<Inkscape::Extension::Output *>(selectionType);
if (omod) {