{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- 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                       ,
    noRepoFinderMount                       ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#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.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
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.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
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 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 (ManagedPtr RepoFinderMount)
    deriving (RepoFinderMount -> RepoFinderMount -> Bool
(RepoFinderMount -> RepoFinderMount -> Bool)
-> (RepoFinderMount -> RepoFinderMount -> Bool)
-> Eq RepoFinderMount
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)
foreign import ccall "ostree_repo_finder_mount_get_type"
    c_ostree_repo_finder_mount_get_type :: IO GType

instance GObject RepoFinderMount where
    gobjectType :: IO GType
gobjectType = IO GType
c_ostree_repo_finder_mount_get_type
    

-- | Convert 'RepoFinderMount' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue RepoFinderMount where
    toGValue :: RepoFinderMount -> IO GValue
toGValue o :: RepoFinderMount
o = do
        GType
gtype <- IO GType
c_ostree_repo_finder_mount_get_type
        RepoFinderMount -> (Ptr RepoFinderMount -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr RepoFinderMount
o (GType
-> (GValue -> Ptr RepoFinderMount -> IO ())
-> Ptr RepoFinderMount
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr RepoFinderMount -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO RepoFinderMount
fromGValue gv :: GValue
gv = do
        Ptr RepoFinderMount
ptr <- GValue -> IO (Ptr RepoFinderMount)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr RepoFinderMount)
        (ManagedPtr RepoFinderMount -> RepoFinderMount)
-> Ptr RepoFinderMount -> IO RepoFinderMount
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
        
    

-- | Type class for types which can be safely cast to `RepoFinderMount`, for instance with `toRepoFinderMount`.
class (GObject o, O.IsDescendantOf RepoFinderMount o) => IsRepoFinderMount o
instance (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 :: (MonadIO m, IsRepoFinderMount o) => o -> m RepoFinderMount
toRepoFinderMount :: o -> m RepoFinderMount
toRepoFinderMount = IO RepoFinderMount -> m RepoFinderMount
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO RepoFinderMount -> m RepoFinderMount)
-> (o -> IO RepoFinderMount) -> o -> m RepoFinderMount
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr RepoFinderMount -> RepoFinderMount)
-> o -> IO RepoFinderMount
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr RepoFinderMount -> RepoFinderMount
RepoFinderMount

-- | A convenience alias for `Nothing` :: `Maybe` `RepoFinderMount`.
noRepoFinderMount :: Maybe RepoFinderMount
noRepoFinderMount :: Maybe RepoFinderMount
noRepoFinderMount = Maybe RepoFinderMount
forall a. Maybe a
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.MethodInfo 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

#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 :: o -> m (Maybe VolumeMonitor)
getRepoFinderMountMonitor obj :: o
obj = IO (Maybe VolumeMonitor) -> m (Maybe VolumeMonitor)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe VolumeMonitor) -> m (Maybe VolumeMonitor))
-> IO (Maybe VolumeMonitor) -> m (Maybe VolumeMonitor)
forall a b. (a -> b) -> a -> b
$ o
-> String
-> (ManagedPtr VolumeMonitor -> VolumeMonitor)
-> IO (Maybe VolumeMonitor)
forall a b.
(GObject a, GObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
B.Properties.getObjectPropertyObject o
obj "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, Gio.VolumeMonitor.IsVolumeMonitor a) => a -> IO (GValueConstruct o)
constructRepoFinderMountMonitor :: a -> IO (GValueConstruct o)
constructRepoFinderMountMonitor val :: a
val = String -> Maybe a -> IO (GValueConstruct o)
forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyObject "monitor" (a -> Maybe a
forall a. a -> Maybe a
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
#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 :: Maybe a -> m RepoFinderMount
repoFinderMountNew monitor :: Maybe a
monitor = IO RepoFinderMount -> m RepoFinderMount
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO RepoFinderMount -> m RepoFinderMount)
-> IO RepoFinderMount -> m RepoFinderMount
forall a b. (a -> b) -> a -> b
$ do
    Ptr VolumeMonitor
maybeMonitor <- case Maybe a
monitor of
        Nothing -> Ptr VolumeMonitor -> IO (Ptr VolumeMonitor)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr VolumeMonitor
forall a. Ptr a
nullPtr
        Just jMonitor :: a
jMonitor -> do
            Ptr VolumeMonitor
jMonitor' <- a -> IO (Ptr VolumeMonitor)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jMonitor
            Ptr VolumeMonitor -> IO (Ptr VolumeMonitor)
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
    Text -> Ptr RepoFinderMount -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "repoFinderMountNew" Ptr RepoFinderMount
result
    RepoFinderMount
result' <- ((ManagedPtr RepoFinderMount -> RepoFinderMount)
-> Ptr RepoFinderMount -> IO RepoFinderMount
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr RepoFinderMount -> RepoFinderMount
RepoFinderMount) Ptr RepoFinderMount
result
    Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
monitor a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    RepoFinderMount -> IO RepoFinderMount
forall (m :: * -> *) a. Monad m => a -> m a
return RepoFinderMount
result'

#if defined(ENABLE_OVERLOADING)
#endif