module Manatee.Toolkit.Gtk.Container where
import Control.Applicative hiding (empty)
import Control.Monad
import Data.Maybe
import Graphics.UI.Gtk
import Manatee.Toolkit.General.List
containerGetFirstChild :: ContainerClass self => self -> IO (Maybe Widget)
containerGetFirstChild self = do
children <- containerGetChildren self
return $ if null children
then Nothing
else Just $ head children
containerGetLastChild :: ContainerClass self => self -> IO (Maybe Widget)
containerGetLastChild self = do
children <- containerGetChildren self
return $ if null children
then Nothing
else Just $ last children
containerRemoveAll :: ContainerClass self => self -> IO ()
containerRemoveAll self = containerForeach self $ containerRemove self
containerTryRemove :: (ContainerClass parent, WidgetClass child) => parent -> child -> IO ()
containerTryRemove parent widget = do
hasParent <- widgetGetParent widget
unless (isNothing hasParent) $ containerRemove parent widget
containerApplySize :: ContainerClass self => self -> (Int -> Int -> IO ()) -> IO ()
containerApplySize container childFun =
widgetGetSize container
>>= \(width, height) -> do
childFun width height
widgetSetSizeRequest container 0 0
containerHasChildren :: ContainerClass self => self -> IO Bool
containerHasChildren self =
has <$> containerGetChildren self