{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- t'GI.Gio.Interfaces.DesktopAppInfoLookup.DesktopAppInfoLookup' is an opaque data structure and can only be accessed
-- using the following functions.

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

module GI.Gio.Interfaces.DesktopAppInfoLookup
    ( 

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


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

#if defined(ENABLE_OVERLOADING)
    ResolveDesktopAppInfoLookupMethod       ,
#endif


-- ** getDefaultForUriScheme #method:getDefaultForUriScheme#

#if defined(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.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

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.
{-# DEPRECATED DesktopAppInfoLookup ["(Since version 2.28)","The t'GI.Gio.Interfaces.DesktopAppInfoLookup.DesktopAppInfoLookup' interface is deprecated and","   unused by GIO."] #-}
newtype DesktopAppInfoLookup = DesktopAppInfoLookup (SP.ManagedPtr DesktopAppInfoLookup)
    deriving (DesktopAppInfoLookup -> DesktopAppInfoLookup -> Bool
(DesktopAppInfoLookup -> DesktopAppInfoLookup -> Bool)
-> (DesktopAppInfoLookup -> DesktopAppInfoLookup -> Bool)
-> Eq DesktopAppInfoLookup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DesktopAppInfoLookup -> DesktopAppInfoLookup -> Bool
$c/= :: DesktopAppInfoLookup -> DesktopAppInfoLookup -> Bool
== :: DesktopAppInfoLookup -> DesktopAppInfoLookup -> Bool
$c== :: DesktopAppInfoLookup -> DesktopAppInfoLookup -> Bool
Eq)

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

foreign import ccall "g_desktop_app_info_lookup_get_type"
    c_g_desktop_app_info_lookup_get_type :: IO B.Types.GType

instance B.Types.TypedObject DesktopAppInfoLookup where
    glibType :: IO GType
glibType = IO GType
c_g_desktop_app_info_lookup_get_type

instance B.Types.GObject DesktopAppInfoLookup

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

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

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

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(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 @info
#else
    fromLabel _ = O.overloadedMethod @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 ["(Since version 2.28)","The t'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 t'GI.Gio.Interfaces.DesktopAppInfoLookup.DesktopAppInfoLookup'
-- implementation.
-- 
-- The t'GI.Gio.Interfaces.DesktopAppInfoLookup.DesktopAppInfoLookup' 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 t'GI.Gio.Interfaces.DesktopAppInfoLookup.DesktopAppInfoLookup'
    -> T.Text
    -- ^ /@uriScheme@/: a string containing a URI scheme.
    -> m Gio.AppInfo.AppInfo
    -- ^ __Returns:__ t'GI.Gio.Interfaces.AppInfo.AppInfo' for given /@uriScheme@/ or 'P.Nothing' on error.
desktopAppInfoLookupGetDefaultForUriScheme :: a -> Text -> m AppInfo
desktopAppInfoLookupGetDefaultForUriScheme a
lookup Text
uriScheme = IO AppInfo -> m AppInfo
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO AppInfo -> m AppInfo) -> IO AppInfo -> m AppInfo
forall a b. (a -> b) -> a -> b
$ do
    Ptr DesktopAppInfoLookup
lookup' <- a -> IO (Ptr DesktopAppInfoLookup)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
lookup
    CString
uriScheme' <- Text -> IO CString
textToCString Text
uriScheme
    Ptr AppInfo
result <- Ptr DesktopAppInfoLookup -> CString -> IO (Ptr AppInfo)
g_desktop_app_info_lookup_get_default_for_uri_scheme Ptr DesktopAppInfoLookup
lookup' CString
uriScheme'
    Text -> Ptr AppInfo -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"desktopAppInfoLookupGetDefaultForUriScheme" Ptr AppInfo
result
    AppInfo
result' <- ((ManagedPtr AppInfo -> AppInfo) -> Ptr AppInfo -> IO AppInfo
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr AppInfo -> AppInfo
Gio.AppInfo.AppInfo) Ptr AppInfo
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
lookup
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
uriScheme'
    AppInfo -> IO AppInfo
forall (m :: * -> *) a. Monad m => a -> m a
return AppInfo
result'

#if defined(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

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

#endif