{- |
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.EmblemedIcon.EmblemedIcon' is an implementation of 'GI.Gio.Interfaces.Icon.Icon' that supports
adding an emblem to an icon. Adding multiple emblems to an
icon is ensured via 'GI.Gio.Objects.EmblemedIcon.emblemedIconAddEmblem'.

Note that 'GI.Gio.Objects.EmblemedIcon.EmblemedIcon' allows no control over the position
of the emblems. See also 'GI.Gio.Objects.Emblem.Emblem' for more information.
-}

module GI.Gio.Objects.EmblemedIcon
    ( 

-- * Exported types
    EmblemedIcon(..)                        ,
    IsEmblemedIcon                          ,
    toEmblemedIcon                          ,
    noEmblemedIcon                          ,


 -- * Methods
-- ** addEmblem #method:addEmblem#
    EmblemedIconAddEmblemMethodInfo         ,
    emblemedIconAddEmblem                   ,


-- ** clearEmblems #method:clearEmblems#
    EmblemedIconClearEmblemsMethodInfo      ,
    emblemedIconClearEmblems                ,


-- ** getEmblems #method:getEmblems#
    EmblemedIconGetEmblemsMethodInfo        ,
    emblemedIconGetEmblems                  ,


-- ** getIcon #method:getIcon#
    EmblemedIconGetIconMethodInfo           ,
    emblemedIconGetIcon                     ,


-- ** new #method:new#
    emblemedIconNew                         ,




 -- * Properties
-- ** gicon #attr:gicon#
    EmblemedIconGiconPropertyInfo           ,
    constructEmblemedIconGicon              ,
    emblemedIconGicon                       ,
    getEmblemedIconGicon                    ,




    ) 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.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Icon as Gio.Icon
import {-# SOURCE #-} qualified GI.Gio.Objects.Emblem as Gio.Emblem

newtype EmblemedIcon = EmblemedIcon (ManagedPtr EmblemedIcon)
foreign import ccall "g_emblemed_icon_get_type"
    c_g_emblemed_icon_get_type :: IO GType

instance GObject EmblemedIcon where
    gobjectType _ = c_g_emblemed_icon_get_type
    

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

toEmblemedIcon :: IsEmblemedIcon o => o -> IO EmblemedIcon
toEmblemedIcon = unsafeCastTo EmblemedIcon

noEmblemedIcon :: Maybe EmblemedIcon
noEmblemedIcon = Nothing

type family ResolveEmblemedIconMethod (t :: Symbol) (o :: *) :: * where
    ResolveEmblemedIconMethod "addEmblem" o = EmblemedIconAddEmblemMethodInfo
    ResolveEmblemedIconMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveEmblemedIconMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveEmblemedIconMethod "clearEmblems" o = EmblemedIconClearEmblemsMethodInfo
    ResolveEmblemedIconMethod "equal" o = Gio.Icon.IconEqualMethodInfo
    ResolveEmblemedIconMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveEmblemedIconMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveEmblemedIconMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveEmblemedIconMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveEmblemedIconMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveEmblemedIconMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveEmblemedIconMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveEmblemedIconMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveEmblemedIconMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveEmblemedIconMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveEmblemedIconMethod "serialize" o = Gio.Icon.IconSerializeMethodInfo
    ResolveEmblemedIconMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveEmblemedIconMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveEmblemedIconMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveEmblemedIconMethod "toString" o = Gio.Icon.IconToStringMethodInfo
    ResolveEmblemedIconMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveEmblemedIconMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveEmblemedIconMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveEmblemedIconMethod "getEmblems" o = EmblemedIconGetEmblemsMethodInfo
    ResolveEmblemedIconMethod "getIcon" o = EmblemedIconGetIconMethodInfo
    ResolveEmblemedIconMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveEmblemedIconMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveEmblemedIconMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveEmblemedIconMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveEmblemedIconMethod l o = O.MethodResolutionFailed l o

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

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

-- VVV Prop "gicon"
   -- Type: TInterface (Name {namespace = "Gio", name = "Icon"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getEmblemedIconGicon :: (MonadIO m, IsEmblemedIcon o) => o -> m (Maybe Gio.Icon.Icon)
getEmblemedIconGicon obj = liftIO $ getObjectPropertyObject obj "gicon" Gio.Icon.Icon

constructEmblemedIconGicon :: (IsEmblemedIcon o, Gio.Icon.IsIcon a) => a -> IO (GValueConstruct o)
constructEmblemedIconGicon val = constructObjectPropertyObject "gicon" (Just val)

data EmblemedIconGiconPropertyInfo
instance AttrInfo EmblemedIconGiconPropertyInfo where
    type AttrAllowedOps EmblemedIconGiconPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint EmblemedIconGiconPropertyInfo = Gio.Icon.IsIcon
    type AttrBaseTypeConstraint EmblemedIconGiconPropertyInfo = IsEmblemedIcon
    type AttrGetType EmblemedIconGiconPropertyInfo = (Maybe Gio.Icon.Icon)
    type AttrLabel EmblemedIconGiconPropertyInfo = "gicon"
    type AttrOrigin EmblemedIconGiconPropertyInfo = EmblemedIcon
    attrGet _ = getEmblemedIconGicon
    attrSet _ = undefined
    attrConstruct _ = constructEmblemedIconGicon
    attrClear _ = undefined

instance O.HasAttributeList EmblemedIcon
type instance O.AttributeList EmblemedIcon = EmblemedIconAttributeList
type EmblemedIconAttributeList = ('[ '("gicon", EmblemedIconGiconPropertyInfo)] :: [(Symbol, *)])

emblemedIconGicon :: AttrLabelProxy "gicon"
emblemedIconGicon = AttrLabelProxy

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

-- method EmblemedIcon::new
-- method type : Constructor
-- Args : [Arg {argCName = "icon", argType = TInterface (Name {namespace = "Gio", name = "Icon"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIcon", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "emblem", argType = TInterface (Name {namespace = "Gio", name = "Emblem"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GEmblem, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "EmblemedIcon"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_emblemed_icon_new" g_emblemed_icon_new :: 
    Ptr Gio.Icon.Icon ->                    -- icon : TInterface (Name {namespace = "Gio", name = "Icon"})
    Ptr Gio.Emblem.Emblem ->                -- emblem : TInterface (Name {namespace = "Gio", name = "Emblem"})
    IO (Ptr EmblemedIcon)

{- |
Creates a new emblemed icon for /@icon@/ with the emblem /@emblem@/.

@since 2.18
-}
emblemedIconNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Icon.IsIcon a, Gio.Emblem.IsEmblem b) =>
    a
    {- ^ /@icon@/: a 'GI.Gio.Interfaces.Icon.Icon' -}
    -> Maybe (b)
    {- ^ /@emblem@/: a 'GI.Gio.Objects.Emblem.Emblem', or 'Nothing' -}
    -> m EmblemedIcon
    {- ^ __Returns:__ a new 'GI.Gio.Interfaces.Icon.Icon' -}
emblemedIconNew icon emblem = liftIO $ do
    icon' <- unsafeManagedPtrCastPtr icon
    maybeEmblem <- case emblem of
        Nothing -> return nullPtr
        Just jEmblem -> do
            jEmblem' <- unsafeManagedPtrCastPtr jEmblem
            return jEmblem'
    result <- g_emblemed_icon_new icon' maybeEmblem
    checkUnexpectedReturnNULL "emblemedIconNew" result
    result' <- (wrapObject EmblemedIcon) result
    touchManagedPtr icon
    whenJust emblem touchManagedPtr
    return result'

-- method EmblemedIcon::add_emblem
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "emblemed", argType = TInterface (Name {namespace = "Gio", name = "EmblemedIcon"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GEmblemedIcon", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "emblem", argType = TInterface (Name {namespace = "Gio", name = "Emblem"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GEmblem", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_emblemed_icon_add_emblem" g_emblemed_icon_add_emblem :: 
    Ptr EmblemedIcon ->                     -- emblemed : TInterface (Name {namespace = "Gio", name = "EmblemedIcon"})
    Ptr Gio.Emblem.Emblem ->                -- emblem : TInterface (Name {namespace = "Gio", name = "Emblem"})
    IO ()

{- |
Adds /@emblem@/ to the 'GI.GLib.Structs.List.List' of @/GEmblems/@.

@since 2.18
-}
emblemedIconAddEmblem ::
    (B.CallStack.HasCallStack, MonadIO m, IsEmblemedIcon a, Gio.Emblem.IsEmblem b) =>
    a
    {- ^ /@emblemed@/: a 'GI.Gio.Objects.EmblemedIcon.EmblemedIcon' -}
    -> b
    {- ^ /@emblem@/: a 'GI.Gio.Objects.Emblem.Emblem' -}
    -> m ()
emblemedIconAddEmblem emblemed emblem = liftIO $ do
    emblemed' <- unsafeManagedPtrCastPtr emblemed
    emblem' <- unsafeManagedPtrCastPtr emblem
    g_emblemed_icon_add_emblem emblemed' emblem'
    touchManagedPtr emblemed
    touchManagedPtr emblem
    return ()

data EmblemedIconAddEmblemMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsEmblemedIcon a, Gio.Emblem.IsEmblem b) => O.MethodInfo EmblemedIconAddEmblemMethodInfo a signature where
    overloadedMethod _ = emblemedIconAddEmblem

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

foreign import ccall "g_emblemed_icon_clear_emblems" g_emblemed_icon_clear_emblems :: 
    Ptr EmblemedIcon ->                     -- emblemed : TInterface (Name {namespace = "Gio", name = "EmblemedIcon"})
    IO ()

{- |
Removes all the emblems from /@icon@/.

@since 2.28
-}
emblemedIconClearEmblems ::
    (B.CallStack.HasCallStack, MonadIO m, IsEmblemedIcon a) =>
    a
    {- ^ /@emblemed@/: a 'GI.Gio.Objects.EmblemedIcon.EmblemedIcon' -}
    -> m ()
emblemedIconClearEmblems emblemed = liftIO $ do
    emblemed' <- unsafeManagedPtrCastPtr emblemed
    g_emblemed_icon_clear_emblems emblemed'
    touchManagedPtr emblemed
    return ()

data EmblemedIconClearEmblemsMethodInfo
instance (signature ~ (m ()), MonadIO m, IsEmblemedIcon a) => O.MethodInfo EmblemedIconClearEmblemsMethodInfo a signature where
    overloadedMethod _ = emblemedIconClearEmblems

-- method EmblemedIcon::get_emblems
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "emblemed", argType = TInterface (Name {namespace = "Gio", name = "EmblemedIcon"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GEmblemedIcon", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Gio", name = "Emblem"})))
-- throws : False
-- Skip return : False

foreign import ccall "g_emblemed_icon_get_emblems" g_emblemed_icon_get_emblems :: 
    Ptr EmblemedIcon ->                     -- emblemed : TInterface (Name {namespace = "Gio", name = "EmblemedIcon"})
    IO (Ptr (GList (Ptr Gio.Emblem.Emblem)))

{- |
Gets the list of emblems for the /@icon@/.

@since 2.18
-}
emblemedIconGetEmblems ::
    (B.CallStack.HasCallStack, MonadIO m, IsEmblemedIcon a) =>
    a
    {- ^ /@emblemed@/: a 'GI.Gio.Objects.EmblemedIcon.EmblemedIcon' -}
    -> m [Gio.Emblem.Emblem]
    {- ^ __Returns:__ a 'GI.GLib.Structs.List.List' of
    @/GEmblems/@ that is owned by /@emblemed@/ -}
emblemedIconGetEmblems emblemed = liftIO $ do
    emblemed' <- unsafeManagedPtrCastPtr emblemed
    result <- g_emblemed_icon_get_emblems emblemed'
    result' <- unpackGList result
    result'' <- mapM (newObject Gio.Emblem.Emblem) result'
    touchManagedPtr emblemed
    return result''

data EmblemedIconGetEmblemsMethodInfo
instance (signature ~ (m [Gio.Emblem.Emblem]), MonadIO m, IsEmblemedIcon a) => O.MethodInfo EmblemedIconGetEmblemsMethodInfo a signature where
    overloadedMethod _ = emblemedIconGetEmblems

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

foreign import ccall "g_emblemed_icon_get_icon" g_emblemed_icon_get_icon :: 
    Ptr EmblemedIcon ->                     -- emblemed : TInterface (Name {namespace = "Gio", name = "EmblemedIcon"})
    IO (Ptr Gio.Icon.Icon)

{- |
Gets the main icon for /@emblemed@/.

@since 2.18
-}
emblemedIconGetIcon ::
    (B.CallStack.HasCallStack, MonadIO m, IsEmblemedIcon a) =>
    a
    {- ^ /@emblemed@/: a 'GI.Gio.Objects.EmblemedIcon.EmblemedIcon' -}
    -> m Gio.Icon.Icon
    {- ^ __Returns:__ a 'GI.Gio.Interfaces.Icon.Icon' that is owned by /@emblemed@/ -}
emblemedIconGetIcon emblemed = liftIO $ do
    emblemed' <- unsafeManagedPtrCastPtr emblemed
    result <- g_emblemed_icon_get_icon emblemed'
    checkUnexpectedReturnNULL "emblemedIconGetIcon" result
    result' <- (newObject Gio.Icon.Icon) result
    touchManagedPtr emblemed
    return result'

data EmblemedIconGetIconMethodInfo
instance (signature ~ (m Gio.Icon.Icon), MonadIO m, IsEmblemedIcon a) => O.MethodInfo EmblemedIconGetIconMethodInfo a signature where
    overloadedMethod _ = emblemedIconGetIcon