WebKit2GTK+ Reference Manual: WebKitContextMenu

## WebKitContextMenu WebKitContextMenu — Represents the context menu in a WebKitWebView |

## Synopsis

                        WebKitContextMenu;
    WebKitContextMenu * webkit_context_menu_new             (void);
    WebKitContextMenu * webkit_context_menu_new_with_items  (GList *items);
    void                webkit_context_menu_prepend         (WebKitContextMenu *menu,
                                                             WebKitContextMenuItem *item);
    void                webkit_context_menu_append          (WebKitContextMenu *menu,
                                                             WebKitContextMenuItem *item);
    void                webkit_context_menu_insert          (WebKitContextMenu *menu,
                                                             WebKitContextMenuItem *item,
                                                             gint position);
    void                webkit_context_menu_move_item       (WebKitContextMenu *menu,
                                                             WebKitContextMenuItem *item,
                                                             gint position);
    GList *             webkit_context_menu_get_items       (WebKitContextMenu *menu);
    guint               webkit_context_menu_get_n_items     (WebKitContextMenu *menu);
    WebKitContextMenuItem * webkit_context_menu_first       (WebKitContextMenu *menu);
    WebKitContextMenuItem * webkit_context_menu_last        (WebKitContextMenu *menu);
    WebKitContextMenuItem * webkit_context_menu_get_item_at_position
                                                            (WebKitContextMenu *menu,
                                                             guint position);
    void                webkit_context_menu_remove          (WebKitContextMenu *menu,
                                                             WebKitContextMenuItem *item);
    void                webkit_context_menu_remove_all      (WebKitContextMenu *menu);

## Object Hierarchy

      GObject
       +----WebKitContextMenu

## Description

WebKitContextMenu represents a context menu containing WebKitContextMenuItems in a WebKitWebView.

When a WebKitWebView is about to display the context menu, it emits the "context-menu" signal, which has the WebKitContextMenu as an argument. You can modify it, adding new submenus that you can create with `webkit_context_menu_new()`, adding new WebKitContextMenuItems with `webkit_context_menu_prepend()`, `webkit_context_menu_append()` or `webkit_context_menu_insert()`, maybe after having removed the existing ones with `webkit_context_menu_remove_all()`.

## Details

### WebKitContextMenu

    typedef struct _WebKitContextMenu WebKitContextMenu;

### webkit_context_menu_new ()

    WebKitContextMenu * webkit_context_menu_new             (void);

Creates a new WebKitContextMenu object to be used as a submenu of an existing WebKitContextMenu. The context menu of a WebKitWebView is created by the view and passed as an argument of "context-menu" signal. To add items to the menu use `webkit_context_menu_prepend()`, `webkit_context_menu_append()` or `webkit_context_menu_insert()`. See also `webkit_context_menu_new_with_items()` to create a WebKitContextMenu with a list of initial items.

Returns : | The newly created WebKitContextMenu object

### webkit_context_menu_new_with_items ()

    WebKitContextMenu * webkit_context_menu_new_with_items  (GList *items);

Creates a new WebKitContextMenu object to be used as a submenu of an existing WebKitContextMenu with the given initial items. See also `webkit_context_menu_new()`

`items` : | a GList of WebKitContextMenuItem. [element-type WebKitContextMenuItem]
Returns : | The newly created WebKitContextMenu object

### webkit_context_menu_prepend ()

    void                webkit_context_menu_prepend         (WebKitContextMenu *menu,
                                                             WebKitContextMenuItem *item);

Adds `item` at the beginning of the `menu`.

`menu` : | a WebKitContextMenu
`item` : | the WebKitContextMenuItem to add

### webkit_context_menu_append ()

    void                webkit_context_menu_append          (WebKitContextMenu *menu,
                                                             WebKitContextMenuItem *item);

Adds `item` at the end of the `menu`.

`menu` : | a WebKitContextMenu
`item` : | the WebKitContextMenuItem to add

### webkit_context_menu_insert ()

    void                webkit_context_menu_insert          (WebKitContextMenu *menu,
                                                             WebKitContextMenuItem *item,
                                                             gint position);

Inserts `item` into the `menu` at the given position. If `position` is negative, or is larger than the number of items in the WebKitContextMenu, the item is added on to the end of the `menu`. The first position is 0.

`menu` : | a WebKitContextMenu
`item` : | the WebKitContextMenuItem to add
`position` : | the position to insert the item

### webkit_context_menu_move_item ()

    void                webkit_context_menu_move_item       (WebKitContextMenu *menu,
                                                             WebKitContextMenuItem *item,
                                                             gint position);

Moves `item` to the given position in the `menu`. If `position` is negative, or is larger than the number of items in the WebKitContextMenu, the item is added on to the end of the `menu`. The first position is 0.

`menu` : | a WebKitContextMenu
`item` : | the WebKitContextMenuItem to add
`position` : | the new position to move the item

### webkit_context_menu_get_items ()

    GList *             webkit_context_menu_get_items       (WebKitContextMenu *menu);

Returns the item list of `menu`.

`menu` : | a WebKitContextMenu
Returns : | a GList of WebKitContextMenuItems. [element-type WebKitContextMenuItem][transfer none]

### webkit_context_menu_get_n_items ()

    guint               webkit_context_menu_get_n_items     (WebKitContextMenu *menu);

Gets the length of the `menu`.

`menu` : | a WebKitContextMenu
Returns : | the number of WebKitContextMenuItems in `menu`

### webkit_context_menu_first ()

    WebKitContextMenuItem * webkit_context_menu_first       (WebKitContextMenu *menu);

Gets the first item in the `menu`.

`menu` : | a WebKitContextMenu
Returns : | the first WebKitContextMenuItem of `menu`, or `NULL` if the WebKitContextMenu is empty. [transfer none]

### webkit_context_menu_last ()

    WebKitContextMenuItem * webkit_context_menu_last        (WebKitContextMenu *menu);

Gets the last item in the `menu`.

`menu` : | a WebKitContextMenu
Returns : | the last WebKitContextMenuItem of `menu`, or `NULL` if the WebKitContextMenu is empty. [transfer none]

### webkit_context_menu_get_item_at_position ()

    WebKitContextMenuItem * webkit_context_menu_get_item_at_position
                                                            (WebKitContextMenu *menu,
                                                             guint position);

Gets the item at the given position in the `menu`.

`menu` : | a WebKitContextMenu
`position` : | the position of the item, counting from 0
Returns : | the WebKitContextMenuItem at position `position` in `menu`, or `NULL` if the position is off the end of the `menu`. [transfer none]

### webkit_context_menu_remove ()

    void                webkit_context_menu_remove          (WebKitContextMenu *menu,
                                                             WebKitContextMenuItem *item);

Removes `item` from the `menu`. See also `webkit_context_menu_remove_all()` to remove all items.

`menu` : | a WebKitContextMenu
`item` : | the WebKitContextMenuItem to remove

### webkit_context_menu_remove_all ()

    void                webkit_context_menu_remove_all      (WebKitContextMenu *menu);

Removes all items of the `menu`.

`menu` : | a WebKitContextMenu