summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will@willthompson.co.uk>2012-01-23 09:35:14 +0000
committerWill Thompson <will@willthompson.co.uk>2012-01-23 09:35:14 +0000
commit267ef5408b5f392c3db133de5b38b3b77af0138b (patch)
treeeee7c28c6ab41095db5b880ab461cadcfc32d562
parent180f8697b71170c1274a466c22777e1688701186 (diff)
OpenTwoDialog: make Open insensitive until two files selected
-rw-r--r--Bustle/UI/OpenTwoDialog.hs34
1 files changed, 19 insertions, 15 deletions
diff --git a/Bustle/UI/OpenTwoDialog.hs b/Bustle/UI/OpenTwoDialog.hs
index bfbce33..01cf411 100644
--- a/Bustle/UI/OpenTwoDialog.hs
+++ b/Bustle/UI/OpenTwoDialog.hs
@@ -58,6 +58,7 @@ setupOpenTwoDialog builder parent callback = do
[sessionBusChooser, systemBusChooser] <-
mapM (builderGetObject builder castToFileChooserButton)
["sessionBusChooser", "systemBusChooser"]
+ openTwoOpenButton <- builderGetObject builder castToButton "openTwoOpenButton"
windowSetTransientFor dialog parent
dialog `on` deleteEvent $ tryEvent $ io $ widgetHide dialog
@@ -70,21 +71,24 @@ setupOpenTwoDialog builder parent callback = do
fileChooserUnselectAll sessionBusChooser
fileChooserUnselectAll systemBusChooser
+ let updateOpenSensitivity = do
+ sessionLogFile <- fileChooserGetFilename sessionBusChooser
+ systemLogFile <- fileChooserGetFilename systemBusChooser
+
+ widgetSetSensitive openTwoOpenButton $
+ case (sessionLogFile, systemLogFile) of
+ (Just _, Just _) -> True
+ _ -> False
+ connectGeneric "file-set" False sessionBusChooser updateOpenSensitivity
+ connectGeneric "file-set" False systemBusChooser updateOpenSensitivity
+ updateOpenSensitivity
+
dialog `afterResponse` \resp -> do
- -- The "Open" button should only be sensitive if both pickers have a
- -- file in them, but the GtkFileChooserButton:file-set signal is not
- -- bound in my version of Gtk2Hs. So yeah...
- if (resp == ResponseAccept)
- then do
- sessionLogFile <- fileChooserGetFilename sessionBusChooser
- systemLogFile <- fileChooserGetFilename systemBusChooser
-
- case (sessionLogFile, systemLogFile) of
- (Just f1, Just f2) -> do
- callback f1 f2
- hideMyself
- _ -> return ()
- else
- hideMyself
+ when (resp == ResponseAccept) $ do
+ Just f1 <- fileChooserGetFilename sessionBusChooser
+ Just f2 <- fileChooserGetFilename systemBusChooser
+ callback f1 f2
+
+ hideMyself
return dialog