Re: Forcing an applet to popup its context menu

Basically the panelapplet library will handle to right click context menu automatically using panel_applet_setup_menu_from_file. You then want to do two things (from the cdplayer applet)

1) Connect to the button press event and copy the "button_press_hack" function from cdplayer.c (see line 1171 here This is a hack around a gtk bug (maybe it has been fixed since. Otherwise the rick click event wasn't getting sent to the applet hence the need for a hack)

2) Connect to the clicked event and in this callback do what you want with the left button.

Hope that helps.


From: Pierre Sarrazin <sarrazip sympatico ca>
To: gnome-devel-list gnome org
Subject: Forcing an applet to popup its context menu
Date: Fri, 7 Nov 2003 23:40:08 -0500

I am coding an applet that shows a button in the panel.  I would
like one action to happen when the user left-clicks the button,
but when the user right-clicks, I would like to show the applet's
context menu.

Currently, I'm connecting the button's "button_press_event" signal
to a callback that would be written like this:

gboolean on_button_press(GtkWidget *, GdkEventButton *event, gpointer)
    if (event->button == 1)
	return TRUE;
    if (event->button == 3)
	/* show applet context menu */
	return TRUE;
    return FALSE;

I'd like to know how to code the second if().

I see that there is the panel_applet_get_popup_component() function
in <>,
but then I wouldn't know what to do with the resulting BonoboUIComponent
pointer.  Thanks.

Pierre Sarrazin <sarrazip at sympatico dot ca>
gnome-devel-list mailing list
gnome-devel-list gnome org

Crave some Miles Davis or Grateful Dead? Your old favorites are always playing on MSN Radio Plus. Trial month free!

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