{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- /No description available in the introspection data./

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.OSTree.Objects.RepoFinderMount
    ( 

-- * Exported types
    RepoFinderMount(..)                     ,
    IsRepoFinderMount                       ,
    toRepoFinderMount                       ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [isFloating]("GI.GObject.Objects.Object#g:method:isFloating"), [notify]("GI.GObject.Objects.Object#g:method:notify"), [notifyByPspec]("GI.GObject.Objects.Object#g:method:notifyByPspec"), [ref]("GI.GObject.Objects.Object#g:method:ref"), [refSink]("GI.GObject.Objects.Object#g:method:refSink"), [resolveAsync]("GI.OSTree.Interfaces.RepoFinder#g:method:resolveAsync"), [resolveFinish]("GI.OSTree.Interfaces.RepoFinder#g:method:resolveFinish"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [stealData]("GI.GObject.Objects.Object#g:method:stealData"), [stealQdata]("GI.GObject.Objects.Object#g:method:stealQdata"), [thawNotify]("GI.GObject.Objects.Object#g:method:thawNotify"), [unref]("GI.GObject.Objects.Object#g:method:unref"), [watchClosure]("GI.GObject.Objects.Object#g:method:watchClosure").
-- 
-- ==== Getters
-- [getData]("GI.GObject.Objects.Object#g:method:getData"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata").
-- 
-- ==== Setters
-- [setData]("GI.GObject.Objects.Object#g:method:setData"), [setDataFull]("GI.GObject.Objects.Object#g:method:setDataFull"), [setProperty]("GI.GObject.Objects.Object#g:method:setProperty").

#if defined(ENABLE_OVERLOADING)
    ResolveRepoFinderMountMethod            ,
#endif

-- ** new #method:new#

    repoFinderMountNew                      ,




 -- * Properties


-- ** monitor #attr:monitor#
-- | Volume monitor to use to look up mounted volumes when queried.
-- 
-- /Since: 2018.6/

#if defined(ENABLE_OVERLOADING)
    RepoFinderMountMonitorPropertyInfo      ,
#endif
    constructRepoFinderMountMonitor         ,
    getRepoFinderMountMonitor               ,
#if defined(ENABLE_OVERLOADING)
    repoFinderMountMonitor                  ,
#endif




    ) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
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 GHC.OverloadedLabels as OL
import qualified GHC.Records as R

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Objects.VolumeMonitor as Gio.VolumeMonitor
import {-# SOURCE #-} qualified GI.OSTree.Interfaces.RepoFinder as OSTree.RepoFinder

-- | Memory-managed wrapper type.
newtype RepoFinderMount = RepoFinderMount (SP.ManagedPtr RepoFinderMount)
    deriving (RepoFinderMount -> RepoFinderMount -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RepoFinderMount -> RepoFinderMount -> Bool
$c/= :: RepoFinderMount -> RepoFinderMount -> Bool
== :: RepoFinderMount -> RepoFinderMount -> Bool
$c== :: RepoFinderMount -> RepoFinderMount -> Bool
Eq)

instance SP.ManagedPtrNewtype RepoFinderMount where
    toManagedPtr :: RepoFinderMount -> ManagedPtr RepoFinderMount
toManagedPtr (RepoFinderMount ManagedPtr RepoFinderMount
p) = ManagedPtr RepoFinderMount
p

foreign import ccall "ostree_repo_finder_mount_get_type"
    c_ostree_repo_finder_mount_get_type :: IO B.Types.GType

instance B.Types.TypedObject RepoFinderMount where
    glibType :: IO GType
glibType = IO GType
c_ostree_repo_finder_mount_get_type

instance B.Types.GObject RepoFinderMount

-- | Type class for types which can be safely cast to `RepoFinderMount`, for instance with `toRepoFinderMount`.
class (SP.GObject o, O.IsDescendantOf RepoFinderMount o) => IsRepoFinderMount o
instance (SP.GObject o, O.IsDescendantOf RepoFinderMount o) => IsRepoFinderMount o

instance O.HasParentTypes RepoFinderMount
type instance O.ParentTypes RepoFinderMount = '[GObject.Object.Object, OSTree.RepoFinder.RepoFinder]

-- | Cast to `RepoFinderMount`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toRepoFinderMount :: (MIO.MonadIO m, IsRepoFinderMount o) => o -> m RepoFinderMount
toRepoFinderMount :: forall (m :: * -> *) o.
(MonadIO m, IsRepoFinderMount o) =>
o -> m RepoFinderMount
toRepoFinderMount = forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr RepoFinderMount -> RepoFinderMount
RepoFinderMount

-- | Convert 'RepoFinderMount' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe RepoFinderMount) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_ostree_repo_finder_mount_get_type
    gvalueSet_ :: Ptr GValue -> Maybe RepoFinderMount -> IO ()
gvalueSet_ Ptr GValue
gv Maybe RepoFinderMount
P.Nothing = forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (forall a. Ptr a
FP.nullPtr :: FP.Ptr RepoFinderMount)
    gvalueSet_ Ptr GValue
gv (P.Just RepoFinderMount
obj) = forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr RepoFinderMount
obj (forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe RepoFinderMount)
gvalueGet_ Ptr GValue
gv = do
        Ptr RepoFinderMount
ptr <- forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr RepoFinderMount)
        if Ptr RepoFinderMount
ptr forall a. Eq a => a -> a -> Bool
/= forall a. Ptr a
FP.nullPtr
        then forall a. a -> Maybe a
P.Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr RepoFinderMount -> RepoFinderMount
RepoFinderMount Ptr RepoFinderMount
ptr
        else forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
P.Nothing
        
    

#if defined(ENABLE_OVERLOADING)
type family ResolveRepoFinderMountMethod (t :: Symbol) (o :: *) :: * where
    ResolveRepoFinderMountMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveRepoFinderMountMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveRepoFinderMountMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveRepoFinderMountMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveRepoFinderMountMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveRepoFinderMountMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveRepoFinderMountMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveRepoFinderMountMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveRepoFinderMountMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveRepoFinderMountMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveRepoFinderMountMethod "resolveAsync" o = OSTree.RepoFinder.RepoFinderResolveAsyncMethodInfo
    ResolveRepoFinderMountMethod "resolveFinish" o = OSTree.RepoFinder.RepoFinderResolveFinishMethodInfo
    ResolveRepoFinderMountMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveRepoFinderMountMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveRepoFinderMountMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveRepoFinderMountMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveRepoFinderMountMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveRepoFinderMountMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveRepoFinderMountMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveRepoFinderMountMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveRepoFinderMountMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveRepoFinderMountMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveRepoFinderMountMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveRepoFinderMountMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveRepoFinderMountMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveRepoFinderMountMethod t RepoFinderMount, O.OverloadedMethod info RepoFinderMount p) => OL.IsLabel t (RepoFinderMount -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveRepoFinderMountMethod t RepoFinderMount, O.OverloadedMethod info RepoFinderMount p, R.HasField t RepoFinderMount p) => R.HasField t RepoFinderMount p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveRepoFinderMountMethod t RepoFinderMount, O.OverloadedMethodInfo info RepoFinderMount) => OL.IsLabel t (O.MethodProxy info RepoFinderMount) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif

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

-- | Get the value of the “@monitor@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' repoFinderMount #monitor
-- @
getRepoFinderMountMonitor :: (MonadIO m, IsRepoFinderMount o) => o -> m (Maybe Gio.VolumeMonitor.VolumeMonitor)
getRepoFinderMountMonitor :: forall (m :: * -> *) o.
(MonadIO m, IsRepoFinderMount o) =>
o -> m (Maybe VolumeMonitor)
getRepoFinderMountMonitor o
obj = forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO forall a b. (a -> b) -> a -> b
$ forall a b.
(GObject a, GObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
B.Properties.getObjectPropertyObject o
obj String
"monitor" ManagedPtr VolumeMonitor -> VolumeMonitor
Gio.VolumeMonitor.VolumeMonitor

-- | Construct a `GValueConstruct` with valid value for the “@monitor@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
constructRepoFinderMountMonitor :: (IsRepoFinderMount o, MIO.MonadIO m, Gio.VolumeMonitor.IsVolumeMonitor a) => a -> m (GValueConstruct o)
constructRepoFinderMountMonitor :: forall o (m :: * -> *) a.
(IsRepoFinderMount o, MonadIO m, IsVolumeMonitor a) =>
a -> m (GValueConstruct o)
constructRepoFinderMountMonitor a
val = forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO forall a b. (a -> b) -> a -> b
$ do
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO forall a b. (a -> b) -> a -> b
$ forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyObject String
"monitor" (forall a. a -> Maybe a
P.Just a
val)

#if defined(ENABLE_OVERLOADING)
data RepoFinderMountMonitorPropertyInfo
instance AttrInfo RepoFinderMountMonitorPropertyInfo where
    type AttrAllowedOps RepoFinderMountMonitorPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrBaseTypeConstraint RepoFinderMountMonitorPropertyInfo = IsRepoFinderMount
    type AttrSetTypeConstraint RepoFinderMountMonitorPropertyInfo = Gio.VolumeMonitor.IsVolumeMonitor
    type AttrTransferTypeConstraint RepoFinderMountMonitorPropertyInfo = Gio.VolumeMonitor.IsVolumeMonitor
    type AttrTransferType RepoFinderMountMonitorPropertyInfo = Gio.VolumeMonitor.VolumeMonitor
    type AttrGetType RepoFinderMountMonitorPropertyInfo = (Maybe Gio.VolumeMonitor.VolumeMonitor)
    type AttrLabel RepoFinderMountMonitorPropertyInfo = "monitor"
    type AttrOrigin RepoFinderMountMonitorPropertyInfo = RepoFinderMount
    attrGet = getRepoFinderMountMonitor
    attrSet = undefined
    attrTransfer _ v = do
        unsafeCastTo Gio.VolumeMonitor.VolumeMonitor v
    attrConstruct = constructRepoFinderMountMonitor
    attrClear = undefined
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.OSTree.Objects.RepoFinderMount.monitor"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-ostree-1.0.16/docs/GI-OSTree-Objects-RepoFinderMount.html#g:attr:monitor"
        })
#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList RepoFinderMount
type instance O.AttributeList RepoFinderMount = RepoFinderMountAttributeList
type RepoFinderMountAttributeList = ('[ '("monitor", RepoFinderMountMonitorPropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
repoFinderMountMonitor :: AttrLabelProxy "monitor"
repoFinderMountMonitor = AttrLabelProxy

#endif

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

#endif

-- method RepoFinderMount::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "monitor"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "VolumeMonitor" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "volume monitor to use, or %NULL to use\n   the system default"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "OSTree" , name = "RepoFinderMount" })
-- throws : False
-- Skip return : False

foreign import ccall "ostree_repo_finder_mount_new" ostree_repo_finder_mount_new :: 
    Ptr Gio.VolumeMonitor.VolumeMonitor ->  -- monitor : TInterface (Name {namespace = "Gio", name = "VolumeMonitor"})
    IO (Ptr RepoFinderMount)

-- | Create a new t'GI.OSTree.Objects.RepoFinderMount.RepoFinderMount', using the given /@monitor@/ to look up
-- volumes. If /@monitor@/ is 'P.Nothing', the monitor from 'GI.Gio.Objects.VolumeMonitor.volumeMonitorGet' will
-- be used.
-- 
-- /Since: 2018.6/
repoFinderMountNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.VolumeMonitor.IsVolumeMonitor a) =>
    Maybe (a)
    -- ^ /@monitor@/: volume monitor to use, or 'P.Nothing' to use
    --    the system default
    -> m RepoFinderMount
    -- ^ __Returns:__ a new t'GI.OSTree.Objects.RepoFinderMount.RepoFinderMount'
repoFinderMountNew :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsVolumeMonitor a) =>
Maybe a -> m RepoFinderMount
repoFinderMountNew Maybe a
monitor = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
    Ptr VolumeMonitor
maybeMonitor <- case Maybe a
monitor of
        Maybe a
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Ptr a
nullPtr
        Just a
jMonitor -> do
            Ptr VolumeMonitor
jMonitor' <- forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jMonitor
            forall (m :: * -> *) a. Monad m => a -> m a
return Ptr VolumeMonitor
jMonitor'
    Ptr RepoFinderMount
result <- Ptr VolumeMonitor -> IO (Ptr RepoFinderMount)
ostree_repo_finder_mount_new Ptr VolumeMonitor
maybeMonitor
    forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"repoFinderMountNew" Ptr RepoFinderMount
result
    RepoFinderMount
result' <- (forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr RepoFinderMount -> RepoFinderMount
RepoFinderMount) Ptr RepoFinderMount
result
    forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
monitor forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    forall (m :: * -> *) a. Monad m => a -> m a
return RepoFinderMount
result'

#if defined(ENABLE_OVERLOADING)
#endif