[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re:the correct way to do pop up menus?
- From: halfline <halfline hawaii rr com>
- To: gtk-app-devel-list redhat com
- Subject: Re:the correct way to do pop up menus?
- Date: Fri, 06 Aug 1999 18:07:46 -1000
Emile wrote,
>> Is there a short answer to this question? I've been digging through
the
>> online docs for gdk/gtk and haven't found anything that looks like
the
>> right way to do it. I'm extending a clock widget that someone else
wrote
>> (the mygtkclock from the XFce/libs project) and want to pop up a menu
when
>> you right click the widget. Should I be looking at the menu factory
>> stuff, or just gtk_menu_new() and adding items, or what?
If you have gnome you can do it like I did it in my program.
Here's how I did it in my program( well plugin actually ):
First you need to make a attach the button-release-event(or
button-press-event)
to a callback, somewhere:
The last argument is data that is sent as (void *) to the callback
function.
/* Attach the button-release-event to a Callback */
gtk_signal_connect( GTK_OBJECT( ModeStatusEventBox ),
"button-release-event",
GTK_SIGNAL_FUNC( plugin_mode_status_click_callback
),
( gpointer ) Daemon );
And heres the callback function:
void plugin_mode_status_click_callback( GtkWidget* ModeStatusEventBox,
GdkEventButton* Button,
gpointer Data )
{
/* Pop up the Status Menu */
gnome_popup_menu_do_popup( plugin_mode_status_menu_create( ),
NULL,
NULL,
NULL,
Data );
}
This is the function that actually contains the menus:
The third argument of each element is a pointer to the function that
will be called
when that menu item is picked.
GtkWidget* plugin_mode_status_menu_create( )
{
GnomeUIInfo StatusMenu[] = {
GNOMEUIINFO_ITEM( "_Online", "Online Status",
plugin_mode_status_menu_online_callback,
NULL ),
GNOMEUIINFO_ITEM( "_Away", "Away Status",
plugin_mode_status_menu_away_callback,
NULL ),
GNOMEUIINFO_ITEM( "_Not Available", "Not Available Status",
plugin_mode_status_menu_not_available_callback,
NULL ),
GNOMEUIINFO_ITEM( "O_ccupied", "Occupied Status",
plugin_mode_status_menu_occupied_callback,
NULL ),
GNOMEUIINFO_ITEM( "_Do Not Disturb", "Do Not Disturb Status",
plugin_mode_status_menu_do_not_disturb_callback,
NULL ),
GNOMEUIINFO_ITEM( "O_ffline", "Offline Status",
plugin_mode_status_menu_offline_callback,
NULL ),
GNOMEUIINFO_END
};
return gnome_popup_menu_new( StatusMenu );
}
Here is the callback function for the first menu item, repeat this for
each menu item.
void plugin_mode_status_menu_online_callback( GtkWidget* MenuWidget,
gpointer Data )
{
CICQDaemon* Daemon = ( CICQDaemon* ) Data;
/* Change to the new Status */
plugin_mode_status_set( ICQ_STATUS_ONLINE, Daemon );
}
This is taken straight from my program, so you will need to modify it to
fit your program
--
Halfline
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]