WebKit2WebExtension.ContextMenu

g GObject.Object GObject.Object WebKit2WebExtension.ContextMenu WebKit2WebExtension.ContextMenu GObject.Object->WebKit2WebExtension.ContextMenu

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

class

new_with_items (items)

append (item)

first ()

get_event ()

get_item_at_position (position)

get_items ()

get_n_items ()

get_user_data ()

insert (item, position)

last ()

move_item (item, position)

prepend (item)

remove (item)

remove_all ()

set_user_data (user_data)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class WebKit2WebExtension.ContextMenu(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

WebKit2WebExtension.ContextMenuClass

Represents the context menu in a #WebKitWebView.

WebKit2WebExtension.ContextMenu represents a context menu containing WebKit2WebExtension.ContextMenuItem s in a #WebKitWebView.

When a #WebKitWebView is about to display the context menu, it emits the #WebKitWebView::context-menu signal, which has the WebKit2WebExtension.ContextMenu as an argument. You can modify it, adding new submenus that you can create with WebKit2WebExtension.ContextMenu.new(), adding new WebKit2WebExtension.ContextMenuItem s with WebKit2WebExtension.ContextMenu.prepend(), WebKit2WebExtension.ContextMenu.append() or WebKit2WebExtension.ContextMenu.insert(), maybe after having removed the existing ones with WebKit2WebExtension.ContextMenu.remove_all().

classmethod new()
Returns:

The newly created WebKit2WebExtension.ContextMenu object

Return type:

WebKit2WebExtension.ContextMenu

Creates a new WebKit2WebExtension.ContextMenu object.

Creates a new WebKit2WebExtension.ContextMenu object to be used as a submenu of an existing WebKit2WebExtension.ContextMenu. The context menu of a #WebKitWebView is created by the view and passed as an argument of #WebKitWebView::context-menu signal. To add items to the menu use WebKit2WebExtension.ContextMenu.prepend(), WebKit2WebExtension.ContextMenu.append() or WebKit2WebExtension.ContextMenu.insert(). See also WebKit2WebExtension.ContextMenu.new_with_items() to create a WebKit2WebExtension.ContextMenu with a list of initial items.

classmethod new_with_items(items)
Parameters:

items ([WebKit2WebExtension.ContextMenuItem]) – a GLib.List of WebKit2WebExtension.ContextMenuItem

Returns:

The newly created WebKit2WebExtension.ContextMenu object

Return type:

WebKit2WebExtension.ContextMenu

Creates a new WebKit2WebExtension.ContextMenu object with the given items.

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

append(item)
Parameters:

item (WebKit2WebExtension.ContextMenuItem) – the WebKit2WebExtension.ContextMenuItem to add

Adds item at the end of the self.

first()
Returns:

the first WebKit2WebExtension.ContextMenuItem of self, or None if the WebKit2WebExtension.ContextMenu is empty.

Return type:

WebKit2WebExtension.ContextMenuItem

Gets the first item in the self.

get_event()
Returns:

the menu event or None.

Return type:

Gdk.Event

Gets the Gdk.Event that triggered the context menu. This function only returns a valid Gdk.Event when called for a WebKit2WebExtension.ContextMenu passed to #WebKitWebView::context-menu signal; in all other cases, None is returned.

The returned Gdk.Event is expected to be one of the following types:

New in version 2.40.

get_item_at_position(position)
Parameters:

position (int) – the position of the item, counting from 0

Returns:

the WebKit2WebExtension.ContextMenuItem at position position in self, or None if the position is off the end of the self.

Return type:

WebKit2WebExtension.ContextMenuItem

Gets the item at the given position in the self.

get_items()
Returns:

a GLib.List of WebKit2WebExtension.ContextMenuItem s

Return type:

[WebKit2WebExtension.ContextMenuItem]

Returns the item list of self.

get_n_items()
Returns:

the number of WebKit2WebExtension.ContextMenuItem s in self

Return type:

int

Gets the length of the self.

get_user_data()
Returns:

the user data of self, or None if self doesn’t have user data

Return type:

GLib.Variant

Gets the user data of self.

This function can be used from the UI Process to get user data previously set from the Web Process with WebKit2WebExtension.ContextMenu.set_user_data().

New in version 2.8.

insert(item, position)
Parameters:

Inserts item into the self at the given position.

If position is negative, or is larger than the number of items in the WebKit2WebExtension.ContextMenu, the item is added on to the end of the self. The first position is 0.

last()
Returns:

the last WebKit2WebExtension.ContextMenuItem of self, or None if the WebKit2WebExtension.ContextMenu is empty.

Return type:

WebKit2WebExtension.ContextMenuItem

Gets the last item in the self.

move_item(item, position)
Parameters:

Moves item to the given position in the self.

If position is negative, or is larger than the number of items in the WebKit2WebExtension.ContextMenu, the item is added on to the end of the self. The first position is 0.

prepend(item)
Parameters:

item (WebKit2WebExtension.ContextMenuItem) – the WebKit2WebExtension.ContextMenuItem to add

Adds item at the beginning of the self.

remove(item)
Parameters:

item (WebKit2WebExtension.ContextMenuItem) – the WebKit2WebExtension.ContextMenuItem to remove

Removes item from the self.

See also WebKit2WebExtension.ContextMenu.remove_all() to remove all items.

remove_all()

Removes all items of the self.

set_user_data(user_data)
Parameters:

user_data (GLib.Variant) – a GLib.Variant

Sets user data to self.

This function can be used from a Web Process extension to set user data that can be retrieved from the UI Process using WebKit2WebExtension.ContextMenu.get_user_data(). If the user_data GLib.Variant is floating, it is consumed.

New in version 2.8.