diff options
author | Will Thompson <will@willthompson.co.uk> | 2012-01-11 13:07:07 +0000 |
---|---|---|
committer | Will Thompson <will@willthompson.co.uk> | 2012-01-12 11:12:17 +0000 |
commit | d7cac3fae6b300969aff6c6b93ad2bcd63c081c2 (patch) | |
tree | 577eede15135b11d8cf3e639d72536d9168509cc /tests | |
parent | 23438e5a8b0c092817229e1512ca4f6f5163267b (diff) |
Wrap up the C monitor in a Haskell module.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Monitor.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/Monitor.hs b/tests/Monitor.hs new file mode 100644 index 0000000..d07cea0 --- /dev/null +++ b/tests/Monitor.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE ForeignFunctionInterface #-} +module Main where + +import Bustle.Monitor + +import System.Glib.GError +import System.Glib.MainLoop + +foreign import ccall "g_type_init" g_type_init :: IO () + +main = do + g_type_init + emonitor <- monitorNew BusTypeSession "/tmp/test.bustle" DebugOutput + case emonitor of + Left (GError _ _ message) -> error message + Right monitor -> do + loop <- mainLoopNew Nothing False + timeoutAdd (mainLoopQuit loop >> return False) 5000 + mainLoopRun loop + monitorStop monitor |