Frequencies Piecharts (gui): Emit 'NOMISSING' when appropriate.
[pspp] / src / ui / gui / main.c
index c860a077618500eb34ce0b18d2541acff2adf569..157a0dc8f4bd8ed94bfe4268df3bbe6c1fd62055 100644 (file)
@@ -57,8 +57,8 @@ show_version_and_exit ()
 
   return TRUE;
 }
-\f
 
+\f
 
 gboolean
 init_prepare (GSource * source, gint * timeout_)
@@ -139,19 +139,28 @@ static gint
 on_local_options (GApplication * application,
                   GVariantDict * options, gpointer user_data)
 {
-  GVariant *b;
-
-  b =
-    g_variant_dict_lookup_value (options, "no-splash",
-                                 G_VARIANT_TYPE_BOOLEAN);
-  if (b)
-    {
+  {
+    GVariant *b =
+      g_variant_dict_lookup_value (options, "no-unique",
+                                  G_VARIANT_TYPE_BOOLEAN);
+    if (b)
+      {
+       GApplicationFlags flags =  g_application_get_flags (application);
+       flags |= G_APPLICATION_NON_UNIQUE;
+       g_application_set_flags (application, flags);
+       g_variant_unref (b);
+      }
+  }
+  {
+    GVariant *b =
+      g_variant_dict_lookup_value (options, "no-splash",
+                                  G_VARIANT_TYPE_BOOLEAN);
+    if (b)
       g_variant_unref (b);
-    }
-  else
-    {
+    else
       start_time = g_get_monotonic_time ();
-    }
+  }
+
 
   return -1;
 }
@@ -206,16 +215,13 @@ destroy_splash (gpointer ud)
   return G_SOURCE_REMOVE;
 }
 
+
 static void
-on_activate (GApplication * app, gpointer ud)
+wait_for_splash (GApplication *app, GtkWindow *x)
 {
-  post_initialise (app);
-
-  GtkWindow *x = create_data_window ();
   if (wsplash)
     {
-      gtk_window_set_transient_for (GTK_WINDOW (wsplash), GTK_WINDOW (x));
-      gtk_application_add_window (GTK_APPLICATION (app), x);
+      gtk_window_set_transient_for (GTK_WINDOW (wsplash), x);
       gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (wsplash));
       gtk_window_set_keep_above (GTK_WINDOW (wsplash), TRUE);
       gtk_window_present (GTK_WINDOW (wsplash));
@@ -231,14 +237,28 @@ on_activate (GApplication * app, gpointer ud)
 
 
 static void
-on_open (GApplication * app, GFile ** files, gint n_files, gchar * hint,
+on_activate (GApplication * app, gpointer ud)
+{
+  post_initialise (app);
+
+  GtkWindow *x = create_data_window ();
+  gtk_application_add_window (GTK_APPLICATION (app), x);
+
+  wait_for_splash (app, x);
+}
+
+
+static void
+on_open (GApplication *app, GFile **files, gint n_files, gchar * hint,
          gpointer ud)
 {
   post_initialise (app);
 
   gchar *file = g_file_get_parse_name (files[0]);
-  psppire_preload_file (file);
+  GtkWindow *x = psppire_preload_file (file);
   g_free (file);
+
+  wait_for_splash (app, x);
 }
 
 
@@ -263,6 +283,8 @@ process_pre_start_arguments (int *argc, char ***argv)
 int
 main (int argc, char *argv[])
 {
+  set_program_name (argv[0]);
+
   GtkApplication *app =
     gtk_application_new ("gnu.pspp", G_APPLICATION_HANDLES_OPEN);
 
@@ -271,6 +293,8 @@ main (int argc, char *argv[])
   GOptionEntry oe[] = {
     {"no-splash", 'q', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL,
       N_("Do not display the splash screen"), 0},
+    {"no-unique", 'n', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL,
+      N_("Do not attempt single instance negotiation"), 0},
     {NULL}
   };