X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fmain.c;h=d1a4798fd11574b3933f09f0e59b54b616abd818;hb=14125d13946c1b2c3b7efe6cb88e35aa4623210b;hp=9dd4307433ab6a9df9520b7890b8dd242e6c3e20;hpb=24c65a5297ebcff267415163eec06731fc170239;p=pspp diff --git a/src/ui/gui/main.c b/src/ui/gui/main.c index 9dd4307433..d1a4798fd1 100644 --- a/src/ui/gui/main.c +++ b/src/ui/gui/main.c @@ -160,7 +160,7 @@ startup_option_callback (int id, void *show_splash_) } } -static gboolean +static gboolean UNUSED print_startup_time (gpointer data) { g_timer_stop (startup); @@ -210,16 +210,6 @@ remove_psn (int argc, char **argv) } - -struct init_source -{ - GSource parent; - int state; - GMainLoop *loop; - gchar *file; -}; - - gboolean init_prepare (GSource *source, gint *timeout_) { @@ -242,7 +232,8 @@ init_dispatch (GSource *ss, { struct init_source *is = (struct init_source *)ss; - bool finished = initialize (is->file, is->state++); + bool finished = initialize (is); + is->state++; if (finished) { @@ -279,12 +270,6 @@ main (int argc, char *argv[]) startup = g_timer_new (); g_timer_start (startup); - if ( ! gtk_parse_args (&argc, &argv) ) - { - perror ("Error parsing arguments"); - exit (1); - } - if ( (vers = gtk_check_version (GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION)) ) @@ -306,9 +291,7 @@ main (int argc, char *argv[]) exit (EXIT_FAILURE); argv_parser_destroy (parser); - /* Initialise GDK. Theoretically this call can remove options from argc,argv if - it thinks they are gdk options. - However there shouldn't be any here because of the gtk_parse_args call above. */ + /* Initialise GDK. GTK gets initialized later. */ gdk_init (&argc, &argv); GMainContext *context = g_main_context_new (); @@ -326,6 +309,8 @@ main (int argc, char *argv[]) g_source_attach (ss, context); + ((struct init_source *) ss)->argc = &argc; + ((struct init_source *) ss)->argv = &argv; ((struct init_source *) ss)->loop = loop; ((struct init_source *) ss)->file = optind < argc ? argv[optind] : NULL; @@ -336,9 +321,9 @@ main (int argc, char *argv[]) g_main_loop_unref (loop); g_main_context_unref (context); - if (win) + if (win) g_timeout_add (500, destroy_splash_window, win); - + gtk_main (); /* Not much point in this except to check for memory leaks */ @@ -372,25 +357,35 @@ gboolean splash_prepare (GSource *source, gint *timeout_) { + GdkEvent *e = gdk_event_peek (); + if (!e) + return FALSE; + + gdk_event_free (e); return TRUE; } gboolean splash_check (GSource *source) { + GdkEvent *e = gdk_event_peek (); + if (!e) + return FALSE; + + gdk_event_free (e); return TRUE; } + gboolean splash_dispatch (GSource *ss, GSourceFunc callback, gpointer user_data) { struct splash_source *source = (struct splash_source *) ss; - GdkEvent *e = gdk_event_get (); if (!e) - return FALSE; + return TRUE; GdkWindow *w = ((GdkEventAny *)e)->window; @@ -401,8 +396,8 @@ splash_dispatch (GSource *ss, } fill_splash_window (w, source->sfc); + gdk_display_flush (gdk_window_get_display (w)); - gdk_window_show (w); gdk_event_free (e); return TRUE;