Gnome User Interface Library Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# gnome-popup-menu

## Name

gnome-popup-menu -- Routines for attaching popup menus to widgets.

## Synopsis

    #include <gnome.h>

    GtkWidget*  gnome_popup_menu_new            (GnomeUIInfo *uiinfo);
    GtkWidget*  gnome_popup_menu_new_with_accelgroup
                                                (GnomeUIInfo *uiinfo,
                                                 GtkAccelGroup *accelgroup);
    GtkAccelGroup* gnome_popup_menu_get_accel_group
                                                (GtkMenu *menu);
    void        gnome_popup_menu_attach         (GtkWidget *popup,
                                                 GtkWidget *widget,
                                                 gpointer user_data);
    void        gnome_popup_menu_do_popup       (GtkWidget *popup,
                                                 GtkMenuPositionFunc pos_func,
                                                 gpointer pos_data,
                                                 GdkEventButton *event,
                                                 gpointer user_data);
    int         gnome_popup_menu_do_popup_modal (GtkWidget *popup,
                                                 GtkMenuPositionFunc pos_func,
                                                 gpointer pos_data,
                                                 GdkEventButton *event,
                                                 gpointer user_data);

## Description

The routines in this module provide various ways of displaying popup menus our application.

## Details

### gnome_popup_menu_new ()

    GtkWidget*  gnome_popup_menu_new            (GnomeUIInfo *uiinfo);

This function behaves just like gnome_popup_menu_new_with_accelgroup(), except that it creates an accelgroup for you and attaches it to the menu object. Use gnome_popup_menu_get_accel_group() to get the accelgroup that is created.

`uiinfo` : |
Returns : | a menu widget

### gnome_popup_menu_new_with_accelgroup ()

    GtkWidget*  gnome_popup_menu_new_with_accelgroup
                                                (GnomeUIInfo *uiinfo,
                                                 GtkAccelGroup *accelgroup);

Creates a popup menu out of the specified uiinfo array. Use gnome_popup_menu_do_popup() to pop the menu up, or attach it to a window with gnome_popup_menu_attach().

`uiinfo` : |
`accelgroup` : |
Returns : | a menu widget

### gnome_popup_menu_get_accel_group ()

    GtkAccelGroup* gnome_popup_menu_get_accel_group
                                                (GtkMenu *menu);

`menu` : |
Returns : | the accelgroup associated with the specified GtkMenu. This is the accelgroup that was created by gnome_popup_menu_new(). If you want to specify the accelgroup that the popup menu accelerators use, then use gnome_popup_menu_new_with_accelgroup().

### gnome_popup_menu_attach ()

    void        gnome_popup_menu_attach         (GtkWidget *popup,
                                                 GtkWidget *widget,
                                                 gpointer user_data);

Attaches the specified popup menu to the specified widget. The menu can then be activated by pressing mouse button 3 over the widget. When a menu item callback is invoked, the specified user_data will be passed to it.

This function requires the widget to have its own window (i.e. GTK_WIDGET_NO_WINDOW (widget) == FALSE), This function will try to set the GDK_BUTTON_PRESS_MASK flag on the widget's event mask if it does not have it yet; if this is the case, then the widget must not be realized for it to work.

The popup menu can be attached to different widgets at the same time. A reference count is kept on the popup menu; when all the widgets it is attached to are destroyed, the popup menu will be destroyed as well.

`popup` : |
`widget` : |
`user_data` : |

### gnome_popup_menu_do_popup ()

    void        gnome_popup_menu_do_popup       (GtkWidget *popup,
                                                 GtkMenuPositionFunc pos_func,
                                                 gpointer pos_data,
                                                 GdkEventButton *event,
                                                 gpointer user_data);

You can use this function to pop up a menu. When a menu item * callback is invoked, the specified user_data will be passed to it.

The pos_func and pos_data parameters are the same as for gtk_menu_popup(), i.e. you can use them to specify a function to position the menu explicitly. If you want the default position (near the mouse), pass NULL for these parameters.

The event parameter is needed to figure out the mouse button that activated the menu and the time at which this happened. If you pass in NULL, then no button and the current time will be used as defaults.

`popup` : |
`pos_func` : |
`pos_data` : |
`event` : |
`user_data` : |

### gnome_popup_menu_do_popup_modal ()

    int         gnome_popup_menu_do_popup_modal (GtkWidget *popup,
                                                 GtkMenuPositionFunc pos_func,
                                                 gpointer pos_data,
                                                 GdkEventButton *event,
                                                 gpointer user_data);

Same as above, but runs the popup menu modally and returns the index of the selected item, or -1 if none.

`popup` : |
`pos_func` : |
`pos_data` : |
`event` : |
`user_data` : |
Returns : |

<<< Previous Page | Home | Up | Next Page >>>
gnome-popup-help | gnome-preferences