From 028c4243a87e41e3b7e2c51eb752d4b089b30680 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 21 Aug 2011 05:38:37 +0200 Subject: Use CacheArrow for rendering Extremely hacky at the moment, for now the caching isn't used at all... --- lib/Phi/Widgets/Clock.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/Phi/Widgets/Clock.hs') 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 -- cgit v1.2.3