summaryrefslogtreecommitdiffstats
path: root/src/file.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-01-12 19:02:53 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-01-12 19:02:53 +0000
commitad38e0a823da469ba8a4866e0d6c46c87ed1b69c (patch)
tree10d2a97375a51ad9ab32e9de58a1fb513e82cdef /src/file.cpp
parentUpdate to trunk (diff)
parentpass class variables by reference for performance (diff)
downloadinkscape-ad38e0a823da469ba8a4866e0d6c46c87ed1b69c.tar.gz
inkscape-ad38e0a823da469ba8a4866e0d6c46c87ed1b69c.zip
update to trunk
(bzr r12588.1.31)
Diffstat (limited to 'src/file.cpp')
-rw-r--r--src/file.cpp42
1 files changed, 15 insertions, 27 deletions
diff --git a/src/file.cpp b/src/file.cpp
index cec634c9b..35039fed3 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -360,11 +360,8 @@ void sp_file_revert_dialog()
bool do_revert = true;
if (doc->isModifiedSinceSave()) {
- gchar *text = g_strdup_printf(_("Changes will be lost! Are you sure you want to reload document %s?"), uri);
-
- bool response = desktop->warnDialog (text);
- g_free(text);
-
+ Glib::ustring tmpString = Glib::ustring::compose(_("Changes will be lost! Are you sure you want to reload document %1?"), uri);
+ bool response = desktop->warnDialog (tmpString);
if (!response) {
do_revert = false;
}
@@ -843,38 +840,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 +871,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 +898,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) {