I have a Glade file with some buttons and I use Gtk.Builder.connect_signals()
to connect methods (on_button_toggled
) with the corresponding signals (toggled
).
(It is acutally quickly which does that for me, but I can see and change that code, so that is only a detail).
What I want to do now, is stop a signal from being processed, e.g. though a call to object.handler_block(handler_id)
or object.disconnect(handler_id)
. So my question is: how can I get the handler_id
s for connections created via Gtk.Builder.connect_signals()
?
Normally you would get the handler_id
from a call to one of:
handler_id = object.connect(name, cb, cb_args)
handler_id = object.connect_after(name, cb, cb_args)
handler_id = object.connect_object(name, cb, slot_object, cb_args)
handler_id = object.connect_object_after(name, cb, slot_object, cb_args)
but the Gtk.Builder version does not return the ids.
Sadly, I don't believe that there's any way to get at the signal handler IDs that were connected by Gtk.Builder
. If you really want the handlers, you have to manually connect your signals, storing any handler_id
s you care about.
An alternative approach is to decide that you don't actually need the handlers themselves, but can block/unblock/etc. based on the connected callable, using GObject.handler_block_by_func
and similar.
The final option is to try to actually find the handler after the fact, using as many details as you can. In C, use g_signal_handler_find
; this isn't bound for pygtk2, but presumably will work using pygobject3. The downside here is that there's no guarantee that you'll find what you actually connected.