    {- |
    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.SimplePermission.SimplePermission' is a trivial implementation of 'GI.Gio.Objects.Permission.Permission' that
    represents a permission that is either always or never allowed.  The
    value is given at construction and doesn\'t change.

    Calling request or release will result in errors.
    -}

    #define ENABLE_OVERLOADING \
           (!defined(__HADDOCK_VERSION__))

    module GI.Gio.Objects.SimplePermission
        (

    -- * Exported types
        SimplePermission(..)                    ,
        IsSimplePermission                      ,
        toSimplePermission                      ,
        noSimplePermission                      ,

     -- * Methods
    -- ** new #method:new#

        simplePermissionNew                     ,

        ) 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.GValue as B.GValue
    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.Objects.Permission as Gio.Permission

    -- | Memory-managed wrapper type.
    newtype SimplePermission = SimplePermission (ManagedPtr SimplePermission)
    foreign import ccall "g_simple_permission_get_type"
        c_g_simple_permission_get_type :: IO GType

    instance GObject SimplePermission where
        gobjectType _ = c_g_simple_permission_get_type

    -- | Type class for types which can be safely cast to `SimplePermission`, for instance with `toSimplePermission`.
    class GObject o => IsSimplePermission o
    #if MIN_VERSION_base(4,9,0)
    instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError SimplePermission a) =>
        IsSimplePermission a
    #endif
    instance IsSimplePermission SimplePermission
    instance Gio.Permission.IsPermission SimplePermission
    instance GObject.Object.IsObject SimplePermission

    -- | Cast to `SimplePermission`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
    toSimplePermission :: (MonadIO m, IsSimplePermission o) => o -> m SimplePermission
    toSimplePermission = liftIO . unsafeCastTo SimplePermission

    -- | A convenience alias for `Nothing` :: `Maybe` `SimplePermission`.
    noSimplePermission :: Maybe SimplePermission
    noSimplePermission = Nothing

    #if ENABLE_OVERLOADING
    type family ResolveSimplePermissionMethod (t :: Symbol) (o :: *) :: * where
        ResolveSimplePermissionMethod "acquire" o = Gio.Permission.PermissionAcquireMethodInfo
        ResolveSimplePermissionMethod "acquireAsync" o = Gio.Permission.PermissionAcquireAsyncMethodInfo
        ResolveSimplePermissionMethod "acquireFinish" o = Gio.Permission.PermissionAcquireFinishMethodInfo
        ResolveSimplePermissionMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
        ResolveSimplePermissionMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
        ResolveSimplePermissionMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
        ResolveSimplePermissionMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
        ResolveSimplePermissionMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
        ResolveSimplePermissionMethod "implUpdate" o = Gio.Permission.PermissionImplUpdateMethodInfo
        ResolveSimplePermissionMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
        ResolveSimplePermissionMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
        ResolveSimplePermissionMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
        ResolveSimplePermissionMethod "ref" o = GObject.Object.ObjectRefMethodInfo
        ResolveSimplePermissionMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
        ResolveSimplePermissionMethod "release" o = Gio.Permission.PermissionReleaseMethodInfo
        ResolveSimplePermissionMethod "releaseAsync" o = Gio.Permission.PermissionReleaseAsyncMethodInfo
        ResolveSimplePermissionMethod "releaseFinish" o = Gio.Permission.PermissionReleaseFinishMethodInfo
        ResolveSimplePermissionMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
        ResolveSimplePermissionMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
        ResolveSimplePermissionMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
        ResolveSimplePermissionMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
        ResolveSimplePermissionMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
        ResolveSimplePermissionMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
        ResolveSimplePermissionMethod "getAllowed" o = Gio.Permission.PermissionGetAllowedMethodInfo
        ResolveSimplePermissionMethod "getCanAcquire" o = Gio.Permission.PermissionGetCanAcquireMethodInfo
        ResolveSimplePermissionMethod "getCanRelease" o = Gio.Permission.PermissionGetCanReleaseMethodInfo
        ResolveSimplePermissionMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
        ResolveSimplePermissionMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
        ResolveSimplePermissionMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
        ResolveSimplePermissionMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
        ResolveSimplePermissionMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
        ResolveSimplePermissionMethod l o = O.MethodResolutionFailed l o

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

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

    #endif

    #if ENABLE_OVERLOADING
    instance O.HasAttributeList SimplePermission
    type instance O.AttributeList SimplePermission = SimplePermissionAttributeList
    type SimplePermissionAttributeList = ('[ '("allowed", Gio.Permission.PermissionAllowedPropertyInfo), '("canAcquire", Gio.Permission.PermissionCanAcquirePropertyInfo), '("canRelease", Gio.Permission.PermissionCanReleasePropertyInfo)] :: [(Symbol, *)])
    #endif

    #if ENABLE_OVERLOADING
    #endif

    #if ENABLE_OVERLOADING
    type instance O.SignalList SimplePermission = SimplePermissionSignalList
    type SimplePermissionSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

    #endif

    -- method SimplePermission::new
    -- method type : Constructor
    -- Args : [Arg {argCName = "allowed", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "%TRUE if the action is allowed", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
    -- Lengths : []
    -- returnType : Just (TInterface (Name {namespace = "Gio", name = "SimplePermission"}))
    -- throws : False
    -- Skip return : False

    foreign import ccall "g_simple_permission_new" g_simple_permission_new ::
        CInt ->                                 -- allowed : TBasicType TBoolean
        IO (Ptr SimplePermission)

    {- |
    Creates a new 'GI.Gio.Objects.Permission.Permission' instance that represents an action that is
    either always or never allowed.

    /Since: 2.26/
    -}
    simplePermissionNew ::
        (B.CallStack.HasCallStack, MonadIO m) =>
        Bool
        {- ^ /@allowed@/: 'True' if the action is allowed -}
        -> m SimplePermission
        {- ^ __Returns:__ the 'GI.Gio.Objects.SimplePermission.SimplePermission', as a 'GI.Gio.Objects.Permission.Permission' -}
    simplePermissionNew allowed = liftIO $ do
        let allowed' = (fromIntegral . fromEnum) allowed
        result <- g_simple_permission_new allowed'
        checkUnexpectedReturnNULL "simplePermissionNew" result
        result' <- (wrapObject SimplePermission) result
        return result'

    #if ENABLE_OVERLOADING
    #endif