PopoverMenuProtocol

public protocol PopoverMenuProtocol : PopoverProtocol

GtkPopoverMenu is a subclass of GtkPopover that treats its children like menus and allows switching between them. It is meant to be used primarily together with GtkModelButton, but any widget can be used, such as GtkSpinButton or GtkScale. In this respect, GtkPopoverMenu is more flexible than popovers that are created from a GMenuModel with gtk_popover_new_from_model().

To add a child as a submenu, set the GtkPopoverMenu:submenu child property to the name of the submenu. To let the user open this submenu, add a GtkModelButton whose GtkModelButton:menu-name property is set to the name you’ve given to the submenu.

By convention, the first child of a submenu should be a GtkModelButton to switch back to the parent menu. Such a button should use the GtkModelButton:inverted and GtkModelButton:centered properties to achieve a title-like appearance and place the submenu indicator at the opposite side. To switch back to the main menu, use “main” as the menu name.

Example

<object class="GtkPopoverMenu">
  <child>
    <object class="GtkBox">
      <property name="visible">True</property>
      <property name="margin">10</property>
      <child>
        <object class="GtkModelButton">
          <property name="visible">True</property>
          <property name="action-name">win.frob</property>
          <property name="text" translatable="yes">Frob</property>
        </object>
      </child>
      <child>
        <object class="GtkModelButton">
          <property name="visible">True</property>
          <property name="menu-name">more</property>
          <property name="text" translatable="yes">More</property>
        </object>
      </child>
    </object>
  </child>
  <child>
    <object class="GtkBox">
      <property name="visible">True</property>
      <property name="margin">10</property>
      <child>
        <object class="GtkModelButton">
          <property name="visible">True</property>
          <property name="action-name">win.foo</property>
          <property name="text" translatable="yes">Foo</property>
        </object>
      </child>
      <child>
        <object class="GtkModelButton">
          <property name="visible">True</property>
          <property name="action-name">win.bar</property>
          <property name="text" translatable="yes">Bar</property>
        </object>
      </child>
    </object>
    <packing>
      <property name="submenu">more</property>
    </packing>
  </child>
</object>

Just like normal popovers created using gtk_popover_new_from_model, GtkPopoverMenu instances have a single css node called “popover” and get the .menu style class.

The PopoverMenuProtocol protocol exposes the methods and properties of an underlying GtkPopoverMenu 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 PopoverMenu. Alternatively, use PopoverMenuRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkPopoverMenu instance.

    Declaration

    Swift

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

    Typed pointer to the underlying GtkPopoverMenu instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkPopoverMenu instance.

    Declaration

    Swift

    var popover_menu_ptr: UnsafeMutablePointer<GtkPopoverMenu>! { get }
  • Required Initialiser for types conforming to PopoverMenuProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

PopoverMenu Class

  • Bind a PopoverMenuPropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: PopoverMenuPropertyName, 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 PopoverMenu property

    Declaration

    Swift

    @inlinable
    func get(property: PopoverMenuPropertyName) -> 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 PopoverMenu property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: PopoverMenuPropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

PopoverMenu Class: PopoverMenuProtocol extension (methods and fields)

  • openSubmenu(name:) Extension method

    Opens a submenu of the popover. The name must be one of the names given to the submenus of popover with GtkPopoverMenu:submenu, or “main” to switch back to the main menu.

    GtkModelButton will open submenus automatically when the GtkModelButton:menu-name property is set, so this function is only needed when you are using other kinds of widgets to initiate menu changes.

    Declaration

    Swift

    @inlinable
    func openSubmenu(name: UnsafePointer<gchar>!)