Re: Bizarre window behavior



Hi,

Jeff Shipman <shippy nmt edu> writes:

> Well, I finally had a chance today to whip up an
> example piece of code so attached is sample code
> that reproduces the error. After clicking on the
> popup dialog, it should popup the dialog, print
> the things instructed, and then close, but instead
> it hangs until the button that originally opened
> the dialog is clicked, which in turn causes the
> things to print again.

Actually I'm not sure what exactly is causing the problems 
but I guess it's a bad idea to call gtk_window_hide() in a 
signal handler connected to "show" since you are in the 
middle of showing the dialog at this moment. 

Here are some comments about your code:

>    printf("%s\n", text);

You should use g_print() instead of printf(), but this is
of course totally unrelated.

> void dialog_shown(GtkWidget *widget, gpointer data)
> {
>    g_list_foreach(list, do_thing, NULL);
>    printf("\n");
>    gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "show");

What is this good for??

>    gtk_widget_hide(widget);

I'd suggest you change this line to something like

     gtk_timeout_add (500, gtk_widget_hide, widget);

so the dialog gets hidden after the showing process has finished.

>    main_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
>    gtk_window_set_position(GTK_WINDOW(main_win), GTK_WIN_POS_CENTER);
>    gtk_window_set_title(GTK_WINDOW(main_win), "gtk_test");
>    gtk_signal_connect(GTK_OBJECT(main_win), "destroy",
>                       GTK_SIGNAL_FUNC(destroy), NULL);
>    gtk_signal_connect(GTK_OBJECT(main_win), "delete_event",
>                       GTK_SIGNAL_FUNC(destroy), NULL);
>    gtk_window_set_policy(GTK_WINDOW(main_win), FALSE, TRUE, TRUE);
>    gtk_widget_realize(main_win);

Huh? You shouldn't call  gtk_widget_realize() w/o a good reason.
One good reason would be if you need to access main_win->window, 
but I do not see you doing so here.


Salut, Sven




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