Gtk2HsContentsIndex
Graphics.UI.Gtk.MenuComboToolbar.Toolbar
Description

Create bars of buttons and other widgets.

  • This widget underwent a signficant overhaul in gtk 2.4 and the recommended api changed substantially. The old interface is still supported but it is not recommended.
  • The following information applies to the new interface only.

A toolbar is created using toolbarNew. A toolbar can contain instances of a subclass of ToolItem. To add a ToolItem to the a toolbar, use toolbarInsert. To remove an item from the toolbar use containerRemove. To add a button to the toolbar, add an instance of ToolButton.

Toolbar items can be visually grouped by adding instances of SeparatorToolItem to the toolbar. If a SeparatorToolItem has the "expand" property set to True and the "draw" property set to False the effect is to force all following items to the end of the toolbar.

Creating a context menu for the toolbar can be done using onPopupContextMenu.

  • The following information applies to the old interface only.

Buttons, RadioButtons and ToggleButtons can be added by refering to stock images. Their size can be changed by calling toolbarSetIconSize. In contrast, normal widget cannot be added. Due to the bad interface of GtkToolbar mnemonics of RadioButtons and ToggleButtons are not honored.

All the append, insert and prepend functions use an internal function to do the actual work. In fact the interface is pretty skrewed up: To insert icons by using stock items is definitely the best practice as all other images cannot react to toolbarSetIconSize and other theming actions. On the other hand toolbarInsertStock always generates simple Buttons but is the only function that is able to insert Mnemonics on the label. Our solution is to use StockItems to specify all Images of the Buttons. If the user inserts RadioButtons or ToggleButtons, the stock image lookup is done manually. A mnemonic in the labels is sadly not honored this way.

Synopsis
data Toolbar
class ContainerClass o => ToolbarClass o
castToToolbar :: GObjectClass obj => obj -> Toolbar
data Orientation
= OrientationHorizontal
| OrientationVertical
data ToolbarStyle
= ToolbarIcons
| ToolbarText
| ToolbarBoth
| ToolbarBothHoriz
toolbarNew :: IO Toolbar
toolbarInsertNewButton :: ToolbarClass tb => tb -> Int -> String -> Maybe (String, String) -> IO Button
toolbarAppendNewButton :: ToolbarClass tb => tb -> String -> Maybe (String, String) -> IO Button
toolbarPrependNewButton :: ToolbarClass tb => tb -> String -> Maybe (String, String) -> IO Button
toolbarInsertNewToggleButton :: ToolbarClass tb => tb -> Int -> String -> Maybe (String, String) -> IO ToggleButton
toolbarAppendNewToggleButton :: ToolbarClass tb => tb -> String -> Maybe (String, String) -> IO ToggleButton
toolbarPrependNewToggleButton :: ToolbarClass tb => tb -> String -> Maybe (String, String) -> IO ToggleButton
toolbarInsertNewRadioButton :: (ToolbarClass tb, RadioButtonClass rb) => tb -> Int -> String -> Maybe (String, String) -> Maybe rb -> IO RadioButton
toolbarAppendNewRadioButton :: (ToolbarClass tb, RadioButtonClass rb) => tb -> String -> Maybe (String, String) -> Maybe rb -> IO RadioButton
toolbarPrependNewRadioButton :: (ToolbarClass tb, RadioButtonClass rb) => tb -> String -> Maybe (String, String) -> Maybe rb -> IO RadioButton
toolbarInsertNewWidget :: (ToolbarClass tb, WidgetClass w) => tb -> Int -> w -> Maybe (String, String) -> IO ()
toolbarAppendNewWidget :: (ToolbarClass tb, WidgetClass w) => tb -> w -> Maybe (String, String) -> IO ()
toolbarPrependNewWidget :: (ToolbarClass tb, WidgetClass w) => tb -> w -> Maybe (String, String) -> IO ()
toolbarSetOrientation :: ToolbarClass tb => tb -> Orientation -> IO ()
toolbarGetOrientation :: ToolbarClass tb => tb -> IO Orientation
toolbarSetStyle :: ToolbarClass tb => tb -> ToolbarStyle -> IO ()
toolbarGetStyle :: ToolbarClass tb => tb -> IO ToolbarStyle
toolbarUnsetStyle :: ToolbarClass tb => tb -> IO ()
toolbarSetTooltips :: ToolbarClass tb => tb -> Bool -> IO ()
toolbarGetTooltips :: ToolbarClass tb => tb -> IO Bool
type IconSize = Int
iconSizeInvalid :: IconSize
iconSizeSmallToolbar :: IconSize
iconSizeLargeToolbar :: IconSize
toolbarSetIconSize :: ToolbarClass tb => tb -> IconSize -> IO ()
toolbarGetIconSize :: ToolbarClass tb => tb -> IO IconSize
toolbarInsert :: (ToolbarClass tb, ToolItemClass item) => tb -> item -> Int -> IO ()
toolbarGetItemIndex :: (ToolbarClass tb, ToolItemClass item) => tb -> item -> IO Int
toolbarGetNItems :: ToolbarClass tb => tb -> IO Int
toolbarGetNthItem :: ToolbarClass tb => tb -> Int -> IO (Maybe ToolItem)
toolbarGetDropIndex :: ToolbarClass tb => tb -> (Int, Int) -> IO Int
toolbarSetDropHighlightItem :: ToolbarClass tb => tb -> Maybe ToolItem -> Int -> IO ()
toolbarSetShowArrow :: ToolbarClass tb => tb -> Bool -> IO ()
toolbarGetShowArrow :: ToolbarClass tb => tb -> IO Bool
data ReliefStyle
= ReliefNormal
| ReliefHalf
| ReliefNone
toolbarGetReliefStyle :: ToolbarClass tb => tb -> IO ReliefStyle
onOrientationChanged :: ToolbarClass tb => tb -> (Orientation -> IO ()) -> IO (ConnectId tb)
afterOrientationChanged :: ToolbarClass tb => tb -> (Orientation -> IO ()) -> IO (ConnectId tb)
onStyleChanged :: ToolbarClass tb => tb -> (ToolbarStyle -> IO ()) -> IO (ConnectId tb)
afterStyleChanged :: ToolbarClass tb => tb -> (ToolbarStyle -> IO ()) -> IO (ConnectId tb)
onPopupContextMenu :: ToolbarClass tb => tb -> (Int -> Int -> Int -> IO Bool) -> IO (ConnectId tb)
afterPopupContextMenu :: ToolbarClass tb => tb -> (Int -> Int -> Int -> IO Bool) -> IO (ConnectId tb)
Documentation
data Toolbar
Instances
ToolbarClass Toolbar
ContainerClass Toolbar
WidgetClass Toolbar
ObjectClass Toolbar
GObjectClass Toolbar
class ContainerClass o => ToolbarClass o
Instances
ToolbarClass Toolbar
castToToolbar :: GObjectClass obj => obj -> Toolbar
data Orientation
Orientation is good
Constructors
OrientationHorizontal
OrientationVertical
Instances
Enum Orientation
data ToolbarStyle
Where to place the toolbar?
Constructors
ToolbarIcons
ToolbarText
ToolbarBoth
ToolbarBothHoriz
Instances
Enum ToolbarStyle
toolbarNew :: IO Toolbar
Create a new, empty toolbar.
toolbarInsertNewButton :: ToolbarClass tb => tb -> Int -> String -> Maybe (String, String) -> IO Button

Insert a new Button into the Toolbar.

  • The new Button is created at position pos, counting from 0.
  • The icon and label for the button is referenced by stockId which must be a valid entry in the Toolbars Style or the default IconFactory.
  • If you whish to have Tooltips added to this button you can specify Just (tipText, tipPrivate) , otherwise specify Nothing.
  • The newly created Button is returned. Use this button to add an action function with "connectToClicked".
toolbarAppendNewButton :: ToolbarClass tb => tb -> String -> Maybe (String, String) -> IO Button

Append a new Button to the Toolbar.

toolbarPrependNewButton :: ToolbarClass tb => tb -> String -> Maybe (String, String) -> IO Button

Prepend a new Button to the Toolbar.

toolbarInsertNewToggleButton :: ToolbarClass tb => tb -> Int -> String -> Maybe (String, String) -> IO ToggleButton

Insert a new ToggleButton into the Toolbar.

  • See toolbarInsertNewButton for details.
  • Mnemonics in the label of the StockItem are removed as they do not work due to the bad interface definition of GtkToolbar.
toolbarAppendNewToggleButton :: ToolbarClass tb => tb -> String -> Maybe (String, String) -> IO ToggleButton

Append a new ToggleButton to the Toolbar.

  • See toolbarInsertNewButton for details.
  • Mnemonics in the label of the StockItem are removed as they do not work due to the bad interface definition of GtkToolbar.
toolbarPrependNewToggleButton :: ToolbarClass tb => tb -> String -> Maybe (String, String) -> IO ToggleButton

Prepend a new ToggleButton to the Toolbar.

  • See toolbarInsertNewButton for details.
  • Mnemonics in the label of the StockItem are removed as they do not work due to the bad interface definition of GtkToolbar.
toolbarInsertNewRadioButton :: (ToolbarClass tb, RadioButtonClass rb) => tb -> Int -> String -> Maybe (String, String) -> Maybe rb -> IO RadioButton

Insert a new RadioButton into the Toolbar.

  • See toolbarInsertNewButton for details.
  • Mnemonics in the label of the StockItem are removed as they do not work due to the bad interface definition of GtkToolbar.
  • The parent argument must be set to another RadioButton in the group. If Nothing is given, a new group is generated (which is the desired behavious for the first button of a group).
toolbarAppendNewRadioButton :: (ToolbarClass tb, RadioButtonClass rb) => tb -> String -> Maybe (String, String) -> Maybe rb -> IO RadioButton

Append a new RadioButton to the Toolbar.

  • See toolbarInsertNewButton for details.
  • Mnemonics in the label of the StockItem are removed as they do not work due to the bad interface definition of GtkToolbar.
toolbarPrependNewRadioButton :: (ToolbarClass tb, RadioButtonClass rb) => tb -> String -> Maybe (String, String) -> Maybe rb -> IO RadioButton

Prepend a new RadioButton to the Toolbar.

  • See toolbarInsertNewButton for details.
  • Mnemonics in the label of the StockItem are removed as they do not work due to the bad interface definition of GtkToolbar.
toolbarInsertNewWidget :: (ToolbarClass tb, WidgetClass w) => tb -> Int -> w -> Maybe (String, String) -> IO ()

Insert an arbitrary widget to the Toolbar.

  • The Widget should not be a button. Adding Buttons with the toolbarInsertButton,... functions with stock objects is much better as it takes care of theme handling.
toolbarAppendNewWidget :: (ToolbarClass tb, WidgetClass w) => tb -> w -> Maybe (String, String) -> IO ()

Append a new Widget to the Toolbar.

  • See toolbarInsertNewButton for details.
  • Mnemonics in the label of the StockItem are removed as they do not work due to the bad interface definition of GtkToolbar.
toolbarPrependNewWidget :: (ToolbarClass tb, WidgetClass w) => tb -> w -> Maybe (String, String) -> IO ()

Prepend a new Widget to the Toolbar.

  • See toolbarInsertNewButton for details.
  • Mnemonics in the label of the StockItem are removed as they do not work due to the bad interface definition of GtkToolbar.
toolbarSetOrientation :: ToolbarClass tb => tb -> Orientation -> IO ()
Set the direction of the Toolbar.
toolbarGetOrientation :: ToolbarClass tb => tb -> IO Orientation
Get the direction of the Toolbar.
toolbarSetStyle :: ToolbarClass tb => tb -> ToolbarStyle -> IO ()
Alters the view of the toolbar to display either icons only, text only, or both.
toolbarGetStyle :: ToolbarClass tb => tb -> IO ToolbarStyle
Retrieves whether the toolbar has text, icons, or both.
toolbarUnsetStyle :: ToolbarClass tb => tb -> IO ()
Unsets a toolbar style set with toolbarSetStyle, so that user preferences will be used to determine the toolbar style.
toolbarSetTooltips :: ToolbarClass tb => tb -> Bool -> IO ()
Enable or disable the Tooltips.
toolbarGetTooltips :: ToolbarClass tb => tb -> IO Bool
Enable or disable the Tooltips.
type IconSize = Int
iconSizeInvalid :: IconSize
iconSizeSmallToolbar :: IconSize
iconSizeLargeToolbar :: IconSize
toolbarSetIconSize :: ToolbarClass tb => tb -> IconSize -> IO ()

Set the size of the icons.

  • It might be sensible to restrict oneself to IconSizeSmallToolbar and IconSizeLargeToolbar.
toolbarGetIconSize :: ToolbarClass tb => tb -> IO IconSize
Retrieve the current icon size that the Toolbar shows.
toolbarInsert :: (ToolbarClass tb, ToolItemClass item) => tb -> item -> Int -> IO ()

Insert a ToolItem into the toolbar at the given position.

  • If the position is 0 the item is prepended to the start of the toolbar. If the position is negative, the item is appended to the end of the toolbar.
toolbarGetItemIndex :: (ToolbarClass tb, ToolItemClass item) => tb -> item -> IO Int
Returns the position of item on the toolbar, starting from 0.
toolbarGetNItems :: ToolbarClass tb => tb -> IO Int
Returns the number of items on the toolbar.
toolbarGetNthItem :: ToolbarClass tb => tb -> Int -> IO (Maybe ToolItem)
Returns the n'th item on toolbar, or Nothing if the toolbar does not contain an n'th item.
toolbarGetDropIndex
:: ToolbarClass tb
=> tb
-> (Int, Int)x,y coordinate of a point on the toolbar
-> IO Int

Returns the position corresponding to the indicated point on toolbar. This is useful when dragging items to the toolbar: this function returns the position a new item should be inserted.

  • x and y are in toolbar coordinates.
toolbarSetDropHighlightItem
:: ToolbarClass tb
=> tb
-> Maybe ToolItemA ToolItem or Nothing
-> IntA position on the toolbar
-> IO ()

Highlights the toolbar to give an idea of what it would look like if item was added to toolbar at the position indicated by the given index. If item is Nothing, highlighting is turned off (and the index is ignored).

  • Note: the ToolItem passed to this function must not be part of any widget hierarchy. When an item is set as a drop highlight item it can not added to any widget hierarchy or used as highlight item for another toolbar.
toolbarSetShowArrow :: ToolbarClass tb => tb -> Bool -> IO ()
Sets whether to show an overflow menu when the toolbar doesn't have room for all items on it.
toolbarGetShowArrow :: ToolbarClass tb => tb -> IO Bool
Returns whether the toolbar has an overflow menu.
data ReliefStyle
I don't have a clue.
Constructors
ReliefNormal
ReliefHalf
ReliefNone
Instances
Enum ReliefStyle
toolbarGetReliefStyle :: ToolbarClass tb => tb -> IO ReliefStyle
Returns the relief style of buttons on the toolbar. See buttonSetRelief.
onOrientationChanged :: ToolbarClass tb => tb -> (Orientation -> IO ()) -> IO (ConnectId tb)
Emitted when toolbarSetOrientation is called.
afterOrientationChanged :: ToolbarClass tb => tb -> (Orientation -> IO ()) -> IO (ConnectId tb)
onStyleChanged :: ToolbarClass tb => tb -> (ToolbarStyle -> IO ()) -> IO (ConnectId tb)
Emitted when toolbarSetStyle is called.
afterStyleChanged :: ToolbarClass tb => tb -> (ToolbarStyle -> IO ()) -> IO (ConnectId tb)
onPopupContextMenu :: ToolbarClass tb => tb -> (Int -> Int -> Int -> IO Bool) -> IO (ConnectId tb)

Emitted when the user right-clicks the toolbar or uses the keybinding to display a popup menu.

  • The handler should return True if the signal was handled, False if not.
afterPopupContextMenu :: ToolbarClass tb => tb -> (Int -> Int -> Int -> IO Bool) -> IO (ConnectId tb)
Produced by Haddock version 0.6