diff options
-rw-r--r-- | Bustle/UI/OpenTwoDialog.hs | 34 |
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 |