Re: Forcing an applet to popup its context menu



On Mon, 2003-11-10 at 09:56, Pierre Sarrazin wrote:
> Thanks.  I ended up studying the source code of the clock applet
> in gnome-panel (clock.c) and saw that there is a special callback
> that prevents the button widget from absorbing the right-button
> press event:
> 
> static gboolean
> do_not_eat_button_press (GtkWidget      *widget,
>                          GdkEventButton *event)
> {
>         if (event->button != 1)
>                 g_signal_stop_emission_by_name (widget, "button_press_event");
> 
>         return FALSE;
> }
> 
> /* ... */
> 
>         g_signal_connect (toggle, "button_press_event",
>                           G_CALLBACK (do_not_eat_button_press), NULL);
> 
> I don't understand how having the button widget stop the emission
> of the signal lets this signal continue to the applet widget,
> but this magic worked for me.

I'm not very experienced myself, but as I understand the code I see
above, you are blocking the default method from handling the
button_press_event.  The default handler usually executes after your
handler as you set using g_signal_connect.  The default handler for the
button handles things like redraw the button.  If you had used
g_signal_connect_after, your function would have executed the default
handler (and you could not block the redraw).  After you block the
default handler, the signal is forwarded to the container object because
your function returned FALSE (meaning was not handled).

-- 
__C U R T I S  C.  H O V E Y____________________
sinzui cox net
Guilty of stealing everything I am.




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