Skip to content

Commit

Permalink
Merge branch 'master' into offset-bytestring
Browse files Browse the repository at this point in the history
Conflicts:
	Scope/Types.hs
  • Loading branch information
kfish committed Jan 18, 2012
2 parents 6859e1e + a2827e7 commit 424bccf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
13 changes: 11 additions & 2 deletions Scope/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ module Scope.Types (
, ScopeFile(..)
, Scope(..)
, scopeNew
, scopeClose
, scopeUpdate
, scopeModifyView

Expand All @@ -84,10 +85,11 @@ module Scope.Types (

import Control.Applicative ((<$>))
import Control.Monad.CatchIO
import Data.Time.Clock
import Data.Maybe
import Data.Iteratee (Enumeratee)
import Data.List (nub)
import Data.Offset
import Data.Maybe
import Data.Time.Clock
import Data.ZoomCache
import System.Posix

Expand Down Expand Up @@ -303,6 +305,13 @@ scopeNew ui = Scope {
, layers = []
}

scopeClose :: Scope ui -> IO (Scope ui)
scopeClose scope = do
mapM_ closeFd . nub . map fd' . layers $ scope
return scope{bounds=Nothing, utcBounds=Nothing, layers=[]}
where
fd' (ScopeLayer l) = fd . layerFile $ l

scopeModifyView :: (View ui -> View ui) -> Scope ui -> Scope ui
scopeModifyView f scope = scope{ view = f (view scope) }

Expand Down
6 changes: 3 additions & 3 deletions scope.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: scope

Version: 0.6.0.0
Version: 0.6.1.0

Synopsis: An interactive renderer for plotting time-series data

Expand Down Expand Up @@ -74,7 +74,7 @@ Library
old-locale,
time,
unix,
zoom-cache >= 1.0.0.0 && < 1.1.0.0
zoom-cache >= 1.1.0.0 && < 1.2.0.0

Exposed-modules:
Scope.Cairo
Expand Down Expand Up @@ -109,7 +109,7 @@ Executable scope
old-locale,
time,
unix,
zoom-cache >= 1.0.0.0 && < 1.1.0.0
zoom-cache >= 1.1.0.0 && < 1.2.0.0

------------------------------------------------------------------------
-- Git repo
Expand Down
8 changes: 5 additions & 3 deletions src/GUI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ guiMain chan args = do
savea <- G.actionNew "SAVEA" "Save" (Just "Just a Stub") (Just G.stockSave)
saveasa <- G.actionNew "SAVEASA" "Save As" (Just "Just a Stub") (Just G.stockSaveAs)
quita <- G.actionNew "QUITA" "Quit" (Just "Just a Stub") (Just G.stockQuit)
quita `G.on` G.actionActivated $ myQuit window chan

let fChooser action label = G.fileChooserDialogNew Nothing (Just window) action
[(G.stockCancel, G.ResponseCancel), (label, G.ResponseAccept)]
Expand Down Expand Up @@ -116,6 +115,8 @@ guiMain chan args = do
let scope = scopeCairoNew drawingArea adj
scopeRef <- newIORef scope

quita `G.on` G.actionActivated $ myQuit scopeRef window chan

mapM_ (modifyIORefM scopeRef . addLayersFromFile) args
openDialog `G.on` G.response $ myFileOpen scopeRef openDialog
saveDialog `G.on` G.response $ myFileSave scopeRef saveDialog
Expand Down Expand Up @@ -154,8 +155,9 @@ guiMain chan args = do
G.widgetShowAll window
G.mainGUI

myQuit :: G.WidgetClass cls => cls -> Chan String -> IO ()
myQuit window chan = do
myQuit :: G.WidgetClass cls => IORef (Scope ViewCairo) -> cls -> Chan String -> IO ()
myQuit scopeRef window chan = do
scopeModifyMUpdate scopeRef scopeClose
G.widgetDestroy window
myWriteChan chan "quit"

Expand Down

0 comments on commit 424bccf

Please sign in to comment.