gi-gtk-hs-0.3.16: A wrapper for gi-gtk, adding a few more idiomatic API parts on top
Stabilityprovisional
Portabilityportable (depends on GHC)
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.GI.Gtk.ComboBox

Description

A widget used to choose from a list of items.

  • Module available since Gtk+ version 2.4
Synopsis

Detail

A ComboBox is a widget that allows the user to choose from a list of valid choices. The ComboBox displays the selected choice. When activated, the ComboBox displays a popup which allows the user to make a new choice. The style in which the selected value is displayed, and the style of the popup is determined by the current theme. It may be similar to a OptionMenu, or similar to a Windows-style combo box.

Unlike its predecessors Combo and OptionMenu, the ComboBox uses the model-view pattern; the list of valid choices is specified in the form of a tree model, and the display of the choices can be adapted to the data in the model by using cell renderers, as you would in a tree view. This is possible since ComboBox implements the CellLayout interface. The tree model holding the valid choices is not restricted to a flat list, it can be a real tree, and the popup will reflect the tree structure.

In addition to the general model-view API, ComboBox offers the function comboBoxNewText which creates a text-only combo box.

Class Hierarchy

|  GObject
|   +----Object
|         +----Widget
|               +----Container
|                     +----Bin
|                           +----ComboBox
|                                 +----ComboBoxEntry

Simple Text API

comboBoxNewText :: MonadIO m => m ComboBox Source #

Convenience function which constructs a new text combo box that is a ComboBox just displaying strings. This function internally calls comboBoxSetModelText after creating a new combo box.

comboBoxSetModelText :: (MonadIO m, IsComboBox self) => self -> m (SeqStore Text) Source #

Create a combo box that holds strings.

This function stores a SeqStore with the widget and sets the model to the list store. The widget can contain only strings. The model can be retrieved with comboBoxGetModel. The list store can be retrieved with comboBoxGetModelText. Any exisiting model or renderers are removed before setting the new text model. Note that the functions comboBoxAppendText, comboBoxInsertText, comboBoxPrependText, comboBoxRemoveText and comboBoxGetActiveText can be called on a combo box only once comboBoxSetModelText is called.

comboBoxGetModelText :: (MonadIO m, IsComboBox self) => self -> m (SeqStore Text) Source #

Retrieve the model that was created with comboBoxSetModelText.

comboBoxAppendText :: (MonadIO m, IsComboBox self) => self -> Text -> m Int32 Source #

Appends string to the list of strings stored in comboBox. Note that you can only use this function with combo boxes constructed with comboBoxNewText. Returns the index of the appended text.

comboBoxInsertText Source #

Arguments

:: (MonadIO m, IsComboBox self) 
=> self 
-> Int32

position - An index to insert text.

-> Text

text - A string.

-> m () 

Inserts string at position in the list of strings stored in comboBox. Note that you can only use this function with combo boxes constructed with comboBoxNewText.

comboBoxPrependText :: (Applicative m, MonadIO m, IsComboBox self) => self -> Text -> m () Source #

Prepends string to the list of strings stored in comboBox. Note that you can only use this function with combo boxes constructed with comboBoxNewText.

comboBoxRemoveText Source #

Arguments

:: (MonadIO m, IsComboBox self) 
=> self 
-> Int32

position - Index of the item to remove.

-> m () 

Removes the string at position from comboBox. Note that you can only use this function with combo boxes constructed with comboBoxNewText.

comboBoxGetActiveText :: (MonadIO m, IsComboBox self) => self -> m (Maybe Text) Source #

Returns the currently active string in comboBox or Nothing if none is selected. Note that you can only use this function with combo boxes constructed with comboBoxNewText.