[gnumeric] Add preference setting to disable the extension check for the configurable text exporter. [#594151]



commit c5606473943f5861c1316b5f78eb7192a0a87062
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Wed Jul 14 10:07:48 2010 -0600

    Add preference setting to disable the extension check for the configurable text exporter. [#594151]
    
    2010-07-14  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* schemas/gnumeric-general.schemas.in
    	(/schemas/apps/gnumeric/core/file/save/extension-check-disabled): new
    	* src/gnumeric-gconf.h: include above key
    	* src/gnumeric-gconf.c: ditto
    	* src/gui-file.c (extension_check_disabled): new
    	(gui_file_save_as): obey the extension-check-disabled preference
    
    2010-07-14  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* dialog-preferences.c (custom_pref_conf_to_widget_ecd): new
    	(gnm_conf_set_core_file_save_extension_check_disabled_wrap): new
    	(gnm_conf_get_core_file_save_extension_check_disabled_wrap): new
    	(custom_pref_create_widget_ecd): new
    	(pref_file_page_initializer): add disable-extension-check check box

 ChangeLog                           |    9 +++++
 NEWS                                |    2 +
 schemas/gnumeric-general.schemas.in |   11 ++++++
 src/dialogs/ChangeLog               |    8 ++++
 src/dialogs/dialog-preferences.c    |   62 +++++++++++++++++++++++++++++++++++
 src/gnumeric-gconf.c                |   30 ++++++++++++++++-
 src/gnumeric-gconf.h                |    4 ++
 src/gui-file.c                      |   14 +++++++-
 8 files changed, 136 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 33900ca..6e8c16a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-07-14  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* schemas/gnumeric-general.schemas.in 
+	(/schemas/apps/gnumeric/core/file/save/extension-check-disabled): new
+	* src/gnumeric-gconf.h: include above key
+	* src/gnumeric-gconf.c: ditto
+	* src/gui-file.c (extension_check_disabled): new
+	(gui_file_save_as): obey the extension-check-disabled preference
+
 2010-07-13  Morten Welinder  <terra gnome org>
 
 	* src/parse-util.h (gnm_expr_lex_all): new
diff --git a/NEWS b/NEWS
index 4c916f9..cb18b85 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,8 @@ Andreas:
 	* Show the number of rows filtered by the auto filter. [#346002]
 	* Improve function tooltips. [#623322]
 	* Improve expression entry range selection. [#80725][#624288][#624289]
+	* Add preference setting to disable the extension check for the 
+	  configurable text exporter. [#594151]
 
 Jean:
 	* Fix strong/weak cursor display. [#623241]
diff --git a/schemas/gnumeric-general.schemas.in b/schemas/gnumeric-general.schemas.in
index 7e92a3e..ae11782 100644
--- a/schemas/gnumeric-general.schemas.in
+++ b/schemas/gnumeric-general.schemas.in
@@ -372,6 +372,17 @@ they are also processed at that time. If `lag' is negative, then recalculation h
         </locale>
       </schema>
       <schema>
+        <key>/schemas/apps/gnumeric/core/file/save/extension-check-disabled</key>
+        <applyto>/apps/gnumeric/core/file/save/extension-check-disabled</applyto>
+        <owner>Gnumeric</owner>
+        <type>list</type>
+	<list_type>string</list_type>
+        <locale name="C">
+        <short>List of file savers with disabled extension check.</short>
+        <long>This list contains the ids of the file savers for which the extension check is disabled.</long>
+        </locale>
+      </schema>
+      <schema>
         <key>/schemas/apps/gnumeric/core/sort/default/by-case</key>
         <applyto>/apps/gnumeric/core/sort/default/by-case</applyto>
         <owner>Gnumeric</owner>
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 997456c..be44f4d 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,11 @@
+2010-07-14  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* dialog-preferences.c (custom_pref_conf_to_widget_ecd): new
+	(gnm_conf_set_core_file_save_extension_check_disabled_wrap): new
+	(gnm_conf_get_core_file_save_extension_check_disabled_wrap): new
+	(custom_pref_create_widget_ecd): new
+	(pref_file_page_initializer): add disable-extension-check check box
+	
 2010-07-09  Morten Welinder  <terra gnome org>
 
 	* dialog-stf-fixed-page.c (calc_char_index): add missing
diff --git a/src/dialogs/dialog-preferences.c b/src/dialogs/dialog-preferences.c
index 60e6d2f..a5b177d 100644
--- a/src/dialogs/dialog-preferences.c
+++ b/src/dialogs/dialog-preferences.c
@@ -867,6 +867,63 @@ pref_window_page_initializer (PrefState *state,
 /*                     File/XML Preferences Page                                           */
 /*******************************************************************************************/
 
+static void
+gnm_conf_set_core_file_save_extension_check_disabled_wrap (gboolean val)
+{
+	GSList *list = NULL;
+
+	if (val)
+		list = g_slist_prepend (NULL, (char *)"Gnumeric_stf:stf_assistant");
+	gnm_conf_set_core_file_save_extension_check_disabled (list);
+	g_slist_free (list);
+}
+static gboolean
+gnm_conf_get_core_file_save_extension_check_disabled_wrap (void)
+{
+	GSList *list = gnm_conf_get_core_file_save_extension_check_disabled ();
+	return (NULL != g_slist_find_custom (list, "Gnumeric_stf:stf_assistant", go_str_compare));
+}
+
+static void
+custom_pref_conf_to_widget_ecd (GOConfNode *node, G_GNUC_UNUSED char const *key,
+				GtkToggleButton *button)
+{
+	gboolean val_in_button = gtk_toggle_button_get_active (button);
+
+	/* We can't use the getter here since the main preferences */
+	/* may be notified after us */
+	GSList *list = go_conf_get_str_list (node, NULL);
+	gboolean val_in_conf 
+		= (NULL != g_slist_find_custom (list, "Gnumeric_stf:stf_assistant", go_str_compare));
+
+	if ((!val_in_button) != (!val_in_conf))
+		gtk_toggle_button_set_active (button, val_in_conf);
+}
+static void
+custom_pref_create_widget_ecd (GOConfNode *node, GtkWidget *table,
+			       gint row, gboolean_conf_setter_t setter,
+			       gboolean_conf_getter_t getter,
+			       char const *default_label)
+{
+	GtkWidget *item = gtk_check_button_new_with_label (default_label);
+
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), getter ());
+
+	g_object_set_data (G_OBJECT (item), "getter", getter);
+	g_signal_connect (G_OBJECT (item), "toggled",
+			  G_CALLBACK (bool_pref_widget_to_conf),
+			  (gpointer) setter);
+	gtk_table_attach (GTK_TABLE (table), item,
+		0, 2, row, row + 1,
+		GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 5, 5);
+
+	connect_notification (node, (GOConfMonitorFunc)custom_pref_conf_to_widget_ecd,
+			      item, table);
+}
+
+
+
+
 static GtkWidget *
 pref_file_page_initializer (PrefState *state,
 			    G_GNUC_UNUSED gpointer data,
@@ -903,6 +960,11 @@ pref_file_page_initializer (PrefState *state,
 				 gnm_conf_set_plugin_latex_use_utf8,
 				 gnm_conf_get_plugin_latex_use_utf8,
 				 _("Use UTF-8 in LaTeX Export"));
+	custom_pref_create_widget_ecd ( gnm_conf_get_core_file_save_extension_check_disabled_node (),
+					page, row++,
+					gnm_conf_set_core_file_save_extension_check_disabled_wrap,
+					gnm_conf_get_core_file_save_extension_check_disabled_wrap,
+					_("Disable Extension Check for Configurable Text Exporter"));
 
 	gtk_widget_show_all (page);
 	return page;
diff --git a/src/gnumeric-gconf.c b/src/gnumeric-gconf.c
index 8d2eddb..320d3c3 100644
--- a/src/gnumeric-gconf.c
+++ b/src/gnumeric-gconf.c
@@ -3,9 +3,9 @@
  * gnumeric-gconf.c:
  *
  * Author:
- *	Andreas J. Guelzow <aguelzow taliesin ca>
+ *	Andreas J. Guelzow <aguelzow pyrshep ca>
  *
- * (C) Copyright 2002-2005 Andreas J. Guelzow <aguelzow taliesin ca>
+ * (C) Copyright 2002-2005 Andreas J. Guelzow <aguelzow pyrshep ca>
  * (C) Copyright 2009 Morten Welinder <terra gnome org>
  *
  * Introduced the concept of "node" and implemented the win32 backend
@@ -1024,6 +1024,32 @@ gnm_conf_get_core_file_save_def_overwrite_node (void)
 	return get_node (watch_core_file_save_def_overwrite.key);
 }
 
+static struct cb_watch_string_list watch_core_file_save_extension_check_disabled = {
+	0, "core/file/save/extension-check-disabled",
+};
+
+GSList *
+gnm_conf_get_core_file_save_extension_check_disabled (void)
+{
+	if (!watch_core_file_save_extension_check_disabled.handler)
+		watch_string_list (&watch_core_file_save_extension_check_disabled);
+	return watch_core_file_save_extension_check_disabled.var;
+}
+
+void
+gnm_conf_set_core_file_save_extension_check_disabled (GSList *x)
+{
+	if (!watch_core_file_save_extension_check_disabled.handler)
+		watch_string_list (&watch_core_file_save_extension_check_disabled);
+	set_string_list (&watch_core_file_save_extension_check_disabled, x);
+}
+
+GOConfNode *
+gnm_conf_get_core_file_save_extension_check_disabled_node (void)
+{
+	return get_node (watch_core_file_save_extension_check_disabled.key);
+}
+
 static struct cb_watch_bool watch_core_file_save_single_sheet = {
 	0, "core/file/save/single_sheet", TRUE,
 };
diff --git a/src/gnumeric-gconf.h b/src/gnumeric-gconf.h
index 43d0c49..41cbfe7 100644
--- a/src/gnumeric-gconf.h
+++ b/src/gnumeric-gconf.h
@@ -89,6 +89,10 @@ GOConfNode *gnm_conf_get_core_file_save_def_overwrite_node (void);
 gboolean gnm_conf_get_core_file_save_def_overwrite (void);
 void gnm_conf_set_core_file_save_def_overwrite (gboolean);
 
+GOConfNode *gnm_conf_get_core_file_save_extension_check_disabled_node (void);
+GSList *gnm_conf_get_core_file_save_extension_check_disabled (void);
+void gnm_conf_set_core_file_save_extension_check_disabled (GSList *);
+
 GOConfNode *gnm_conf_get_core_file_save_single_sheet_node (void);
 gboolean gnm_conf_get_core_file_save_single_sheet (void);
 void gnm_conf_set_core_file_save_single_sheet (gboolean);
diff --git a/src/gui-file.c b/src/gui-file.c
index ccd9f7b..c93a83a 100644
--- a/src/gui-file.c
+++ b/src/gui-file.c
@@ -1,11 +1,11 @@
-/* vim: set sw=8: */
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  * GUI-file.c:
  *
  * Authors:
  *    Jon K Hellan (hellan acm org)
  *    Zbigniew Chyla (cyba gnome pl)
- *    Andreas J. Guelzow (aguelzow taliesin ca)
+ *    Andreas J. Guelzow (aguelzow pyrshep ca)
  *
  * Port to Maemo:
  *	Eduardo Lima  (eduardo lima indt org br)
@@ -397,6 +397,15 @@ check_multiple_sheet_support_if_needed (GOFileSaver *fs,
 	return (ret_val);
 }
 
+static gboolean
+extension_check_disabled (GOFileSaver *fs)
+{
+	GSList *list = gnm_conf_get_core_file_save_extension_check_disabled ();
+	char const *id = go_file_saver_get_id (fs);
+
+	return (NULL != g_slist_find_custom (list, id, go_str_compare));
+}
+
 gboolean
 gui_file_save_as (WBCGtk *wbcg, WorkbookView *wb_view)
 {
@@ -530,6 +539,7 @@ gui_file_save_as (WBCGtk *wbcg, WorkbookView *wb_view)
 		if (!go_url_check_extension (uri,
 					     go_file_saver_get_extension (fs),
 					     &uri2) &&
+		    !extension_check_disabled (fs) &&
 		    !go_gtk_query_yes_no (GTK_WINDOW (fsel),
 					  TRUE,
 					  _("The given file extension does not match the"



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]