Skip to content

Commit

Permalink
Rework high level API
Browse files Browse the repository at this point in the history
  • Loading branch information
supki committed Feb 27, 2014
1 parent 9142e11 commit efedf18
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 150 deletions.
Binary file added asset/Greeting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 16 additions & 13 deletions example/endless.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,35 @@
-- | This little example program shows how to use libnotify action
-- callback together with glib MainLoop thing so they actually work

import Control.Applicative ((<$))
import Control.Concurrent (threadDelay)
import Data.Functor.Identity
import Data.Semigroup ((<>))
import Libnotify
import Libnotify.C.NotifyNotification
import System.Glib.MainLoop (MainLoop, mainLoopNew, mainLoopRun, mainLoopQuit)

main :: IO ()
main = withNotifications "endless" $ do
main = () <$ do
l <- mainLoopNew Nothing False
n <- notify_notification_new "Hello!" query "face-embarrassed"
notify_notification_set_timeout n Infinite
notify_notification_add_action n "blob" "Say \"blop\"" blopCallback
notify_notification_add_action n "flop" "Say \"flop\"" (flopCallback l)
notify_notification_show n
display $
summary "Hello!"
<> body query
<> icon "face-embarrassed"
<> timeout Infinite
<> action "blob" "Say \"blop\"" blopCallback
<> action "flop" "Say \"flop\"" (flopCallback l)
mainLoopRun l

blopCallback :: NotifyNotification -> t -> IO ()
blopCallback :: Notification Identity -> t -> IO (Notification Identity)
blopCallback n _ = do
notify_notification_close n
close n
putStrLn response
threadDelay second
notify_notification_show n
return ()
display (base n)

flopCallback :: MainLoop -> NotifyNotification -> t -> IO ()
flopCallback :: MainLoop -> Notification Identity -> t -> IO ()
flopCallback l n _ = do
notify_notification_close n
close n
putStrLn "Pfft.."
mainLoopQuit l

Expand Down
8 changes: 7 additions & 1 deletion libnotify.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: libnotify
version: 0.0.2.1
description: Usable binding to libnotify library.
description: Bindings to libnotify
license: MIT
license-file: LICENSE
author: Emon Tsukimiya, Matvey Aksenov
Expand All @@ -9,6 +9,10 @@ category: System, Desktop
synopsis: Haskell binding for Libnotify
cabal-version: >= 1.10
build-type: Simple
extra-doc-files:
asset/Greeting.png
extra-source-files:
example/endless.hs

library
default-language: Haskell2010
Expand All @@ -19,6 +23,8 @@ library
, glib
, gtk
, mtl
, semigroups
, transformers
, void >= 0.5
exposed-modules:
Libnotify
Expand Down
Loading

0 comments on commit efedf18

Please sign in to comment.