Re: 2 events with the GDK
- From: Neil Bird <neil fnxweb com>
- To: hasnaoui chello fr
- Cc: gtk-list gnome org
- Subject: Re: 2 events with the GDK
- Date: Wed, 24 Jan 2001 09:33:25 +0000
Gibran Hasnaoui wrote:
> Because in a little program I done, when you click, it run a very long for(),
> and, what I want, is that a second click stop this boucle.
> I thought to use pthread, but is this the good way?
I wouldn't, but you are going to have to figure out how your callback
tells whether it's the first or the second click (maybe using GLib's
StaticMutex - see the online GLib docs under 'threads'). Initially, you
may get away with a simple static int flag, though.
http://developer.gnome.org/doc/API/glib/index.html
Anyhow, the simple answer is that you need to perform a GTK main-loop
pass inside your for-loop (in order to process the mouse clicks, redraw,
etc.).
gtk_main_loop() calls can be nested, but what you want is the
single-pass call gtk_main_iteration_do(0) ('0' for "non-blocking"). Put
that at the end of your for-loop, then set a flag upon the second click
(when your routine's called for the 'second' time) that can cause your
for-loop to terminate.
--
=====================- http://www.thalesgroup.com/ -=====================
Neil Bird | If this .signature |
work mailto:neil bird rdel co uk | looks pants, then | $> cd /pub
personal mailto:neil fnxweb com | stop using Outlook! | $> more beer
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]