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
GtkMenu
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
menu_ptr
Default implementationTyped pointer to the underlying
GtkMenu
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkMenu
instance.Declaration
Swift
var menu_ptr: UnsafeMutablePointer<GtkMenu>! { get }
-
Required Initialiser for types conforming to
MenuProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
MenuPropertyName
source 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 : ObjectProtocol
Parameters
source_property
the source property to bind
target
the target object to bind to
target_property
the target property to bind to
flags
the flags to pass to the
Binding
transform_from
ValueTransformer
to use for forward transformationtransform_to
ValueTransformer
to use for backwards transformationReturn Value
binding reference or
nil
in case of an error -
get(property:
Extension method) Get the value of a Menu property
Declaration
Swift
@inlinable func get(property: MenuPropertyName) -> GLibObject.Value
Parameters
property
the 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
property
the 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
MenuSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: MenuSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
handler
The 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
MenuSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: MenuSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
signalHandler
The C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
poppedUpSignal
Extension methodEmitted when the position of
menu
is finalized after being popped up using gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (), or gtk_menu_popup_at_pointer ().menu
might be flipped over the anchor rectangle in order to keep it on-screen, in which caseflipped_x
andflipped_y
will be set totrue
accordingly.flipped_rect
is the ideal position ofmenu
after any possible flipping, but before any possible sliding.final_rect
isflipped_rect
, but possibly translated in the case that flipping is still ineffective in keepingmenu
on-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-up
signalWarning
aonPoppedUp
wrapper for this signal could not be generated because it contains unimplemented features: { (4) gpointer argument is not yet supported }Note
Instead, you can connectpoppedUpSignal
using theconnect(signal:)
methodsDeclaration
Swift
static var poppedUpSignal: MenuSignalName { get }
Parameters
flags
Flags
unownedSelf
Reference to instance of self
flippedRect
the position of
menu
after any possible flipping ornil
if the backend can’t obtain itfinalRect
the final position of
menu
ornil
if the backend can’t obtain itflippedX
true
if the anchors were flipped horizontallyflippedY
true
if the anchors were flipped verticallyhandler
The signal handler to call
-
onMoveScroll(flags:
Extension methodhandler: ) Note
This represents the underlyingmove-scroll
signalDeclaration
Swift
@discardableResult @inlinable func onMoveScroll(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ scrollType: ScrollType) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
scrollType
a
GtkScrollType
handler
The signal handler to call Run the given callback whenever the
moveScroll
signal is emitted -
moveScrollSignal
Extension methodTyped
move-scroll
signal 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 innotify
being 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-group
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyAccelGroup(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyAccelGroup
signal is emitted -
notifyAccelGroupSignal
Extension methodTyped
notify::accel-group
signal 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 innotify
being 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-path
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyAccelPath(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyAccelPath
signal is emitted -
notifyAccelPathSignal
Extension methodTyped
notify::accel-path
signal 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 innotify
being 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::active
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyActive(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyActive
signal is emitted -
notifyActiveSignal
Extension methodTyped
notify::active
signal 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 innotify
being 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-hints
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyAnchorHints(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyAnchorHints
signal is emitted -
notifyAnchorHintsSignal
Extension methodTyped
notify::anchor-hints
signal 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 innotify
being 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-widget
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyAttachWidget(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyAttachWidget
signal is emitted -
notifyAttachWidgetSignal
Extension methodTyped
notify::attach-widget
signal 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 innotify
being 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-hint
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyMenuTypeHint(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyMenuTypeHint
signal is emitted -
notifyMenuTypeHintSignal
Extension methodTyped
notify::menu-type-hint
signal 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 innotify
being 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::monitor
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyMonitor(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyMonitor
signal is emitted -
notifyMonitorSignal
Extension methodTyped
notify::monitor
signal 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 innotify
being 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-dx
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyRectAnchorDx(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyRectAnchorDx
signal is emitted -
notifyRectAnchorDxSignal
Extension methodTyped
notify::rect-anchor-dx
signal 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 innotify
being 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-dy
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyRectAnchorDy(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyRectAnchorDy
signal is emitted -
notifyRectAnchorDySignal
Extension methodTyped
notify::rect-anchor-dy
signal 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 innotify
being 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-size
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyReserveToggleSize(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyReserveToggleSize
signal is emitted -
notifyReserveToggleSizeSignal
Extension methodTyped
notify::reserve-toggle-size
signal 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 innotify
being 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-state
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyTearoffState(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyTearoffState
signal is emitted -
notifyTearoffStateSignal
Extension methodTyped
notify::tearoff-state
signal 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 innotify
being 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-title
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyTearoffTitle(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: MenuRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyTearoffTitle
signal is emitted -
notifyTearoffTitleSignal
Extension methodTyped
notify::tearoff-title
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyTearoffTitleSignal: MenuSignalName { get }
-
attach(child:
Extension methodleftAttach: rightAttach: topAttach: bottomAttach: ) Adds a new
GtkMenuItem
to a (table) menu. The number of “cells” that an item will occupy is specified byleft_attach
,right_attach
,top_attach
andbottom_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
GtkAccelGroup
which 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
GtkWidget
that 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
menu
on 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
nil
for theparent_menu_shell
,parent_menu_item
,func
anddata
parameters. The default menu positioning function will position the menu at the current mouse cursor position.The
button
parameter 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,button
should be 0.The
activate_time
parameter 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
nil
for theparent_menu_shell
,parent_menu_item
,func
anddata
parameters. The default menu positioning function will position the menu at the current mouse cursor position.The
button
parameter 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,button
should be 0.The
activate_time
parameter 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
menu
and 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.
menu
will 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-up
signal to find out how it was actually positioned.Declaration
Swift
@inlinable func popupAtPointer(triggerEvent: Gdk.EventRef? = nil)
-
popupAtPointer(triggerEvent:
Extension method) Displays
menu
and 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.
menu
will 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-up
signal 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
menu
and 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.
menu
will be positioned atrect
, aligning their anchor points.rect
is relative to the top-left corner ofrect_window
.rect_anchor
andmenu_anchor
determine anchor points onrect
andmenu
to pin together.menu
can optionally be offset byGtkMenu:rect-anchor-dx
andGtkMenu: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-hints
andGtkMenu:menu-type-hint
. Connect to theGtkMenu::popped-up
signal 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
menu
and 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.
menu
will be positioned atrect
, aligning their anchor points.rect
is relative to the top-left corner ofrect_window
.rect_anchor
andmenu_anchor
determine anchor points onrect
andmenu
to pin together.menu
can optionally be offset byGtkMenu:rect-anchor-dx
andGtkMenu: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-hints
andGtkMenu:menu-type-hint
. Connect to theGtkMenu::popped-up
signal 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
menu
and 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.
menu
will be positioned atwidget
, aligning their anchor points.widget_anchor
andmenu_anchor
determine anchor points onwidget
andmenu
to pin together.menu
can optionally be offset byGtkMenu:rect-anchor-dx
andGtkMenu: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-hints
andGtkMenu:menu-type-hint
. Connect to theGtkMenu::popped-up
signal 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
menu
and 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.
menu
will be positioned atwidget
, aligning their anchor points.widget_anchor
andmenu_anchor
determine anchor points onwidget
andmenu
to pin together.menu
can optionally be offset byGtkMenu:rect-anchor-dx
andGtkMenu: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-hints
andGtkMenu:menu-type-hint
. Connect to theGtkMenu::popped-up
signal 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
nil
for theparent_menu_shell
,parent_menu_item
,func
,data
anddestroy
parameters. The default menu positioning function will position the menu at the current position ofdevice
(or its corresponding pointer).The
button
parameter 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,button
should be 0.The
activate_time
parameter 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
nil
for theparent_menu_shell
,parent_menu_item
,func
,data
anddestroy
parameters. The default menu positioning function will position the menu at the current position ofdevice
(or its corresponding pointer).The
button
parameter 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,button
should be 0.The
activate_time
parameter 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
child
to a newposition
in the list ofmenu
children.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
GtkAccelGroup
which 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
GtkAccelGroup
which 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_path
string 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
GtkComboBox
and 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
GtkMenuPositionFunc
if 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
GdkScreen
on which the menu will be displayed.Declaration
Swift
@inlinable func set(screen: Gdk.ScreenRef? = nil)
-
set(screen:
Extension method) Sets the
GdkScreen
on 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
title
isnil
, 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)
-
accelGroup
Extension methodGets the
GtkAccelGroup
which holds global accelerators for the menu. Seegtk_menu_set_accel_group()
.Declaration
Swift
@inlinable var accelGroup: AccelGroupRef! { get nonmutating set }
-
accelPath
Extension methodRetrieves the accelerator path set on the menu.
Declaration
Swift
@inlinable var accelPath: String! { get nonmutating set }
-
active
Extension 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 }
-
attachWidget
Extension methodReturns the
GtkWidget
that the menu is attached to.Declaration
Swift
@inlinable var attachWidget: WidgetRef! { get }
-
monitor
Extension methodThe monitor the menu will be popped up on.
Declaration
Swift
@inlinable var monitor: Int { get nonmutating set }
-
reserveToggleSize
Extension methodReturns whether the menu reserves space for toggles and icons, regardless of their actual presence.
Declaration
Swift
@inlinable var reserveToggleSize: Bool { get nonmutating set }
-
tearoffState
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
@inlinable var tearoffState: Bool { get nonmutating set }
-
title
Extension 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 }
-
menuShell
Extension methodUndocumented
Declaration
Swift
@inlinable var menuShell: GtkMenuShell { get }