X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fmain.c;h=157a0dc8f4bd8ed94bfe4268df3bbe6c1fd62055;hb=bbebcf3f9d827d8c68aeaf90b65c88ad1b77ba8e;hp=2d90ce8fd257648527c26850d1809e8a9b1c6a4c;hpb=7293c1a383d325c371bd708401e5a1d7586a4d90;p=pspp diff --git a/src/ui/gui/main.c b/src/ui/gui/main.c index 2d90ce8fd2..157a0dc8f4 100644 --- a/src/ui/gui/main.c +++ b/src/ui/gui/main.c @@ -57,8 +57,8 @@ show_version_and_exit () return TRUE; } - + gboolean init_prepare (GSource * source, gint * timeout_) @@ -94,7 +94,7 @@ static GSourceFuncs init_funcs = -GtkWidget *wsplash; +GtkWidget *wsplash = 0; gint64 start_time = 0; @@ -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; } @@ -202,39 +211,54 @@ destroy_splash (gpointer ud) { GtkWidget *sp = GTK_WIDGET (ud); gtk_widget_destroy (sp); + wsplash = NULL; return G_SOURCE_REMOVE; } + +static void +wait_for_splash (GApplication *app, GtkWindow *x) +{ + if (wsplash) + { + 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)); + + /* Remove the splash screen after SPLASH_DURATION milliseconds */ + gint64 elapsed_time = (g_get_monotonic_time () - start_time) / 1000; + if (SPLASH_DURATION - elapsed_time <= 0) + destroy_splash (wsplash); + else + g_timeout_add (SPLASH_DURATION - elapsed_time, destroy_splash, wsplash); + } +} + + static void on_activate (GApplication * app, gpointer ud) { post_initialise (app); GtkWindow *x = create_data_window (); - gtk_window_set_transient_for (GTK_WINDOW (wsplash), GTK_WINDOW (x)); gtk_application_add_window (GTK_APPLICATION (app), 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)); - - /* Remove the splash screen after SPLASH_DURATION milliseconds */ - gint64 elapsed_time = (g_get_monotonic_time () - start_time) / 1000; - if (SPLASH_DURATION - elapsed_time <= 0) - destroy_splash (wsplash); - else - g_timeout_add (SPLASH_DURATION - elapsed_time, destroy_splash, wsplash); + + wait_for_splash (app, x); } static void -on_open (GApplication * app, GFile ** files, gint n_files, gchar * hint, +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); } @@ -244,7 +268,7 @@ process_pre_start_arguments (int *argc, char ***argv) { GOptionEntry oe[] = { {"version", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, - show_version_and_exit, "Show version information and exit", 0}, + show_version_and_exit, N_("Show version information and exit"), 0}, {NULL} }; @@ -259,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); @@ -266,7 +292,9 @@ main (int argc, char *argv[]) GOptionEntry oe[] = { {"no-splash", 'q', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, - "Do not display the splash screen", 0}, + 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} };