summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2010-11-07 23:09:09 (GMT)
committerWill Thompson <will.thompson@collabora.co.uk>2010-11-07 23:09:09 (GMT)
commit14d78a0e31389550b5de7d341c58f900b86a4024 (patch)
treec582653e57ebb2fa5d34f9d5091a530da8436eef
parent2b9deb7a52298e4f56efa9600e4cabd05db6bfb0 (diff)
downloadhaskell-gi-14d78a0e31389550b5de7d341c58f900b86a4024.tar.gz
haskell-gi-14d78a0e31389550b5de7d341c58f900b86a4024.tar.xz
It works!
-rw-r--r--GI/BaseInfo.chs16
-rw-r--r--GI/Typelib.chs9
-rw-r--r--GI/Types.chs4
-rw-r--r--GObject-Introspection.cabal2
-rw-r--r--Main.hs11
5 files changed, 38 insertions, 4 deletions
diff --git a/GI/BaseInfo.chs b/GI/BaseInfo.chs
new file mode 100644
index 0000000..baecbba
--- /dev/null
+++ b/GI/BaseInfo.chs
@@ -0,0 +1,16 @@
+module GI.BaseInfo
+ ( baseInfoGetName
+ )
+where
+
+import Foreign
+import Foreign.C
+import Foreign.C.String
+{# import GI.Types #}
+
+#include <girepository.h>
+
+baseInfoGetName :: BaseInfo -> IO String
+baseInfoGetName (BaseInfo p) = do
+ ret <- {# call g_base_info_get_name #} $ TypeInfo $ castPtr p
+ peekCString ret
diff --git a/GI/Typelib.chs b/GI/Typelib.chs
index bdc451f..b9ac524 100644
--- a/GI/Typelib.chs
+++ b/GI/Typelib.chs
@@ -1,5 +1,6 @@
module GI.Typelib
( repositoryGetNInfos
+ , repositoryGetInfo
, repositoryRequire
, repositoryLoad
)
@@ -10,6 +11,8 @@ import Foreign.C
import System.Glib.GError
+import GI.Types
+
#include <girepository.h>
{# pointer *GITypelib as Typelib newtype #}
@@ -24,6 +27,11 @@ repositoryGetNInfos :: String -> IO CInt
repositoryGetNInfos ns = withCString ns $ \nsPtr ->
{# call unsafe g_irepository_get_n_infos #} nullRepository nsPtr
+repositoryGetInfo :: String -> CInt -> IO BaseInfo
+repositoryGetInfo ns i = withCString ns $ \nsPtr -> do
+ ret <- {# call unsafe g_irepository_get_info #} nullRepository nsPtr (fromIntegral i)
+ return $ BaseInfo $ castPtr ret
+
repositoryRequire :: String -> IO Typelib
repositoryRequire ns = --version =
withCString ns $ \nsPtr ->
@@ -34,3 +42,4 @@ repositoryLoad :: Typelib -> IO String
repositoryLoad typelib = do
ret <- propagateGError $ {# call unsafe g_irepository_load_typelib #} nullRepository typelib 0
peekCString ret
+
diff --git a/GI/Types.chs b/GI/Types.chs
index ba0e82d..d9f6436 100644
--- a/GI/Types.chs
+++ b/GI/Types.chs
@@ -1,6 +1,8 @@
module GI.Types
(
- CallableInfo(..)
+ BaseInfo(..)
+ , BaseInfoClass(..)
+ , CallableInfo(..)
, CallableInfoClass(..)
, FunctionInfo(..)
, FunctionInfoClass(..)
diff --git a/GObject-Introspection.cabal b/GObject-Introspection.cabal
index 68e85a9..20260a3 100644
--- a/GObject-Introspection.cabal
+++ b/GObject-Introspection.cabal
@@ -50,7 +50,7 @@ Cabal-version: >=1.2
Executable lol
main-is: Main.hs
- other-modules: GI.Types, GI.Typelib
+ other-modules: GI.Types, GI.Typelib, GI.BaseInfo
pkgconfig-depends: gobject-introspection-1.0
extensions: ForeignFunctionInterface
build-depends: base >= 4, gtk, glib
diff --git a/Main.hs b/Main.hs
index 8f9bd4e..a433da0 100644
--- a/Main.hs
+++ b/Main.hs
@@ -1,11 +1,18 @@
module Main where
+import Control.Monad (forM_)
+import GI.Types
import GI.Typelib
+import GI.BaseInfo
import Graphics.UI.Gtk
import System.Glib.GError
main = handleGError (\(GError dom code msg) -> print (dom, code, msg)) $ do
initGUI
- tp <- repositoryRequire "GLib"
+ tp <- repositoryRequire "TelepathyGLib"
repositoryLoad tp
- print =<< repositoryGetNInfos "GLib"
+ n <- repositoryGetNInfos "TelepathyGLib"
+ forM_ [0..n-1] $ \i -> do
+ putStrLn =<< baseInfoGetName =<< repositoryGetInfo "TelepathyGLib" i
+
+