[gnumeric] ssconvert: don't save configuration



commit ab31a649d0516a20cd3f4cb1e130086cfde30ded
Author: Morten Welinder <terra gnome org>
Date:   Thu May 17 20:27:17 2018 -0400

    ssconvert: don't save configuration
    
    This should avoid warnings about dbus not being started without DISPLAY
    set.

 NEWS                |    1 +
 src/gnumeric-conf.c |   57 ++++++++++++++++++++++++++++++++++++++------------
 src/gnumeric-conf.h |    2 +
 src/ssconvert.c     |    3 ++
 src/ssdiff.c        |    4 +++
 src/ssgrep.c        |    3 ++
 src/ssindex.c       |    3 ++
 src/sstest.c        |    3 ++
 8 files changed, 62 insertions(+), 14 deletions(-)
---
diff --git a/NEWS b/NEWS
index 04eedf3..df5a5a6 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Morten:
        * Test suite improvements.
        * ssconvert improvements.
        * Makefile improvements.
+       * Don't save any configuration when running ssconvert/ssdiff/...
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.41
diff --git a/src/gnumeric-conf.c b/src/gnumeric-conf.c
index f1b8f19..aa2ff98 100644
--- a/src/gnumeric-conf.c
+++ b/src/gnumeric-conf.c
@@ -47,6 +47,8 @@
 
 #define GNM_CONF_DIR "gnumeric"
 
+static gboolean persist_changes = TRUE;
+
 static GOConfNode *root = NULL;
 
 /*
@@ -204,8 +206,10 @@ set_bool (struct cb_watch_bool *watch, gboolean x)
 
        MAYBE_DEBUG_SET (watch->key);
        watch->var = x;
-       go_conf_set_bool (root, watch->key, x);
-       schedule_sync ();
+       if (persist_changes) {
+               go_conf_set_bool (root, watch->key, x);
+               schedule_sync ();
+       }
 }
 
 /* ---------------------------------------- */
@@ -249,8 +253,10 @@ set_int (struct cb_watch_int *watch, int x)
 
        MAYBE_DEBUG_SET (watch->key);
        watch->var = x;
-       go_conf_set_int (root, watch->key, x);
-       schedule_sync ();
+       if (persist_changes) {
+               go_conf_set_int (root, watch->key, x);
+               schedule_sync ();
+       }
 }
 
 /* ---------------------------------------- */
@@ -294,8 +300,10 @@ set_double (struct cb_watch_double *watch, double x)
 
        MAYBE_DEBUG_SET (watch->key);
        watch->var = x;
-       go_conf_set_double (root, watch->key, x);
-       schedule_sync ();
+       if (persist_changes) {
+               go_conf_set_double (root, watch->key, x);
+               schedule_sync ();
+       }
 }
 
 /* ---------------------------------------- */
@@ -343,8 +351,10 @@ set_string (struct cb_watch_string *watch, const char *x)
        watch->var = xc;
        /* Update pool before setting so monitors see the right value.  */
        g_hash_table_replace (string_pool, (gpointer)watch->key, xc);
-       go_conf_set_string (root, watch->key, xc);
-       schedule_sync ();
+       if (persist_changes) {
+               go_conf_set_string (root, watch->key, xc);
+               schedule_sync ();
+       }
 }
 
 /* ---------------------------------------- */
@@ -381,8 +391,10 @@ static gboolean
 string_list_equal (GSList *x, GSList *y)
 {
        while (x && y) {
-               if (strcmp (x->data, y->data) != 0)
+               if (strcmp (x->data, y->data) != 0) {
+                       g_printerr ("Diff: %s %s\n", x->data, y->data);
                        return FALSE;
+               }
                x = x->next;
                y = y->next;
        }
@@ -402,8 +414,10 @@ set_string_list (struct cb_watch_string_list *watch, GSList *x)
        watch->var = x;
        /* Update pool before setting so monitors see the right value.  */
        g_hash_table_replace (string_list_pool, (gpointer)watch->key, x);
-       go_conf_set_str_list (root, watch->key, x);
-       schedule_sync ();
+       if (persist_changes) {
+               go_conf_set_str_list (root, watch->key, x);
+               schedule_sync ();
+       }
 }
 
 /* ---------------------------------------- */
@@ -446,8 +460,10 @@ set_enum (struct cb_watch_enum *watch, int x)
 
        MAYBE_DEBUG_SET (watch->key);
        watch->var = x;
-       go_conf_set_enum (root, watch->key, watch->typ, x);
-       schedule_sync ();
+       if (persist_changes) {
+               go_conf_set_enum (root, watch->key, watch->typ, x);
+               schedule_sync ();
+       }
 }
 
 /* -------------------------------------------------------------------------- */
@@ -494,7 +510,7 @@ gnm_conf_shutdown (void)
        if (debug_getters || debug_setters)
                g_printerr ("gnm_conf_shutdown\n");
 
-       go_conf_sync (root);
+       //go_conf_sync (root);
        if (sync_handler) {
                g_source_remove (sync_handler);
                sync_handler = 0;
@@ -519,6 +535,19 @@ gnm_conf_shutdown (void)
 }
 
 /**
+ * gnm_conf_set_persistence:
+ * @persist: whether to save changes
+ *
+ * If @persist is %TRUE, then changes from this point on will not be saved.
+ */
+void
+gnm_conf_set_persistence (gboolean persist)
+{
+       persist_changes = persist;
+}
+
+
+/**
  * gnm_conf_get_page_setup:
  *
  * Returns: (transfer full): the default #GtkPageSetup.
diff --git a/src/gnumeric-conf.h b/src/gnumeric-conf.h
index 9ca710a..3e573d8 100644
--- a/src/gnumeric-conf.h
+++ b/src/gnumeric-conf.h
@@ -9,6 +9,8 @@ G_BEGIN_DECLS
 
 void     gnm_conf_init (void);
 void     gnm_conf_shutdown (void);
+void     gnm_conf_set_persistence (gboolean persist);
+
 GOConfNode *gnm_conf_get_root (void);
 
 char const *gnm_conf_get_short_desc (GOConfNode *node);
diff --git a/src/ssconvert.c b/src/ssconvert.c
index 3a39b3c..319e302 100644
--- a/src/ssconvert.c
+++ b/src/ssconvert.c
@@ -30,6 +30,7 @@
 #include <command-context.h>
 #include <command-context-stderr.h>
 #include <workbook-view.h>
+#include <gnumeric-conf.h>
 #include <tools/analysis-tools.h>
 #include <dialogs/dialogs.h>
 #include <goffice/goffice.h>
@@ -1046,6 +1047,8 @@ main (int argc, char const **argv)
        /* No code before here, we need to init threads */
        argv = gnm_pre_parse_init (argc, argv);
 
+       gnm_conf_set_persistence (FALSE);
+
        ocontext = g_option_context_new (_("INFILE [OUTFILE]"));
        g_option_context_add_main_entries (ocontext, ssconvert_options, GETTEXT_PACKAGE);
        g_option_context_add_group (ocontext, gnm_get_option_group ());
diff --git a/src/ssdiff.c b/src/ssdiff.c
index b9aeeed..42743d6 100644
--- a/src/ssdiff.c
+++ b/src/ssdiff.c
@@ -32,6 +32,8 @@
 #include <input-msg.h>
 #include <expr-name.h>
 #include <sheet-diff.h>
+#include <gnumeric-conf.h>
+
 #include <gsf/gsf-libxml.h>
 #include <gsf/gsf-output-stdio.h>
 #include <gsf/gsf-input.h>
@@ -922,6 +924,8 @@ main (int argc, char const **argv)
        // No code before here, we need to init threads
        argv = gnm_pre_parse_init (argc, argv);
 
+       gnm_conf_set_persistence (FALSE);
+
        ocontext = g_option_context_new (_("OLDFILE NEWFILE"));
        g_option_context_add_main_entries (ocontext, ssdiff_options, GETTEXT_PACKAGE);
        g_option_context_add_group        (ocontext, gnm_get_option_group ());
diff --git a/src/ssgrep.c b/src/ssgrep.c
index 9d2f39d..bc90a84 100644
--- a/src/ssgrep.c
+++ b/src/ssgrep.c
@@ -21,6 +21,7 @@
 #include <func.h>
 #include <parse-util.h>
 #include <sheet-object-cell-comment.h>
+#include <gnumeric-conf.h>
 
 #include <gsf/gsf-input-stdio.h>
 #include <gsf/gsf-input-textline.h>
@@ -423,6 +424,8 @@ main (int argc, char const **argv)
        /* No code before here, we need to init threads */
        argv = gnm_pre_parse_init (argc, argv);
 
+       gnm_conf_set_persistence (FALSE);
+
        ocontext = g_option_context_new (_("PATTERN INFILE..."));
        g_option_context_add_main_entries (ocontext, ssgrep_options, GETTEXT_PACKAGE);
        g_option_context_add_group        (ocontext, gnm_get_option_group ());
diff --git a/src/ssindex.c b/src/ssindex.c
index c7df7d8..14274fd 100644
--- a/src/ssindex.c
+++ b/src/ssindex.c
@@ -27,6 +27,7 @@
 #include <validation.h>
 #include <sheet-object-graph.h>
 #include <gnm-plugin.h>
+#include <gnumeric-conf.h>
 
 #include <gsf/gsf-utils.h>
 #include <gsf/gsf-libxml.h>
@@ -246,6 +247,8 @@ main (int argc, char const **argv)
        /* No code before here, we need to init threads */
        argv = gnm_pre_parse_init (argc, argv);
 
+       gnm_conf_set_persistence (FALSE);
+
        ocontext = g_option_context_new (_("INFILE..."));
        g_option_context_add_main_entries (ocontext, ssindex_options, GETTEXT_PACKAGE);
        g_option_context_add_group        (ocontext, gnm_get_option_group ());
diff --git a/src/sstest.c b/src/sstest.c
index ff3cfed..8c11513 100644
--- a/src/sstest.c
+++ b/src/sstest.c
@@ -27,6 +27,7 @@
 #include <sf-dpq.h>
 #include <sf-gamma.h>
 #include <rangefunc.h>
+#include <gnumeric-conf.h>
 
 #include <gsf/gsf-input-stdio.h>
 #include <gsf/gsf-input-textline.h>
@@ -3473,6 +3474,8 @@ main (int argc, char const **argv)
        /* No code before here, we need to init threads */
        argv = gnm_pre_parse_init (argc, argv);
 
+       gnm_conf_set_persistence (FALSE);
+
        ocontext = g_option_context_new (_("[testname]"));
        g_option_context_add_main_entries (ocontext, sstest_options, GETTEXT_PACKAGE);
        g_option_context_add_group        (ocontext, gnm_get_option_group ());


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