Re: [gtk-list] RE: Label wont show right.



> See the FAQ question 4.11 (whose name I'm gonna have to change).

I still get unexpected behaviour even with
	 while(gtk_event_pending())
		gtk_main_iteration();
in the function. The label showes up once or twice or whenever it feels like it..:). Am i doing something wrong? This isnt the X server queing on me , is it?.
Doesnt gdk_flush() take care of that?. Here's the codes again. And thanks for your help.

#include <gtk/gtk.h>

static GtkWidget *wwin;

static void wdialog()
{
        GtkWidget *label;

        wwin = gtk_window_new(GTK_WINDOW_DIALOG);
        gtk_widget_set_usize(wwin,100,20);

        label = gtk_label_new("Please wait...");
        gtk_container_add(GTK_CONTAINER(wwin),label);

        gtk_widget_show(label);
        gtk_widget_show(wwin);
        gdk_flush();
	while(gtk_event_pending())
		gtk_main_iteration();
}

static void callback(GtkWidget *widget)
{
        g_print("start\n");
        wdialog();
        g_print("doing some work.....\n");
        sleep(5);
        g_print("end\n");
	
	/* dialog should be destroyed at this point here. I commented out so
	 * that you can see the label in the dialog window. The label will
	 * not show until the last call which is g_print("end\n") is executed.
	 * Another word, when callback() is thru.
	*/ 
/*       gtk_widget_destroy(wwin); */
}

int main(int argc,char *argv[])
{
        GtkWidget *window;
        GtkWidget *button;

        gtk_init(&argc,&argv);

        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_widget_set_usize(window,100,20);

        button = gtk_button_new_with_label("test");
        gtk_signal_connect(GTK_OBJECT(button),"clicked",
                           GTK_SIGNAL_FUNC(callback),NULL);
        gtk_container_add(GTK_CONTAINER(window),button);

        gtk_widget_show(button);
        gtk_widget_show(window);

        gtk_main();
        return 0;
}

						Thanks in advance,
							htn 



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