{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)

Opaque context structure for the plugin installation. Use the provided
API to set details on it.
-}

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

module GI.GstPbutils.Structs.InstallPluginsContext
    (

-- * Exported types
    InstallPluginsContext(..)               ,
    noInstallPluginsContext                 ,


 -- * Methods
-- ** copy #method:copy#

#if ENABLE_OVERLOADING
    InstallPluginsContextCopyMethodInfo     ,
#endif
    installPluginsContextCopy               ,


-- ** free #method:free#

#if ENABLE_OVERLOADING
    InstallPluginsContextFreeMethodInfo     ,
#endif
    installPluginsContextFree               ,


-- ** new #method:new#

    installPluginsContextNew                ,


-- ** setConfirmSearch #method:setConfirmSearch#

#if ENABLE_OVERLOADING
    InstallPluginsContextSetConfirmSearchMethodInfo,
#endif
    installPluginsContextSetConfirmSearch   ,


-- ** setDesktopId #method:setDesktopId#

#if ENABLE_OVERLOADING
    InstallPluginsContextSetDesktopIdMethodInfo,
#endif
    installPluginsContextSetDesktopId       ,


-- ** setStartupNotificationId #method:setStartupNotificationId#

#if ENABLE_OVERLOADING
    InstallPluginsContextSetStartupNotificationIdMethodInfo,
#endif
    installPluginsContextSetStartupNotificationId,


-- ** setXid #method:setXid#

#if ENABLE_OVERLOADING
    InstallPluginsContextSetXidMethodInfo   ,
#endif
    installPluginsContextSetXid             ,




    ) 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.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


-- | Memory-managed wrapper type.
newtype InstallPluginsContext = InstallPluginsContext (ManagedPtr InstallPluginsContext)
foreign import ccall "gst_install_plugins_context_get_type" c_gst_install_plugins_context_get_type ::
    IO GType

instance BoxedObject InstallPluginsContext where
    boxedType _ = c_gst_install_plugins_context_get_type

-- | A convenience alias for `Nothing` :: `Maybe` `InstallPluginsContext`.
noInstallPluginsContext :: Maybe InstallPluginsContext
noInstallPluginsContext = Nothing


#if ENABLE_OVERLOADING
instance O.HasAttributeList InstallPluginsContext
type instance O.AttributeList InstallPluginsContext = InstallPluginsContextAttributeList
type InstallPluginsContextAttributeList = ('[ ] :: [(Symbol, *)])
#endif

-- method InstallPluginsContext::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsContext"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_install_plugins_context_new" gst_install_plugins_context_new ::
    IO (Ptr InstallPluginsContext)

{- |
Creates a new 'GI.GstPbutils.Structs.InstallPluginsContext.InstallPluginsContext'.
-}
installPluginsContextNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m InstallPluginsContext
    {- ^ __Returns:__ a new 'GI.GstPbutils.Structs.InstallPluginsContext.InstallPluginsContext'. Free with
'GI.GstPbutils.Structs.InstallPluginsContext.installPluginsContextFree' when no longer needed -}
installPluginsContextNew  = liftIO $ do
    result <- gst_install_plugins_context_new
    checkUnexpectedReturnNULL "installPluginsContextNew" result
    result' <- (wrapBoxed InstallPluginsContext) result
    return result'

#if ENABLE_OVERLOADING
#endif

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

foreign import ccall "gst_install_plugins_context_copy" gst_install_plugins_context_copy ::
    Ptr InstallPluginsContext ->            -- ctx : TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsContext"})
    IO (Ptr InstallPluginsContext)

{- |
/No description available in the introspection data./
-}
installPluginsContextCopy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    InstallPluginsContext
    -> m InstallPluginsContext
installPluginsContextCopy ctx = liftIO $ do
    ctx' <- unsafeManagedPtrGetPtr ctx
    result <- gst_install_plugins_context_copy ctx'
    checkUnexpectedReturnNULL "installPluginsContextCopy" result
    result' <- (wrapBoxed InstallPluginsContext) result
    touchManagedPtr ctx
    return result'

#if ENABLE_OVERLOADING
data InstallPluginsContextCopyMethodInfo
instance (signature ~ (m InstallPluginsContext), MonadIO m) => O.MethodInfo InstallPluginsContextCopyMethodInfo InstallPluginsContext signature where
    overloadedMethod _ = installPluginsContextCopy

#endif

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

foreign import ccall "gst_install_plugins_context_free" gst_install_plugins_context_free ::
    Ptr InstallPluginsContext ->            -- ctx : TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsContext"})
    IO ()

{- |
Frees a 'GI.GstPbutils.Structs.InstallPluginsContext.InstallPluginsContext'.
-}
installPluginsContextFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    InstallPluginsContext
    {- ^ /@ctx@/: a 'GI.GstPbutils.Structs.InstallPluginsContext.InstallPluginsContext' -}
    -> m ()
installPluginsContextFree ctx = liftIO $ do
    ctx' <- unsafeManagedPtrGetPtr ctx
    gst_install_plugins_context_free ctx'
    touchManagedPtr ctx
    return ()

#if ENABLE_OVERLOADING
data InstallPluginsContextFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo InstallPluginsContextFreeMethodInfo InstallPluginsContext signature where
    overloadedMethod _ = installPluginsContextFree

#endif

-- method InstallPluginsContext::set_confirm_search
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "ctx", argType = TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstInstallPluginsContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "confirm_search", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether to ask for confirmation before searching for plugins", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_install_plugins_context_set_confirm_search" gst_install_plugins_context_set_confirm_search ::
    Ptr InstallPluginsContext ->            -- ctx : TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsContext"})
    CInt ->                                 -- confirm_search : TBasicType TBoolean
    IO ()

{- |
This function is used to tell the external installer process whether it
should ask for confirmation or not before searching for missing plugins.

If set, this option will be passed to the installer via a
--interaction=[show-confirm-search|hide-confirm-search] command line option.

/Since: 1.6/
-}
installPluginsContextSetConfirmSearch ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    InstallPluginsContext
    {- ^ /@ctx@/: a 'GI.GstPbutils.Structs.InstallPluginsContext.InstallPluginsContext' -}
    -> Bool
    {- ^ /@confirmSearch@/: whether to ask for confirmation before searching for plugins -}
    -> m ()
installPluginsContextSetConfirmSearch ctx confirmSearch = liftIO $ do
    ctx' <- unsafeManagedPtrGetPtr ctx
    let confirmSearch' = (fromIntegral . fromEnum) confirmSearch
    gst_install_plugins_context_set_confirm_search ctx' confirmSearch'
    touchManagedPtr ctx
    return ()

#if ENABLE_OVERLOADING
data InstallPluginsContextSetConfirmSearchMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m) => O.MethodInfo InstallPluginsContextSetConfirmSearchMethodInfo InstallPluginsContext signature where
    overloadedMethod _ = installPluginsContextSetConfirmSearch

#endif

-- method InstallPluginsContext::set_desktop_id
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "ctx", argType = TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstInstallPluginsContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "desktop_id", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the desktop file ID of the calling application", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_install_plugins_context_set_desktop_id" gst_install_plugins_context_set_desktop_id ::
    Ptr InstallPluginsContext ->            -- ctx : TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsContext"})
    CString ->                              -- desktop_id : TBasicType TUTF8
    IO ()

{- |
This function is used to pass the calling application\'s desktop file ID to
the external installer process.

A desktop file ID is the basename of the desktop file, including the
.desktop extension.

If set, the desktop file ID will be passed to the installer via a
--desktop-id= command line option.

/Since: 1.6/
-}
installPluginsContextSetDesktopId ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    InstallPluginsContext
    {- ^ /@ctx@/: a 'GI.GstPbutils.Structs.InstallPluginsContext.InstallPluginsContext' -}
    -> T.Text
    {- ^ /@desktopId@/: the desktop file ID of the calling application -}
    -> m ()
installPluginsContextSetDesktopId ctx desktopId = liftIO $ do
    ctx' <- unsafeManagedPtrGetPtr ctx
    desktopId' <- textToCString desktopId
    gst_install_plugins_context_set_desktop_id ctx' desktopId'
    touchManagedPtr ctx
    freeMem desktopId'
    return ()

#if ENABLE_OVERLOADING
data InstallPluginsContextSetDesktopIdMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m) => O.MethodInfo InstallPluginsContextSetDesktopIdMethodInfo InstallPluginsContext signature where
    overloadedMethod _ = installPluginsContextSetDesktopId

#endif

-- method InstallPluginsContext::set_startup_notification_id
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "ctx", argType = TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstInstallPluginsContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "startup_id", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the startup notification ID", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_install_plugins_context_set_startup_notification_id" gst_install_plugins_context_set_startup_notification_id ::
    Ptr InstallPluginsContext ->            -- ctx : TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsContext"})
    CString ->                              -- startup_id : TBasicType TUTF8
    IO ()

{- |
Sets the startup notification ID for the launched process.

This is typically used to to pass the current X11 event timestamp to the
external installer process.

Startup notification IDs are defined in the
<http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt FreeDesktop.Org Startup Notifications standard>.

If set, the ID will be passed to the installer via a
--startup-notification-id= command line option.

GTK+\/GNOME applications should be able to create a startup notification ID
like this:
>
>  timestamp = gtk_get_current_event_time ();
>  startup_id = g_strdup_printf ("_TIME%u", timestamp);
>...


/Since: 1.6/
-}
installPluginsContextSetStartupNotificationId ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    InstallPluginsContext
    {- ^ /@ctx@/: a 'GI.GstPbutils.Structs.InstallPluginsContext.InstallPluginsContext' -}
    -> T.Text
    {- ^ /@startupId@/: the startup notification ID -}
    -> m ()
installPluginsContextSetStartupNotificationId ctx startupId = liftIO $ do
    ctx' <- unsafeManagedPtrGetPtr ctx
    startupId' <- textToCString startupId
    gst_install_plugins_context_set_startup_notification_id ctx' startupId'
    touchManagedPtr ctx
    freeMem startupId'
    return ()

#if ENABLE_OVERLOADING
data InstallPluginsContextSetStartupNotificationIdMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m) => O.MethodInfo InstallPluginsContextSetStartupNotificationIdMethodInfo InstallPluginsContext signature where
    overloadedMethod _ = installPluginsContextSetStartupNotificationId

#endif

-- method InstallPluginsContext::set_xid
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "ctx", argType = TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsContext"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstInstallPluginsContext", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "xid", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the XWindow ID (XID) of the top-level application", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gst_install_plugins_context_set_xid" gst_install_plugins_context_set_xid ::
    Ptr InstallPluginsContext ->            -- ctx : TInterface (Name {namespace = "GstPbutils", name = "InstallPluginsContext"})
    Word32 ->                               -- xid : TBasicType TUInt
    IO ()

{- |
This function is for X11-based applications (such as most Gtk\/Qt
applications on linux\/unix) only. You can use it to tell the external
installer the XID of your main application window. That way the installer
can make its own window transient to your application window during the
installation.

If set, the XID will be passed to the installer via a --transient-for=XID
command line option.

Gtk+\/Gnome application should be able to obtain the XID of the top-level
window like this:
>
>##include &lt;gtk/gtk.h&gt;
>##ifdef GDK_WINDOWING_X11
>##include &lt;gdk/gdkx.h&gt;
>##endif
>...
>##ifdef GDK_WINDOWING_X11
>  xid = GDK_WINDOW_XWINDOW (GTK_WIDGET (application_window)-&gt;window);
>##endif
>...
-}
installPluginsContextSetXid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    InstallPluginsContext
    {- ^ /@ctx@/: a 'GI.GstPbutils.Structs.InstallPluginsContext.InstallPluginsContext' -}
    -> Word32
    {- ^ /@xid@/: the XWindow ID (XID) of the top-level application -}
    -> m ()
installPluginsContextSetXid ctx xid = liftIO $ do
    ctx' <- unsafeManagedPtrGetPtr ctx
    gst_install_plugins_context_set_xid ctx' xid
    touchManagedPtr ctx
    return ()

#if ENABLE_OVERLOADING
data InstallPluginsContextSetXidMethodInfo
instance (signature ~ (Word32 -> m ()), MonadIO m) => O.MethodInfo InstallPluginsContextSetXidMethodInfo InstallPluginsContext signature where
    overloadedMethod _ = installPluginsContextSetXid

#endif

#if ENABLE_OVERLOADING
type family ResolveInstallPluginsContextMethod (t :: Symbol) (o :: *) :: * where
    ResolveInstallPluginsContextMethod "copy" o = InstallPluginsContextCopyMethodInfo
    ResolveInstallPluginsContextMethod "free" o = InstallPluginsContextFreeMethodInfo
    ResolveInstallPluginsContextMethod "setConfirmSearch" o = InstallPluginsContextSetConfirmSearchMethodInfo
    ResolveInstallPluginsContextMethod "setDesktopId" o = InstallPluginsContextSetDesktopIdMethodInfo
    ResolveInstallPluginsContextMethod "setStartupNotificationId" o = InstallPluginsContextSetStartupNotificationIdMethodInfo
    ResolveInstallPluginsContextMethod "setXid" o = InstallPluginsContextSetXidMethodInfo
    ResolveInstallPluginsContextMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveInstallPluginsContextMethod t InstallPluginsContext, O.MethodInfo info InstallPluginsContext p) => OL.IsLabel t (InstallPluginsContext -> 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