Irregular gtk application behavior - Help

Hi all

Im testing the follwing code and I have some problems. I want to emulate a temporized label. When the application start I want to show the label and after x time (here 2 sec) I want to destroy it. When I run the applictation sometimes the label isn't shown but sometimes it's shown well. What's wrong? Any Idea? How can I solve this problem? What do I have to change in the code to emulate this? Any suggestion?

Thank a lot


// prueba.c

#include <stdlib.h>
#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <unistd.h>

GtkWidget *window;
GtkWidget *label;

gint func (void)
// g_print("Event \n");

sleep (1);
   gtk_widget_destroy (window);
//    g_print("End Event \n");

return FALSE;

void Create_Window (char *text_label)


   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

   label = gtk_label_new (text_label);
   gtk_widget_set_name(label, "mylabel");
   gtk_container_add (GTK_CONTAINER (window), label);

   gtk_widget_set_uposition ( window, 550, 61);

   gtk_widget_show (label);
   gtk_widget_show_all (window);


int main( int argc,
char *argv[] )

   char mensaje[] = {"Hello World"};

gtk_init (&argc, &argv); Create_Window ( mensaje);

   gtk_idle_add((GtkFunction) func, NULL);
// g_print ("End of main loop\n");


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