{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

An opaque type representing a string as an index into a table
of strings on the X server.
-}

module GI.Gdk.Structs.Atom
    ( 

-- * Exported types
    Atom(..)                                ,
    noAtom                                  ,


 -- * Methods
-- ** atomName
    atomName                                ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Gdk.Types
import GI.Gdk.Callbacks

newtype Atom = Atom (ForeignPtr Atom)
noAtom :: Maybe Atom
noAtom = Nothing

-- method Atom::name
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gdk" "Atom", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gdk" "Atom", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "gdk_atom_name" gdk_atom_name :: 
    Ptr Atom ->                             -- _obj : TInterface "Gdk" "Atom"
    IO CString


atomName ::
    (MonadIO m) =>
    Atom ->                                 -- _obj
    m T.Text
atomName _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- gdk_atom_name _obj'
    checkUnexpectedReturnNULL "gdk_atom_name" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr _obj
    return result'