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

'GI.Gio.Objects.BytesIcon.BytesIcon' specifies an image held in memory in a common format (usually
png) to be used as icon.
-}

module GI.Gio.Objects.BytesIcon
    ( 

-- * Exported types
    BytesIcon(..)                           ,
    IsBytesIcon                             ,
    toBytesIcon                             ,
    noBytesIcon                             ,


 -- * Methods
-- ** getBytes #method:getBytes#
    BytesIconGetBytesMethodInfo             ,
    bytesIconGetBytes                       ,


-- ** new #method:new#
    bytesIconNew                            ,




 -- * Properties
-- ** bytes #attr:bytes#
    BytesIconBytesPropertyInfo              ,
    bytesIconBytes                          ,
    constructBytesIconBytes                 ,
    getBytesIconBytes                       ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GLib.Structs.Bytes as GLib.Bytes
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Icon as Gio.Icon
import {-# SOURCE #-} qualified GI.Gio.Interfaces.LoadableIcon as Gio.LoadableIcon

newtype BytesIcon = BytesIcon (ManagedPtr BytesIcon)
foreign import ccall "g_bytes_icon_get_type"
    c_g_bytes_icon_get_type :: IO GType

instance GObject BytesIcon where
    gobjectType _ = c_g_bytes_icon_get_type
    

class GObject o => IsBytesIcon o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError BytesIcon a) =>
    IsBytesIcon a
#endif
instance IsBytesIcon BytesIcon
instance GObject.Object.IsObject BytesIcon
instance Gio.Icon.IsIcon BytesIcon
instance Gio.LoadableIcon.IsLoadableIcon BytesIcon

toBytesIcon :: IsBytesIcon o => o -> IO BytesIcon
toBytesIcon = unsafeCastTo BytesIcon

noBytesIcon :: Maybe BytesIcon
noBytesIcon = Nothing

type family ResolveBytesIconMethod (t :: Symbol) (o :: *) :: * where
    ResolveBytesIconMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveBytesIconMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveBytesIconMethod "equal" o = Gio.Icon.IconEqualMethodInfo
    ResolveBytesIconMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveBytesIconMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveBytesIconMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveBytesIconMethod "load" o = Gio.LoadableIcon.LoadableIconLoadMethodInfo
    ResolveBytesIconMethod "loadAsync" o = Gio.LoadableIcon.LoadableIconLoadAsyncMethodInfo
    ResolveBytesIconMethod "loadFinish" o = Gio.LoadableIcon.LoadableIconLoadFinishMethodInfo
    ResolveBytesIconMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveBytesIconMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveBytesIconMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveBytesIconMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveBytesIconMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveBytesIconMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveBytesIconMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveBytesIconMethod "serialize" o = Gio.Icon.IconSerializeMethodInfo
    ResolveBytesIconMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveBytesIconMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveBytesIconMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveBytesIconMethod "toString" o = Gio.Icon.IconToStringMethodInfo
    ResolveBytesIconMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveBytesIconMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveBytesIconMethod "getBytes" o = BytesIconGetBytesMethodInfo
    ResolveBytesIconMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveBytesIconMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveBytesIconMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveBytesIconMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveBytesIconMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveBytesIconMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveBytesIconMethod t BytesIcon, O.MethodInfo info BytesIcon p) => O.IsLabelProxy t (BytesIcon -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveBytesIconMethod t BytesIcon, O.MethodInfo info BytesIcon p) => O.IsLabel t (BytesIcon -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- VVV Prop "bytes"
   -- Type: TInterface (Name {namespace = "GLib", name = "Bytes"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getBytesIconBytes :: (MonadIO m, IsBytesIcon o) => o -> m GLib.Bytes.Bytes
getBytesIconBytes obj = liftIO $ checkUnexpectedNothing "getBytesIconBytes" $ getObjectPropertyBoxed obj "bytes" GLib.Bytes.Bytes

constructBytesIconBytes :: (IsBytesIcon o) => GLib.Bytes.Bytes -> IO (GValueConstruct o)
constructBytesIconBytes val = constructObjectPropertyBoxed "bytes" (Just val)

data BytesIconBytesPropertyInfo
instance AttrInfo BytesIconBytesPropertyInfo where
    type AttrAllowedOps BytesIconBytesPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint BytesIconBytesPropertyInfo = (~) GLib.Bytes.Bytes
    type AttrBaseTypeConstraint BytesIconBytesPropertyInfo = IsBytesIcon
    type AttrGetType BytesIconBytesPropertyInfo = GLib.Bytes.Bytes
    type AttrLabel BytesIconBytesPropertyInfo = "bytes"
    type AttrOrigin BytesIconBytesPropertyInfo = BytesIcon
    attrGet _ = getBytesIconBytes
    attrSet _ = undefined
    attrConstruct _ = constructBytesIconBytes
    attrClear _ = undefined

instance O.HasAttributeList BytesIcon
type instance O.AttributeList BytesIcon = BytesIconAttributeList
type BytesIconAttributeList = ('[ '("bytes", BytesIconBytesPropertyInfo)] :: [(Symbol, *)])

bytesIconBytes :: AttrLabelProxy "bytes"
bytesIconBytes = AttrLabelProxy

type instance O.SignalList BytesIcon = BytesIconSignalList
type BytesIconSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method BytesIcon::new
-- method type : Constructor
-- Args : [Arg {argCName = "bytes", argType = TInterface (Name {namespace = "GLib", name = "Bytes"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GBytes.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "BytesIcon"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_bytes_icon_new" g_bytes_icon_new :: 
    Ptr GLib.Bytes.Bytes ->                 -- bytes : TInterface (Name {namespace = "GLib", name = "Bytes"})
    IO (Ptr BytesIcon)

{- |
Creates a new icon for a bytes.

@since 2.38
-}
bytesIconNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GLib.Bytes.Bytes
    {- ^ /@bytes@/: a 'GI.GLib.Structs.Bytes.Bytes'. -}
    -> m BytesIcon
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.Icon.Icon' for the given
  /@bytes@/, or 'Nothing' on error. -}
bytesIconNew bytes = liftIO $ do
    bytes' <- unsafeManagedPtrGetPtr bytes
    result <- g_bytes_icon_new bytes'
    checkUnexpectedReturnNULL "bytesIconNew" result
    result' <- (wrapObject BytesIcon) result
    touchManagedPtr bytes
    return result'

-- method BytesIcon::get_bytes
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "icon", argType = TInterface (Name {namespace = "Gio", name = "BytesIcon"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIcon.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "Bytes"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_bytes_icon_get_bytes" g_bytes_icon_get_bytes :: 
    Ptr BytesIcon ->                        -- icon : TInterface (Name {namespace = "Gio", name = "BytesIcon"})
    IO (Ptr GLib.Bytes.Bytes)

{- |
Gets the 'GI.GLib.Structs.Bytes.Bytes' associated with the given /@icon@/.

@since 2.38
-}
bytesIconGetBytes ::
    (B.CallStack.HasCallStack, MonadIO m, IsBytesIcon a) =>
    a
    {- ^ /@icon@/: a 'GI.Gio.Interfaces.Icon.Icon'. -}
    -> m GLib.Bytes.Bytes
    {- ^ __Returns:__ a 'GI.GLib.Structs.Bytes.Bytes', or 'Nothing'. -}
bytesIconGetBytes icon = liftIO $ do
    icon' <- unsafeManagedPtrCastPtr icon
    result <- g_bytes_icon_get_bytes icon'
    checkUnexpectedReturnNULL "bytesIconGetBytes" result
    result' <- (newBoxed GLib.Bytes.Bytes) result
    touchManagedPtr icon
    return result'

data BytesIconGetBytesMethodInfo
instance (signature ~ (m GLib.Bytes.Bytes), MonadIO m, IsBytesIcon a) => O.MethodInfo BytesIconGetBytesMethodInfo a signature where
    overloadedMethod _ = bytesIconGetBytes