module Graphics.UI.Gtk.MenuComboToolbar.Toolbar (
Toolbar,
ToolbarClass,
castToToolbar, gTypeToolbar,
toToolbar,
Orientation(..),
ToolbarStyle(..),
toolbarNew,
toolbarInsertNewButton,
toolbarAppendNewButton,
toolbarPrependNewButton,
toolbarInsertNewToggleButton,
toolbarAppendNewToggleButton,
toolbarPrependNewToggleButton,
toolbarInsertNewRadioButton,
toolbarAppendNewRadioButton,
toolbarPrependNewRadioButton,
toolbarInsertNewWidget,
toolbarAppendNewWidget,
toolbarPrependNewWidget,
toolbarSetOrientation,
toolbarGetOrientation,
toolbarSetStyle,
toolbarGetStyle,
toolbarUnsetStyle,
toolbarSetTooltips,
toolbarGetTooltips,
IconSize(..),
toolbarSetIconSize,
toolbarGetIconSize,
toolbarInsert,
toolbarGetItemIndex,
toolbarGetNItems,
toolbarGetNthItem,
toolbarGetDropIndex,
toolbarSetDropHighlightItem,
toolbarSetShowArrow,
toolbarGetShowArrow,
ReliefStyle(..),
toolbarGetReliefStyle,
toolbarOrientation,
toolbarShowArrow,
toolbarTooltips,
toolbarStyle,
toolbarChildExpand,
toolbarChildHomogeneous,
onOrientationChanged,
afterOrientationChanged,
onStyleChanged,
afterStyleChanged,
onPopupContextMenu,
afterPopupContextMenu,
) where
import Control.Monad (liftM)
import Data.Maybe (fromJust)
import System.Glib.FFI
import System.Glib.UTFString
import System.Glib.Attributes
import System.Glib.Properties
import Graphics.UI.Gtk.Abstract.Object (makeNewObject)
import Graphics.UI.Gtk.Types
import Graphics.UI.Gtk.Signals
import Graphics.UI.Gtk.Abstract.ContainerChildProperties
import Graphics.UI.Gtk.General.Enums (Orientation(..), ToolbarStyle(..),
ReliefStyle(..))
import Graphics.UI.Gtk.General.StockItems
import Graphics.UI.Gtk.General.Structs (
toolbarChildToggleButton,
toolbarChildRadioButton,
IconSize(..))
import Graphics.UI.Gtk.General.StockItems (stockLookupItem, siLabel, stockMissingImage)
import Graphics.UI.Gtk.Display.Image (imageNewFromStock)
toolbarNew :: IO Toolbar
toolbarNew =
makeNewObject mkToolbar $
liftM (castPtr :: Ptr Widget -> Ptr Toolbar) $
gtk_toolbar_new
mkToolText :: Maybe (String,String) -> (CString -> CString -> IO a) -> IO a
mkToolText Nothing fun = fun nullPtr nullPtr
mkToolText (Just (text,private)) fun = withUTFString text $ \txtPtr ->
withUTFString private $ \prvPtr -> fun txtPtr prvPtr
toolbarInsertNewButton :: ToolbarClass self => self
-> Int
-> StockId
-> Maybe (String,String)
-> IO Button
toolbarInsertNewButton self pos stockId tooltips =
withUTFString stockId $ \stockPtr ->
mkToolText tooltips $ \textPtr privPtr ->
makeNewObject mkButton $ liftM castPtr $
(\(Toolbar arg1) arg2 arg3 arg4 arg5 arg6 arg7 -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_insert_stock argPtr1 arg2 arg3 arg4 arg5 arg6 arg7)
(toToolbar self)
stockPtr
textPtr
privPtr
nullFunPtr
nullPtr
(fromIntegral pos)
toolbarAppendNewButton :: ToolbarClass self => self
-> String
-> Maybe (String, String)
-> IO Button
toolbarAppendNewButton self = toolbarInsertNewButton self (1)
toolbarPrependNewButton :: ToolbarClass self => self
-> String
-> Maybe (String, String)
-> IO Button
toolbarPrependNewButton self = toolbarInsertNewButton self 0
toolbarInsertNewToggleButton :: ToolbarClass self => self
-> Int
-> StockId
-> Maybe (String, String)
-> IO ToggleButton
toolbarInsertNewToggleButton self pos stockId tooltips = do
mItem <- stockLookupItem stockId
item <- case mItem of
(Just item) -> return item
Nothing -> liftM fromJust $ stockLookupItem stockMissingImage
let label = (filter (/= '_')) $ siLabel item
size <- toolbarGetIconSize (toToolbar self)
image <- imageNewFromStock stockId size
makeNewObject mkToggleButton $ liftM castPtr $
withUTFString label $ \lblPtr -> mkToolText tooltips $ \textPtr privPtr ->
(\(Toolbar arg1) arg2 (Widget arg3) arg4 arg5 arg6 (Widget arg7) arg8 arg9 arg10 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg3 $ \argPtr3 ->withForeignPtr arg7 $ \argPtr7 ->gtk_toolbar_insert_element argPtr1 arg2 argPtr3 arg4 arg5 arg6 argPtr7 arg8 arg9 arg10) (toToolbar self)
toolbarChildToggleButton (Widget nullForeignPtr) lblPtr
textPtr privPtr (toWidget image) nullFunPtr nullPtr (fromIntegral pos)
toolbarAppendNewToggleButton :: ToolbarClass self => self
-> String
-> Maybe (String, String)
-> IO ToggleButton
toolbarAppendNewToggleButton self = toolbarInsertNewToggleButton self (1)
toolbarPrependNewToggleButton :: ToolbarClass self => self
-> String
-> Maybe (String, String)
-> IO ToggleButton
toolbarPrependNewToggleButton self = toolbarInsertNewToggleButton self 0
toolbarInsertNewRadioButton :: (ToolbarClass self, RadioButtonClass rb) => self
-> Int
-> StockId
-> Maybe (String,String)
-> Maybe rb
-> IO RadioButton
toolbarInsertNewRadioButton self pos stockId tooltips rb = do
mItem <- stockLookupItem stockId
item <- case mItem of
(Just item) -> return item
Nothing -> liftM fromJust $ stockLookupItem stockMissingImage
let label = (filter (/= '_')) $ siLabel item
size <- toolbarGetIconSize (toToolbar self)
image <- imageNewFromStock stockId size
makeNewObject mkRadioButton $ liftM castPtr $
withUTFString label $ \lblPtr -> mkToolText tooltips $ \textPtr privPtr ->
(\(Toolbar arg1) arg2 (Widget arg3) arg4 arg5 arg6 (Widget arg7) arg8 arg9 arg10 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg3 $ \argPtr3 ->withForeignPtr arg7 $ \argPtr7 ->gtk_toolbar_insert_element argPtr1 arg2 argPtr3 arg4 arg5 arg6 argPtr7 arg8 arg9 arg10) (toToolbar self)
toolbarChildRadioButton (maybe (Widget nullForeignPtr) toWidget rb)
lblPtr textPtr privPtr (toWidget image) nullFunPtr nullPtr
(fromIntegral pos)
toolbarAppendNewRadioButton :: (ToolbarClass self, RadioButtonClass rb) => self
-> String
-> Maybe (String, String)
-> Maybe rb
-> IO RadioButton
toolbarAppendNewRadioButton self = toolbarInsertNewRadioButton self (1)
toolbarPrependNewRadioButton :: (ToolbarClass self, RadioButtonClass rb) => self
-> String
-> Maybe (String, String)
-> Maybe rb
-> IO RadioButton
toolbarPrependNewRadioButton self = toolbarInsertNewRadioButton self 0
toolbarInsertNewWidget :: (ToolbarClass self, WidgetClass w) => self
-> Int
-> w
-> Maybe (String,String)
-> IO ()
toolbarInsertNewWidget self pos w tooltips =
mkToolText tooltips $ \textPtr privPtr ->
(\(Toolbar arg1) (Widget arg2) arg3 arg4 arg5 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_toolbar_insert_widget argPtr1 argPtr2 arg3 arg4 arg5)
(toToolbar self)
(toWidget w)
textPtr
privPtr
(fromIntegral pos)
toolbarAppendNewWidget :: (ToolbarClass self, WidgetClass w) => self
-> w
-> Maybe (String, String)
-> IO ()
toolbarAppendNewWidget self = toolbarInsertNewWidget self (1)
toolbarPrependNewWidget :: (ToolbarClass self, WidgetClass w) => self
-> w
-> Maybe (String, String)
-> IO ()
toolbarPrependNewWidget self = toolbarInsertNewWidget self 0
toolbarSetOrientation :: ToolbarClass self => self -> Orientation -> IO ()
toolbarSetOrientation self orientation =
(\(Toolbar arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_set_orientation argPtr1 arg2)
(toToolbar self)
((fromIntegral . fromEnum) orientation)
toolbarGetOrientation :: ToolbarClass self => self -> IO Orientation
toolbarGetOrientation self =
liftM (toEnum . fromIntegral) $
(\(Toolbar arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_get_orientation argPtr1)
(toToolbar self)
toolbarSetStyle :: ToolbarClass self => self -> ToolbarStyle -> IO ()
toolbarSetStyle self style =
(\(Toolbar arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_set_style argPtr1 arg2)
(toToolbar self)
((fromIntegral . fromEnum) style)
toolbarGetStyle :: ToolbarClass self => self -> IO ToolbarStyle
toolbarGetStyle self =
liftM (toEnum . fromIntegral) $
(\(Toolbar arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_get_style argPtr1)
(toToolbar self)
toolbarUnsetStyle :: ToolbarClass self => self -> IO ()
toolbarUnsetStyle self =
(\(Toolbar arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_unset_style argPtr1)
(toToolbar self)
toolbarSetTooltips :: ToolbarClass self => self
-> Bool
-> IO ()
toolbarSetTooltips self enable =
(\(Toolbar arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_set_tooltips argPtr1 arg2)
(toToolbar self)
(fromBool enable)
toolbarGetTooltips :: ToolbarClass self => self -> IO Bool
toolbarGetTooltips self =
liftM toBool $
(\(Toolbar arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_get_tooltips argPtr1)
(toToolbar self)
toolbarSetIconSize :: ToolbarClass self => self -> IconSize -> IO ()
toolbarSetIconSize self iconSize =
(\(Toolbar arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_set_icon_size argPtr1 arg2)
(toToolbar self)
((fromIntegral . fromEnum) iconSize)
toolbarGetIconSize :: ToolbarClass self => self -> IO IconSize
toolbarGetIconSize self =
liftM (toEnum . fromIntegral) $
(\(Toolbar arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_get_icon_size argPtr1)
(toToolbar self)
toolbarInsert :: (ToolbarClass self, ToolItemClass item) => self
-> item
-> Int
-> IO ()
toolbarInsert self item pos =
(\(Toolbar arg1) (ToolItem arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_toolbar_insert argPtr1 argPtr2 arg3)
(toToolbar self)
(toToolItem item)
(fromIntegral pos)
toolbarGetItemIndex :: (ToolbarClass self, ToolItemClass item) => self
-> item
-> IO Int
toolbarGetItemIndex self item =
liftM fromIntegral $
(\(Toolbar arg1) (ToolItem arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_toolbar_get_item_index argPtr1 argPtr2)
(toToolbar self)
(toToolItem item)
toolbarGetNItems :: ToolbarClass self => self -> IO Int
toolbarGetNItems self =
liftM fromIntegral $
(\(Toolbar arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_get_n_items argPtr1)
(toToolbar self)
toolbarGetNthItem :: ToolbarClass self => self
-> Int
-> IO (Maybe ToolItem)
toolbarGetNthItem self n =
maybeNull (makeNewObject mkToolItem) $
(\(Toolbar arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_get_nth_item argPtr1 arg2)
(toToolbar self)
(fromIntegral n)
toolbarGetDropIndex :: ToolbarClass self => self
-> (Int, Int)
-> IO Int
toolbarGetDropIndex self (x,y) =
liftM fromIntegral $
(\(Toolbar arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_get_drop_index argPtr1 arg2 arg3)
(toToolbar self)
(fromIntegral x)
(fromIntegral y)
toolbarSetDropHighlightItem :: (ToolbarClass self, ToolItemClass toolItem) => self
-> Maybe toolItem
-> Int
-> IO ()
toolbarSetDropHighlightItem self toolItem index =
(\(Toolbar arg1) (ToolItem arg2) arg3 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gtk_toolbar_set_drop_highlight_item argPtr1 argPtr2 arg3)
(toToolbar self)
(maybe (ToolItem nullForeignPtr) toToolItem toolItem)
(fromIntegral index)
toolbarSetShowArrow :: ToolbarClass self => self -> Bool -> IO ()
toolbarSetShowArrow self showArrow =
(\(Toolbar arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_set_show_arrow argPtr1 arg2)
(toToolbar self)
(fromBool showArrow)
toolbarGetShowArrow :: ToolbarClass self => self -> IO Bool
toolbarGetShowArrow self =
liftM toBool $
(\(Toolbar arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_get_show_arrow argPtr1)
(toToolbar self)
toolbarGetReliefStyle :: ToolbarClass self => self -> IO ReliefStyle
toolbarGetReliefStyle self =
liftM (toEnum . fromIntegral) $
(\(Toolbar arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_toolbar_get_relief_style argPtr1)
(toToolbar self)
toolbarOrientation :: ToolbarClass self => Attr self Orientation
toolbarOrientation = newAttr
toolbarGetOrientation
toolbarSetOrientation
toolbarStyle :: ToolbarClass self => Attr self ToolbarStyle
toolbarStyle = newAttrFromEnumProperty "toolbar-style"
gtk_toolbar_style_get_type
toolbarShowArrow :: ToolbarClass self => Attr self Bool
toolbarShowArrow = newAttr
toolbarGetShowArrow
toolbarSetShowArrow
toolbarTooltips :: ToolbarClass self => Attr self Bool
toolbarTooltips = newAttr
toolbarGetTooltips
toolbarSetTooltips
toolbarChildExpand :: (ToolbarClass self, WidgetClass child) => child -> Attr self Bool
toolbarChildExpand = newAttrFromContainerChildBoolProperty "expand"
toolbarChildHomogeneous :: (ToolbarClass self, WidgetClass child) => child -> Attr self Bool
toolbarChildHomogeneous = newAttrFromContainerChildBoolProperty "homogeneous"
onOrientationChanged, afterOrientationChanged :: ToolbarClass self => self
-> (Orientation -> IO ())
-> IO (ConnectId self)
onOrientationChanged = connect_ENUM__NONE "orientation-changed" False
afterOrientationChanged = connect_ENUM__NONE "orientation-changed" True
onStyleChanged, afterStyleChanged :: ToolbarClass self => self
-> (ToolbarStyle -> IO ())
-> IO (ConnectId self)
onStyleChanged = connect_ENUM__NONE "style-changed" False
afterStyleChanged = connect_ENUM__NONE "style-changed" True
onPopupContextMenu, afterPopupContextMenu :: ToolbarClass self => self
-> (Int -> Int -> Int -> IO Bool)
-> IO (ConnectId self)
onPopupContextMenu = connect_INT_INT_INT__BOOL "popup-context-menu" False
afterPopupContextMenu = connect_INT_INT_INT__BOOL "popup-context-menu" True
foreign import ccall unsafe "gtk_toolbar_new"
gtk_toolbar_new :: (IO (Ptr Widget))
foreign import ccall unsafe "gtk_toolbar_insert_stock"
gtk_toolbar_insert_stock :: ((Ptr Toolbar) -> ((Ptr CChar) -> ((Ptr CChar) -> ((Ptr CChar) -> ((FunPtr (IO ())) -> ((Ptr ()) -> (CInt -> (IO (Ptr Widget)))))))))
foreign import ccall unsafe "gtk_toolbar_insert_element"
gtk_toolbar_insert_element :: ((Ptr Toolbar) -> (CInt -> ((Ptr Widget) -> ((Ptr CChar) -> ((Ptr CChar) -> ((Ptr CChar) -> ((Ptr Widget) -> ((FunPtr (IO ())) -> ((Ptr ()) -> (CInt -> (IO (Ptr Widget))))))))))))
foreign import ccall unsafe "gtk_toolbar_insert_widget"
gtk_toolbar_insert_widget :: ((Ptr Toolbar) -> ((Ptr Widget) -> ((Ptr CChar) -> ((Ptr CChar) -> (CInt -> (IO ()))))))
foreign import ccall safe "gtk_toolbar_set_orientation"
gtk_toolbar_set_orientation :: ((Ptr Toolbar) -> (CInt -> (IO ())))
foreign import ccall unsafe "gtk_toolbar_get_orientation"
gtk_toolbar_get_orientation :: ((Ptr Toolbar) -> (IO CInt))
foreign import ccall safe "gtk_toolbar_set_style"
gtk_toolbar_set_style :: ((Ptr Toolbar) -> (CInt -> (IO ())))
foreign import ccall safe "gtk_toolbar_get_style"
gtk_toolbar_get_style :: ((Ptr Toolbar) -> (IO CInt))
foreign import ccall safe "gtk_toolbar_unset_style"
gtk_toolbar_unset_style :: ((Ptr Toolbar) -> (IO ()))
foreign import ccall safe "gtk_toolbar_set_tooltips"
gtk_toolbar_set_tooltips :: ((Ptr Toolbar) -> (CInt -> (IO ())))
foreign import ccall unsafe "gtk_toolbar_get_tooltips"
gtk_toolbar_get_tooltips :: ((Ptr Toolbar) -> (IO CInt))
foreign import ccall safe "gtk_toolbar_set_icon_size"
gtk_toolbar_set_icon_size :: ((Ptr Toolbar) -> (CInt -> (IO ())))
foreign import ccall unsafe "gtk_toolbar_get_icon_size"
gtk_toolbar_get_icon_size :: ((Ptr Toolbar) -> (IO CInt))
foreign import ccall safe "gtk_toolbar_insert"
gtk_toolbar_insert :: ((Ptr Toolbar) -> ((Ptr ToolItem) -> (CInt -> (IO ()))))
foreign import ccall unsafe "gtk_toolbar_get_item_index"
gtk_toolbar_get_item_index :: ((Ptr Toolbar) -> ((Ptr ToolItem) -> (IO CInt)))
foreign import ccall unsafe "gtk_toolbar_get_n_items"
gtk_toolbar_get_n_items :: ((Ptr Toolbar) -> (IO CInt))
foreign import ccall unsafe "gtk_toolbar_get_nth_item"
gtk_toolbar_get_nth_item :: ((Ptr Toolbar) -> (CInt -> (IO (Ptr ToolItem))))
foreign import ccall unsafe "gtk_toolbar_get_drop_index"
gtk_toolbar_get_drop_index :: ((Ptr Toolbar) -> (CInt -> (CInt -> (IO CInt))))
foreign import ccall safe "gtk_toolbar_set_drop_highlight_item"
gtk_toolbar_set_drop_highlight_item :: ((Ptr Toolbar) -> ((Ptr ToolItem) -> (CInt -> (IO ()))))
foreign import ccall safe "gtk_toolbar_set_show_arrow"
gtk_toolbar_set_show_arrow :: ((Ptr Toolbar) -> (CInt -> (IO ())))
foreign import ccall unsafe "gtk_toolbar_get_show_arrow"
gtk_toolbar_get_show_arrow :: ((Ptr Toolbar) -> (IO CInt))
foreign import ccall unsafe "gtk_toolbar_get_relief_style"
gtk_toolbar_get_relief_style :: ((Ptr Toolbar) -> (IO CInt))
foreign import ccall unsafe "gtk_toolbar_style_get_type"
gtk_toolbar_style_get_type :: CUInt