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

'GI.Gio.Interfaces.DesktopAppInfoLookup.DesktopAppInfoLookup' is an opaque data structure and can only be accessed
using the following functions.
-}

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

module GI.Gio.Interfaces.DesktopAppInfoLookup
    (

-- * Exported types
    DesktopAppInfoLookup(..)                ,
    noDesktopAppInfoLookup                  ,
    IsDesktopAppInfoLookup                  ,
    toDesktopAppInfoLookup                  ,


 -- * Methods
-- ** getDefaultForUriScheme #method:getDefaultForUriScheme#

#if ENABLE_OVERLOADING
    DesktopAppInfoLookupGetDefaultForUriSchemeMethodInfo,
#endif
    desktopAppInfoLookupGetDefaultForUriScheme,




    ) 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

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AppInfo as Gio.AppInfo

-- interface DesktopAppInfoLookup 
-- | Memory-managed wrapper type.
newtype DesktopAppInfoLookup = DesktopAppInfoLookup (ManagedPtr DesktopAppInfoLookup)
-- | A convenience alias for `Nothing` :: `Maybe` `DesktopAppInfoLookup`.
noDesktopAppInfoLookup :: Maybe DesktopAppInfoLookup
noDesktopAppInfoLookup = Nothing

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

#endif

foreign import ccall "g_desktop_app_info_lookup_get_type"
    c_g_desktop_app_info_lookup_get_type :: IO GType

instance GObject DesktopAppInfoLookup where
    gobjectType = c_g_desktop_app_info_lookup_get_type


-- | Type class for types which can be safely cast to `DesktopAppInfoLookup`, for instance with `toDesktopAppInfoLookup`.
class (GObject o, O.IsDescendantOf DesktopAppInfoLookup o) => IsDesktopAppInfoLookup o
instance (GObject o, O.IsDescendantOf DesktopAppInfoLookup o) => IsDesktopAppInfoLookup o

instance O.HasParentTypes DesktopAppInfoLookup
type instance O.ParentTypes DesktopAppInfoLookup = '[GObject.Object.Object]

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

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

#if ENABLE_OVERLOADING
#endif

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

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

-- method DesktopAppInfoLookup::get_default_for_uri_scheme
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "lookup", argType = TInterface (Name {namespace = "Gio", name = "DesktopAppInfoLookup"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GDesktopAppInfoLookup", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "uri_scheme", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string containing a URI scheme.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "AppInfo"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_desktop_app_info_lookup_get_default_for_uri_scheme" g_desktop_app_info_lookup_get_default_for_uri_scheme ::
    Ptr DesktopAppInfoLookup ->             -- lookup : TInterface (Name {namespace = "Gio", name = "DesktopAppInfoLookup"})
    CString ->                              -- uri_scheme : TBasicType TUTF8
    IO (Ptr Gio.AppInfo.AppInfo)

{-# DEPRECATED desktopAppInfoLookupGetDefaultForUriScheme ["The 'GI.Gio.Interfaces.DesktopAppInfoLookup.DesktopAppInfoLookup' interface is deprecated and unused by gio."] #-}
{- |
Gets the default application for launching applications
using this URI scheme for a particular GDesktopAppInfoLookup
implementation.

The GDesktopAppInfoLookup interface and this function is used
to implement 'GI.Gio.Functions.appInfoGetDefaultForUriScheme' backends
in a GIO module. There is no reason for applications to use it
directly. Applications should use 'GI.Gio.Functions.appInfoGetDefaultForUriScheme'.
-}
desktopAppInfoLookupGetDefaultForUriScheme ::
    (B.CallStack.HasCallStack, MonadIO m, IsDesktopAppInfoLookup a) =>
    a
    {- ^ /@lookup@/: a 'GI.Gio.Interfaces.DesktopAppInfoLookup.DesktopAppInfoLookup' -}
    -> T.Text
    {- ^ /@uriScheme@/: a string containing a URI scheme. -}
    -> m Gio.AppInfo.AppInfo
    {- ^ __Returns:__ 'GI.Gio.Interfaces.AppInfo.AppInfo' for given /@uriScheme@/ or 'Nothing' on error. -}
desktopAppInfoLookupGetDefaultForUriScheme lookup uriScheme = liftIO $ do
    lookup' <- unsafeManagedPtrCastPtr lookup
    uriScheme' <- textToCString uriScheme
    result <- g_desktop_app_info_lookup_get_default_for_uri_scheme lookup' uriScheme'
    checkUnexpectedReturnNULL "desktopAppInfoLookupGetDefaultForUriScheme" result
    result' <- (wrapObject Gio.AppInfo.AppInfo) result
    touchManagedPtr lookup
    freeMem uriScheme'
    return result'

#if ENABLE_OVERLOADING
data DesktopAppInfoLookupGetDefaultForUriSchemeMethodInfo
instance (signature ~ (T.Text -> m Gio.AppInfo.AppInfo), MonadIO m, IsDesktopAppInfoLookup a) => O.MethodInfo DesktopAppInfoLookupGetDefaultForUriSchemeMethodInfo a signature where
    overloadedMethod _ = desktopAppInfoLookupGetDefaultForUriScheme

#endif