[maemo-developers] Fwd: [maemo-developers] show pictures with delay

From: Kalle Vahlman kalle.vahlman at gmail.com
Date: Wed Sep 7 09:04:53 EEST 2005
Whoops, I forgot to send to the list.

---------- Forwarded message ----------
From: Kalle Vahlman <kalle.vahlman at gmail.com>
Date: 7.9.2005 9:03
Subject: Re: [maemo-developers] show pictures with delay
To: rh <ronny at get-intouch.com>


2005/9/7, rh <ronny at get-intouch.com>:
> > Hi all,
> >
> > I have a problem.
> > I have 8 pictures & I want to display those pictures one by one in one
> > GtkImage, with 500ms delay in every picture.
> > I try to refresh my Hildonapp, Hildonappview & GtkImage every 500 ms
> > automatically (loop),
>
> If that loop isn't in a separate thread or doesn't do
>
>   while (gtk_main_iteration() );
>
> in the loop, then it most definetly won't update the screen as the
> execution of code is stuck waiting for your loop to finish before it
> can update the screen again.
>
> --
> Kalle Vahlman, zuh at iki.fi
>
>
> Hi,
> My loop is in another function (not in main function).
> The only parameter type for that function is HildonApp
> which is sent from main function, because I want to create a new
> HildonAppView in that function.
> Howto use gtk_main_iteration() in that function ?

Well you'd use it just the way I said, it isn't function specific.

BUT

The way you are implementing the timeout will prevent updates to the
screen even with the mainloop iteration, as the sleeping happens in
the same thread that the mainloop runs in, so when you call *sleep(),
the whole process stops executing code. This includes any mainloop
that is inside the same thread.

The way you'd do this (without using threads, they are nasty), is to
use the g_timeout_add() function. See

http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html#g-timeout-add

for documentation, and

http://s1x.homelinux.net/documents/gtk/gtk_threads.html

for an example (the "Example 4: Let's progress" uses g_timeout_add).

-- 
Kalle Vahlman, zuh at iki.fi

More information about the maemo-developers mailing list