packages feed

taffybar 0.1.1 → 0.1.2

raw patch · 7 files changed

+82/−38 lines, 7 files

Files

src/System/Taffybar/FreedesktopNotifications.hs view
@@ -16,6 +16,7 @@   ) where  import Control.Concurrent+import Control.Monad.Trans ( liftIO ) import Data.Int ( Int32 ) import Data.IORef import Data.Map ( Map )@@ -48,13 +49,13 @@                                , noteIdSource :: MVar Word32                                , noteWorkerChan :: Chan WorkType                                , noteWidget :: Label-                               , noteContainer :: InfoBar+                               , noteContainer :: Widget                                , noteTimerThread :: MVar (Maybe ThreadId)                                , noteConfig :: NotificationConfig                                } -initialNoteState :: InfoBar -> Label -> NotificationConfig -> IO NotifyState-initialNoteState ib l cfg = do+initialNoteState :: Widget -> Label -> NotificationConfig -> IO NotifyState+initialNoteState wrapper l cfg = do   c <- newChan   m <- newMVar 1   q <- newMVar S.empty@@ -63,7 +64,7 @@                      , noteIdSource = m                      , noteWorkerChan = c                      , noteWidget = l-                     , noteContainer = ib+                     , noteContainer = wrapper                      , noteTimerThread = t                      , noteConfig = cfg                      }@@ -262,7 +263,9 @@   threadDelay (fromIntegral seconds * 1000000)   writeChan c (ExpireNote nid) -userCancel s _ = writeChan (noteWorkerChan s) (CancelNote Nothing)+userCancel s = do+  liftIO $ writeChan (noteWorkerChan s) (CancelNote Nothing)+  return True  data NotificationConfig =   NotificationConfig { notificationMaxTimeout :: Int -- ^ Maximum time that a notification will be displayed (in seconds).  Default: 10@@ -275,7 +278,8 @@   where     msg = case T.null (noteBody note) of       True -> T.unpack $ noteSummary note-      False -> T.unpack $ mconcat [ noteSummary note, ": ", noteBody note ]+      False -> T.unpack $ mconcat [ "<span fgcolor='yellow'>Note:</span>"+                                  , noteSummary note, ": ", noteBody note ]  -- | The default formatter is one of --@@ -294,21 +298,32 @@ -- | Create a new notification area with the given configuration. notifyAreaNew :: NotificationConfig -> IO Widget notifyAreaNew cfg = do-  ib <- infoBarNew-  l <- labelNew Nothing-  button <- buttonNew -- FromStock stockClose-  img <- imageNewFromStock stockClose (IconSizeUser 16)-  ca <- infoBarGetContentArea ib-  let container = castToContainer ca-  containerAdd container l-  containerAdd button img-  infoBarAddActionWidget ib button 0-  widgetHideAll ib+  frame <- frameNew+  box <- hBoxNew False 3+  textArea <- labelNew Nothing+  button <- eventBoxNew+  sep <- vSeparatorNew +  buttonLabel <- labelNew Nothing+  widgetSetName buttonLabel "NotificationCloseButton"+  buttonStyle <- rcGetStyle buttonLabel+  buttonTextColor <- styleGetText buttonStyle StateNormal+  labelSetMarkup buttonLabel "×" +  labelSetMaxWidthChars textArea (notificationMaxLength cfg)+  labelSetEllipsize textArea EllipsizeEnd -  istate <- initialNoteState ib l cfg-  _ <- on ib infoBarResponse (userCancel istate)+  containerAdd button buttonLabel+  boxPackStart box textArea PackGrow 0+  boxPackStart box sep PackNatural 0+  boxPackStart box button PackNatural 0++  containerAdd frame box++  widgetHideAll frame++  istate <- initialNoteState (toWidget frame) textArea cfg+  _ <- on button buttonReleaseEvent (userCancel istate)   _ <- forkIO (workerThread istate)    -- This is only available to the notify handler, so it doesn't need@@ -316,7 +331,16 @@   -- notifiation handler threads, though (not sure), so keep it safe   -- and use an mvar.   idSrc <- newMVar 1-  notificationDaemon (notify idSrc istate) (closeNotification istate) +  realizableWrapper <- hBoxNew False 0+  boxPackStart realizableWrapper frame PackNatural 0+  widgetShow realizableWrapper++  -- We can't start the dbus listener thread until we are in the GTK+  -- main loop, otherwise things are prone to lock up and block+  -- infinitely on an mvar.  Bad stuff - only start the dbus thread+  -- after the fake invisible wrapper widget is realized.+  on realizableWrapper realize $ notificationDaemon (notify idSrc istate) (closeNotification istate)+   -- Don't show ib by default - it will appear when needed-  return (toWidget ib)+  return (toWidget realizableWrapper)
src/System/Taffybar/MPRIS.hs view
@@ -80,6 +80,6 @@ mprisNew = do   l <- labelNew Nothing -  setupDBus l+  _ <- on l realize $ setupDBus l   widgetShowAll l   return (toWidget l)
src/System/Taffybar/Widgets/PollingBar.hs view
@@ -19,9 +19,11 @@ pollingBarNew cfg pollSeconds action = do   (drawArea, h) <- verticalBarNew cfg -  _ <- forkIO $ forever $ do-    sample <- action-    verticalBarSetPercent h sample-    threadDelay $ floor (pollSeconds * 1000000)+  _ <- on drawArea realize $ do+    _ <- forkIO $ forever $ do+      sample <- action+      verticalBarSetPercent h sample+      threadDelay $ floor (pollSeconds * 1000000)+    return ()    return drawArea
src/System/Taffybar/Widgets/PollingGraph.hs view
@@ -22,9 +22,11 @@ pollingGraphNew cfg pollSeconds action = do   (da, h) <- graphNew cfg -  _ <- forkIO $ forever $ do-    sample <- action-    graphAddSample h sample-    threadDelay $ floor (pollSeconds * 1000000)+  _ <- on da realize $ do+       _ <- forkIO $ forever $ do+         sample <- action+         graphAddSample h sample+         threadDelay $ floor (pollSeconds * 1000000)+       return ()    return da
src/System/Taffybar/Widgets/PollingLabel.hs view
@@ -24,9 +24,11 @@   l <- labelNew Nothing   labelSetMarkup l initialString -  _ <- forkIO $ forever $ do-    str <- cmd-    postGUIAsync $ labelSetMarkup l str-    threadDelay $ floor (interval * 1000000)+  _ <- on l realize $ do+    _ <- forkIO $ forever $ do+      str <- cmd+      postGUIAsync $ labelSetMarkup l str+      threadDelay $ floor (interval * 1000000)+    return ()    return (toWidget l)
taffybar.cabal view
@@ -1,5 +1,5 @@ name: taffybar-version: 0.1.1+version: 0.1.2 synopsis: A desktop bar similar to xmobar, but with more GUI license: BSD3 license-file: LICENSE@@ -13,9 +13,18 @@ extra-source-files: README.md,                     taffybar.hs.example -description: A somewhat fancier desktop bar than xmobar.  This bar is based on-             gtk2hs and provides several widgets (including a few graphical ones).-             It also sports an optional snazzy system tray.+description:+  A somewhat fancier desktop bar than xmobar.  This bar is based on+  gtk2hs and provides several widgets (including a few graphical ones).+  It also sports an optional snazzy system tray.+  .+  Changes in v0.1.2:+  .+    * Readable widget for freedesktop notifications+  .+    * Fixed a few potential deadlocks on startup+  .+    * Use the GTK+ rc-file styling system for colors instead of hard coding them   library
taffybar.rc view
@@ -4,5 +4,10 @@   text[NORMAL] = "#FFFFFF" } -class "GtkWidget" style "default"+style "notification-button" = "default" {+  text[NORMAL] = "#FF0000"+  fg[NORMAL] = "#FF0000"+} +class "GtkWidget" style "default"+widget "*NotificationCloseButton" style "notification-button"