How to disconnect a signal of Gtk?
If you didn't save the signal handler ID, you can search for it using g_signal_handler_find()
and disconnect it the usual way, or disconnect any signals that match certain criteria with g_signal_handlers_disconnect_matched()
or g_signal_handlers_disconnect_by_func()
.
You can use the *handler_block_by_func* and *handler_unblock_by_func* methods.
Example (PyGTK):
def on_treeview_fixedexpenses_cursor_changed(self, widget):
self.checkbutton_fixedexpensetax.handler_block_by_func(self.on_checkbutton_fixedexpensetax_toggled)
self.updateCurrentFixedExpense()
self.checkbutton_fixedexpensetax.handler_unblock_by_func(self.on_checkbutton_fixedexpensetax_toggled)
Source: http://www.pygtk.org/docs/pygobject/class-gobject.html
Of course when the target object is destroyed, the signals connected to it are removed (otherwise there would be a massive memory leak, but read the warning on g_signal_connect_object). However, to call g_signal_handler_disconnect you need the handler id given by g_signal_connect
and friends.