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

module GI.Gio.Interfaces.Icon
    ( 

-- * Exported types
    Icon(..)                                ,
    noIcon                                  ,
    IconK                                   ,
    toIcon                                  ,


 -- * Methods
-- ** iconEqual
    iconEqual                               ,


-- ** iconSerialize
    iconSerialize                           ,


-- ** iconToString
    iconToString                            ,




    ) 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.Gio.Types
import GI.Gio.Callbacks
import qualified GI.GObject as GObject

-- interface Icon 

newtype Icon = Icon (ForeignPtr Icon)
noIcon :: Maybe Icon
noIcon = Nothing

type instance AttributeList Icon = IconAttributeList
type IconAttributeList = ('[ ] :: [(Symbol, *)])

type instance SignalList Icon = IconSignalList
type IconSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

foreign import ccall "g_icon_get_type"
    c_g_icon_get_type :: IO GType

type instance ParentTypes Icon = IconParentTypes
type IconParentTypes = '[GObject.Object]

instance GObject Icon where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_icon_get_type
    

class GObject o => IconK o
instance (GObject o, IsDescendantOf Icon o) => IconK o

toIcon :: IconK o => o -> IO Icon
toIcon = unsafeCastTo Icon

-- method Icon::equal
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Icon", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "icon2", argType = TInterface "Gio" "Icon", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Icon", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "icon2", argType = TInterface "Gio" "Icon", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_icon_equal" g_icon_equal :: 
    Ptr Icon ->                             -- _obj : TInterface "Gio" "Icon"
    Ptr Icon ->                             -- icon2 : TInterface "Gio" "Icon"
    IO CInt


iconEqual ::
    (MonadIO m, IconK a, IconK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- icon2
    m Bool
iconEqual _obj icon2 = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeIcon2 <- case icon2 of
        Nothing -> return nullPtr
        Just jIcon2 -> do
            let jIcon2' = unsafeManagedPtrCastPtr jIcon2
            return jIcon2'
    result <- g_icon_equal _obj' maybeIcon2
    let result' = (/= 0) result
    touchManagedPtr _obj
    whenJust icon2 touchManagedPtr
    return result'

-- method Icon::serialize
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Icon", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Icon", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TVariant
-- throws : False
-- Skip return : False

foreign import ccall "g_icon_serialize" g_icon_serialize :: 
    Ptr Icon ->                             -- _obj : TInterface "Gio" "Icon"
    IO (Ptr GVariant)


iconSerialize ::
    (MonadIO m, IconK a) =>
    a ->                                    -- _obj
    m GVariant
iconSerialize _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_icon_serialize _obj'
    checkUnexpectedReturnNULL "g_icon_serialize" result
    result' <- wrapGVariantPtr result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "g_icon_to_string" g_icon_to_string :: 
    Ptr Icon ->                             -- _obj : TInterface "Gio" "Icon"
    IO CString


iconToString ::
    (MonadIO m, IconK a) =>
    a ->                                    -- _obj
    m T.Text
iconToString _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_icon_to_string _obj'
    checkUnexpectedReturnNULL "g_icon_to_string" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr _obj
    return result'