[gnumeric] sstest: move --dump-func-state to here from main binary.



commit 90b9fb1d26513302d09a76763d11bda8ea9ccf4a
Author: Morten Welinder <terra gnome org>
Date:   Wed Nov 29 18:48:15 2017 -0500

    sstest: move --dump-func-state to here from main binary.
    
    Last one.  "with_gui" now always true in main binary, so code simplifies.

 src/main-application.c |   45 +++++++++++----------------------------------
 src/sstest.c           |   10 ++++++++++
 2 files changed, 21 insertions(+), 34 deletions(-)
---
diff --git a/src/main-application.c b/src/main-application.c
index e17bd79..91e4e29 100644
--- a/src/main-application.c
+++ b/src/main-application.c
@@ -49,7 +49,6 @@
 static gboolean immediate_exit_flag = FALSE;
 static gboolean gnumeric_no_splash = FALSE;
 static gboolean gnumeric_no_warnings = FALSE;
-static gchar  *func_state_file = NULL;
 static gchar  *geometry = NULL;
 static gchar **startup_files;
 
@@ -70,12 +69,6 @@ static const GOptionEntry gnumeric_options [] = {
        /*********************************
         * Hidden Actions */
        {
-               "dump-func-state", 0,
-               G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME, &func_state_file,
-               N_("Dumps the function definitions"),
-               N_("FILE")
-       },
-       {
                "quit", 0,
                G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &immediate_exit_flag,
                N_("Exit immediately after loading the selected books"),
@@ -204,7 +197,6 @@ int
 main (int argc, char const **argv)
 {
        gboolean opened_workbook = FALSE;
-       gboolean with_gui;
        GOIOContext *ioc;
        WorkbookView *wbv;
        GSList *wbcgs_to_kill = NULL;
@@ -249,34 +241,19 @@ main (int argc, char const **argv)
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
        bind_textdomain_codeset (GETTEXT_PACKAGE "-functions", "UTF-8");
 
-       with_gui = !func_state_file;
-
-       if (with_gui) {
-               gnm_session_init (argv[0]);
-       }
+       gnm_session_init (argv[0]);
 
        gnm_init ();
 
-       /* These are useful for the build process only.  */
-       if (func_state_file)
-               return gnm_dump_func_defs (func_state_file, 0);
-
-       if (with_gui) {
-               go_component_set_default_command_context (cc = gnm_cmd_context_stderr_new ());
-               g_object_unref (cc);
-               cc = g_object_new (GNM_TYPE_IO_CONTEXT_GTK,
-                                  "show-splash", !gnumeric_no_splash,
-                                  "show-warnings", !gnumeric_no_warnings,
-                                  NULL);
-               ioc = GO_IO_CONTEXT (g_object_ref (cc));
-               handle_paint_events ();
-               pathetic_qt_workaround ();
-       } else {
-               /* TODO: Make this inconsistency go away */
-               cc = gnm_cmd_context_stderr_new ();
-               ioc = go_io_context_new (cc);
-               go_component_set_default_command_context (cc);
-       }
+       go_component_set_default_command_context (cc = gnm_cmd_context_stderr_new ());
+       g_object_unref (cc);
+       cc = g_object_new (GNM_TYPE_IO_CONTEXT_GTK,
+                          "show-splash", !gnumeric_no_splash,
+                          "show-warnings", !gnumeric_no_warnings,
+                          NULL);
+       ioc = GO_IO_CONTEXT (g_object_ref (cc));
+       handle_paint_events ();
+       pathetic_qt_workaround ();
 
        /* Keep in sync with .desktop file */
        g_set_application_name (_("Gnumeric Spreadsheet"));
@@ -388,7 +365,7 @@ main (int argc, char const **argv)
         * This helps finding leaks.  We might want it in developent
         * only.
         */
-       if (with_gui && gnm_debug_flag ("close-displays")) {
+       if (gnm_debug_flag ("close-displays")) {
                GSList *displays;
 
                gdk_flush();
diff --git a/src/sstest.c b/src/sstest.c
index 168bf47..85fff58 100644
--- a/src/sstest.c
+++ b/src/sstest.c
@@ -37,6 +37,7 @@
 static gboolean sstest_show_version = FALSE;
 static gboolean sstest_fast = FALSE;
 static gchar *func_def_file = NULL;
+static gchar *func_state_file = NULL;
 static gchar *ext_refs_file = NULL;
 static gchar *samples_file = NULL;
 
@@ -56,6 +57,13 @@ static GOptionEntry const sstest_options [] = {
        },
 
        {
+               "dump-func-state", 0,
+               0, G_OPTION_ARG_FILENAME, &func_state_file,
+               N_("Dumps the function definitions"),
+               N_("FILE")
+       },
+
+       {
                "ext-refs-file", 0,
                0, G_OPTION_ARG_FILENAME, &ext_refs_file,
                N_("Dumps web page for function help"),
@@ -2681,6 +2689,8 @@ main (int argc, char const **argv)
                go_error_info_free (plugin_errs);
        }
 
+       if (func_state_file)
+               return gnm_dump_func_defs (func_state_file, 0);
        if (func_def_file)
                return gnm_dump_func_defs (func_def_file, 1);
        if (ext_refs_file)


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