ContextMenuItem
Superclasses: InitiallyUnowned
, Object
- Constructors:
ContextMenuItem(**properties)
new_from_gaction(action:Gio.Action, label:str, target:GLib.Variant=None) -> WebKit.ContextMenuItem
new_from_stock_action(action:WebKit.ContextMenuAction) -> WebKit.ContextMenuItem
new_from_stock_action_with_label(action:WebKit.ContextMenuAction, label:str) -> WebKit.ContextMenuItem
new_separator() -> WebKit.ContextMenuItem
new_with_submenu(label:str, submenu:WebKit.ContextMenu) -> WebKit.ContextMenuItem
Constructors
- class ContextMenuItem
- classmethod new_from_gaction(action: Action, label: str, target: Variant | None = None) → ContextMenuItem
Creates a new
ContextMenuItem
for the givenaction
andlabel
.On activation
target
will be passed as parameter to the callback.Added in version 2.18.
- classmethod new_from_stock_action(action: ContextMenuAction) → ContextMenuItem
Creates a new
ContextMenuItem
for the given stock action.Stock actions are handled automatically by WebKit so that, for example, when a menu item created with a
STOP
is activated the action associated will be handled by WebKit and the current load operation will be stopped. You can get theAction
of aContextMenuItem
created with aContextMenuAction
withget_gaction()
and connect to theSimpleAction
::activate signal to be notified when the item is activated, but you can’t prevent the associated action from being performed.- Parameters:
action – a
ContextMenuAction
stock action
- classmethod new_from_stock_action_with_label(action: ContextMenuAction, label: str) → ContextMenuItem
Creates a new
ContextMenuItem
for the given stock action using the givenlabel
.Stock actions have a predefined label, this method can be used to create a
ContextMenuItem
for aContextMenuAction
but using a custom label.- Parameters:
action – a
ContextMenuAction
stock actionlabel – a custom label text to use instead of the predefined one
- classmethod new_separator() → ContextMenuItem
Creates a new
ContextMenuItem
representing a separator.
- classmethod new_with_submenu(label: str, submenu: ContextMenu) → ContextMenuItem
Creates a new
ContextMenuItem
using the givenlabel
with a submenu.- Parameters:
label – the menu item label text
submenu – a
ContextMenu
to set
Methods
- class ContextMenuItem
-
- get_stock_action() → ContextMenuAction
Gets the
ContextMenuAction
ofitem
.If the
ContextMenuItem
was not created for a stock actionCUSTOM
will be returned. If theContextMenuItem
is a separatorNO_ACTION
will be returned.
- get_submenu() → ContextMenu
Gets the submenu of
item
.
- set_submenu(submenu: ContextMenu | None = None) → None
Sets or replaces the
item
submenu.If
submenu
isNone
the current submenu ofitem
is removed.- Parameters:
submenu – a
ContextMenu