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.

  • ptr

    Untyped pointer to the underlying GtkMenu instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • menu_ptr Default implementation

    Typed 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)

Menu Class

  • 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 transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return 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:value:) Extension method

    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

Menu signals

  • Connect a Swift signal handler to the given, typed MenuSignalName signal

    Declaration

    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 by userData

    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 a C signal handler to the given, typed MenuSignalName signal

    Declaration

    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 by userData

    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 method

    Emitted 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 case flipped_x and flipped_y will be set to true accordingly.

    flipped_rect is the ideal position of menu after any possible flipping, but before any possible sliding. final_rect is flipped_rect, but possibly translated in the case that flipping is still ineffective in keeping menu on-screen.

    The blue menu is menu‘s ideal position, the green menu is flipped_rect, and the red menu is final_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, and GtkMenu:menu-type-hint.

    Note

    This represents the underlying popped-up signal

    Warning

    a onPoppedUp wrapper for this signal could not be generated because it contains unimplemented features: { (4) gpointer argument is not yet supported }

    Note

    Instead, you can connect poppedUpSignal using the connect(signal:) methods

    Declaration

    Swift

    static var poppedUpSignal: MenuSignalName { get }

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    flippedRect

    the position of menu after any possible flipping or nil if the backend can’t obtain it

    finalRect

    the final position of menu or nil if the backend can’t obtain it

    flippedX

    true if the anchors were flipped horizontally

    flippedY

    true if the anchors were flipped vertically

    handler

    The signal handler to call

  • onMoveScroll(flags:handler:) Extension method

    Note

    This represents the underlying move-scroll signal

    Declaration

    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 method

    Typed move-scroll signal for using the connect(signal:) methods

    Declaration

    Swift

    static var moveScrollSignal: MenuSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::accel-group signal

    Declaration

    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 method

    Typed notify::accel-group signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyAccelGroupSignal: MenuSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::accel-path signal

    Declaration

    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 method

    Typed notify::accel-path signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyAccelPathSignal: MenuSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::active signal

    Declaration

    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 method

    Typed notify::active signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyActiveSignal: MenuSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::anchor-hints signal

    Declaration

    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 method

    Typed notify::anchor-hints signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyAnchorHintsSignal: MenuSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::attach-widget signal

    Declaration

    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 method

    Typed notify::attach-widget signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyAttachWidgetSignal: MenuSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::menu-type-hint signal

    Declaration

    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 method

    Typed notify::menu-type-hint signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyMenuTypeHintSignal: MenuSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::monitor signal

    Declaration

    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 method

    Typed notify::monitor signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyMonitorSignal: MenuSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::rect-anchor-dx signal

    Declaration

    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 method

    Typed notify::rect-anchor-dx signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyRectAnchorDxSignal: MenuSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::rect-anchor-dy signal

    Declaration

    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 method

    Typed notify::rect-anchor-dy signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyRectAnchorDySignal: MenuSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::reserve-toggle-size signal

    Declaration

    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

  • Typed notify::reserve-toggle-size signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyReserveToggleSizeSignal: MenuSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::tearoff-state signal

    Declaration

    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 method

    Typed notify::tearoff-state signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyTearoffStateSignal: MenuSignalName { get }
  • 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 to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_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 underlying notify::tearoff-title signal

    Declaration

    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 method

    Typed notify::tearoff-title signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyTearoffTitleSignal: MenuSignalName { get }

Menu Class: MenuProtocol extension (methods and fields)

  • Adds a new GtkMenuItem to a (table) menu. The number of “cells” that an item will occupy is specified by left_attach, right_attach, top_attach and bottom_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
  • 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 method

    Detaches the menu from the widget to which it had been attached. This function will call the callback function, detacher, provided when the gtk_menu_attach_to_widget() function was called.

    Declaration

    Swift

    @inlinable
    func detach()
  • getAccelGroup() Extension method

    Gets the GtkAccelGroup which holds global accelerators for the menu. See gtk_menu_set_accel_group().

    Declaration

    Swift

    @inlinable
    func getAccelGroup() -> AccelGroupRef!
  • getAccelPath() Extension method

    Retrieves the accelerator path set on the menu.

    Declaration

    Swift

    @inlinable
    func getAccelPath() -> String!
  • getActive() Extension method

    Returns the selected menu item from the menu. This is used by the GtkComboBox.

    Declaration

    Swift

    @inlinable
    func getActive() -> WidgetRef!
  • getAttachWidget() Extension method

    Returns the GtkWidget that the menu is attached to.

    Declaration

    Swift

    @inlinable
    func getAttachWidget() -> WidgetRef!
  • getMonitor() Extension method

    Retrieves the number of the monitor on which to show the menu.

    Declaration

    Swift

    @inlinable
    func getMonitor() -> Int
  • getReserveToggleSize() Extension method

    Returns whether the menu reserves space for toggles and icons, regardless of their actual presence.

    Declaration

    Swift

    @inlinable
    func getReserveToggleSize() -> Bool
  • getTearoffState() Extension method

    Returns 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 method

    Returns 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 method

    Removes the menu from the screen.

    Declaration

    Swift

    @inlinable
    func popdown()
  • 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 the parent_menu_shell, parent_menu_item, func and data 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(parentMenuShell: WidgetRef? = nil, parentMenuItem: WidgetRef? = nil, func: GtkMenuPositionFunc? = nil, data: gpointer! = nil, button: Int, activateTime: guint32)
  • 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 the parent_menu_shell, parent_menu_item, func and data 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
  • 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 with trigger_event.

    Properties that influence the behaviour of this function are GtkMenu:anchor-hints, GtkMenu:rect-anchor-dx, GtkMenu:rect-anchor-dy, and GtkMenu:menu-type-hint. Connect to the GtkMenu::popped-up signal to find out how it was actually positioned.

    Declaration

    Swift

    @inlinable
    func popupAtPointer(triggerEvent: Gdk.EventRef? = nil)
  • 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 with trigger_event.

    Properties that influence the behaviour of this function are GtkMenu:anchor-hints, GtkMenu:rect-anchor-dx, GtkMenu:rect-anchor-dy, and GtkMenu:menu-type-hint. Connect to the GtkMenu::popped-up signal to find out how it was actually positioned.

    Declaration

    Swift

    @inlinable
    func popupAtPointer<EventT>(triggerEvent: EventT?) where EventT : EventProtocol
  • 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 at rect, aligning their anchor points. rect is relative to the top-left corner of rect_window. rect_anchor and menu_anchor determine anchor points on rect and menu to pin together. menu can optionally be offset by GtkMenu:rect-anchor-dx and GtkMenu: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 and GtkMenu:menu-type-hint. Connect to the GtkMenu::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
  • 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 at rect, aligning their anchor points. rect is relative to the top-left corner of rect_window. rect_anchor and menu_anchor determine anchor points on rect and menu to pin together. menu can optionally be offset by GtkMenu:rect-anchor-dx and GtkMenu: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 and GtkMenu:menu-type-hint. Connect to the GtkMenu::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
  • 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 at widget, aligning their anchor points. widget_anchor and menu_anchor determine anchor points on widget and menu to pin together. menu can optionally be offset by GtkMenu:rect-anchor-dx and GtkMenu: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 and GtkMenu:menu-type-hint. Connect to the GtkMenu::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
  • 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 at widget, aligning their anchor points. widget_anchor and menu_anchor determine anchor points on widget and menu to pin together. menu can optionally be offset by GtkMenu:rect-anchor-dx and GtkMenu: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 and GtkMenu:menu-type-hint. Connect to the GtkMenu::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
  • 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 the parent_menu_shell, parent_menu_item, func, data and destroy parameters. The default menu positioning function will position the menu at the current position of device (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(device: Gdk.DeviceRef? = nil, parentMenuShell: WidgetRef? = nil, parentMenuItem: WidgetRef? = nil, func: GtkMenuPositionFunc? = nil, data: gpointer! = nil, destroy: GDestroyNotify? = nil, button: Int, activateTime: guint32)
  • 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 the parent_menu_shell, parent_menu_item, func, data and destroy parameters. The default menu positioning function will position the menu at the current position of device (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:position:) Extension method

    Moves child to a new position in the list of menu children.

    Declaration

    Swift

    @inlinable
    func reorder<WidgetT>(child: WidgetT, position: Int) where WidgetT : WidgetProtocol
  • reposition() Extension method

    Repositions 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 with gtk_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 with gtk_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 calling gtk_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, "&lt;Gnumeric-Sheet&gt;/File"); has been called, assign its items the accel paths: "&lt;Gnumeric-Sheet&gt;/File/New" and "&lt;Gnumeric-Sheet&gt;/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 a GQuark. Therefore, if you pass a static string, you can save some memory by interning it first with g_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 a GtkMenuPositionFunc, 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 is nil, 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 method

    Gets the GtkAccelGroup which holds global accelerators for the menu. See gtk_menu_set_accel_group().

    Declaration

    Swift

    @inlinable
    var accelGroup: AccelGroupRef! { get nonmutating set }
  • accelPath Extension method

    Retrieves the accelerator path set on the menu.

    Declaration

    Swift

    @inlinable
    var accelPath: String! { get nonmutating set }
  • active Extension method

    The 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 method

    Returns the GtkWidget that the menu is attached to.

    Declaration

    Swift

    @inlinable
    var attachWidget: WidgetRef! { get }
  • monitor Extension method

    The monitor the menu will be popped up on.

    Declaration

    Swift

    @inlinable
    var monitor: Int { get nonmutating set }
  • reserveToggleSize Extension method

    Returns 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 method

    Returns 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 method

    Returns 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 method

    Undocumented

    Declaration

    Swift

    @inlinable
    var menuShell: GtkMenuShell { get }