summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will@willthompson.co.uk>2019-01-11 13:00:47 +0000
committerWill Thompson <will@willthompson.co.uk>2019-03-07 09:57:40 +0000
commitd1f7d8011a598d8c05962501f5c483af3566c725 (patch)
tree27ecded6168de29f651896b8e00a27623c6ea267
parent8be3319692ca7aa540a0427aad9d51f6e7f47cde (diff)
Update diagram immediately when filter changes
-rw-r--r--Bustle/UI.hs12
-rw-r--r--Bustle/UI/FilterDialog.hs16
2 files changed, 11 insertions, 17 deletions
diff --git a/Bustle/UI.hs b/Bustle/UI.hs
index 09c8317..28ede19 100644
--- a/Bustle/UI.hs
+++ b/Bustle/UI.hs
@@ -696,14 +696,12 @@ displayLog wi@WindowInfo { wiWindow = window
widgetHide sidebarHeader
widgetSetSensitivity filterNames True
- onMenuItemActivate filterNames $ do
- nameFilter <- readIORef nameFilterRef
+ onMenuItemActivate filterNames $
-- FIXME: also allow filtering system bus in two-bus case
- nameFilter' <- runFilterDialog window (sessionParticipants $ rrApplications rr) nameFilter
- writeIORef nameFilterRef nameFilter'
- let rr' = processWithFilters (sessionMessages, nameFilter') (systemMessages, emptyNameFilter)
-
- updateDisplayedLog wi rr'
+ runFilterDialog window (sessionParticipants $ rrApplications rr) nameFilterRef $ do
+ nameFilter <- readIORef nameFilterRef
+ let rr' = processWithFilters (sessionMessages, nameFilter) (systemMessages, emptyNameFilter)
+ updateDisplayedLog wi rr'
showOpenDialog :: Window
-> B ()
diff --git a/Bustle/UI/FilterDialog.hs b/Bustle/UI/FilterDialog.hs
index 873448f..cd44ccd 100644
--- a/Bustle/UI/FilterDialog.hs
+++ b/Bustle/UI/FilterDialog.hs
@@ -152,13 +152,13 @@ makeView nameStore nameView = do
return ()
-
runFilterDialog :: WindowClass parent
=> parent -- ^ The window to which to attach the dialog
-> [(UniqueName, Set OtherName)] -- ^ Names, in order of appearance
- -> NameFilter -- ^ Current filter
- -> IO NameFilter -- ^ New filter
-runFilterDialog parent names currentFilter = do
+ -> IORef NameFilter -- ^ Current filter
+ -> IO () -- ^ Callback when filter changes
+ -> IO ()
+runFilterDialog parent names filterRef callback = do
builder <- builderNew
builderAddFromFile builder =<< getDataFileName "data/FilterDialog.ui"
@@ -167,7 +167,7 @@ runFilterDialog parent names currentFilter = do
windowSetDefaultSize d (-1) (windowHeight * 3 `div` 4)
d `set` [ windowTransientFor := parent ]
- nameStore <- makeStore names currentFilter
+ nameStore <- makeStore names =<< readIORef filterRef
makeView nameStore =<< builderGetObject builder castToTreeView ("filterTreeView" :: String)
resetButton <- builderGetObject builder castToButton ("resetButton" :: String)
@@ -180,9 +180,6 @@ runFilterDialog parent names currentFilter = do
_ -> listStoreSetValue nameStore i $
ne { neVisibility = NameVisibilityDefault }
- -- TODO: expose this ref to the caller, with change notification, so the
- -- diagram can update instantly
- filterRef <- newIORef currentFilter
let updateResetSensitivity = do
nf <- readIORef filterRef
let isEmpty = Set.null (nfOnly nf) && Set.null (nfNever nf)
@@ -200,9 +197,8 @@ runFilterDialog parent names currentFilter = do
NameVisibilityNever -> nameFilterAddNever
modifyIORef' filterRef $ f u
updateResetSensitivity
+ callback
_ <- dialogRun d
widgetDestroy d
-
- readIORef filterRef