Re: How to get id of/remove a default handler?

On Fri, Jul 31, 2009 at 6:44 PM,
machinegodzilla<machinegodzilla gmail com> wrote:
> Thank you Yeti for you reply. Now I can see that I should've added some
> context to my questions.
> What I mean by a default handler is a piece of code that gets executed when
> an object emits a signal, and which code you don't have to write yourself
> but is there, somewhere already (as opposed to a custom handler that I'd
> attach to an object with g_signal_connect()). I am currently playing with
> GStreamer framework, where I create elements that emit signals in response
> to particular situations, e.g. disconnection from other elements. Then a
> thing that I call "a default handler" catches those signals and does
> something accordingly.
> For example, I can create an element of type GstBin:
> [
> ]
> in which I can place other elements. Every time an elements is placed in a
> bin an "element-added" signal is emitted:
> [
> ].
> Now what I want to do is to block/freeze/temporarily disable the handler
> that is about to get executed, or hijack the signal.
> I've just stumbled across g_signal_override_class_handler () method which
> seems to be sort of what I'm after... I'll try that tomorrow (-:

Heres my interpretation of your seemingly complex problem ;-)

You are listening to a callback "element-added"; you dont want the callback to
fire when you explicitly add an element (doh, the code adding the element
already knows its adding the element, no need to fire some possibly dangerously
recursive code).

Or synonymously; you have a function that updates the database when a
toggle button
is pressed, and sometimes the database hooks indicate that you need to
update the
state of the toggle button, again you dont want the "toggled" handler to run.

set_toggle_button_state() {
   g_signal_handers_block_by_func ()
   gtk_toggle_button_set_active ();
   g_signal_handers_unblock_by_func ()

Hope this helps ;-)


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