MenuProtocol
public protocol MenuProtocol : MenuShellProtocol
A GtkMenu is a GtkMenuShell that implements a drop down menu
consisting of a list of GtkMenuItem objects which can be navigated
and activated by the user to perform application functions.
A GtkMenu is most commonly dropped down by activating a
GtkMenuItem in a GtkMenuBar or popped up by activating a
GtkMenuItem in another GtkMenu.
A GtkMenu can also be popped up by activating a GtkComboBox.
Other composite widgets such as the GtkNotebook can pop up a
GtkMenu as well.
Applications can display a GtkMenu as a popup menu by calling the
gtk_menu_popup() function. The example below shows how an application
can pop up a menu when the 3rd mouse button is pressed.
Connecting the popup signal handler.
(C Language Example):
// connect our handler which will popup the menu
g_signal_connect_swapped (window, "button_press_event",
G_CALLBACK (my_popup_handler), menu);
Signal handler which displays a popup menu.
(C Language Example):
static gint
my_popup_handler (GtkWidget *widget, GdkEvent *event)
{
GtkMenu *menu;
GdkEventButton *event_button;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
// The "widget" is the menu that was supplied when
// g_signal_connect_swapped() was called.
menu = GTK_MENU (widget);
if (event->type == GDK_BUTTON_PRESS)
{
event_button = (GdkEventButton *) event;
if (event_button->button == GDK_BUTTON_SECONDARY)
{
gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
event_button->button, event_button->time);
return TRUE;
}
}
return FALSE;
}
CSS nodes
(plain Language Example):
menu
├── arrow.top
├── <child>
┊
├── <child>
╰── arrow.bottom
The main CSS node of GtkMenu has name menu, and there are two subnodes with name arrow, for scrolling menu arrows. These subnodes get the .top and .bottom style classes.
The MenuProtocol protocol exposes the methods and properties of an underlying GtkMenu instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see Menu.
Alternatively, use MenuRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkMenuinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
menu_ptrDefault implementationTyped pointer to the underlying
GtkMenuinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkMenuinstance.Declaration
Swift
var menu_ptr: UnsafeMutablePointer<GtkMenu>! { get } -
Required Initialiser for types conforming to
MenuProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
MenuPropertyNamesource property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: MenuPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocolParameters
source_propertythe source property to bind
targetthe target object to bind to
target_propertythe target property to bind to
flagsthe flags to pass to the
Bindingtransform_fromValueTransformerto use for forward transformationtransform_toValueTransformerto use for backwards transformationReturn Value
binding reference or
nilin case of an error -
get(property:Extension method) Get the value of a Menu property
Declaration
Swift
@inlinable func get(property: MenuPropertyName) -> GLibObject.ValueParameters
propertythe property to get the value for
Return Value
the value of the named property
-
set(property:Extension methodvalue: ) Set the value of a Menu property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: MenuPropertyName, value v: GLibObject.Value)Parameters
propertythe property to get the value for
Return Value
the value of the named property
-
connect(signal:Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
MenuSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: MenuSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatahandlerThe Swift signal handler (function or callback) to invoke on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
connect(signal:Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
MenuSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: MenuSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatasignalHandlerThe C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
poppedUpSignalExtension methodEmitted when the position of
menuis finalized after being popped up using gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (), or gtk_menu_popup_at_pointer ().menumight be flipped over the anchor rectangle in order to keep it on-screen, in which caseflipped_xandflipped_ywill be set totrueaccordingly.flipped_rectis the ideal position ofmenuafter any possible flipping, but before any possible sliding.final_rectisflipped_rect, but possibly translated in the case that flipping is still ineffective in keepingmenuon-screen.
The blue menu is
menu‘s ideal position, the green menu isflipped_rect, and the red menu isfinal_rect.See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (), gtk_menu_popup_at_pointer (),
GtkMenu:anchor-hints,GtkMenu:rect-anchor-dx,GtkMenu:rect-anchor-dy, andGtkMenu:menu-type-hint.Note
This represents the underlyingpopped-upsignalWarning
aonPoppedUpwrapper for this signal could not be generated because it contains unimplemented features: { (4) gpointer argument is not yet supported }Note
Instead, you can connectpoppedUpSignalusing theconnect(signal:)methodsDeclaration
Swift
static var poppedUpSignal: MenuSignalName { get }Parameters
flagsFlags
unownedSelfReference to instance of self
flippedRectthe position of
menuafter any possible flipping ornilif the backend can’t obtain itfinalRectthe final position of
menuornilif the backend can’t obtain itflippedXtrueif the anchors were flipped horizontallyflippedYtrueif the anchors were flipped verticallyhandlerThe signal handler to call
-
onMoveScroll(flags:Extension methodhandler: ) Note
This represents the underlyingmove-scrollsignalDeclaration
Swift
@discardableResult @inlinable func onMoveScroll(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ scrollType: ScrollType) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
scrollTypea
GtkScrollTypehandlerThe signal handler to call Run the given callback whenever the
moveScrollsignal is emitted -
moveScrollSignalExtension methodTyped
move-scrollsignal for using theconnect(signal:)methodsDeclaration
Swift
static var moveScrollSignal: MenuSignalName { get } -
onNotifyAccelGroup(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::accel-groupsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyAccelGroup(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyAccelGroupsignal is emitted -
notifyAccelGroupSignalExtension methodTyped
notify::accel-groupsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyAccelGroupSignal: MenuSignalName { get } -
onNotifyAccelPath(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::accel-pathsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyAccelPath(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyAccelPathsignal is emitted -
notifyAccelPathSignalExtension methodTyped
notify::accel-pathsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyAccelPathSignal: MenuSignalName { get } -
onNotifyActive(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::activesignalDeclaration
Swift
@discardableResult @inlinable func onNotifyActive(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyActivesignal is emitted -
notifyActiveSignalExtension methodTyped
notify::activesignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyActiveSignal: MenuSignalName { get } -
onNotifyAnchorHints(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::anchor-hintssignalDeclaration
Swift
@discardableResult @inlinable func onNotifyAnchorHints(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyAnchorHintssignal is emitted -
notifyAnchorHintsSignalExtension methodTyped
notify::anchor-hintssignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyAnchorHintsSignal: MenuSignalName { get } -
onNotifyAttachWidget(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::attach-widgetsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyAttachWidget(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyAttachWidgetsignal is emitted -
notifyAttachWidgetSignalExtension methodTyped
notify::attach-widgetsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyAttachWidgetSignal: MenuSignalName { get } -
onNotifyMenuTypeHint(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::menu-type-hintsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyMenuTypeHint(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyMenuTypeHintsignal is emitted -
notifyMenuTypeHintSignalExtension methodTyped
notify::menu-type-hintsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyMenuTypeHintSignal: MenuSignalName { get } -
onNotifyMonitor(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::monitorsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyMonitor(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyMonitorsignal is emitted -
notifyMonitorSignalExtension methodTyped
notify::monitorsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyMonitorSignal: MenuSignalName { get } -
onNotifyRectAnchorDx(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::rect-anchor-dxsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyRectAnchorDx(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyRectAnchorDxsignal is emitted -
notifyRectAnchorDxSignalExtension methodTyped
notify::rect-anchor-dxsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyRectAnchorDxSignal: MenuSignalName { get } -
onNotifyRectAnchorDy(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::rect-anchor-dysignalDeclaration
Swift
@discardableResult @inlinable func onNotifyRectAnchorDy(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyRectAnchorDysignal is emitted -
notifyRectAnchorDySignalExtension methodTyped
notify::rect-anchor-dysignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyRectAnchorDySignal: MenuSignalName { get } -
onNotifyReserveToggleSize(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::reserve-toggle-sizesignalDeclaration
Swift
@discardableResult @inlinable func onNotifyReserveToggleSize(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyReserveToggleSizesignal is emitted -
notifyReserveToggleSizeSignalExtension methodTyped
notify::reserve-toggle-sizesignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyReserveToggleSizeSignal: MenuSignalName { get } -
onNotifyTearoffState(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::tearoff-statesignalDeclaration
Swift
@discardableResult @inlinable func onNotifyTearoffState(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyTearoffStatesignal is emitted -
notifyTearoffStateSignalExtension methodTyped
notify::tearoff-statesignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyTearoffStateSignal: MenuSignalName { get } -
onNotifyTearoffTitle(flags:Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property(),g_object_set(), et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY, then any call tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::tearoff-titlesignalDeclaration
Swift
@discardableResult @inlinable func onNotifyTearoffTitle(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyTearoffTitlesignal is emitted -
notifyTearoffTitleSignalExtension methodTyped
notify::tearoff-titlesignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyTearoffTitleSignal: MenuSignalName { get }
-
attach(child:Extension methodleftAttach: rightAttach: topAttach: bottomAttach: ) Adds a new
GtkMenuItemto a (table) menu. The number of “cells” that an item will occupy is specified byleft_attach,right_attach,top_attachandbottom_attach. These each represent the leftmost, rightmost, uppermost and lower column and row numbers of the table. (Columns and rows are indexed from zero).Note that this function is not related to
gtk_menu_detach().Declaration
Swift
@inlinable func attach<WidgetT>(child: WidgetT, leftAttach: Int, rightAttach: Int, topAttach: Int, bottomAttach: Int) where WidgetT : WidgetProtocol -
attachToWidget(attachWidget:Extension methoddetacher: ) Attaches the menu to the widget and provides a callback function that will be invoked when the menu calls
gtk_menu_detach()during its destruction.If the menu is attached to the widget then it will be destroyed when the widget is destroyed, as if it was a child widget. An attached menu will also move between screens correctly if the widgets moves between screens.
Declaration
Swift
@inlinable func attachToWidget<WidgetT>(attachWidget: WidgetT, detacher: GtkMenuDetachFunc? = nil) where WidgetT : WidgetProtocol -
detach()Extension methodDetaches the menu from the widget to which it had been attached. This function will call the callback function,
detacher, provided when thegtk_menu_attach_to_widget()function was called.Declaration
Swift
@inlinable func detach() -
getAccelGroup()Extension methodGets the
GtkAccelGroupwhich holds global accelerators for the menu. Seegtk_menu_set_accel_group().Declaration
Swift
@inlinable func getAccelGroup() -> AccelGroupRef! -
getAccelPath()Extension methodRetrieves the accelerator path set on the menu.
Declaration
Swift
@inlinable func getAccelPath() -> String! -
getActive()Extension methodReturns the selected menu item from the menu. This is used by the
GtkComboBox.Declaration
Swift
@inlinable func getActive() -> WidgetRef! -
getAttachWidget()Extension methodReturns the
GtkWidgetthat the menu is attached to.Declaration
Swift
@inlinable func getAttachWidget() -> WidgetRef! -
getMonitor()Extension methodRetrieves the number of the monitor on which to show the menu.
Declaration
Swift
@inlinable func getMonitor() -> Int -
getReserveToggleSize()Extension methodReturns whether the menu reserves space for toggles and icons, regardless of their actual presence.
Declaration
Swift
@inlinable func getReserveToggleSize() -> Bool -
getTearoffState()Extension methodReturns whether the menu is torn off. See
gtk_menu_set_tearoff_state().get_tearoff_state is deprecated: This method is deprecated.
Declaration
Swift
@available(*, deprecated) @inlinable func getTearoffState() -> Bool -
getTitle()Extension methodReturns the title of the menu. See
gtk_menu_set_title().get_title is deprecated: This method is deprecated.
Declaration
Swift
@available(*, deprecated) @inlinable func getTitle() -> String! -
placeOn(monitor:Extension method) Places
menuon the given monitor.Declaration
Swift
@inlinable func placeOn<MonitorT>(monitor: MonitorT) where MonitorT : MonitorProtocol -
popdown()Extension methodRemoves the menu from the screen.
Declaration
Swift
@inlinable func popdown() -
popup(parentMenuShell:Extension methodparentMenuItem: func: data: button: activateTime: ) Displays a menu and makes it available for selection.
Applications can use this function to display context-sensitive menus, and will typically supply
nilfor theparent_menu_shell,parent_menu_item,funcanddataparameters. The default menu positioning function will position the menu at the current mouse cursor position.The
buttonparameter should be the mouse button pressed to initiate the menu popup. If the menu popup was initiated by something other than a mouse button press, such as a mouse button release or a keypress,buttonshould be 0.The
activate_timeparameter is used to conflict-resolve initiation of concurrent requests for mouse/keyboard grab requests. To function properly, this needs to be the timestamp of the user event (such as a mouse click or key press) that caused the initiation of the popup. Only if no such event is available,gtk_get_current_event_time()can be used instead.Note that this function does not work very well on GDK backends that do not have global coordinates, such as Wayland or Mir. You should probably use one of the gtk_menu_popup_at_ variants, which do not have this problem.
popup is deprecated: Please use gtk_menu_popup_at_widget(), gtk_menu_popup_at_pointer(). or gtk_menu_popup_at_rect() instead
Declaration
-
popup(parentMenuShell:Extension methodparentMenuItem: func: data: button: activateTime: ) Displays a menu and makes it available for selection.
Applications can use this function to display context-sensitive menus, and will typically supply
nilfor theparent_menu_shell,parent_menu_item,funcanddataparameters. The default menu positioning function will position the menu at the current mouse cursor position.The
buttonparameter should be the mouse button pressed to initiate the menu popup. If the menu popup was initiated by something other than a mouse button press, such as a mouse button release or a keypress,buttonshould be 0.The
activate_timeparameter is used to conflict-resolve initiation of concurrent requests for mouse/keyboard grab requests. To function properly, this needs to be the timestamp of the user event (such as a mouse click or key press) that caused the initiation of the popup. Only if no such event is available,gtk_get_current_event_time()can be used instead.Note that this function does not work very well on GDK backends that do not have global coordinates, such as Wayland or Mir. You should probably use one of the gtk_menu_popup_at_ variants, which do not have this problem.
popup is deprecated: Please use gtk_menu_popup_at_widget(), gtk_menu_popup_at_pointer(). or gtk_menu_popup_at_rect() instead
Declaration
Swift
@available(*, deprecated) @inlinable func popup<WidgetT>(parentMenuShell: WidgetT?, parentMenuItem: WidgetT?, func: GtkMenuPositionFunc? = nil, data: gpointer! = nil, button: Int, activateTime: guint32) where WidgetT : WidgetProtocol -
popupAtPointer(triggerEvent:Extension method) Displays
menuand makes it available for selection.See gtk_menu_popup_at_widget () to pop up a menu at a widget. gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary rectangle.
menuwill be positioned at the pointer associated withtrigger_event.Properties that influence the behaviour of this function are
GtkMenu:anchor-hints,GtkMenu:rect-anchor-dx,GtkMenu:rect-anchor-dy, andGtkMenu:menu-type-hint. Connect to theGtkMenu::popped-upsignal to find out how it was actually positioned.Declaration
Swift
@inlinable func popupAtPointer(triggerEvent: Gdk.EventRef? = nil) -
popupAtPointer(triggerEvent:Extension method) Displays
menuand makes it available for selection.See gtk_menu_popup_at_widget () to pop up a menu at a widget. gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary rectangle.
menuwill be positioned at the pointer associated withtrigger_event.Properties that influence the behaviour of this function are
GtkMenu:anchor-hints,GtkMenu:rect-anchor-dx,GtkMenu:rect-anchor-dy, andGtkMenu:menu-type-hint. Connect to theGtkMenu::popped-upsignal to find out how it was actually positioned.Declaration
Swift
@inlinable func popupAtPointer<EventT>(triggerEvent: EventT?) where EventT : EventProtocol -
popupAtRect(rectWindow:Extension methodrect: rectAnchor: menuAnchor: triggerEvent: ) Displays
menuand makes it available for selection.See gtk_menu_popup_at_widget () and gtk_menu_popup_at_pointer (), which handle more common cases for popping up menus.
menuwill be positioned atrect, aligning their anchor points.rectis relative to the top-left corner ofrect_window.rect_anchorandmenu_anchordetermine anchor points onrectandmenuto pin together.menucan optionally be offset byGtkMenu:rect-anchor-dxandGtkMenu:rect-anchor-dy.Anchors should be specified under the assumption that the text direction is left-to-right; they will be flipped horizontally automatically if the text direction is right-to-left.
Other properties that influence the behaviour of this function are
GtkMenu:anchor-hintsandGtkMenu:menu-type-hint. Connect to theGtkMenu::popped-upsignal to find out how it was actually positioned.Declaration
Swift
@inlinable func popupAtRect<RectangleT, WindowT>(rectWindow: WindowT, rect: RectangleT, rectAnchor: GdkGravity, menuAnchor: GdkGravity, triggerEvent: Gdk.EventRef? = nil) where RectangleT : RectangleProtocol, WindowT : WindowProtocol -
popupAtRect(rectWindow:Extension methodrect: rectAnchor: menuAnchor: triggerEvent: ) Displays
menuand makes it available for selection.See gtk_menu_popup_at_widget () and gtk_menu_popup_at_pointer (), which handle more common cases for popping up menus.
menuwill be positioned atrect, aligning their anchor points.rectis relative to the top-left corner ofrect_window.rect_anchorandmenu_anchordetermine anchor points onrectandmenuto pin together.menucan optionally be offset byGtkMenu:rect-anchor-dxandGtkMenu:rect-anchor-dy.Anchors should be specified under the assumption that the text direction is left-to-right; they will be flipped horizontally automatically if the text direction is right-to-left.
Other properties that influence the behaviour of this function are
GtkMenu:anchor-hintsandGtkMenu:menu-type-hint. Connect to theGtkMenu::popped-upsignal to find out how it was actually positioned.Declaration
Swift
@inlinable func popupAtRect<EventT, RectangleT, WindowT>(rectWindow: WindowT, rect: RectangleT, rectAnchor: GdkGravity, menuAnchor: GdkGravity, triggerEvent: EventT?) where EventT : EventProtocol, RectangleT : RectangleProtocol, WindowT : WindowProtocol -
popupAt(widget:Extension methodwidgetAnchor: menuAnchor: triggerEvent: ) Displays
menuand makes it available for selection.See gtk_menu_popup_at_pointer () to pop up a menu at the master pointer. gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary rectangle.

menuwill be positioned atwidget, aligning their anchor points.widget_anchorandmenu_anchordetermine anchor points onwidgetandmenuto pin together.menucan optionally be offset byGtkMenu:rect-anchor-dxandGtkMenu:rect-anchor-dy.Anchors should be specified under the assumption that the text direction is left-to-right; they will be flipped horizontally automatically if the text direction is right-to-left.
Other properties that influence the behaviour of this function are
GtkMenu:anchor-hintsandGtkMenu:menu-type-hint. Connect to theGtkMenu::popped-upsignal to find out how it was actually positioned.Declaration
Swift
@inlinable func popupAt<WidgetT>(widget: WidgetT, widgetAnchor: GdkGravity, menuAnchor: GdkGravity, triggerEvent: Gdk.EventRef? = nil) where WidgetT : WidgetProtocol -
popupAt(widget:Extension methodwidgetAnchor: menuAnchor: triggerEvent: ) Displays
menuand makes it available for selection.See gtk_menu_popup_at_pointer () to pop up a menu at the master pointer. gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary rectangle.

menuwill be positioned atwidget, aligning their anchor points.widget_anchorandmenu_anchordetermine anchor points onwidgetandmenuto pin together.menucan optionally be offset byGtkMenu:rect-anchor-dxandGtkMenu:rect-anchor-dy.Anchors should be specified under the assumption that the text direction is left-to-right; they will be flipped horizontally automatically if the text direction is right-to-left.
Other properties that influence the behaviour of this function are
GtkMenu:anchor-hintsandGtkMenu:menu-type-hint. Connect to theGtkMenu::popped-upsignal to find out how it was actually positioned.Declaration
Swift
@inlinable func popupAt<EventT, WidgetT>(widget: WidgetT, widgetAnchor: GdkGravity, menuAnchor: GdkGravity, triggerEvent: EventT?) where EventT : EventProtocol, WidgetT : WidgetProtocol -
popupFor(device:Extension methodparentMenuShell: parentMenuItem: func: data: destroy: button: activateTime: ) Displays a menu and makes it available for selection.
Applications can use this function to display context-sensitive menus, and will typically supply
nilfor theparent_menu_shell,parent_menu_item,func,dataanddestroyparameters. The default menu positioning function will position the menu at the current position ofdevice(or its corresponding pointer).The
buttonparameter should be the mouse button pressed to initiate the menu popup. If the menu popup was initiated by something other than a mouse button press, such as a mouse button release or a keypress,buttonshould be 0.The
activate_timeparameter is used to conflict-resolve initiation of concurrent requests for mouse/keyboard grab requests. To function properly, this needs to be the time stamp of the user event (such as a mouse click or key press) that caused the initiation of the popup. Only if no such event is available,gtk_get_current_event_time()can be used instead.Note that this function does not work very well on GDK backends that do not have global coordinates, such as Wayland or Mir. You should probably use one of the gtk_menu_popup_at_ variants, which do not have this problem.
popup_for_device is deprecated: Please use gtk_menu_popup_at_widget(), gtk_menu_popup_at_pointer(). or gtk_menu_popup_at_rect() instead
Declaration
-
popupFor(device:Extension methodparentMenuShell: parentMenuItem: func: data: destroy: button: activateTime: ) Displays a menu and makes it available for selection.
Applications can use this function to display context-sensitive menus, and will typically supply
nilfor theparent_menu_shell,parent_menu_item,func,dataanddestroyparameters. The default menu positioning function will position the menu at the current position ofdevice(or its corresponding pointer).The
buttonparameter should be the mouse button pressed to initiate the menu popup. If the menu popup was initiated by something other than a mouse button press, such as a mouse button release or a keypress,buttonshould be 0.The
activate_timeparameter is used to conflict-resolve initiation of concurrent requests for mouse/keyboard grab requests. To function properly, this needs to be the time stamp of the user event (such as a mouse click or key press) that caused the initiation of the popup. Only if no such event is available,gtk_get_current_event_time()can be used instead.Note that this function does not work very well on GDK backends that do not have global coordinates, such as Wayland or Mir. You should probably use one of the gtk_menu_popup_at_ variants, which do not have this problem.
popup_for_device is deprecated: Please use gtk_menu_popup_at_widget(), gtk_menu_popup_at_pointer(). or gtk_menu_popup_at_rect() instead
Declaration
Swift
@available(*, deprecated) @inlinable func popupFor<DeviceT, WidgetT>(device: DeviceT?, parentMenuShell: WidgetT?, parentMenuItem: WidgetT?, func: GtkMenuPositionFunc? = nil, data: gpointer! = nil, destroy: GDestroyNotify? = nil, button: Int, activateTime: guint32) where DeviceT : DeviceProtocol, WidgetT : WidgetProtocol -
reorder(child:Extension methodposition: ) Moves
childto a newpositionin the list ofmenuchildren.Declaration
Swift
@inlinable func reorder<WidgetT>(child: WidgetT, position: Int) where WidgetT : WidgetProtocol -
reposition()Extension methodRepositions the menu according to its position function.
Declaration
Swift
@inlinable func reposition() -
set(accelGroup:Extension method) Set the
GtkAccelGroupwhich holds global accelerators for the menu. This accelerator group needs to also be added to all windows that this menu is being used in withgtk_window_add_accel_group(), in order for those windows to support all the accelerators contained in this group.Declaration
Swift
@inlinable func set(accelGroup: AccelGroupRef? = nil) -
set(accelGroup:Extension method) Set the
GtkAccelGroupwhich holds global accelerators for the menu. This accelerator group needs to also be added to all windows that this menu is being used in withgtk_window_add_accel_group(), in order for those windows to support all the accelerators contained in this group.Declaration
Swift
@inlinable func set<AccelGroupT>(accelGroup: AccelGroupT?) where AccelGroupT : AccelGroupProtocol -
set(accelPath:Extension method) Sets an accelerator path for this menu from which accelerator paths for its immediate children, its menu items, can be constructed. The main purpose of this function is to spare the programmer the inconvenience of having to call
gtk_menu_item_set_accel_path()on each menu item that should support runtime user changable accelerators. Instead, by just callinggtk_menu_set_accel_path()on their parent, each menu item of this menu, that contains a label describing its purpose, automatically gets an accel path assigned.For example, a menu containing menu items “New” and “Exit”, will, after
gtk_menu_set_accel_path (menu, "<Gnumeric-Sheet>/File");has been called, assign its items the accel paths:"<Gnumeric-Sheet>/File/New"and"<Gnumeric-Sheet>/File/Exit".Assigning accel paths to menu items then enables the user to change their accelerators at runtime. More details about accelerator paths and their default setups can be found at
gtk_accel_map_add_entry().Note that
accel_pathstring will be stored in aGQuark. Therefore, if you pass a static string, you can save some memory by interning it first withg_intern_static_string().Declaration
Swift
@inlinable func set(accelPath: UnsafePointer<gchar>? = nil) -
setActive(index:Extension method) Selects the specified menu item within the menu. This is used by the
GtkComboBoxand should not be used by anyone else.Declaration
Swift
@inlinable func setActive(index: Int) -
setMonitor(monitorNum:Extension method) Informs GTK+ on which monitor a menu should be popped up. See
gdk_monitor_get_geometry().This function should be called from a
GtkMenuPositionFuncif the menu should not appear on the same monitor as the pointer. This information can’t be reliably inferred from the coordinates returned by aGtkMenuPositionFunc, since, for very long menus, these coordinates may extend beyond the monitor boundaries or even the screen boundaries.Declaration
Swift
@inlinable func setMonitor(monitorNum: Int) -
set(reserveToggleSize:Extension method) Sets whether the menu should reserve space for drawing toggles or icons, regardless of their actual presence.
Declaration
Swift
@inlinable func set(reserveToggleSize: Bool) -
set(screen:Extension method) Sets the
GdkScreenon which the menu will be displayed.Declaration
Swift
@inlinable func set(screen: Gdk.ScreenRef? = nil) -
set(screen:Extension method) Sets the
GdkScreenon which the menu will be displayed.Declaration
Swift
@inlinable func set<ScreenT>(screen: ScreenT?) where ScreenT : ScreenProtocol -
setTearoffState(tornOff:Extension method) Changes the tearoff state of the menu. A menu is normally displayed as drop down menu which persists as long as the menu is active. It can also be displayed as a tearoff menu which persists until it is closed or reattached.
set_tearoff_state is deprecated: This method is deprecated.
Declaration
Swift
@available(*, deprecated) @inlinable func setTearoffState(tornOff: Bool) -
set(title:Extension method) Sets the title string for the menu.
The title is displayed when the menu is shown as a tearoff menu. If
titleisnil, the menu will see if it is attached to a parent menu item, and if so it will try to use the same text as that menu item’s label.set_title is deprecated: This method is deprecated.
Declaration
Swift
@available(*, deprecated) @inlinable func set(title: UnsafePointer<gchar>? = nil) -
accelGroupExtension methodGets the
GtkAccelGroupwhich holds global accelerators for the menu. Seegtk_menu_set_accel_group().Declaration
Swift
@inlinable var accelGroup: AccelGroupRef! { get nonmutating set } -
accelPathExtension methodRetrieves the accelerator path set on the menu.
Declaration
Swift
@inlinable var accelPath: String! { get nonmutating set } -
activeExtension methodThe index of the currently selected menu item, or -1 if no menu item is selected.
Declaration
Swift
@inlinable var active: WidgetRef! { get nonmutating set } -
attachWidgetExtension methodReturns the
GtkWidgetthat the menu is attached to.Declaration
Swift
@inlinable var attachWidget: WidgetRef! { get } -
monitorExtension methodThe monitor the menu will be popped up on.
Declaration
Swift
@inlinable var monitor: Int { get nonmutating set } -
reserveToggleSizeExtension methodReturns whether the menu reserves space for toggles and icons, regardless of their actual presence.
Declaration
Swift
@inlinable var reserveToggleSize: Bool { get nonmutating set } -
tearoffStateExtension methodReturns whether the menu is torn off. See
gtk_menu_set_tearoff_state().get_tearoff_state is deprecated: This method is deprecated.
Declaration
Swift
@inlinable var tearoffState: Bool { get nonmutating set } -
titleExtension methodReturns the title of the menu. See
gtk_menu_set_title().get_title is deprecated: This method is deprecated.
Declaration
Swift
@inlinable var title: String! { get nonmutating set } -
menuShellExtension methodUndocumented
Declaration
Swift
@inlinable var menuShell: GtkMenuShell { get }
View on GitHub
Install in Dash
MenuProtocol Protocol Reference