Class: Gtk::ModelButton
- Inherits:
-
Object
- Object
- Gtk::ModelButton
- Defined in:
- (unknown)
Overview
GtkModelButton is a button class that can use a #GAction 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, GtkModelButton 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 and Gtk::Actionable:action-target properties, the role of the button (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 and Gtk::ModelButton:icon properties.
The appearance of model buttons can be influenced with the Gtk::ModelButton:centered and #GtkModelButton:iconic properties.
Model buttons have built-in support for submenus in Gtk::PopoverMenu. To make a GtkModelButton that opens a submenu when activated, set the Gtk::ModelButton:menu-name property. To make a button that goes back to the parent menu, you should set the Gtk::ModelButton:inverted property to place the submenu indicator at the opposite side.
# 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> ]|
# CSS nodes
button.model
├── <child>
╰── check
Iconic model buttons (see Gtk::ModelButton:iconic) change the name of their main node to button and add a .model style class to it. The indicator subnode is invisible in this case.
Instance Method Summary collapse
-
#active=(active) ⇒ TrueClass
The state of the button.
-
#active? ⇒ TrueClass
The state of the button.
-
#centered=(centered) ⇒ TrueClass
Whether to render the button contents centered instead of left-aligned.
-
#centered? ⇒ TrueClass
Whether to render the button contents centered instead of left-aligned.
-
#icon ⇒ Gio::Icon
A #GIcon that will be used if iconic appearance for the button is desired.
-
#icon=(icon) ⇒ Gio::Icon
A #GIcon that will be used if iconic appearance for the button is desired.
-
#iconic=(iconic) ⇒ TrueClass
If this property is set, the button will show an icon if one is set.
-
#iconic? ⇒ TrueClass
If this property is set, the button will show an icon if one is set.
-
#inverted=(inverted) ⇒ TrueClass
Whether to show the submenu indicator at the opposite side than normal.
-
#inverted? ⇒ TrueClass
Whether to show the submenu indicator at the opposite side than normal.
-
#menu_name ⇒ String
The name of a submenu to open when the button is activated.
-
#menu_name=(menu_name) ⇒ String
The name of a submenu to open when the button is activated.
-
#new ⇒ Gtk::Widget
Creates a new GtkModelButton.
-
#role ⇒ Gtk::ButtonRole
Specifies whether the button is a plain, check or radio button.
-
#role=(role) ⇒ Gtk::ButtonRole
Specifies whether the button is a plain, check or radio button.
-
#text ⇒ String
The label for the button.
-
#text=(text) ⇒ String
The label for the button.
-
#use_markup=(use_markup) ⇒ TrueClass
If true, XML tags in the text of the button are interpreted as by pango_parse_markup() to format the enclosed spans of text.
-
#use_markup? ⇒ TrueClass
If true, XML tags in the text of the button are interpreted as by pango_parse_markup() to format the enclosed spans of text.
Instance Method Details
#active=(active) ⇒ TrueClass
The state of the button. This is reflecting the state of the associated #GAction.
#active? ⇒ TrueClass
The state of the button. This is reflecting the state of the associated #GAction.
#centered=(centered) ⇒ TrueClass
Whether to render the button contents centered instead of left-aligned. This property should be set for title-like items.
#centered? ⇒ TrueClass
Whether to render the button contents centered instead of left-aligned. This property should be set for title-like items.
#icon ⇒ Gio::Icon
A #GIcon that will be used if iconic appearance for the button is desired.
#icon=(icon) ⇒ Gio::Icon
A #GIcon that will be used if iconic appearance for the button is desired.
#iconic=(iconic) ⇒ TrueClass
If this property is set, the button will show an icon if one is set. If no icon is set, the text will be used. This is typically used for horizontal sections of linked buttons.
#iconic? ⇒ TrueClass
If this property is set, the button will show an icon if one is set. If no icon is set, the text will be used. This is typically used for horizontal sections of linked buttons.
#inverted=(inverted) ⇒ TrueClass
Whether to show the submenu indicator at the opposite side than normal. This property should be set for model buttons that ‘go back’ to a parent menu.
#inverted? ⇒ TrueClass
Whether to show the submenu indicator at the opposite side than normal. This property should be set for model buttons that ‘go back’ to a parent menu.
#menu_name ⇒ String
The name of a submenu to open when the button is activated. If this is set, the button should not have an action associated with it.
#menu_name=(menu_name) ⇒ String
The name of a submenu to open when the button is activated. If this is set, the button should not have an action associated with it.
#new ⇒ Gtk::Widget
Creates a new GtkModelButton.
#role ⇒ Gtk::ButtonRole
Specifies whether the button is a plain, check or radio button. When Gtk::Actionable:action-name is set, the role will be determined from the action and does not have to be set explicitly.
#role=(role) ⇒ Gtk::ButtonRole
Specifies whether the button is a plain, check or radio button. When Gtk::Actionable:action-name is set, the role will be determined from the action and does not have to be set explicitly.
#text ⇒ String
The label for the button.
#text=(text) ⇒ String
The label for the button.
#use_markup=(use_markup) ⇒ TrueClass
If true, XML tags in the text of the button are interpreted as by pango_parse_markup() to format the enclosed spans of text. If false, the text will be displayed verbatim.
#use_markup? ⇒ TrueClass
If true, XML tags in the text of the button are interpreted as by pango_parse_markup() to format the enclosed spans of text. If false, the text will be displayed verbatim.