I'm writing my first gtk2hs+glade application, and I'm using a textview to display output from the program. Instead of scrolling which I thought was supposed to be the default behavior, the textview gets bigger everytime I re-set the text, and makes my buttons below it smaller until they disappear, but the scroll bars never pop up, and it never scrolls. Am I supposed to do something special to get it to scroll? Here is the main function I'm using at the moment, forgive the dirty code, I intend to house-clean later. :)
main :: FilePath -> IO ()
main gladepath = do
initGUI
-- Create inital game state
st <- newIORef (State "" "" "" 0 0 0)
-- Get handles to all needed widgets from Glade file
Just xml <- xmlNew gladepath
mw <- xmlGetWidget xml castToWindow "mainWindow"
sw <- xmlGetWidget xml castToWindow "window2"
mb <- xmlGetWidget xml castToButton "fireButton"
ng <- xmlGetWidget xml castToButton "nbutton"
mv <- xmlGetWidget xml castToTextView "textview1"
but <- xmlGetWidget xml castToButton "button1"
ab <- xmlGetWidget xml castToAboutDialog "aboutdialog1"
menu <- xmlGetWidget xml castToMenuItem "menuitem3"
about <- xmlGetWidget xml castToMenuItem "imagemenuitem10"
quitb <- xmlGetWidget xml castToMenuItem "menuitem3"
p1name <- xmlGetWidget xml castToEntry "entry1"
p2name <- xmlGetWidget xml castToEntry "entry2"
spin <- xmlGetWidget xml castToSpinButton "spinbutton1"
sett <- xmlGetWidget xml castToMenuItem "menuitem2"
p1lab <- xmlGetWidget xml castToLabel "label4"
p2lab <- xmlGetWidget xml castToLabel "label5"
cylab <- xmlGetWidget xml castToLabel "label6"
-- Handle events and such
buff <- textViewGetBuffer mv
onActivateLeaf quitb mainQuit
onResponse ab $ \resp ->
case resp of
ResponseClose -> widgetHide ab
_ -> widgetHide ab
onActivateLeaf about $ widgetShow ab
onActivateLeaf sett $ widgetShowAll sw
onDelete sw $ \_ -> widgetHide sw >> return True
onClicked but $
initalize sw p1name p2name spin st p1lab p2lab cylab buff
onClicked ng $ widgetShowAll sw
onDelete ab $ \_ -> widgetHide ab >> return True
onClicked mb $ fireButton st sw buff cylab
onActivateLeaf menu $ widgetDestroy mw
onDestroy mw mainQuit
widgetShowAll mw
mainGUI
If you need anything else, please request it in a comment. I'm not sure if I need to provide anything else.
The glade file is too large to show here, but I pasted it here in case someone needs it: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=6310#a6310