[gnumeric] GUI: Fix file extension for export.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GUI: Fix file extension for export.
- Date: Tue, 23 Apr 2013 17:29:49 +0000 (UTC)
commit 7de8a5c4fb6b8ea42184150214be1da8716e4e3b
Author: Morten Welinder <terra gnome org>
Date: Tue Apr 23 13:29:22 2013 -0400
GUI: Fix file extension for export.
ChangeLog | 5 +++++
src/gui-file.c | 30 +++++++++++++++++++++++++-----
2 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 95e0120..2d0db42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-23 Morten Welinder <terra gnome org>
+
+ * src/gui-file.c (gui_file_save_as): For export, change extension.
+ Fixes #698636.
+
2013-04-22 Morten Welinder <terra gnome org>
* src/gui-file.c (gui_file_read): Re-take focus if the read fails.
diff --git a/src/gui-file.c b/src/gui-file.c
index 8f85b17..d12e43c 100644
--- a/src/gui-file.c
+++ b/src/gui-file.c
@@ -637,12 +637,32 @@ gui_file_save_as (WBCGtk *wbcg, WorkbookView *wb_view, file_save_as_t type,
gtk_combo_box_set_active (format_combo, g_list_index (savers, fs));
/* Set default file name */
- if (!(wb_uri = workbook_get_last_export_uri (wb)) || (type != FILE_SAVE_AS_EXPORT)
- || (fs != workbook_get_file_exporter (wb)))
- wb_uri = go_doc_get_uri (GO_DOC (wb));
+ if (type == FILE_SAVE_AS_EXPORT) {
+ char *basename, *dot, *newname;
+ char const *ext = go_file_saver_get_extension (fs);
+
+ wb_uri = workbook_get_last_export_uri (wb);
+ if (!wb_uri || fs != workbook_get_file_exporter (wb))
+ wb_uri = go_doc_get_uri (GO_DOC (wb));
+ if (!wb_uri) wb_uri = _("Untitled");
+ if (!ext) ext = "txt";
+
+ basename = go_basename_from_uri (wb_uri);
+ dot = strchr (basename, '.');
+ if (dot) *dot = 0;
+ newname = g_strconcat (basename, ".", ext, NULL);
+
+ gtk_file_chooser_set_uri (fsel, wb_uri);
+ gtk_file_chooser_set_current_name (fsel, newname);
- if (wb_uri != NULL) {
- char *basename = go_basename_from_uri (wb_uri);
+ g_free (basename);
+ g_free (newname);
+ } else {
+ char *basename;
+
+ wb_uri = go_doc_get_uri (GO_DOC (wb));
+ if (!wb_uri) wb_uri = _("Untitled");
+ basename = go_basename_from_uri (wb_uri);
/*
* If the file exists, the following is dominated by the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]