Switching windows after giving delay in Maemo
Hello,
I am using g_usleep in my 1st window. And after specified time interval I want to display 2nd window.
My code is as follows:
HildonWindow *window;
static gboolean main_quit_handler(GtkWidget *image)
{
GtkWidget *win;
GtkWidget *vbox;
GtkWidget *label;
/* Create the main window */
win = hildon_stackable_window_new();
gtk_window_set_title(GTK_WINDOW (win), "Display image ");
/* Setting a label in the new window */
label = gtk_label_new("Hello");
gtk_container_add(GTK_CONTAINER (win), label);
g_usleep(500);
gtk_container_remove(GTK_CONTAINER (window), image);
gtk_widget_show_all(win);
gtk_container_add(GTK_CONTAINER (window), label);
gtk_widget_show_all ( GTK_WIDGET ( window ) );
}
int main
{
--------
GtkWidget *image;
gboolean value;
image = gtk_image_new_from_file("my_file_path");
gtk_container_add(GTK_CONTAINER (window), image);
gtk_widget_show_all ( GTK_WIDGET ( window ) );
gtk_quit_add(0, main_quit_handler, image);
gtk_main();
return 0;
}
When i run the code I am able to see only 1st window. 2nd window isnt visible.
Any help please?
Re: Switching windows after giving delay in Maemo
What you should do to achieve your goal:
1. Connect callback to delete-event of the first window
[url]http://library.gnome.org/devel/gtk/2.21/GtkWidget.html#GtkWidget-delete-event[/url]
2. In this callback add timeout callback with g_timeout_add
[url]http://library.gnome.org/devel/glib/unstable/glib-The-Main-Event-Loop.html#g-timeout-add[/url]
3. Do in this callback what you currently do in main_quit_handler except of using g_usleep.