{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- This interface offers methods to query and manipulate parameter preset sets.
-- A preset is a bunch of property settings, together with meta data and a name.
-- The name of a preset serves as key for subsequent method calls to manipulate
-- single presets.
-- All instances of one type will share the list of presets. The list is created
-- on demand, if presets are not used, the list is not created.
-- 
-- The interface comes with a default implementation that serves most plugins.
-- Wrapper plugins will override most methods to implement support for the
-- native preset format of those wrapped plugins.
-- One method that is useful to be overridden is 'GI.Gst.Interfaces.Preset.presetGetPropertyNames'.
-- With that one can control which properties are saved and in which order.
-- When implementing support for read-only presets, one should set the vmethods
-- for 'GI.Gst.Interfaces.Preset.presetSavePreset' and 'GI.Gst.Interfaces.Preset.presetDeletePreset' to 'P.Nothing'.
-- Applications can use 'GI.Gst.Interfaces.Preset.presetIsEditable' to check for that.
-- 
-- The default implementation supports presets located in a system directory,
-- application specific directory and in the users home directory. When getting
-- a list of presets individual presets are read and overlaid in 1) system,
-- 2) application and 3) user order. Whenever an earlier entry is newer, the
-- later entries will be updated. Since 1.8 you can also provide extra paths
-- where to find presets through the GST_PRESET_PATH environment variable.
-- Presets found in those paths will be considered as \"app presets\".

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

module GI.Gst.Interfaces.Preset
    ( 

-- * Exported types
    Preset(..)                              ,
    IsPreset                                ,


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

#if defined(ENABLE_OVERLOADING)
    ResolvePresetMethod                     ,
#endif


-- ** deletePreset #method:deletePreset#

#if defined(ENABLE_OVERLOADING)
    PresetDeletePresetMethodInfo            ,
#endif
    presetDeletePreset                      ,


-- ** getAppDir #method:getAppDir#

    presetGetAppDir                         ,


-- ** getMeta #method:getMeta#

#if defined(ENABLE_OVERLOADING)
    PresetGetMetaMethodInfo                 ,
#endif
    presetGetMeta                           ,


-- ** getPresetNames #method:getPresetNames#

#if defined(ENABLE_OVERLOADING)
    PresetGetPresetNamesMethodInfo          ,
#endif
    presetGetPresetNames                    ,


-- ** getPropertyNames #method:getPropertyNames#

#if defined(ENABLE_OVERLOADING)
    PresetGetPropertyNamesMethodInfo        ,
#endif
    presetGetPropertyNames                  ,


-- ** isEditable #method:isEditable#

#if defined(ENABLE_OVERLOADING)
    PresetIsEditableMethodInfo              ,
#endif
    presetIsEditable                        ,


-- ** loadPreset #method:loadPreset#

#if defined(ENABLE_OVERLOADING)
    PresetLoadPresetMethodInfo              ,
#endif
    presetLoadPreset                        ,


-- ** renamePreset #method:renamePreset#

#if defined(ENABLE_OVERLOADING)
    PresetRenamePresetMethodInfo            ,
#endif
    presetRenamePreset                      ,


-- ** savePreset #method:savePreset#

#if defined(ENABLE_OVERLOADING)
    PresetSavePresetMethodInfo              ,
#endif
    presetSavePreset                        ,


-- ** setAppDir #method:setAppDir#

    presetSetAppDir                         ,


-- ** setMeta #method:setMeta#

#if defined(ENABLE_OVERLOADING)
    PresetSetMetaMethodInfo                 ,
#endif
    presetSetMeta                           ,




    ) 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.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 Control.Monad.IO.Class as MIO
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


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

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

-- | Type class for types which implement `Preset`.
class (ManagedPtrNewtype o, O.IsDescendantOf Preset o) => IsPreset o
instance (ManagedPtrNewtype o, O.IsDescendantOf Preset o) => IsPreset o
-- XXX Wrapping a foreign struct/union with no known destructor or size, leak?
instance BoxedPtr Preset where
    boxedPtrCopy :: Preset -> IO Preset
boxedPtrCopy = Preset -> IO Preset
forall (m :: * -> *) a. Monad m => a -> m a
return
    boxedPtrFree :: Preset -> IO ()
boxedPtrFree = \Preset
_x -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


#if defined(ENABLE_OVERLOADING)
type family ResolvePresetMethod (t :: Symbol) (o :: *) :: * where
    ResolvePresetMethod "deletePreset" o = PresetDeletePresetMethodInfo
    ResolvePresetMethod "isEditable" o = PresetIsEditableMethodInfo
    ResolvePresetMethod "loadPreset" o = PresetLoadPresetMethodInfo
    ResolvePresetMethod "renamePreset" o = PresetRenamePresetMethodInfo
    ResolvePresetMethod "savePreset" o = PresetSavePresetMethodInfo
    ResolvePresetMethod "getMeta" o = PresetGetMetaMethodInfo
    ResolvePresetMethod "getPresetNames" o = PresetGetPresetNamesMethodInfo
    ResolvePresetMethod "getPropertyNames" o = PresetGetPropertyNamesMethodInfo
    ResolvePresetMethod "setMeta" o = PresetSetMetaMethodInfo
    ResolvePresetMethod l o = O.MethodResolutionFailed l o

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

#endif

-- method Preset::delete_preset
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "preset"
--           , argType = TInterface Name { namespace = "Gst" , name = "Preset" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GObject that implements #GstPreset"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "preset name to remove"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_preset_delete_preset" gst_preset_delete_preset :: 
    Ptr Preset ->                           -- preset : TInterface (Name {namespace = "Gst", name = "Preset"})
    CString ->                              -- name : TBasicType TUTF8
    IO CInt

-- | Delete the given preset.
presetDeletePreset ::
    (B.CallStack.HasCallStack, MonadIO m, IsPreset a) =>
    a
    -- ^ /@preset@/: a t'GI.GObject.Objects.Object.Object' that implements t'GI.Gst.Interfaces.Preset.Preset'
    -> T.Text
    -- ^ /@name@/: preset name to remove
    -> m Bool
    -- ^ __Returns:__ 'P.True' for success, 'P.False' if e.g. there is no preset with that /@name@/
presetDeletePreset :: a -> Text -> m Bool
presetDeletePreset a
preset Text
name = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Preset
preset' <- a -> IO (Ptr Preset)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
preset
    CString
name' <- Text -> IO CString
textToCString Text
name
    CInt
result <- Ptr Preset -> CString -> IO CInt
gst_preset_delete_preset Ptr Preset
preset' CString
name'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
preset
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data PresetDeletePresetMethodInfo
instance (signature ~ (T.Text -> m Bool), MonadIO m, IsPreset a) => O.MethodInfo PresetDeletePresetMethodInfo a signature where
    overloadedMethod = presetDeletePreset

#endif

-- method Preset::get_meta
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "preset"
--           , argType = TInterface Name { namespace = "Gst" , name = "Preset" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GObject that implements #GstPreset"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "preset name" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "tag"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "meta data item name"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TBasicType TUTF8
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_preset_get_meta" gst_preset_get_meta :: 
    Ptr Preset ->                           -- preset : TInterface (Name {namespace = "Gst", name = "Preset"})
    CString ->                              -- name : TBasicType TUTF8
    CString ->                              -- tag : TBasicType TUTF8
    Ptr CString ->                          -- value : TBasicType TUTF8
    IO CInt

-- | Gets the /@value@/ for an existing meta data /@tag@/. Meta data /@tag@/ names can be
-- something like e.g. \"comment\". Returned values need to be released when done.
presetGetMeta ::
    (B.CallStack.HasCallStack, MonadIO m, IsPreset a) =>
    a
    -- ^ /@preset@/: a t'GI.GObject.Objects.Object.Object' that implements t'GI.Gst.Interfaces.Preset.Preset'
    -> T.Text
    -- ^ /@name@/: preset name
    -> T.Text
    -- ^ /@tag@/: meta data item name
    -> m ((Bool, T.Text))
    -- ^ __Returns:__ 'P.True' for success, 'P.False' if e.g. there is no preset with that /@name@/
    -- or no value for the given /@tag@/
presetGetMeta :: a -> Text -> Text -> m (Bool, Text)
presetGetMeta a
preset Text
name Text
tag = IO (Bool, Text) -> m (Bool, Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, Text) -> m (Bool, Text))
-> IO (Bool, Text) -> m (Bool, Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Preset
preset' <- a -> IO (Ptr Preset)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
preset
    CString
name' <- Text -> IO CString
textToCString Text
name
    CString
tag' <- Text -> IO CString
textToCString Text
tag
    Ptr CString
value <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr CString)
    CInt
result <- Ptr Preset -> CString -> CString -> Ptr CString -> IO CInt
gst_preset_get_meta Ptr Preset
preset' CString
name' CString
tag' Ptr CString
value
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString
value' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
value
    Text
value'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
value'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
value'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
preset
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
tag'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
value
    (Bool, Text) -> IO (Bool, Text)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', Text
value'')

#if defined(ENABLE_OVERLOADING)
data PresetGetMetaMethodInfo
instance (signature ~ (T.Text -> T.Text -> m ((Bool, T.Text))), MonadIO m, IsPreset a) => O.MethodInfo PresetGetMetaMethodInfo a signature where
    overloadedMethod = presetGetMeta

#endif

-- method Preset::get_preset_names
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "preset"
--           , argType = TInterface Name { namespace = "Gst" , name = "Preset" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GObject that implements #GstPreset"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "gst_preset_get_preset_names" gst_preset_get_preset_names :: 
    Ptr Preset ->                           -- preset : TInterface (Name {namespace = "Gst", name = "Preset"})
    IO (Ptr CString)

-- | Get a copy of preset names as a 'P.Nothing' terminated string array.
presetGetPresetNames ::
    (B.CallStack.HasCallStack, MonadIO m, IsPreset a) =>
    a
    -- ^ /@preset@/: a t'GI.GObject.Objects.Object.Object' that implements t'GI.Gst.Interfaces.Preset.Preset'
    -> m [T.Text]
    -- ^ __Returns:__ 
    --     list with names, use 'GI.GLib.Functions.strfreev' after usage.
presetGetPresetNames :: a -> m [Text]
presetGetPresetNames a
preset = IO [Text] -> m [Text]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Text] -> m [Text]) -> IO [Text] -> m [Text]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Preset
preset' <- a -> IO (Ptr Preset)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
preset
    Ptr CString
result <- Ptr Preset -> IO (Ptr CString)
gst_preset_get_preset_names Ptr Preset
preset'
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"presetGetPresetNames" Ptr CString
result
    [Text]
result' <- HasCallStack => Ptr CString -> IO [Text]
Ptr CString -> IO [Text]
unpackZeroTerminatedUTF8CArray Ptr CString
result
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
preset
    [Text] -> IO [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
result'

#if defined(ENABLE_OVERLOADING)
data PresetGetPresetNamesMethodInfo
instance (signature ~ (m [T.Text]), MonadIO m, IsPreset a) => O.MethodInfo PresetGetPresetNamesMethodInfo a signature where
    overloadedMethod = presetGetPresetNames

#endif

-- method Preset::get_property_names
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "preset"
--           , argType = TInterface Name { namespace = "Gst" , name = "Preset" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GObject that implements #GstPreset"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "gst_preset_get_property_names" gst_preset_get_property_names :: 
    Ptr Preset ->                           -- preset : TInterface (Name {namespace = "Gst", name = "Preset"})
    IO (Ptr CString)

-- | Get a the names of the GObject properties that can be used for presets.
presetGetPropertyNames ::
    (B.CallStack.HasCallStack, MonadIO m, IsPreset a) =>
    a
    -- ^ /@preset@/: a t'GI.GObject.Objects.Object.Object' that implements t'GI.Gst.Interfaces.Preset.Preset'
    -> m [T.Text]
    -- ^ __Returns:__ an
    --   array of property names which should be freed with 'GI.GLib.Functions.strfreev' after use.
presetGetPropertyNames :: a -> m [Text]
presetGetPropertyNames a
preset = IO [Text] -> m [Text]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Text] -> m [Text]) -> IO [Text] -> m [Text]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Preset
preset' <- a -> IO (Ptr Preset)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
preset
    Ptr CString
result <- Ptr Preset -> IO (Ptr CString)
gst_preset_get_property_names Ptr Preset
preset'
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"presetGetPropertyNames" Ptr CString
result
    [Text]
result' <- HasCallStack => Ptr CString -> IO [Text]
Ptr CString -> IO [Text]
unpackZeroTerminatedUTF8CArray Ptr CString
result
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
preset
    [Text] -> IO [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
result'

#if defined(ENABLE_OVERLOADING)
data PresetGetPropertyNamesMethodInfo
instance (signature ~ (m [T.Text]), MonadIO m, IsPreset a) => O.MethodInfo PresetGetPropertyNamesMethodInfo a signature where
    overloadedMethod = presetGetPropertyNames

#endif

-- method Preset::is_editable
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "preset"
--           , argType = TInterface Name { namespace = "Gst" , name = "Preset" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GObject that implements #GstPreset"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_preset_is_editable" gst_preset_is_editable :: 
    Ptr Preset ->                           -- preset : TInterface (Name {namespace = "Gst", name = "Preset"})
    IO CInt

-- | Check if one can add new presets, change existing ones and remove presets.
-- 
-- /Since: 1.6/
presetIsEditable ::
    (B.CallStack.HasCallStack, MonadIO m, IsPreset a) =>
    a
    -- ^ /@preset@/: a t'GI.GObject.Objects.Object.Object' that implements t'GI.Gst.Interfaces.Preset.Preset'
    -> m Bool
    -- ^ __Returns:__ 'P.True' if presets are editable or 'P.False' if they are static
presetIsEditable :: a -> m Bool
presetIsEditable a
preset = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Preset
preset' <- a -> IO (Ptr Preset)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
preset
    CInt
result <- Ptr Preset -> IO CInt
gst_preset_is_editable Ptr Preset
preset'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
preset
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data PresetIsEditableMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsPreset a) => O.MethodInfo PresetIsEditableMethodInfo a signature where
    overloadedMethod = presetIsEditable

#endif

-- method Preset::load_preset
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "preset"
--           , argType = TInterface Name { namespace = "Gst" , name = "Preset" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GObject that implements #GstPreset"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "preset name to load"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_preset_load_preset" gst_preset_load_preset :: 
    Ptr Preset ->                           -- preset : TInterface (Name {namespace = "Gst", name = "Preset"})
    CString ->                              -- name : TBasicType TUTF8
    IO CInt

-- | Load the given preset.
presetLoadPreset ::
    (B.CallStack.HasCallStack, MonadIO m, IsPreset a) =>
    a
    -- ^ /@preset@/: a t'GI.GObject.Objects.Object.Object' that implements t'GI.Gst.Interfaces.Preset.Preset'
    -> T.Text
    -- ^ /@name@/: preset name to load
    -> m Bool
    -- ^ __Returns:__ 'P.True' for success, 'P.False' if e.g. there is no preset with that /@name@/
presetLoadPreset :: a -> Text -> m Bool
presetLoadPreset a
preset Text
name = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Preset
preset' <- a -> IO (Ptr Preset)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
preset
    CString
name' <- Text -> IO CString
textToCString Text
name
    CInt
result <- Ptr Preset -> CString -> IO CInt
gst_preset_load_preset Ptr Preset
preset' CString
name'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
preset
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data PresetLoadPresetMethodInfo
instance (signature ~ (T.Text -> m Bool), MonadIO m, IsPreset a) => O.MethodInfo PresetLoadPresetMethodInfo a signature where
    overloadedMethod = presetLoadPreset

#endif

-- method Preset::rename_preset
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "preset"
--           , argType = TInterface Name { namespace = "Gst" , name = "Preset" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GObject that implements #GstPreset"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "old_name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "current preset name"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "new_name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "new preset name" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_preset_rename_preset" gst_preset_rename_preset :: 
    Ptr Preset ->                           -- preset : TInterface (Name {namespace = "Gst", name = "Preset"})
    CString ->                              -- old_name : TBasicType TUTF8
    CString ->                              -- new_name : TBasicType TUTF8
    IO CInt

-- | Renames a preset. If there is already a preset by the /@newName@/ it will be
-- overwritten.
presetRenamePreset ::
    (B.CallStack.HasCallStack, MonadIO m, IsPreset a) =>
    a
    -- ^ /@preset@/: a t'GI.GObject.Objects.Object.Object' that implements t'GI.Gst.Interfaces.Preset.Preset'
    -> T.Text
    -- ^ /@oldName@/: current preset name
    -> T.Text
    -- ^ /@newName@/: new preset name
    -> m Bool
    -- ^ __Returns:__ 'P.True' for success, 'P.False' if e.g. there is no preset with /@oldName@/
presetRenamePreset :: a -> Text -> Text -> m Bool
presetRenamePreset a
preset Text
oldName Text
newName = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Preset
preset' <- a -> IO (Ptr Preset)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
preset
    CString
oldName' <- Text -> IO CString
textToCString Text
oldName
    CString
newName' <- Text -> IO CString
textToCString Text
newName
    CInt
result <- Ptr Preset -> CString -> CString -> IO CInt
gst_preset_rename_preset Ptr Preset
preset' CString
oldName' CString
newName'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
preset
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
oldName'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
newName'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data PresetRenamePresetMethodInfo
instance (signature ~ (T.Text -> T.Text -> m Bool), MonadIO m, IsPreset a) => O.MethodInfo PresetRenamePresetMethodInfo a signature where
    overloadedMethod = presetRenamePreset

#endif

-- method Preset::save_preset
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "preset"
--           , argType = TInterface Name { namespace = "Gst" , name = "Preset" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GObject that implements #GstPreset"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "preset name to save"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_preset_save_preset" gst_preset_save_preset :: 
    Ptr Preset ->                           -- preset : TInterface (Name {namespace = "Gst", name = "Preset"})
    CString ->                              -- name : TBasicType TUTF8
    IO CInt

-- | Save the current object settings as a preset under the given name. If there
-- is already a preset by this /@name@/ it will be overwritten.
presetSavePreset ::
    (B.CallStack.HasCallStack, MonadIO m, IsPreset a) =>
    a
    -- ^ /@preset@/: a t'GI.GObject.Objects.Object.Object' that implements t'GI.Gst.Interfaces.Preset.Preset'
    -> T.Text
    -- ^ /@name@/: preset name to save
    -> m Bool
    -- ^ __Returns:__ 'P.True' for success, 'P.False'
presetSavePreset :: a -> Text -> m Bool
presetSavePreset a
preset Text
name = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Preset
preset' <- a -> IO (Ptr Preset)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
preset
    CString
name' <- Text -> IO CString
textToCString Text
name
    CInt
result <- Ptr Preset -> CString -> IO CInt
gst_preset_save_preset Ptr Preset
preset' CString
name'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
preset
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data PresetSavePresetMethodInfo
instance (signature ~ (T.Text -> m Bool), MonadIO m, IsPreset a) => O.MethodInfo PresetSavePresetMethodInfo a signature where
    overloadedMethod = presetSavePreset

#endif

-- method Preset::set_meta
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "preset"
--           , argType = TInterface Name { namespace = "Gst" , name = "Preset" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GObject that implements #GstPreset"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "preset name" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "tag"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "meta data item name"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "new value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_preset_set_meta" gst_preset_set_meta :: 
    Ptr Preset ->                           -- preset : TInterface (Name {namespace = "Gst", name = "Preset"})
    CString ->                              -- name : TBasicType TUTF8
    CString ->                              -- tag : TBasicType TUTF8
    CString ->                              -- value : TBasicType TUTF8
    IO CInt

-- | Sets a new /@value@/ for an existing meta data item or adds a new item. Meta
-- data /@tag@/ names can be something like e.g. \"comment\". Supplying 'P.Nothing' for the
-- /@value@/ will unset an existing value.
presetSetMeta ::
    (B.CallStack.HasCallStack, MonadIO m, IsPreset a) =>
    a
    -- ^ /@preset@/: a t'GI.GObject.Objects.Object.Object' that implements t'GI.Gst.Interfaces.Preset.Preset'
    -> T.Text
    -- ^ /@name@/: preset name
    -> T.Text
    -- ^ /@tag@/: meta data item name
    -> Maybe (T.Text)
    -- ^ /@value@/: new value
    -> m Bool
    -- ^ __Returns:__ 'P.True' for success, 'P.False' if e.g. there is no preset with that /@name@/
presetSetMeta :: a -> Text -> Text -> Maybe Text -> m Bool
presetSetMeta a
preset Text
name Text
tag Maybe Text
value = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Preset
preset' <- a -> IO (Ptr Preset)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
preset
    CString
name' <- Text -> IO CString
textToCString Text
name
    CString
tag' <- Text -> IO CString
textToCString Text
tag
    CString
maybeValue <- case Maybe Text
value of
        Maybe Text
Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just Text
jValue -> do
            CString
jValue' <- Text -> IO CString
textToCString Text
jValue
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jValue'
    CInt
result <- Ptr Preset -> CString -> CString -> CString -> IO CInt
gst_preset_set_meta Ptr Preset
preset' CString
name' CString
tag' CString
maybeValue
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
preset
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
tag'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeValue
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
data PresetSetMetaMethodInfo
instance (signature ~ (T.Text -> T.Text -> Maybe (T.Text) -> m Bool), MonadIO m, IsPreset a) => O.MethodInfo PresetSetMetaMethodInfo a signature where
    overloadedMethod = presetSetMeta

#endif

-- method Preset::get_app_dir
-- method type : MemberFunction
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TFileName)
-- throws : False
-- Skip return : False

foreign import ccall "gst_preset_get_app_dir" gst_preset_get_app_dir :: 
    IO CString

-- | Gets the directory for application specific presets if set by the
-- application.
presetGetAppDir ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m (Maybe [Char])
    -- ^ __Returns:__ the directory or 'P.Nothing', don\'t free or modify
    -- the string
presetGetAppDir :: m (Maybe [Char])
presetGetAppDir  = IO (Maybe [Char]) -> m (Maybe [Char])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe [Char]) -> m (Maybe [Char]))
-> IO (Maybe [Char]) -> m (Maybe [Char])
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
gst_preset_get_app_dir
    Maybe [Char]
maybeResult <- CString -> (CString -> IO [Char]) -> IO (Maybe [Char])
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO [Char]) -> IO (Maybe [Char]))
-> (CString -> IO [Char]) -> IO (Maybe [Char])
forall a b. (a -> b) -> a -> b
$ \CString
result' -> do
        [Char]
result'' <- HasCallStack => CString -> IO [Char]
CString -> IO [Char]
cstringToString CString
result'
        [Char] -> IO [Char]
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
result''
    Maybe [Char] -> IO (Maybe [Char])
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe [Char]
maybeResult

#if defined(ENABLE_OVERLOADING)
#endif

-- method Preset::set_app_dir
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "app_dir"
--           , argType = TBasicType TFileName
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the application specific preset dir"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gst_preset_set_app_dir" gst_preset_set_app_dir :: 
    CString ->                              -- app_dir : TBasicType TFileName
    IO CInt

-- | Sets an extra directory as an absolute path that should be considered when
-- looking for presets. Any presets in the application dir will shadow the
-- system presets.
presetSetAppDir ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Char]
    -- ^ /@appDir@/: the application specific preset dir
    -> m Bool
    -- ^ __Returns:__ 'P.True' for success, 'P.False' if the dir already has been set
presetSetAppDir :: [Char] -> m Bool
presetSetAppDir [Char]
appDir = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
appDir' <- [Char] -> IO CString
stringToCString [Char]
appDir
    CInt
result <- CString -> IO CInt
gst_preset_set_app_dir CString
appDir'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
appDir'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList Preset = PresetSignalList
type PresetSignalList = ('[ ] :: [(Symbol, *)])

#endif