Animiertes Gif unter GTK
-
Hi, I have a problem with keeping an animated gif running while the gtk main loop is blocked.
The gif (called waitImage) is placed on a GtkDialog (waitDialog). The GdkPixbufAnimation "behind" waitImage is called waitImageAnimated.
I tried to do it like this:while(...) { gtk_widget_queue_draw(GTK_WIDGET (GTK_DIALOG (waitDlg)->vbox)); gdk_window_process_updates (gtk_widget_get_parent_window (GTK_DIALOG (waitDlg)->vbox), true); waitImagePixbuf = gdk_pixbuf_animation_iter_get_pixbuf( gdk_pixbuf_animation_get_iter(waitImageAnimated, NULL)); gtk_image_set_from_pixbuf(GTK_IMAGE (waitImage),waitImagePixbuf); }
But this doesn't work. The gif doesn't run.
Does anybody know, how to do it correctly?
A solution without memory leaks would be especially niceThank you, dasaspock
-
Ok: Ich hab's.
So funktionierts:GdkPixbufAnimationIter *animIter = gdk_pixbuf_animation_get_iter(waitImageAnimated, NULL); while(WaitForSingleObject(hHomeThread,100) == WAIT_TIMEOUT) { gtk_widget_queue_draw(GTK_WIDGET (GTK_DIALOG (waitDlg)->vbox)); gdk_window_process_updates (gtk_widget_get_parent_window (GTK_DIALOG (waitDlg)->vbox), true); gdk_pixbuf_animation_iter_advance (animIter,NULL); waitImagePixbuf = gdk_pixbuf_animation_iter_get_pixbuf(animIter); gtk_image_set_from_pixbuf(GTK_IMAGE (waitImage),waitImagePixbuf); } g_object_unref(G_OBJECT(animIter));