[gnumeric] Clarify the distinction beween open/save and import/export.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Clarify the distinction beween open/save and import/export.
- Date: Tue, 2 Aug 2011 04:36:37 +0000 (UTC)
commit f529412dde443ae0722011e78e63c4ef9f2c5089
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Mon Aug 1 22:35:20 2011 -0600
Clarify the distinction beween open/save and import/export.
2011-08-01 Andreas J. Guelzow <aguelzow pyrshep ca>
* component/Gnumeric-embed.xml.in: add data import/export menu items
* src/GNOME_Gnumeric-gtk.xml.in: ditto
* src/HILDON_Gnumeric-gtk.xml.in: ditto
* src/application.c (gnm_app_create_opener_filter): distinguish between
file history and file-open/import
(gnm_app_history_get_list): adjust call to gnm_app_create_opener_filter
* src/application.h (gnm_app_create_opener_filter): add argument
* src/gui-file.c (gui_file_open): distinguish between "open" and "import"
(gui_file_save_as): distinguish between "save as" and "export"
* src/gui-file.h (gui_file_open): add argument
(gui_file_save_as): add argument
* src/stf.c (stf_read_workbook): set save info
(stf_read_workbook_auto_csvtab): ditto
(stf_init): separate mime types
* src/wbc-gtk-actions.c (cb_file_open): adjust call to gui_file_open
(cb_data_import_text): ditto
(cb_data_import_other): new
(cb_data_export): new
(cb_data_export_text): new
(cb_data_export_csv): new
(cb_file_save_as): adjust call to gui_file_save_as
(actions): connect the above new actions
* src/wbc-gtk-impl.h (_WBCGtk): delete duplicate field
* src/wbc-gtk.c (wbc_gtk_init): and do not initialize it
* src/workbook-priv.h (_Workbook): new field
* src/workbook.c (workbook_get_file_exporter): new
(workbook_dispose): finalize file_saver and file_exporter
(workbook_set_saveinfo): handle a wider range of savers
* src/workbook.h (workbook_get_file_exporter): new
2011-08-01 Andreas J. Guelzow <aguelzow pyrshep ca>
* plugin.xml.in: add mime-type
2011-08-01 Andreas J. Guelzow <aguelzow pyrshep ca>
* plugin.xml.in: correct mime types
2011-08-01 Andreas J. Guelzow <aguelzow pyrshep ca>
* plugins/excel/plugin.xml.in: use TM symbol
ChangeLog | 38 +++++++-
NEWS | 3 +-
component/Gnumeric-embed.xml.in | 6 ++
plugins/excel/ChangeLog | 4 +
plugins/excel/plugin.xml.in | 28 ++++---
plugins/openoffice/ChangeLog | 4 +
plugins/openoffice/plugin.xml.in | 10 ++-
plugins/sylk/ChangeLog | 4 +
plugins/sylk/plugin.xml.in | 3 +-
src/GNOME_Gnumeric-gtk.xml.in | 6 ++
src/HILDON_Gnumeric-gtk.xml.in | 6 ++
src/application.c | 111 +++++++++++++------------
src/application.h | 2 +-
src/gui-file.c | 171 ++++++++++++++++++++++++++++++-------
src/gui-file.h | 16 +++-
src/stf.c | 21 ++++-
src/wbc-gtk-actions.c | 37 +++++++-
src/wbc-gtk-impl.h | 2 -
src/wbc-gtk.c | 2 -
src/workbook-priv.h | 1 +
src/workbook.c | 57 ++++++++++---
src/workbook.h | 1 +
22 files changed, 394 insertions(+), 139 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 87db20a..4fc8400 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,37 @@
2011-08-01 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * component/Gnumeric-embed.xml.in: add data import/export menu items
+ * src/GNOME_Gnumeric-gtk.xml.in: ditto
+ * src/HILDON_Gnumeric-gtk.xml.in: ditto
+ * src/application.c (gnm_app_create_opener_filter): distinguish between
+ file history and file-open/import
+ (gnm_app_history_get_list): adjust call to gnm_app_create_opener_filter
+ * src/application.h (gnm_app_create_opener_filter): add argument
+ * src/gui-file.c (gui_file_open): distinguish between "open" and "import"
+ (gui_file_save_as): distinguish between "save as" and "export"
+ * src/gui-file.h (gui_file_open): add argument
+ (gui_file_save_as): add argument
+ * src/stf.c (stf_read_workbook): set save info
+ (stf_read_workbook_auto_csvtab): ditto
+ (stf_init): separate mime types
+ * src/wbc-gtk-actions.c (cb_file_open): adjust call to gui_file_open
+ (cb_data_import_text): ditto
+ (cb_data_import_other): new
+ (cb_data_export): new
+ (cb_data_export_text): new
+ (cb_data_export_csv): new
+ (cb_file_save_as): adjust call to gui_file_save_as
+ (actions): connect the above new actions
+ * src/wbc-gtk-impl.h (_WBCGtk): delete duplicate field
+ * src/wbc-gtk.c (wbc_gtk_init): and do not initialize it
+ * src/workbook-priv.h (_Workbook): new field
+ * src/workbook.c (workbook_get_file_exporter): new
+ (workbook_dispose): finalize file_saver and file_exporter
+ (workbook_set_saveinfo): handle a wider range of savers
+ * src/workbook.h (workbook_get_file_exporter): new
+
+2011-08-01 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* configure.in: Disable GTK depreciation check
* src/cell-draw.c (cell_calc_layout): use gnm_rendered_value_get_color
* src/cell.c (gnm_cell_get_render_color): ditto
@@ -18,13 +50,9 @@
(colour_selector_cb): new
(colour_from_layout): new
* src/widgets/gnm-format-sel.c (cb_generate_preview): use attributes
- * src/workbook-view.c (wb_view_auto_expr_recalc): use
+ * src/workbook-view.c (wb_view_auto_expr_recalc): use
format_value_layout
-2011-08-01 Morten Welinder <terra gnome org>
-
- * Branch to 1.11.0
-
2011-07-31 Morten Welinder <terra gnome org>
* configure.in: Post-release bump.
diff --git a/NEWS b/NEWS
index fa1b57c..0712679 100644
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,8 @@ Gnumeric 1.11.0
Andreas:
* Use formatting attributes whenever we format numbers.
- [#584380][#651561]
+ [#584380][#651561]
+ * Clarify the distinction beween open/save and import/export.
--------------------------------------------------------------------------
Gnumeric 1.10.17
diff --git a/component/Gnumeric-embed.xml.in b/component/Gnumeric-embed.xml.in
index 3e1925c..197ed0e 100644
--- a/component/Gnumeric-embed.xml.in
+++ b/component/Gnumeric-embed.xml.in
@@ -288,6 +288,12 @@
<menuitem action="DataTextToColumns"/>
<menu name="ExternalData" action="MenuExternalData">
<menuitem action="DataImportText"/>
+ <menuitem action="DataImportOther"/>
+ </menu>
+ <menu name="ExportData" action="MenuExportData">
+ <menuitem action="DataExportText"/>
+ <menuitem action="DataExportCSV"/>
+ <menuitem action="DataExport"/>
</menu>
</menu>
<menu name="Help" action="MenuHelp">
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 98fa2cf..a05d47b 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,7 @@
+2011-08-01 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * plugins/excel/plugin.xml.in: use TM symbol
+
2011-07-31 Morten Welinder <terra gnome org>
* Release 1.10.17
diff --git a/plugins/excel/plugin.xml.in b/plugins/excel/plugin.xml.in
index c07aad7..a7b8f9f 100644
--- a/plugins/excel/plugin.xml.in
+++ b/plugins/excel/plugin.xml.in
@@ -40,28 +40,28 @@
this the default. For now use "1" to give it
higher priority than the other xls savers -->
<information>
- <_description>MS Excel (tm) 97/2000/XP</_description>
+ <_description>MS Excel™ 97/2000/XP</_description>
</information>
</service>
<service type="file_saver" id="excel_biff7" file_extension="xls"
format_level="auto" overwrite_files="TRUE"
mime_type="application/vnd.ms-excel">
<information>
- <_description>MS Excel (tm) 5.0/95</_description>
+ <_description>MS Excel™ 5.0/95</_description>
</information>
</service>
<service type="file_saver" id="excel_dsf" file_extension="xls"
format_level="auto" overwrite_files="TRUE"
mime_type="application/vnd.ms-excel">
<information>
- <_description>MS Excel (tm) 97/2000/XP & 5.0/95</_description>
+ <_description>MS Excel™ 97/2000/XP & 5.0/95</_description>
</information>
</service>
<!-- IMPORT partial format spreadsheetml from 2003 -->
<service type="file_opener" id="excel_xml" priority="1" probe="TRUE">
<information>
- <_description>MS Excel (tm) 2003 SpreadsheetML</_description>
+ <_description>MS Excel™ 2003 SpreadsheetML</_description>
</information>
<suffixes>
<suffix>xml</suffix>
@@ -71,7 +71,7 @@
<!-- Office Open XML packages from Office 2007 -->
<service type="file_opener" id="xlsx" priority="100" probe="TRUE">
<information>
- <_description>MS Excel (tm) 2007</_description>
+ <_description>MS Excel™ 2007/2010 (*.xlsx)</_description>
</information>
<suffixes>
<suffix>xlsx</suffix>
@@ -80,28 +80,30 @@
<suffix>xlsm</suffix>
<suffix>xltm</suffix>
</suffixes>
-<!--
<mime-types>
<mime-type>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</mime-type>
<mime-type>application/vnd.openxmlformats-officedocument.spreadsheetml.template</mime-type>
+<!--
<mime-type>application/vnd.ms-excel.sheet.binary.macroEnabled.12</mime-type>
<mime-type>application/vnd.ms-excel.sheet.macroEnabled.12</mime-type>
<mime-type>application/vnd.ms-excel.template.macroEnabled.12</mime-type>
- <mime-types>
- -->
- </service>
+ -->
+ </mime-types>
+ </service>
<service type="file_saver" id="xlsx" file_extension="xlsx"
- format_level="auto" overwrite_files="TRUE">
+ format_level="auto" overwrite_files="TRUE"
+ mime_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
<information>
- <_description>MS Excel (tm) 2007 (ECMA 376 1st edition (2006))</_description>
+ <_description>MS Excel™ 2007 (ECMA 376 1st edition (2006))</_description>
</information>
</service>
<service type="file_saver" id="xlsx2" file_extension="xlsx"
- format_level="auto" overwrite_files="TRUE">
+ format_level="auto" overwrite_files="TRUE"
+ mime_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
<information>
- <_description>MS Excel (tm) 2010 (ECMA 376 2nd edition (2008))</_description>
+ <_description>MS Excel™ 2010 (ECMA 376 2nd edition (2008))</_description>
</information>
</service>
</services>
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index cc9339a..19c1652 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,7 @@
+2011-08-01 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * plugin.xml.in: correct mime types
+
2011-07-31 Morten Welinder <terra gnome org>
* Release 1.10.17
diff --git a/plugins/openoffice/plugin.xml.in b/plugins/openoffice/plugin.xml.in
index e9e9429..ffef4a0 100644
--- a/plugins/openoffice/plugin.xml.in
+++ b/plugins/openoffice/plugin.xml.in
@@ -19,20 +19,22 @@
<suffix>stc</suffix>
</suffixes>
<mime-types>
- <mime-type>vnd.oasis.opendocument.spreadsheet</mime-type>
- <mime-type>vnd.oasis.opendocument.spreadsheet-template</mime-type>
+ <mime-type>application/vnd.oasis.opendocument.spreadsheet</mime-type>
+ <mime-type>application/vnd.oasis.opendocument.spreadsheet-template</mime-type>
<mime-type>application/vnd.sun.xml.calc</mime-type>
<mime-type>application/vnd.sun.xml.calc.template</mime-type>
</mime-types>
</service>
<service type="file_saver" id="openoffice" file_extension="ods"
- format_level="auto" overwrite_files="TRUE">
+ format_level="auto" overwrite_files="TRUE"
+ mime_type="application/vnd.oasis.opendocument.spreadsheet">
<information>
<_description>ODF/OpenOffice without foreign elements (*.ods)</_description>
</information>
</service>
<service type="file_saver" id="odf" file_extension="ods"
- format_level="auto" overwrite_files="TRUE">
+ format_level="auto" overwrite_files="TRUE"
+ mime_type="application/vnd.oasis.opendocument.spreadsheet">
<information>
<_description>ODF/OpenOffice with foreign elements (*.ods)</_description>
</information>
diff --git a/plugins/sylk/ChangeLog b/plugins/sylk/ChangeLog
index 933e74f..79d26cc 100644
--- a/plugins/sylk/ChangeLog
+++ b/plugins/sylk/ChangeLog
@@ -1,3 +1,7 @@
+2011-08-01 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * plugin.xml.in: add mime-type
+
2011-07-31 Morten Welinder <terra gnome org>
* Release 1.10.17
diff --git a/plugins/sylk/plugin.xml.in b/plugins/sylk/plugin.xml.in
index a051b83..d59750d 100644
--- a/plugins/sylk/plugin.xml.in
+++ b/plugins/sylk/plugin.xml.in
@@ -21,7 +21,8 @@
</mime-types>
</service>
<service type="file_saver" id="sylk" file_extension="slk"
- save_scope="sheet" format_level="auto" overwrite_files="TRUE">
+ save_scope="sheet" format_level="auto"
+ overwrite_files="TRUE" mime_type="application/x-sylk">
<information>
<_description>MultiPlan (SYLK)</_description>
</information>
diff --git a/src/GNOME_Gnumeric-gtk.xml.in b/src/GNOME_Gnumeric-gtk.xml.in
index b9b3880..de7d0c0 100644
--- a/src/GNOME_Gnumeric-gtk.xml.in
+++ b/src/GNOME_Gnumeric-gtk.xml.in
@@ -290,6 +290,12 @@
<menuitem action="DataTextToColumns"/>
<menu name="ExternalData" action="MenuExternalData">
<menuitem action="DataImportText"/>
+ <menuitem action="DataImportOther"/>
+ </menu>
+ <menu name="ExportData" action="MenuExportData">
+ <menuitem action="DataExportText"/>
+ <menuitem action="DataExportCSV"/>
+ <menuitem action="DataExport"/>
</menu>
</menu>
<menu name="Help" action="MenuHelp">
diff --git a/src/HILDON_Gnumeric-gtk.xml.in b/src/HILDON_Gnumeric-gtk.xml.in
index 7dda95d..8f60e4e 100644
--- a/src/HILDON_Gnumeric-gtk.xml.in
+++ b/src/HILDON_Gnumeric-gtk.xml.in
@@ -282,6 +282,12 @@
-->
<menu name="ExternalData" action="MenuExternalData">
<menuitem action="DataImportText"/>
+ <menuitem action="DataImportOther"/>
+ </menu>
+ <menu name="ExportData" action="MenuExportData">
+ <menuitem action="DataExportText"/>
+ <menuitem action="DataExportCSV"/>
+ <menuitem action="DataExport"/>
</menu>
</menu>
<menu name="Help" action="MenuHelp">
diff --git a/src/application.c b/src/application.c
index 60512c2..90e4567 100644
--- a/src/application.c
+++ b/src/application.c
@@ -465,7 +465,7 @@ gnm_app_dpi_to_pixels (void)
/* GtkFileFilter */
void *
-gnm_app_create_opener_filter (void)
+gnm_app_create_opener_filter (GList *openers)
{
/* See below. */
static const char *const bad_suffixes[] = {
@@ -476,61 +476,64 @@ gnm_app_create_opener_filter (void)
};
GtkFileFilter *filter = gtk_file_filter_new ();
+ gboolean for_history = (openers == NULL);
+
+ if (openers == NULL)
+ openers = go_get_file_openers ();
- GList *openers;
-
- for (openers = go_get_file_openers ();
- openers;
- openers = openers->next) {
+ for (; openers; openers = openers->next) {
GOFileOpener *opener = openers->data;
- const GSList *mimes = go_file_opener_get_mimes (opener);
- const GSList *suffixes = go_file_opener_get_suffixes (opener);
-
- while (mimes) {
-#if 0
- const char *mime = mimes->data;
- /*
- * This needs rethink, see 438918. Too many things
- * like *.xml and *.txt get added.
- */
- gtk_file_filter_add_mime_type (filter, mime);
- if (0)
- g_print ("%s: Adding mime %s\n", go_file_opener_get_description (opener), mime);
-#endif
- mimes = mimes->next;
- }
-
- while (suffixes) {
- const char *suffix = suffixes->data;
- GString *pattern;
- int i;
-
- for (i = 0; bad_suffixes[i]; i++)
- if (strcmp (suffix, bad_suffixes[i]) == 0)
- goto bad_suffix;
-
- /* Create "*.[xX][lL][sS]" */
- pattern = g_string_new ("*.");
- while (*suffix) {
- gunichar uc = g_utf8_get_char (suffix);
- suffix = g_utf8_next_char (suffix);
- if (g_unichar_islower (uc)) {
- g_string_append_c (pattern, '[');
- g_string_append_unichar (pattern, uc);
- uc = g_unichar_toupper (uc);
- g_string_append_unichar (pattern, uc);
- g_string_append_c (pattern, ']');
- } else
- g_string_append_unichar (pattern, uc);
+ if (opener != NULL) {
+ const GSList *mimes = go_file_opener_get_mimes (opener);
+ const GSList *suffixes = go_file_opener_get_suffixes (opener);
+
+ if (!for_history)
+ while (mimes) {
+ const char *mime = mimes->data;
+ /*
+ * See 438918. Too many things
+ * like *.xml and *.txt get added
+ * to be useful for the file history
+ */
+ gtk_file_filter_add_mime_type (filter, mime);
+ if (0)
+ g_print ("%s: Adding mime %s\n", go_file_opener_get_description (opener), mime);
+ mimes = mimes->next;
+ }
+
+ while (suffixes) {
+ const char *suffix = suffixes->data;
+ GString *pattern;
+ int i;
+
+ if (for_history)
+ for (i = 0; bad_suffixes[i]; i++)
+ if (strcmp (suffix, bad_suffixes[i]) == 0)
+ goto bad_suffix;
+
+ /* Create "*.[xX][lL][sS]" */
+ pattern = g_string_new ("*.");
+ while (*suffix) {
+ gunichar uc = g_utf8_get_char (suffix);
+ suffix = g_utf8_next_char (suffix);
+ if (g_unichar_islower (uc)) {
+ g_string_append_c (pattern, '[');
+ g_string_append_unichar (pattern, uc);
+ uc = g_unichar_toupper (uc);
+ g_string_append_unichar (pattern, uc);
+ g_string_append_c (pattern, ']');
+ } else
+ g_string_append_unichar (pattern, uc);
+ }
+
+ gtk_file_filter_add_pattern (filter, pattern->str);
+ if (0)
+ g_print ("%s: Adding %s\n", go_file_opener_get_description (opener), pattern->str);
+ g_string_free (pattern, TRUE);
+
+ bad_suffix:
+ suffixes = suffixes->next;
}
-
- gtk_file_filter_add_pattern (filter, pattern->str);
- if (0)
- g_print ("%s: Adding %s\n", go_file_opener_get_description (opener), pattern->str);
- g_string_free (pattern, TRUE);
-
- bad_suffix:
- suffixes = suffixes->next;
}
}
return filter;
@@ -557,7 +560,7 @@ gnm_app_history_get_list (int max_elements)
{
GSList *res = NULL;
GList *items, *l;
- GtkFileFilter *filter = gnm_app_create_opener_filter ();
+ GtkFileFilter *filter = gnm_app_create_opener_filter (NULL);
int n_elements = 0;
items = gtk_recent_manager_get_items (app->recent);
diff --git a/src/application.h b/src/application.h
index ed4c871..e59b725 100644
--- a/src/application.h
+++ b/src/application.h
@@ -29,7 +29,7 @@ void gnm_app_recalc_finish (void);
void gnm_app_recalc_clear_caches (void);
/* GtkFileFilter */
-void *gnm_app_create_opener_filter (void);
+void *gnm_app_create_opener_filter (GList *openers);
double gnm_app_display_dpi_get (gboolean horizontal);
double gnm_app_dpi_to_pixels (void);
diff --git a/src/gui-file.c b/src/gui-file.c
index b31def6..95b0d97 100644
--- a/src/gui-file.c
+++ b/src/gui-file.c
@@ -220,30 +220,99 @@ cb_advanced_clicked (GtkButton *advanced, GtkFileChooser *fsel)
* import filter for selected file.
*/
void
-gui_file_open (WBCGtk *wbcg, char const *default_format)
+gui_file_open (WBCGtk *wbcg, file_open_t type, char const *default_format)
{
- GList *openers;
+ GList *openers = NULL, *all_openers, *l;
GtkFileChooser *fsel;
GtkWidget *advanced_button;
GtkComboBox *format_combo;
GtkWidget *go_charmap_sel;
file_format_changed_cb_data data;
gint opener_default;
- char const *title;
+ char const *title = NULL;
GSList *uris = NULL;
char const *encoding = NULL;
GOFileOpener *fo = NULL;
Workbook *workbook = wb_control_get_workbook (WORKBOOK_CONTROL (wbcg));
- openers = g_list_sort (g_list_copy (go_get_file_openers ()),
- file_opener_description_cmp);
- /* NULL represents automatic file type recognition */
- openers = g_list_prepend (openers, NULL);
+ all_openers = go_get_file_openers ();
+
+ if (default_format != NULL) {
+ fo = go_file_opener_for_id (default_format);
+ }
+
+ if (fo != NULL)
+ openers = g_list_prepend (NULL, fo);
+ else {
+ for (l = all_openers; l; l = l->next)
+ if (l->data != NULL) {
+ GOFileOpener *fo = l->data;
+ GSList const *mimes = go_file_opener_get_mimes (fo);
+ GSList *fsavers = NULL, *fl;
+
+ for (; mimes; mimes = mimes->next) {
+ GOFileSaver *fs = go_file_saver_for_mime_type
+ (mimes->data);
+ if (fs != NULL)
+ fsavers = g_slist_prepend (fsavers, fs);
+ }
+ switch (type) {
+ case FILE_OPEN_OPEN:
+ for (fl = fsavers; fl; fl = fl->next) {
+ GOFileSaver *fs = GO_FILE_SAVER (fl->data);
+ if ((go_file_saver_get_save_scope (fs)
+ != GO_FILE_SAVE_RANGE) &&
+ (go_file_saver_get_format_level (fs)
+ == GO_FILE_FL_AUTO)) {
+ openers = g_list_prepend
+ (openers, fo);
+ break;
+ }
+ }
+ break;
+ case FILE_OPEN_IMPORT:
+ {
+ gboolean is_open = FALSE;
+ for (fl = fsavers; fl; fl = fl->next) {
+ GOFileSaver *fs = GO_FILE_SAVER
+ (fl->data);
+ if ((go_file_saver_get_save_scope
+ (fs)
+ != GO_FILE_SAVE_RANGE) &&
+ (go_file_saver_get_format_level
+ (fs)
+ == GO_FILE_FL_AUTO)) {
+ is_open = TRUE;
+ break;
+ }
+ }
+ if (!(is_open))
+ openers = g_list_prepend
+ (openers, fo);
+ break;
+ }
+ }
+ g_slist_free (fsavers);
+ }
+ openers = g_list_sort (openers, file_opener_description_cmp);
+ /* NULL represents automatic file type recognition */
+ openers = g_list_prepend (openers, NULL);
+ }
+
opener_default = file_opener_find_by_id (openers, default_format);
- title = (opener_default == 0)
- ? _("Load file")
- : (go_file_opener_get_description
- (g_list_nth_data (openers, opener_default)));
+
+ if (opener_default != 0)
+ title = (go_file_opener_get_description
+ (g_list_nth_data (openers, opener_default)));
+ if (title == NULL)
+ switch (type) {
+ case FILE_OPEN_OPEN:
+ title = _("Open Spreadsheet File");
+ break;
+ case FILE_OPEN_IMPORT:
+ title = _("Import Data File");
+ break;
+ }
data.openers = openers;
/* Make charmap chooser */
@@ -255,7 +324,7 @@ gui_file_open (WBCGtk *wbcg, char const *default_format)
format_combo = GTK_COMBO_BOX (gtk_combo_box_new_text ());
make_format_chooser (openers, format_combo);
g_signal_connect (G_OBJECT (format_combo), "changed",
- G_CALLBACK (file_format_changed_cb), &data);
+ G_CALLBACK (file_format_changed_cb), &data);
gtk_combo_box_set_active (format_combo, opener_default);
gtk_widget_set_sensitive (GTK_WIDGET (format_combo), opener_default == 0);
file_format_changed_cb (format_combo, &data);
@@ -267,7 +336,7 @@ gui_file_open (WBCGtk *wbcg, char const *default_format)
(g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
"action", GTK_FILE_CHOOSER_ACTION_OPEN,
"local-only", FALSE,
- "title", _("Select a file"),
+ "title", title,
"select-multiple", TRUE,
NULL));
@@ -296,14 +365,29 @@ gui_file_open (WBCGtk *wbcg, char const *default_format)
/* Filters */
{
GtkFileFilter *filter;
+ char const *filter_name = NULL;
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("All Files"));
gtk_file_filter_add_pattern (filter, "*");
gtk_file_chooser_add_filter (fsel, filter);
- filter = gnm_app_create_opener_filter ();
- gtk_file_filter_set_name (filter, _("Spreadsheets"));
+ filter = gnm_app_create_opener_filter (openers);
+ if (default_format != NULL) {
+ if (0 == strcmp (default_format,
+ "Gnumeric_stf:stf_assistant"))
+ filter_name = _("Text Files");
+ }
+ if (filter_name == NULL)
+ switch (type) {
+ case FILE_OPEN_OPEN:
+ filter_name = _("Spreadsheets");
+ break;
+ case FILE_OPEN_IMPORT:
+ filter_name = _("Data Files");
+ break;
+ }
+ gtk_file_filter_set_name (filter, filter_name);
gtk_file_chooser_add_filter (fsel, filter);
/* Make this filter the default */
gtk_file_chooser_set_filter (fsel, filter);
@@ -408,7 +492,8 @@ extension_check_disabled (GOFileSaver *fs)
}
gboolean
-gui_file_save_as (WBCGtk *wbcg, WorkbookView *wb_view)
+gui_file_save_as (WBCGtk *wbcg, WorkbookView *wb_view, file_save_as_t type,
+ char const *default_format)
{
GList *savers = NULL, *l;
GtkFileChooser *fsel;
@@ -419,17 +504,35 @@ gui_file_save_as (WBCGtk *wbcg, WorkbookView *wb_view)
char *uri;
Workbook *wb;
WBCGtk *wbcg2;
+#ifndef GNM_USE_HILDON
+ char const *title = (type == FILE_SAVE_AS_SAVE) ? _("Save the current workbook as")
+ : _("Export the current workbook or sheet to");
+#endif
g_return_val_if_fail (wbcg != NULL, FALSE);
wb = wb_view_get_workbook (wb_view);
wbcg2 = wbcg_find_for_workbook (wb, wbcg, NULL, NULL);
- for (l = go_get_file_savers (); l; l = l->next) {
- if ((l->data == NULL) ||
- (go_file_saver_get_save_scope (GO_FILE_SAVER (l->data))
- != GO_FILE_SAVE_RANGE))
- savers = g_list_prepend (savers, l->data);
+ for (l = go_get_file_savers (); l; l = l->next)
+ switch (type) {
+ case FILE_SAVE_AS_SAVE:
+ if ((l->data == NULL) ||
+ ((go_file_saver_get_save_scope (GO_FILE_SAVER (l->data))
+ != GO_FILE_SAVE_RANGE) &&
+ (go_file_saver_get_format_level (GO_FILE_SAVER (l->data))
+ == GO_FILE_FL_AUTO)))
+ savers = g_list_prepend (savers, l->data);
+ break;
+ case FILE_SAVE_AS_EXPORT:
+ default:
+ if ((l->data == NULL) ||
+ ((go_file_saver_get_save_scope (GO_FILE_SAVER (l->data))
+ != GO_FILE_SAVE_RANGE) &&
+ (go_file_saver_get_format_level (GO_FILE_SAVER (l->data))
+ != GO_FILE_FL_AUTO)))
+ savers = g_list_prepend (savers, l->data);
+ break;
}
savers = g_list_sort (savers, file_saver_description_cmp);
@@ -440,7 +543,7 @@ gui_file_save_as (WBCGtk *wbcg, WorkbookView *wb_view)
(g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
"action", GTK_FILE_CHOOSER_ACTION_SAVE,
"local-only", FALSE,
- "title", _("Select a file"),
+ "title", title,
NULL));
gtk_dialog_add_buttons (GTK_DIALOG (fsel),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@@ -462,7 +565,7 @@ gui_file_save_as (WBCGtk *wbcg, WorkbookView *wb_view)
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("Spreadsheets"));
- for (l = savers->next; l; l = l->next) {
+ for (l = savers; l; l = l->next) {
GOFileSaver *fs = l->data;
char const *ext = go_file_saver_get_extension (fs);
char const *mime = go_file_saver_get_mime_type (fs);
@@ -503,11 +606,16 @@ gui_file_save_as (WBCGtk *wbcg, WorkbookView *wb_view)
}
/* Set default file saver */
- fs = wbcg2 ? wbcg2->current_saver : NULL;
- if (!fs)
+ if (type == FILE_SAVE_AS_SAVE) {
fs = workbook_get_file_saver (wb);
- if (!fs || g_list_find (savers, fs) == NULL)
- fs = go_file_saver_get_default ();
+ if (!fs || g_list_find (savers, fs) == NULL)
+ fs = go_file_saver_get_default ();
+ } else {
+ fs = workbook_get_file_exporter (wb);
+ if (!fs || g_list_find (savers, fs) == NULL)
+ fs = go_file_saver_for_id (default_format ? default_format
+ : "Gnumeric_html:latex_table");
+ }
gtk_combo_box_set_active (format_combo, g_list_index (savers, fs));
@@ -574,12 +682,8 @@ gui_file_save_as (WBCGtk *wbcg, WorkbookView *wb_view)
/* Destroy early so no-one can repress the Save button. */
gtk_widget_destroy (GTK_WIDGET (fsel));
fsel = NULL;
- success = wb_view_save_as (wb_view, fs, uri, GO_CMD_CONTEXT (wbcg));
- if (success) {
- if (wbcg2)
- wbcg2->current_saver = fs;
+ if (wb_view_save_as (wb_view, fs, uri, GO_CMD_CONTEXT (wbcg)))
workbook_update_history (wb);
- }
}
g_free (uri);
@@ -607,7 +711,8 @@ gui_file_save (WBCGtk *wbcg, WorkbookView *wb_view)
}
if (wb->file_format_level < GO_FILE_FL_AUTO)
- return gui_file_save_as (wbcg, wb_view);
+ return gui_file_save_as (wbcg, wb_view,
+ FILE_SAVE_AS_SAVE, NULL);
else {
gboolean ok;
diff --git a/src/gui-file.h b/src/gui-file.h
index 4e3bf87..37f98be 100644
--- a/src/gui-file.h
+++ b/src/gui-file.h
@@ -6,9 +6,21 @@
G_BEGIN_DECLS
-gboolean gui_file_save_as (WBCGtk *wbcg, WorkbookView *wbv);
+typedef enum {
+ FILE_SAVE_AS_SAVE,
+ FILE_SAVE_AS_EXPORT,
+ FILE_SAVE_AS_EXPORT_RANGE
+} file_save_as_t;
+typedef enum {
+ FILE_OPEN_OPEN,
+ FILE_OPEN_IMPORT,
+} file_open_t;
+
+gboolean gui_file_save_as (WBCGtk *wbcg, WorkbookView *wbv,
+ file_save_as_t type,
+ char const *default_format);
gboolean gui_file_save (WBCGtk *wbcg, WorkbookView *wbv);
-void gui_file_open (WBCGtk *wbcg,
+void gui_file_open (WBCGtk *wbcg, file_open_t type,
char const *default_format);
void gui_wb_view_show (WBCGtk *wbcg, WorkbookView *wbv);
gboolean gui_file_read (WBCGtk *wbcg, char const *file_name,
diff --git a/src/stf.c b/src/stf.c
index 2c90cbe..e1a770c 100644
--- a/src/stf.c
+++ b/src/stf.c
@@ -276,6 +276,11 @@ stf_read_workbook (GOFileOpener const *fo, gchar const *enc,
if (stf_store_results (dialogresult, sheet, 0, 0)) {
workbook_recalc_all (book);
resize_columns (sheet);
+ workbook_set_saveinfo
+ (book,
+ GO_FILE_FL_WRITE_ONLY,
+ go_file_saver_for_id
+ ("Gnumeric_stf:stf_assistant"));
} else {
/* the user has cancelled */
/* the caller should notice that we have no sheets */
@@ -478,6 +483,11 @@ stf_read_workbook_auto_csvtab (GOFileOpener const *fo, gchar const *enc,
_("Some data did not fit on the "
"sheet and was dropped."));
}
+ workbook_set_saveinfo
+ (book,
+ GO_FILE_FL_WRITE_ONLY,
+ go_file_saver_for_id
+ ("Gnumeric_stf:stf_assistant"));
} else {
workbook_sheet_delete (sheet);
go_cmd_context_error_import (GO_CMD_CONTEXT (context),
@@ -609,6 +619,13 @@ stf_init (void)
g_strdup ("text/spreadsheet"),
g_strdup ("text/tab-separated-values"),
NULL);
+ GSList *mimes_txt = go_slist_create (
+ g_strdup ("text/plain"),
+ g_strdup ("text/csv"),
+ g_strdup ("text/x-csv"),
+ g_strdup ("text/comma-separated-values"),
+ g_strdup ("text/tab-separated-values"),
+ NULL);
GOFileSaver *saver;
GOFileOpener *opener;
@@ -623,7 +640,7 @@ stf_init (void)
opener = go_file_opener_new_with_enc (
"Gnumeric_stf:stf_assistant",
_("Text import (configurable)"),
- NULL, NULL,
+ NULL, mimes_txt,
NULL, stf_read_workbook);
go_file_opener_register (opener, 0);
g_object_unref (opener);
@@ -635,7 +652,7 @@ stf_init (void)
saver = go_file_saver_new (
"Gnumeric_stf:stf_csv", "csv",
_("Comma separated values (CSV)"),
- GO_FILE_FL_WRITE_ONLY, stf_write_csv);
+ GO_FILE_FL_MANUAL_REMEMBER, stf_write_csv);
go_file_saver_set_save_scope (saver, GO_FILE_SAVE_SHEET);
go_file_saver_register (saver);
g_object_unref (saver);
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index b5b5c40..d0faf14 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -99,9 +99,11 @@ static GNM_ACTION_DEF (cb_file_new)
wbcg_copy_toolbar_visibility (new_wbcg, wbcg);
}
-static GNM_ACTION_DEF (cb_file_open) { gui_file_open (wbcg, NULL); }
+static GNM_ACTION_DEF (cb_file_open) { gui_file_open (wbcg, FILE_OPEN_OPEN, NULL); }
static GNM_ACTION_DEF (cb_file_save) { gui_file_save (wbcg, wb_control_view (WORKBOOK_CONTROL (wbcg))); }
-static GNM_ACTION_DEF (cb_file_save_as) { gui_file_save_as (wbcg, wb_control_view (WORKBOOK_CONTROL (wbcg))); }
+static GNM_ACTION_DEF (cb_file_save_as) { gui_file_save_as
+ (wbcg, wb_control_view (WORKBOOK_CONTROL (wbcg)),
+ FILE_SAVE_AS_SAVE, NULL); }
#ifndef HAVE_MKDTEMP
#include "gnm-random.h"
@@ -976,7 +978,10 @@ static GNM_ACTION_DEF (cb_tools_random_generator_uncorrelated) { dialog_random_t
static GNM_ACTION_DEF (cb_tools_random_generator_correlated) { dialog_random_cor_tool (wbcg, wbcg_cur_sheet (wbcg)); }
static GNM_ACTION_DEF (cb_data_sort) { dialog_cell_sort (wbcg); }
static GNM_ACTION_DEF (cb_data_shuffle) { dialog_shuffle (wbcg); }
-static GNM_ACTION_DEF (cb_data_import_text) { gui_file_open (wbcg, "Gnumeric_stf:stf_assistant"); }
+static GNM_ACTION_DEF (cb_data_import_text) { gui_file_open
+ (wbcg, FILE_OPEN_IMPORT, "Gnumeric_stf:stf_assistant"); }
+static GNM_ACTION_DEF (cb_data_import_other) { gui_file_open
+ (wbcg, FILE_OPEN_IMPORT, NULL); }
static GNM_ACTION_DEF (cb_auto_filter) { cmd_autofilter_add_remove (WORKBOOK_CONTROL (wbcg)); }
static GNM_ACTION_DEF (cb_show_all) { filter_show_all (WORKBOOK_CONTROL (wbcg)); }
@@ -988,6 +993,15 @@ static GNM_ACTION_DEF (cb_data_table) { dialog_data_table (wbcg); }
static GNM_ACTION_DEF (cb_data_slicer_create) { dialog_data_slicer (wbcg, TRUE); }
static GNM_ACTION_DEF (cb_data_slicer_refresh) { cmd_slicer_refresh (WORKBOOK_CONTROL (wbcg)); }
static GNM_ACTION_DEF (cb_data_slicer_edit) { dialog_data_slicer (wbcg, FALSE); }
+static GNM_ACTION_DEF (cb_data_export) { gui_file_save_as
+ (wbcg, wb_control_view (WORKBOOK_CONTROL (wbcg)),
+ FILE_SAVE_AS_EXPORT, NULL); }
+static GNM_ACTION_DEF (cb_data_export_text) { gui_file_save_as
+ (wbcg, wb_control_view (WORKBOOK_CONTROL (wbcg)),
+ FILE_SAVE_AS_EXPORT, "Gnumeric_stf:stf_assistant"); }
+static GNM_ACTION_DEF (cb_data_export_csv) { gui_file_save_as
+ (wbcg, wb_control_view (WORKBOOK_CONTROL (wbcg)),
+ FILE_SAVE_AS_EXPORT, "Gnumeric_stf:stf_csv"); }
static void
hide_show_detail_real (WBCGtk *wbcg, gboolean is_cols, gboolean show)
@@ -1932,7 +1946,8 @@ static GtkActionEntry const permanent_actions[] = {
{ "MenuEditFill", NULL, N_("F_ill") },
{ "MenuRandomGenerator", NULL, N_("_Random Generators") },
{ "MenuOutline", NULL, N_("_Group and Outline") },
- { "MenuExternalData", NULL, N_("Get External _Data") },
+ { "MenuExternalData", NULL, N_("Import _Data") },
+ { "MenuExportData", NULL, N_("E_xport Data") },
{ "MenuSlicer", NULL, N_("Data S_licer") },
{ "MenuHelp", NULL, N_("_Help") },
@@ -2518,6 +2533,15 @@ static GtkActionEntry const actions[] = {
{ "DataTable", NULL, N_("_Table..."),
NULL, N_("Create a Data Table to evaluate a function with multiple inputs"),
G_CALLBACK (cb_data_table) },
+ { "DataExport", NULL, N_("E_xport into Other Format"),
+ NULL, N_("Export the current workbook or sheet"),
+ G_CALLBACK (cb_data_export) },
+ { "DataExportText", NULL, N_("Export as _Text File"),
+ NULL, N_("Export the current sheet as a text file"),
+ G_CALLBACK (cb_data_export_text) },
+ { "DataExportCSV", NULL, N_("Export as _CSV File"),
+ NULL, N_("Export the current sheet as a csv file"),
+ G_CALLBACK (cb_data_export_csv) },
/* Data -> Fill */
{ "EditFillAutofill", NULL, N_("Auto_fill"),
@@ -2570,8 +2594,11 @@ static GtkActionEntry const actions[] = {
G_CALLBACK (cb_data_filter) },
/* Data -> External */
{ "DataImportText", GTK_STOCK_DND, N_("Import _Text File..."),
- NULL, N_("Import the text from a file"),
+ NULL, N_("Import data from a text file"),
G_CALLBACK (cb_data_import_text) },
+ { "DataImportOther", GTK_STOCK_DND, N_("Import _Other File..."),
+ NULL, N_("Import data from a file"),
+ G_CALLBACK (cb_data_import_other) },
/* Data -> Data Slicer */
/* label and tip are context dependent, see wbcg_menu_state_update */
diff --git a/src/wbc-gtk-impl.h b/src/wbc-gtk-impl.h
index 36b87a4..8a14298 100644
--- a/src/wbc-gtk-impl.h
+++ b/src/wbc-gtk-impl.h
@@ -94,8 +94,6 @@ struct _WBCGtk {
PangoFontDescription *font_desc;
- GOFileSaver *current_saver;
-
SheetControlGUI *active_scg;
gulong sig_view_changed;
gulong sig_auto_expr_text, sig_auto_expr_attrs;
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 07e73b4..bc315f1 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -5807,8 +5807,6 @@ wbc_gtk_init (GObject *obj)
wbcg->new_object = NULL;
-#warning "why is this here ?"
- wbcg->current_saver = NULL;
wbcg->menu_zone = gtk_vbox_new (TRUE, 0);
wbcg->everything = gtk_vbox_new (FALSE, 0);
diff --git a/src/workbook-priv.h b/src/workbook-priv.h
index 765ed67..cb48b81 100644
--- a/src/workbook-priv.h
+++ b/src/workbook-priv.h
@@ -21,6 +21,7 @@ struct _Workbook {
GOFileFormatLevel file_format_level;
GOFileSaver *file_saver;
+ GOFileSaver *file_exporter;
/* Undo support */
GSList *undo_commands;
diff --git a/src/workbook.c b/src/workbook.c
index 9ba5f9c..c3c40da 100644
--- a/src/workbook.c
+++ b/src/workbook.c
@@ -69,6 +69,14 @@ cb_saver_finalize (Workbook *wb, GOFileSaver *saver)
g_return_if_fail (wb->file_saver == saver);
wb->file_saver = NULL;
}
+static void
+cb_exporter_finalize (Workbook *wb, GOFileSaver *saver)
+{
+ g_return_if_fail (GO_IS_FILE_SAVER (saver));
+ g_return_if_fail (IS_WORKBOOK (wb));
+ g_return_if_fail (wb->file_exporter == saver);
+ wb->file_exporter = NULL;
+}
void
workbook_update_history (Workbook *wb)
@@ -92,7 +100,9 @@ workbook_dispose (GObject *wb_object)
wb->during_destruction = TRUE;
if (wb->file_saver)
- workbook_set_saveinfo (wb, wb->file_format_level, NULL);
+ workbook_set_saveinfo (wb, GO_FILE_FL_AUTO, NULL);
+ if (wb->file_exporter)
+ workbook_set_saveinfo (wb, GO_FILE_FL_WRITE_ONLY, NULL);
/* Remove all the sheet controls to avoid displaying while we exit */
WORKBOOK_FOREACH_CONTROL (wb, view, control,
@@ -188,6 +198,7 @@ workbook_init (GObject *object)
wb->file_format_level = GO_FILE_FL_NEW;
wb->file_saver = NULL;
+ wb->file_exporter = NULL;
wb->during_destruction = FALSE;
wb->being_reordered = FALSE;
@@ -385,7 +396,7 @@ workbook_new_with_sheets (int sheet_count)
*
* If level is sufficiently advanced assign the info.
*
- * Returns : TRUE if save info was set succesfully.
+ * Returns : TRUE if save info was set and history may require updating
*
* FIXME : Add a check to ensure the name is unique.
*/
@@ -393,22 +404,32 @@ gboolean
workbook_set_saveinfo (Workbook *wb, GOFileFormatLevel level, GOFileSaver *fs)
{
g_return_val_if_fail (wb != NULL, FALSE);
- g_return_val_if_fail (level > GO_FILE_FL_NONE && level <= GO_FILE_FL_AUTO,
+ g_return_val_if_fail (level > GO_FILE_FL_NONE && level < GO_FILE_FL_LAST,
FALSE);
- if (level <= GO_FILE_FL_WRITE_ONLY)
+ if (level != GO_FILE_FL_AUTO) {
+ if (wb->file_exporter != NULL)
+ g_object_weak_unref (G_OBJECT (wb->file_exporter),
+ (GWeakNotify) cb_exporter_finalize, wb);
+
+ wb->file_exporter = fs;
+ if (fs != NULL)
+ g_object_weak_ref (G_OBJECT (fs),
+ (GWeakNotify) cb_exporter_finalize, wb);
+ } else {
+ if (wb->file_saver != NULL)
+ g_object_weak_unref (G_OBJECT (wb->file_saver),
+ (GWeakNotify) cb_saver_finalize, wb);
+
+ wb->file_saver = fs;
+ if (fs != NULL)
+ g_object_weak_ref (G_OBJECT (fs),
+ (GWeakNotify) cb_saver_finalize, wb);
+ }
+
+ if (level == GO_FILE_FL_WRITE_ONLY)
return FALSE;
-
wb->file_format_level = level;
- if (wb->file_saver != NULL)
- g_object_weak_unref (G_OBJECT (wb->file_saver),
- (GWeakNotify) cb_saver_finalize, wb);
-
- wb->file_saver = fs;
- if (fs != NULL)
- g_object_weak_ref (G_OBJECT (fs),
- (GWeakNotify) cb_saver_finalize, wb);
-
return TRUE;
}
@@ -420,6 +441,14 @@ workbook_get_file_saver (Workbook *wb)
return wb->file_saver;
}
+GOFileSaver *
+workbook_get_file_exporter (Workbook *wb)
+{
+ g_return_val_if_fail (IS_WORKBOOK (wb), NULL);
+
+ return wb->file_exporter;
+}
+
/**
* workbook_foreach_cell_in_range :
*
diff --git a/src/workbook.h b/src/workbook.h
index 1128905..139c787 100644
--- a/src/workbook.h
+++ b/src/workbook.h
@@ -49,6 +49,7 @@ gboolean workbook_set_saveinfo (Workbook *wb, GOFileFormatLevel lev,
GOFileSaver *saver);
void workbook_update_history (Workbook *wb);
GOFileSaver *workbook_get_file_saver (Workbook *wb);
+GOFileSaver *workbook_get_file_exporter (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]