Gtk.ModelButton


Gtk.ModelButton — A button that uses a GAction as model

Object Hierarchy:

    GObject
    ╰── GInitiallyUnowned
        ╰── Gtk.Widget
            ╰── Gtk.Container
                ╰── Gtk.Bin
                    ╰── Gtk.Button
                        ╰── Gtk.ModelButton

Functions:

  • new () -> Gtk.Widget

Description:

Gtk.ModelButton is a button class that can use a Gio.Action as its model.

In contrast to Gtk.ToggleButton or GtkRadioButton, which can also be backed by a #GAction via the Gtk.Actionable:action-name property, Gtk.ModelButton will adapt its appearance according to the kind of action it is backed by, and appear either as a plain, check or radio button.

Model buttons are used when popovers from a menu model with Gtk.Popover::new_from_model(); they can also be used manually in a Gtk.PopoverMenu.

When the action is specified via the Gtk.Actionable::action-name (i.e. whether it is a plain, check or radio button) is determined by the type of the action and doesn't have to be explicitly specified with the Gtk.ModelButton::role property.

The content of the button is specified by the Gtk.ModelButton::text. The appearance of model buttons can be influenced with the Model buttons have built-in support for submenus in Gtk.PopoverMenu.

To make a Gtk.ModelButton that opens a submenu when activated, set back to the parent menu, you should set the Gtk.ModelButton::inverted property to place the submenu indicator at the opposite side.

Glade UI 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">view.cut</property>
          <property name="text" translatable="yes">Cut</property>
        </object>
      </child>
      <child>
        <object class="GtkModelButton">
          <property name="visible">True</property>
          <property name="action-name">view.copy</property>
          <property name="text" translatable="yes">Copy</property>
        </object>
      </child>
      <child>
        <object class="GtkModelButton">
          <property name="visible">True</property>
          <property name="action-name">view.paste</property>
          <property name="text" translatable="yes">Paste</property>
        </object>
      </child>
    </object>
  </child>
</object>

Function Details:

new()

new () -> Gtk.Widget

Creates a new Gtk.ModelButton.

  • Returns: the newly created Gtk.ModelButton widget

  • Since: 3.16


results matching ""

    No results matching ""