diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-08-21 05:38:37 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2011-08-21 05:38:37 +0200 |
commit | 028c4243a87e41e3b7e2c51eb752d4b089b30680 (patch) | |
tree | d401761df8a383b9dfdf3054a4d1365400879435 /lib/Phi/Widgets/Clock.hs | |
parent | 15bccc001a5ff2e76d0890f85e300e9312cddd1b (diff) | |
download | phi-028c4243a87e41e3b7e2c51eb752d4b089b30680.tar phi-028c4243a87e41e3b7e2c51eb752d4b089b30680.zip |
Use CacheArrow for rendering
Extremely hacky at the moment, for now the caching isn't used at all...
Diffstat (limited to 'lib/Phi/Widgets/Clock.hs')
-rw-r--r-- | lib/Phi/Widgets/Clock.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/Phi/Widgets/Clock.hs b/lib/Phi/Widgets/Clock.hs index d2ad134..2607288 100644 --- a/lib/Phi/Widgets/Clock.hs +++ b/lib/Phi/Widgets/Clock.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeFamilies, DeriveDataTypeable #-} +{-# LANGUAGE MultiParamTypeClasses, DeriveDataTypeable #-} module Phi.Widgets.Clock ( ClockConfig(..) , defaultClockConfig @@ -29,20 +29,21 @@ data ClockConfig = ClockConfig { clockFormat :: !String , fontColor :: !Color , lineSpacing :: !Double , clockSize :: !Int - } deriving Show + } deriving (Show, Eq) defaultClockConfig :: ClockConfig defaultClockConfig = ClockConfig "%R" (0, 0, 0, 1) 0 50 -data Clock = Clock !ClockConfig deriving Show +data Clock = Clock !ClockConfig deriving (Show, Eq) -data ClockState = ClockState !ZonedTime deriving Show +instance Eq ZonedTime where + (ZonedTime localTime timezone) == (ZonedTime localTime' timezone') = (localTime == localTime') && (timezone == timezone') + +data ClockState = ClockState !ZonedTime deriving (Show, Eq) data ClockMessage = UpdateTime !ZonedTime deriving (Show, Typeable) -instance WidgetClass Clock where - type WidgetData Clock = ClockState - +instance WidgetClass Clock ClockState where initWidget (Clock _) phi _ = do forkIO $ forever $ do time <- getZonedTime @@ -57,8 +58,7 @@ instance WidgetClass Clock where minSize (Clock config) _ _ _ = clockSize config - render (Clock config) (ClockState time) w h _ = do - time <- liftIO getZonedTime + render (Clock config) (ClockState time) _ _ w h _ = do let (r, g, b, a) = fontColor config str = formatTime defaultTimeLocale (clockFormat config) time setSourceRGBA r g b a |