Re: multiple changed events?



On Tue, 2007-09-25 at 11:32 +0100, Dave Howorth wrote:

The changed callback is called twice from within set_text. The first
time, the text is an empty string. The second time it is the value that
was passed to set_text.

the convention in gtk+ is that any changed signal is emitted at least
once when "something" changes: there's no upper bound, just the lower
one[1].

having said this, you can block the emission of a particular signal, or
the calling of a specific callback. for instance:

  $entry->signal_handlers_block_by_func(\&your_entry_callback, $data);
  $entry->set_text('foo');
  $entry->signal_handlers_unblock_by_func(\&your_entry_callback, $data);

will result in your callback not being invoked[2]; you can use this
inside the callback of the other widget that controls the contents of
the entry.

ciao,
 Emmanuele.

+++

[1] I think there's a bug open, somewhere in bugzilla, for this specific
instance (making a set_text() atomic); personally, I think it's merely a
matter of taste: the ::changed signal convention is known and
documented.

[2] remember: you have to use the same function and the same data you
passed to signal_connect(); in lieu of this, you can use the unsigned
integer returned by signal_connect(), and the signal_handler_block() and
signal_handler_unblock() pair.

-- 
Emmanuele Bassi,
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net




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