blocking signal emission



Hi,
I'am having trouble blocking signal emission. In the following code I try to block "value-changed" signal emission during a call to gtk_range_set_range();

...
GtkRange *tmpscale;

tmpscale = (GtkRange*)lookup_widget(GTK_WIDGET(wmphicam_config),"hscale_height");
        
guint id1 = g_signal_lookup("value-changed",
                        G_OBJECT_TYPE(tmpscale));

g_print("typename = %s\n",g_type_name(G_OBJECT_TYPE(tmpscale)));
        
gint n;
guint *tmparray = g_signal_list_ids(G_OBJECT_TYPE(GTK_RANGE(tmpscale)),
                                           &n);
g_print("n_ids = %d\n",n);
        
g_signal_handler_block(tmpscale,id1);

gtk_range_set_range(GTK_RANGE(tmpscale),
        pcap->minheight,
        pcap->maxheight);

g_signal_handler_unblock(tmpscale,id1);
...


What I get is:
--------------------------
typename = GtkHScale <--- Ok, in fact my widget is GtkHScale
n_ids = 0 <----- Hmmm, this seems to be wrong, I'am sure there is at least one signal handler connected

(wmphicam-config:9308): GLib-GObject-WARNING **: gsignal.c:1692: instance `0x80ad390' has no handler with id `116' <-- a lie :-)

height slider=120,000000 rounded 120 device=120 <---- evidence that there is a handler and it has just been called

(wmphicam-config:9308): GLib-GObject-WARNING **: gsignal.c:1715: instance `0x80ad390' has no handler with id `116' <-- a lie :-)
--------------------------

I must be doing something totally wrong and I need a clue. A handler is connected using a call:

g_signal_connect ((gpointer) hscale_height, "value_changed",
                    G_CALLBACK (on_hscale_height_value_changed),
                    NULL);

and it works all right, but there are cases when I don't want it to be called.

Thanks for help,
Tomek



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