Label wont show right.



Hello,
	I need a callback function that'll pop up a dialog window while its working(sorta like a status dialog, except it shows no status). My problem is that the label thats packed into the dialog window will not show till the last call in the callback function
 is executed eventho the dialog function is the first call in the callback function. Here's the test codes.

#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();
}

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;
}

	Is this something to do with OOP?. I strongly feel that there's a good 
explanation for this rather than a bug, but I'm completely stumped.
						Thanks in advance,
							htn 



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