gi-gtk-3.0.27: Gtk bindings

CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Objects.ModelButton

Contents

Description

GtkModelButton is a button class that can use a Action as its model. In contrast to ToggleButton or RadioButton, which can also be backed by a Action via the 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 popoverNewFromModel; they can also be used manually in a PopoverMenu.

When the action is specified via the Actionable:action-name and 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 ModelButton:role property.

The content of the button is specified by the ModelButton:text and ModelButton:icon properties.

The appearance of model buttons can be influenced with the ModelButton:centered and ModelButton:iconic properties.

Model buttons have built-in support for submenus in PopoverMenu. To make a GtkModelButton that opens a submenu when activated, set the ModelButton:menu-name property. To make a button that goes back to the parent menu, you should set the 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

plain code

modelbutton
├── <child>
╰── check

plain code

modelbutton
├── <child>
╰── radio

plain code

modelbutton
├── <child>
╰── arrow

GtkModelButton has a main CSS node with name modelbutton, and a subnode, which will have the name check, radio or arrow, depending on the role of the button and whether it has a menu name set.

The subnode is positioned before or after the content nodes and gets the .left or .right style class, depending on where it is located.

plain code

button.model
├── <child>
╰── check

Iconic model buttons (see 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.

Synopsis

Exported types

class GObject o => IsModelButton o Source #

Type class for types which can be safely cast to ModelButton, for instance with toModelButton.

toModelButton :: (MonadIO m, IsModelButton o) => o -> m ModelButton Source #

Cast to ModelButton, for types for which this is known to be safe. For general casts, use castTo.

Methods

new

modelButtonNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m ModelButton

Returns: the newly created ModelButton widget

Creates a new GtkModelButton.

Since: 3.16

Properties

active

The state of the button. This is reflecting the state of the associated Action.

Since: 3.16

constructModelButtonActive :: IsModelButton o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “active” property. This is rarely needed directly, but it is used by new.

getModelButtonActive :: (MonadIO m, IsModelButton o) => o -> m Bool Source #

Get the value of the “active” property. When overloading is enabled, this is equivalent to

get modelButton #active

setModelButtonActive :: (MonadIO m, IsModelButton o) => o -> Bool -> m () Source #

Set the value of the “active” property. When overloading is enabled, this is equivalent to

set modelButton [ #active := value ]

centered

Whether to render the button contents centered instead of left-aligned. This property should be set for title-like items.

Since: 3.16

constructModelButtonCentered :: IsModelButton o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “centered” property. This is rarely needed directly, but it is used by new.

getModelButtonCentered :: (MonadIO m, IsModelButton o) => o -> m Bool Source #

Get the value of the “centered” property. When overloading is enabled, this is equivalent to

get modelButton #centered

setModelButtonCentered :: (MonadIO m, IsModelButton o) => o -> Bool -> m () Source #

Set the value of the “centered” property. When overloading is enabled, this is equivalent to

set modelButton [ #centered := value ]

icon

A Icon that will be used if iconic appearance for the button is desired.

Since: 3.16

clearModelButtonIcon :: (MonadIO m, IsModelButton o) => o -> m () Source #

Set the value of the “icon” property to Nothing. When overloading is enabled, this is equivalent to

clear #icon

constructModelButtonIcon :: (IsModelButton o, IsIcon a) => a -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “icon” property. This is rarely needed directly, but it is used by new.

getModelButtonIcon :: (MonadIO m, IsModelButton o) => o -> m (Maybe Icon) Source #

Get the value of the “icon” property. When overloading is enabled, this is equivalent to

get modelButton #icon

setModelButtonIcon :: (MonadIO m, IsModelButton o, IsIcon a) => o -> a -> m () Source #

Set the value of the “icon” property. When overloading is enabled, this is equivalent to

set modelButton [ #icon := value ]

iconic

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.

Since: 3.16

constructModelButtonIconic :: IsModelButton o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “iconic” property. This is rarely needed directly, but it is used by new.

getModelButtonIconic :: (MonadIO m, IsModelButton o) => o -> m Bool Source #

Get the value of the “iconic” property. When overloading is enabled, this is equivalent to

get modelButton #iconic

setModelButtonIconic :: (MonadIO m, IsModelButton o) => o -> Bool -> m () Source #

Set the value of the “iconic” property. When overloading is enabled, this is equivalent to

set modelButton [ #iconic := value ]

inverted

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.

Since: 3.16

constructModelButtonInverted :: IsModelButton o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “inverted” property. This is rarely needed directly, but it is used by new.

getModelButtonInverted :: (MonadIO m, IsModelButton o) => o -> m Bool Source #

Get the value of the “inverted” property. When overloading is enabled, this is equivalent to

get modelButton #inverted

setModelButtonInverted :: (MonadIO m, IsModelButton o) => o -> Bool -> m () Source #

Set the value of the “inverted” property. When overloading is enabled, this is equivalent to

set modelButton [ #inverted := value ]

menuName

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.

Since: 3.16

clearModelButtonMenuName :: (MonadIO m, IsModelButton o) => o -> m () Source #

Set the value of the “menu-name” property to Nothing. When overloading is enabled, this is equivalent to

clear #menuName

constructModelButtonMenuName :: IsModelButton o => Text -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “menu-name” property. This is rarely needed directly, but it is used by new.

getModelButtonMenuName :: (MonadIO m, IsModelButton o) => o -> m (Maybe Text) Source #

Get the value of the “menu-name” property. When overloading is enabled, this is equivalent to

get modelButton #menuName

setModelButtonMenuName :: (MonadIO m, IsModelButton o) => o -> Text -> m () Source #

Set the value of the “menu-name” property. When overloading is enabled, this is equivalent to

set modelButton [ #menuName := value ]

role

Specifies whether the button is a plain, check or radio button. When Actionable:action-name is set, the role will be determined from the action and does not have to be set explicitly.

Since: 3.16

constructModelButtonRole :: IsModelButton o => ButtonRole -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “role” property. This is rarely needed directly, but it is used by new.

getModelButtonRole :: (MonadIO m, IsModelButton o) => o -> m ButtonRole Source #

Get the value of the “role” property. When overloading is enabled, this is equivalent to

get modelButton #role

setModelButtonRole :: (MonadIO m, IsModelButton o) => o -> ButtonRole -> m () Source #

Set the value of the “role” property. When overloading is enabled, this is equivalent to

set modelButton [ #role := value ]

text

The label for the button.

Since: 3.16

clearModelButtonText :: (MonadIO m, IsModelButton o) => o -> m () Source #

Set the value of the “text” property to Nothing. When overloading is enabled, this is equivalent to

clear #text

constructModelButtonText :: IsModelButton o => Text -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “text” property. This is rarely needed directly, but it is used by new.

getModelButtonText :: (MonadIO m, IsModelButton o) => o -> m (Maybe Text) Source #

Get the value of the “text” property. When overloading is enabled, this is equivalent to

get modelButton #text

setModelButtonText :: (MonadIO m, IsModelButton o) => o -> Text -> m () Source #

Set the value of the “text” property. When overloading is enabled, this is equivalent to

set modelButton [ #text := value ]

useMarkup

If True, XML tags in the text of the button are interpreted as by parseMarkup to format the enclosed spans of text. If False, the text will be displayed verbatim.

Since: 3.24

constructModelButtonUseMarkup :: IsModelButton o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “use-markup” property. This is rarely needed directly, but it is used by new.

getModelButtonUseMarkup :: (MonadIO m, IsModelButton o) => o -> m Bool Source #

Get the value of the “use-markup” property. When overloading is enabled, this is equivalent to

get modelButton #useMarkup

setModelButtonUseMarkup :: (MonadIO m, IsModelButton o) => o -> Bool -> m () Source #

Set the value of the “use-markup” property. When overloading is enabled, this is equivalent to

set modelButton [ #useMarkup := value ]