Re: Signal blocking
- From: Chad Robinson <crj lucubration com>
- To: gtk-app-devel-list gnome org
- Subject: Re: Signal blocking
- Date: Thu, 05 Jan 2006 08:55:01 -0500
Arne Caspari wrote:
Hi!
I want to block the emission of the "value_changed" signal when I call
gtk_range_set_value( ... )
My code so far is roughly:
/********************************************************************/
handler_id = g_signal_connect( GTK_RANGE( widget ) , "value_changed",
cb_func, data );
.
.
.
g_signal_handler_block( widget, handler_id );
gtk_range_set_value( GTK_RANGE( widget ), .... );
g_signal_handler_unblock( widget, handler_id );
g_signal_stop_emission_by_name( widget, "value_changed" );
/********************************************************************/
But the value_changed callback is called anyways. How do I temporarly
disable the signal handler?
I'm sure there's a GTK solution, but is there any reason you don't just:
static int ignore_signals = 0;
cb_func(...)
{
if (ignore_signals) return;
...
}
handler_id = g_signal_connect( GTK_RANGE( widget ) , "value_changed",
cb_func, data );
.
.
.
ignore_signals++;
gtk_range_set_value( GTK_RANGE( widget ), .... );
ignore_signals--;
It requires a global (unless you're passing state data in via a struct via the
data parameter to cb_func, and can add an element to the struct), but it's not
really any uglier and eliminates the mucking about with signals.
Regards,
Chad
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]