packages feed

tabloid-0.3: MultiWidgetContainerView.hs

module MultiWidgetContainerView where

import Graphics.UI.Gtk

data ViewState = V 
    { mainWidget :: Widget
    , notebook :: Notebook
    , nameE :: Entry
    , addB :: Button
    }

new :: IO ViewState
new = do
  vbox <- vBoxNew False 4
  nb <- notebookNew 
  set nb [ notebookScrollable := True
         , notebookEnablePopup := True
         , notebookTabPos := PosRight 
         ]
  hbox <- hBoxNew False 4  
  nameE <- entryNew
  addB <- buttonNewFromStock stockAdd

  boxPackEnd hbox addB PackNatural 2
  boxPackEnd hbox nameE PackNatural 2
  boxPackStart vbox nb PackGrow 2
  sep <- hSeparatorNew
  boxPackStart vbox sep PackNatural 2
  boxPackStart vbox hbox PackNatural 2
  return (V (toWidget vbox) nb nameE addB)

add :: ViewState -> String -> Widget -> IO ()
add vs name w = do
  putStrLn $ "appending notebook page " ++ name
  notebookAppendPage (notebook vs) w name
  widgetShowAll (notebook vs) 
  return ()