Re: implementing a delayed "busy" cursor



Paul Fox wrote:
> paul davis wrote:
>  > On Sun, 2007-08-05 at 12:56 -0400, Paul Fox wrote:
>  > 
>  > google gtk timeout -> gtk_timeout_add -> gtk.org/api -> Main Loop &
>  > Events -> "gtk_timeout_add has been deprecated since version 2.4 and
>  > should not be used in newly-written code. Use g_timeout_add() instead."
>  > 
>  > and no, these run synchronously with the main loop, which is why they
>  > are safe to use.
> 
> thanks -- i'll do some reading.  at the moment, i'm not sure how
> this will work.  if i set a gtk timeout for 1 second, but my
> program's "think" time is 10 seconds, then i won't get back to
> the event loop until after that, and i've therefore blown my
> intended timeout.

During this think time, the GTK main loop cannot run, so yes, your
timeout won't fire.  But at the same time your app won't respond to the
user either.  It's just going to appear to be hung.  This is generally
considered bad.

> 
> but i've probably just given myself away as the gtk newb that i
> am, and am probably missing something really obvious, so i'll go
> do some reading, like i said.
> 
> (i'm actually kind of surprised there's no gdk_window_set_cursor_after_delay()
> call, for just this purpose. :-)

Even if there was, it wouldn't do any good in this case, as your app is
spending those 10 seconds hogging the CPU, and never giving control to
the main loop. So it wouldn't possibly have a chance to run, even if
such a call existed.

Just a note of caution.  Threaded programming with GTK has be careful.
 Calling GTK calls from threads is problematic, and not cross-platform
to boot.  The recommended way is probably to use g_idle_add calls from
the thread to notify the GUI loop of things, and using asyncqueues (a
glib primitive) to pass data back and forth between the long-running
task and the gui.

Either that, or iterate the GTK main loop every so often from within
your long-running task.

Michael


> 
> paul
> =---------------------
>  paul fox, pgf foxharp boston ma us (arlington, ma, where it's 74.1 degrees)
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
> 




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