[gnumeric] Remember export file name.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Remember export file name.
- Date: Tue, 7 Aug 2012 06:54:59 +0000 (UTC)
commit 088007b3d5b4e901d0194971eea10f606e4ebd80
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Tue Aug 7 00:53:21 2012 -0600
Remember export file name.
2012-08-07 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/gui-file.c: adjust all calls to workbook_update_history
(gui_file_save_as): get the correct file name,
* src/main-application.c: adjust all calls to workbook_update_history
* src/workbook-priv.h (_Workbook): add fields
* src/workbook-view.c (wb_view_save_as): save all file names
* src/workbook.c (workbook_update_history): add argument and change all callers
(workbook_dispose): free saved export file name
(workbook_set_saveinfo): save format level for exports too
(workbook_get_last_export_uri): new
* src/workbook.h (workbook_update_history): add argument
(workbook_get_last_export_uri): new
ChangeLog | 14 ++++++++++++++
NEWS | 1 +
src/gui-file.c | 11 +++++++----
src/main-application.c | 2 +-
src/workbook-priv.h | 2 ++
src/workbook-view.c | 16 ++++++++++------
src/workbook.c | 45 +++++++++++++++++++++++++++++++++++++--------
src/workbook.h | 4 +++-
8 files changed, 75 insertions(+), 20 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2c62849..50234fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2012-08-07 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/gui-file.c: adjust all calls to workbook_update_history
+ (gui_file_save_as): get the correct file name,
+ * src/main-application.c: adjust all calls to workbook_update_history
+ * src/workbook-priv.h (_Workbook): add fields
+ * src/workbook-view.c (wb_view_save_as): save all file names
+ * src/workbook.c (workbook_update_history): add argument and change all callers
+ (workbook_dispose): free saved export file name
+ (workbook_set_saveinfo): save format level for exports too
+ (workbook_get_last_export_uri): new
+ * src/workbook.h (workbook_update_history): add argument
+ (workbook_get_last_export_uri): new
+
2012-08-06 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/gui-file.c (gui_file_save_as): use the default format whenever
diff --git a/NEWS b/NEWS
index 57630ad..3aa6331 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,7 @@ Andreas:
* Provide new saver for uncompressed Gnumeric xml. [#672622]
* Do not change workbook save info when exporting. [#672323]
* Fix format selection on export. [#681316]
+ * Remember export file name.
Jean:
* Fix component references issues. [#680190]
diff --git a/src/gui-file.c b/src/gui-file.c
index 4c5958b..416b83e 100644
--- a/src/gui-file.c
+++ b/src/gui-file.c
@@ -126,7 +126,7 @@ gui_file_read (WBCGtk *wbcg, char const *uri,
if (wbv != NULL) {
gui_wb_view_show (wbcg, wbv);
- workbook_update_history (wb_view_get_workbook (wbv));
+ workbook_update_history (wb_view_get_workbook (wbv), FILE_SAVE_AS_SAVE);
return TRUE;
}
return FALSE;
@@ -592,7 +592,10 @@ 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 */
- wb_uri = go_doc_get_uri (GO_DOC (wb));
+ if (wb->last_export_uri && (type == FILE_SAVE_AS_EXPORT) && fs == wb->file_exporter)
+ wb_uri = wb->last_export_uri;
+ else
+ wb_uri = go_doc_get_uri (GO_DOC (wb));
if (wb_uri != NULL) {
char *basename = go_basename_from_uri (wb_uri);
char *dot = basename ? strrchr (basename, '.') : NULL;
@@ -655,7 +658,7 @@ gui_file_save_as (WBCGtk *wbcg, WorkbookView *wb_view, file_save_as_t type,
gtk_widget_destroy (GTK_WIDGET (fsel));
fsel = NULL;
if (wb_view_save_as (wb_view, fs, uri, GO_CMD_CONTEXT (wbcg)))
- workbook_update_history (wb);
+ workbook_update_history (wb, type);
}
g_free (uri);
@@ -695,7 +698,7 @@ gui_file_save (WBCGtk *wbcg, WorkbookView *wb_view)
ok = wb_view_save (wb_view, GO_CMD_CONTEXT (wbcg));
if (ok)
- workbook_update_history (wb);
+ workbook_update_history (wb, FILE_SAVE_AS_SAVE);
g_object_unref (wb);
return ok;
}
diff --git a/src/main-application.c b/src/main-application.c
index bdfc44c..a854514 100644
--- a/src/main-application.c
+++ b/src/main-application.c
@@ -330,7 +330,7 @@ main (int argc, char const **argv)
if (wbv != NULL) {
WBCGtk *wbcg;
- workbook_update_history (wb_view_get_workbook (wbv));
+ workbook_update_history (wb_view_get_workbook (wbv), FILE_SAVE_AS_SAVE);
wbcg = wbc_gtk_new (wbv, NULL, NULL, geometry);
geometry = NULL;
diff --git a/src/workbook-priv.h b/src/workbook-priv.h
index cb48b81..2d8a4ba 100644
--- a/src/workbook-priv.h
+++ b/src/workbook-priv.h
@@ -20,8 +20,10 @@ struct _Workbook {
gboolean is_placeholder;
GOFileFormatLevel file_format_level;
+ GOFileFormatLevel file_export_format_level;
GOFileSaver *file_saver;
GOFileSaver *file_exporter;
+ char *last_export_uri;
/* Undo support */
GSList *undo_commands;
diff --git a/src/workbook-view.c b/src/workbook-view.c
index 3f7c44b..a3bd75b 100644
--- a/src/workbook-view.c
+++ b/src/workbook-view.c
@@ -1113,12 +1113,16 @@ wb_view_save_as (WorkbookView *wbv, GOFileSaver *fs, char const *uri,
has_error = go_io_error_occurred (io_context);
has_warning = go_io_warning_occurred (io_context);
if (!has_error) {
- if (workbook_set_saveinfo (wb,
- go_file_saver_get_format_level (fs), fs) &&
- go_doc_set_uri (GO_DOC (wb), uri)) {
- go_doc_set_dirty (GO_DOC (wb), FALSE);
- /* See 634792. */
- go_doc_set_pristine (GO_DOC (wb), FALSE);
+ if (workbook_set_saveinfo
+ (wb, go_file_saver_get_format_level (fs), fs)) {
+ if (go_doc_set_uri (GO_DOC (wb), uri)) {
+ go_doc_set_dirty (GO_DOC (wb), FALSE);
+ /* See 634792. */
+ go_doc_set_pristine (GO_DOC (wb), FALSE);
+ }
+ } else {
+ g_free (wb->last_export_uri);
+ wb->last_export_uri = g_strdup (uri);
}
}
if (has_error || has_warning)
diff --git a/src/workbook.c b/src/workbook.c
index 3f980bb..9d7b7d1 100644
--- a/src/workbook.c
+++ b/src/workbook.c
@@ -79,15 +79,29 @@ cb_exporter_finalize (Workbook *wb, GOFileSaver *saver)
}
void
-workbook_update_history (Workbook *wb)
+workbook_update_history (Workbook *wb, file_save_as_t type)
{
g_return_if_fail (IS_WORKBOOK (wb));
- if (wb->doc.uri && wb->file_format_level >= GO_FILE_FL_MANUAL_REMEMBER) {
- const char *mimetype = wb->file_saver
- ? go_file_saver_get_mime_type (wb->file_saver)
- : NULL;
- gnm_app_history_add (wb->doc.uri, mimetype);
+ switch (type) {
+ case FILE_SAVE_AS_SAVE:
+ if (wb->doc.uri && wb->file_format_level >= GO_FILE_FL_MANUAL_REMEMBER) {
+ const char *mimetype = wb->file_saver
+ ? go_file_saver_get_mime_type (wb->file_saver)
+ : NULL;
+ gnm_app_history_add (wb->doc.uri, mimetype);
+ }
+ break;
+ case FILE_SAVE_AS_EXPORT:
+ default:
+ if (wb->last_export_uri &&
+ wb->file_export_format_level >= GO_FILE_FL_MANUAL_REMEMBER) {
+ const char *mimetype = wb->file_exporter
+ ? go_file_saver_get_mime_type (wb->file_exporter)
+ : NULL;
+ gnm_app_history_add (wb->last_export_uri, mimetype);
+ }
+ break;
}
}
@@ -104,6 +118,9 @@ workbook_dispose (GObject *wb_object)
if (wb->file_exporter)
workbook_set_saveinfo (wb, GO_FILE_FL_WRITE_ONLY, NULL);
+ g_free (wb->last_export_uri);
+ wb->last_export_uri = NULL;
+
/* Remove all the sheet controls to avoid displaying while we exit */
WORKBOOK_FOREACH_CONTROL (wb, view, control,
wb_control_sheet_remove_all (control););
@@ -192,8 +209,10 @@ workbook_init (GObject *object)
workbook_set_1904 (wb, FALSE);
wb->file_format_level = GO_FILE_FL_NEW;
+ wb->file_export_format_level = GO_FILE_FL_NEW;
wb->file_saver = NULL;
- wb->file_exporter = NULL;
+ wb->file_exporter = NULL;
+ wb->last_export_uri = NULL;
wb->during_destruction = FALSE;
wb->being_reordered = FALSE;
@@ -422,8 +441,10 @@ workbook_set_saveinfo (Workbook *wb, GOFileFormatLevel level, GOFileSaver *fs)
(GWeakNotify) cb_saver_finalize, wb);
}
- if (level != GO_FILE_FL_AUTO)
+ if (level != GO_FILE_FL_AUTO) {
+ wb->file_export_format_level = level;
return FALSE;
+ }
wb->file_format_level = level;
return TRUE;
}
@@ -444,6 +465,14 @@ workbook_get_file_exporter (Workbook *wb)
return wb->file_exporter;
}
+gchar const *
+workbook_get_last_export_uri (Workbook *wb)
+{
+ g_return_val_if_fail (IS_WORKBOOK (wb), NULL);
+
+ return wb->last_export_uri;
+}
+
/**
* workbook_foreach_cell_in_range:
*
diff --git a/src/workbook.h b/src/workbook.h
index 139c787..9a3d8b3 100644
--- a/src/workbook.h
+++ b/src/workbook.h
@@ -5,6 +5,7 @@
#include "gnumeric.h"
#include <goffice/goffice.h>
#include <glib-object.h>
+#include "gui-file.h"
G_BEGIN_DECLS
@@ -47,9 +48,10 @@ void workbook_optimize_style (Workbook *wb);
/* IO Routines */
gboolean workbook_set_saveinfo (Workbook *wb, GOFileFormatLevel lev,
GOFileSaver *saver);
-void workbook_update_history (Workbook *wb);
+void workbook_update_history (Workbook *wb, file_save_as_t type);
GOFileSaver *workbook_get_file_saver (Workbook *wb);
GOFileSaver *workbook_get_file_exporter (Workbook *wb);
+gchar const *workbook_get_last_export_uri (Workbook *wb);
/* See also sheet_cell_foreach_range */
GnmValue *workbook_foreach_cell_in_range (GnmEvalPos const *pos,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]