Commits

Max Rabkin  committed 0db8823

Add image support

  • Participants
  • Parent commits 8e6e1a0

Comments (0)

Files changed (1)

File DBus/Notify.hs

     , Timeout (..)
     , Action (..)
     , Image
+    , Icon (..)
     , Category (..)
     , UrgencyLevel (..)
     , Hint (..)
 
 -- |Contents of a notification
 data Note = Note { appName :: String
-                 , appImage :: Maybe Image
+                 , appImage :: Maybe Icon
                  , summary :: String
                  , body :: Maybe Body
                  , actions :: [(Action, String)]
 newtype Image = Image { bitmap :: String }
     deriving (Eq, Show)
 
+-- |An Icon is either a path to an image, or a name in an icon theme
+data Icon = File FilePath | Icon String
+    deriving (Eq, Show)
+
+iconString (File fp) = "file://" ++ fp
+iconString (Icon name) = name
+
 -- |Urgency of the notification. Notifications may be prioritised by urgency.
 data UrgencyLevel =   Low
                     | Normal
             | Category Category
             -- DesktopEntry ApplicationDesktopID
             | ImageData Image
+            | ImagePath Icon
             | SoundFile FilePath
             | SuppressSound Bool
             | X Int32
         args = map ($ note)
             [ toVariant . appName
                , const $ toVariant (replaceId::Word32)
-               , toVariant . fromMaybe "" .fmap bitmap . appImage
+               , toVariant . fromMaybe "" . fmap iconString . appImage
                , toVariant . summary
                , toVariant . fromMaybe "" . fmap flattenBody . body
                , toVariant . actionsArray . actions
         hint :: Hint -> (String, Variant)
         hint (Urgency u) = ("urgency", toVariant (fromIntegral $ fromEnum u :: Word8))
         hint (Category c) = ("category", toVariant $ catName c)
-        hint (ImageData i) = ("image_data", toVariant $ bitmap i)
+        hint (ImagePath p) = ("image-path", toVariant $ iconString p)
+        hint (ImageData i) = ("image-data", toVariant $ bitmap i)
         hint (SoundFile s) = ("sound-file", toVariant s)
         hint (SuppressSound b) = ("suppress-sound", toVariant b)
         hint (X x) = ("x", toVariant x)