Re: Fwd: Animation problem

2006-08-06 Thread Lance Dillon
What you can do is use g_object_get_property on the image to get the reference 
(or, if it doesn't reference it, you may need to use g_object_ref), then use 
g_object_set_property to set the image.  This works on GtkImage, for example.

- Original Message 
From: [EMAIL PROTECTED]
To: gtk-app-devel-list@gnome.org
Sent: Sunday, August 6, 2006 8:33:41 AM
Subject: Fwd: Animation problem

Hi, unfortunately nobody seems to have an idea so far.
Perhaps I can try it more simple:
How can I replace an Image by another one at runtime (without producing a 
memory leak)?
In fact this could help to solve the same problem. At least it's worth a try...

Thanks, dasaspock



 Original-Nachricht 
Datum: Sun, 06 Aug 2006 03:40:53 +0200
Von: [EMAIL PROTECTED]
An: gtk-app-devel-list@gnome.org
Betreff: Animation problem

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 nice ;-)

Thank you, dasaspock
-- 


Echte DSL-Flatrate dauerhaft für 0,- Euro*. Nur noch kurze Zeit!
Feel free mit GMX DSL: http://www.gmx.net/de/go/dsl
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

-- 


Feel free – 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Fwd: Animation problem

2006-08-06 Thread tomas
On Sun, Aug 06, 2006 at 02:33:41PM +0200, [EMAIL PROTECTED] wrote:
 Hi, unfortunately nobody seems to have an idea so far.

[...]

So many things, I don't know where to start...

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

Here's the leak: on each round, you order an animation iterator with
gdk_pixbuf_animation_get_iter(...) just to throw it away without
unref()ing it.

The way to avoid this leak might be:

 |   GdkPixbufAnimationIter *iter = 
gdk_pixbuf_animation_get_iter(waitImageAnimated, NULL);
 |   while(...) {
 | ...
 |gtk_image_set_from_pixbuf(gdk_pixbuf_animation_iter_get_pixbuf(iter));
 |   }
 |   g_object_unref(G_OBJECT(iter));

As I understand the doc, you don't have to unref the pixbufs you get
from the iterator (but the iterator itself!). Plus you don't have to
dreate a new iterator on each round of your loop (I guess it would start
at the first image of the animation each time anyway).

But I don't understand why you try to do it all yourself. There is an
gtk_image_set_from_animation() which should just work for you (plus, if
you want to step all by yourself through the anim frames, maybe you
should do it in a timer or idle func, instead of doing the gtk loop by
hand and getting into hot water about that ;)

HTH
-- tomás
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list