{-# 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.WebKit2WebExtension.Objects.WebEditor
    ( 

-- * Exported types
    WebEditor(..)                           ,
    IsWebEditor                             ,
    toWebEditor                             ,


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

#if defined(ENABLE_OVERLOADING)
    ResolveWebEditorMethod                  ,
#endif


-- ** getPage #method:getPage#

#if defined(ENABLE_OVERLOADING)
    WebEditorGetPageMethodInfo              ,
#endif
    webEditorGetPage                        ,




 -- * Signals
-- ** selectionChanged #signal:selectionChanged#

    C_WebEditorSelectionChangedCallback     ,
    WebEditorSelectionChangedCallback       ,
#if defined(ENABLE_OVERLOADING)
    WebEditorSelectionChangedSignalInfo     ,
#endif
    afterWebEditorSelectionChanged          ,
    genClosure_WebEditorSelectionChanged    ,
    mk_WebEditorSelectionChangedCallback    ,
    noWebEditorSelectionChangedCallback     ,
    onWebEditorSelectionChanged             ,
    wrap_WebEditorSelectionChangedCallback  ,




    ) 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.WebKit2WebExtension.Objects.WebPage as WebKit2WebExtension.WebPage

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

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

foreign import ccall "webkit_web_editor_get_type"
    c_webkit_web_editor_get_type :: IO B.Types.GType

instance B.Types.TypedObject WebEditor where
    glibType :: IO GType
glibType = IO GType
c_webkit_web_editor_get_type

instance B.Types.GObject WebEditor

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

-- | Type class for types which can be safely cast to `WebEditor`, for instance with `toWebEditor`.
class (SP.GObject o, O.IsDescendantOf WebEditor o) => IsWebEditor o
instance (SP.GObject o, O.IsDescendantOf WebEditor o) => IsWebEditor o

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

-- | Cast to `WebEditor`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toWebEditor :: (MonadIO m, IsWebEditor o) => o -> m WebEditor
toWebEditor :: o -> m WebEditor
toWebEditor = IO WebEditor -> m WebEditor
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO WebEditor -> m WebEditor)
-> (o -> IO WebEditor) -> o -> m WebEditor
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr WebEditor -> WebEditor) -> o -> IO WebEditor
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr WebEditor -> WebEditor
WebEditor

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

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

#endif

-- signal WebEditor::selection-changed
-- | This signal is emitted for every selection change inside a t'GI.WebKit2WebExtension.Objects.WebPage.WebPage'
-- as well as for every caret position change as the caret is a collapsed
-- selection.
-- 
-- /Since: 2.10/
type WebEditorSelectionChangedCallback =
    IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `WebEditorSelectionChangedCallback`@.
noWebEditorSelectionChangedCallback :: Maybe WebEditorSelectionChangedCallback
noWebEditorSelectionChangedCallback :: Maybe (IO ())
noWebEditorSelectionChangedCallback = Maybe (IO ())
forall a. Maybe a
Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_WebEditorSelectionChangedCallback =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_WebEditorSelectionChangedCallback`.
foreign import ccall "wrapper"
    mk_WebEditorSelectionChangedCallback :: C_WebEditorSelectionChangedCallback -> IO (FunPtr C_WebEditorSelectionChangedCallback)

-- | Wrap the callback into a `GClosure`.
genClosure_WebEditorSelectionChanged :: MonadIO m => WebEditorSelectionChangedCallback -> m (GClosure C_WebEditorSelectionChangedCallback)
genClosure_WebEditorSelectionChanged :: IO () -> m (GClosure C_WebEditorSelectionChangedCallback)
genClosure_WebEditorSelectionChanged IO ()
cb = IO (GClosure C_WebEditorSelectionChangedCallback)
-> m (GClosure C_WebEditorSelectionChangedCallback)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (GClosure C_WebEditorSelectionChangedCallback)
 -> m (GClosure C_WebEditorSelectionChangedCallback))
-> IO (GClosure C_WebEditorSelectionChangedCallback)
-> m (GClosure C_WebEditorSelectionChangedCallback)
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_WebEditorSelectionChangedCallback
cb' = IO () -> C_WebEditorSelectionChangedCallback
wrap_WebEditorSelectionChangedCallback IO ()
cb
    C_WebEditorSelectionChangedCallback
-> IO (FunPtr C_WebEditorSelectionChangedCallback)
mk_WebEditorSelectionChangedCallback C_WebEditorSelectionChangedCallback
cb' IO (FunPtr C_WebEditorSelectionChangedCallback)
-> (FunPtr C_WebEditorSelectionChangedCallback
    -> IO (GClosure C_WebEditorSelectionChangedCallback))
-> IO (GClosure C_WebEditorSelectionChangedCallback)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunPtr C_WebEditorSelectionChangedCallback
-> IO (GClosure C_WebEditorSelectionChangedCallback)
forall (m :: * -> *) a. MonadIO m => FunPtr a -> m (GClosure a)
B.GClosure.newGClosure


-- | Wrap a `WebEditorSelectionChangedCallback` into a `C_WebEditorSelectionChangedCallback`.
wrap_WebEditorSelectionChangedCallback ::
    WebEditorSelectionChangedCallback ->
    C_WebEditorSelectionChangedCallback
wrap_WebEditorSelectionChangedCallback :: IO () -> C_WebEditorSelectionChangedCallback
wrap_WebEditorSelectionChangedCallback IO ()
_cb Ptr ()
_ Ptr ()
_ = do
    IO ()
_cb 


-- | Connect a signal handler for the [selectionChanged](#signal:selectionChanged) signal, to be run before the default handler.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Signals.on' webEditor #selectionChanged callback
-- @
-- 
-- 
onWebEditorSelectionChanged :: (IsWebEditor a, MonadIO m) => a -> WebEditorSelectionChangedCallback -> m SignalHandlerId
onWebEditorSelectionChanged :: a -> IO () -> m SignalHandlerId
onWebEditorSelectionChanged a
obj IO ()
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_WebEditorSelectionChangedCallback
cb' = IO () -> C_WebEditorSelectionChangedCallback
wrap_WebEditorSelectionChangedCallback IO ()
cb
    FunPtr C_WebEditorSelectionChangedCallback
cb'' <- C_WebEditorSelectionChangedCallback
-> IO (FunPtr C_WebEditorSelectionChangedCallback)
mk_WebEditorSelectionChangedCallback C_WebEditorSelectionChangedCallback
cb'
    a
-> Text
-> FunPtr C_WebEditorSelectionChangedCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"selection-changed" FunPtr C_WebEditorSelectionChangedCallback
cb'' SignalConnectMode
SignalConnectBefore Maybe Text
forall a. Maybe a
Nothing

-- | Connect a signal handler for the [selectionChanged](#signal:selectionChanged) signal, to be run after the default handler.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Signals.after' webEditor #selectionChanged callback
-- @
-- 
-- 
afterWebEditorSelectionChanged :: (IsWebEditor a, MonadIO m) => a -> WebEditorSelectionChangedCallback -> m SignalHandlerId
afterWebEditorSelectionChanged :: a -> IO () -> m SignalHandlerId
afterWebEditorSelectionChanged a
obj IO ()
cb = IO SignalHandlerId -> m SignalHandlerId
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
    let cb' :: C_WebEditorSelectionChangedCallback
cb' = IO () -> C_WebEditorSelectionChangedCallback
wrap_WebEditorSelectionChangedCallback IO ()
cb
    FunPtr C_WebEditorSelectionChangedCallback
cb'' <- C_WebEditorSelectionChangedCallback
-> IO (FunPtr C_WebEditorSelectionChangedCallback)
mk_WebEditorSelectionChangedCallback C_WebEditorSelectionChangedCallback
cb'
    a
-> Text
-> FunPtr C_WebEditorSelectionChangedCallback
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
forall o a.
GObject o =>
o
-> Text
-> FunPtr a
-> SignalConnectMode
-> Maybe Text
-> IO SignalHandlerId
connectSignalFunPtr a
obj Text
"selection-changed" FunPtr C_WebEditorSelectionChangedCallback
cb'' SignalConnectMode
SignalConnectAfter Maybe Text
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
data WebEditorSelectionChangedSignalInfo
instance SignalInfo WebEditorSelectionChangedSignalInfo where
    type HaskellCallbackType WebEditorSelectionChangedSignalInfo = WebEditorSelectionChangedCallback
    connectSignal obj cb connectMode detail = do
        let cb' = wrap_WebEditorSelectionChangedCallback cb
        cb'' <- mk_WebEditorSelectionChangedCallback cb'
        connectSignalFunPtr obj "selection-changed" cb'' connectMode detail

#endif

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

#if defined(ENABLE_OVERLOADING)
#endif

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

#endif

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

foreign import ccall "webkit_web_editor_get_page" webkit_web_editor_get_page :: 
    Ptr WebEditor ->                        -- editor : TInterface (Name {namespace = "WebKit2WebExtension", name = "WebEditor"})
    IO (Ptr WebKit2WebExtension.WebPage.WebPage)

-- | Gets the t'GI.WebKit2WebExtension.Objects.WebPage.WebPage' that is associated with the t'GI.WebKit2WebExtension.Objects.WebEditor.WebEditor' that can
-- be used to access the t'GI.WebKit2WebExtension.Objects.DOMDocument.DOMDocument' currently loaded into it.
-- 
-- /Since: 2.10/
webEditorGetPage ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebEditor a) =>
    a
    -- ^ /@editor@/: a t'GI.WebKit2WebExtension.Objects.WebEditor.WebEditor'
    -> m WebKit2WebExtension.WebPage.WebPage
    -- ^ __Returns:__ the associated t'GI.WebKit2WebExtension.Objects.WebPage.WebPage'
webEditorGetPage :: a -> m WebPage
webEditorGetPage a
editor = IO WebPage -> m WebPage
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO WebPage -> m WebPage) -> IO WebPage -> m WebPage
forall a b. (a -> b) -> a -> b
$ do
    Ptr WebEditor
editor' <- a -> IO (Ptr WebEditor)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
editor
    Ptr WebPage
result <- Ptr WebEditor -> IO (Ptr WebPage)
webkit_web_editor_get_page Ptr WebEditor
editor'
    Text -> Ptr WebPage -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"webEditorGetPage" Ptr WebPage
result
    WebPage
result' <- ((ManagedPtr WebPage -> WebPage) -> Ptr WebPage -> IO WebPage
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr WebPage -> WebPage
WebKit2WebExtension.WebPage.WebPage) Ptr WebPage
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
editor
    WebPage -> IO WebPage
forall (m :: * -> *) a. Monad m => a -> m a
return WebPage
result'

#if defined(ENABLE_OVERLOADING)
data WebEditorGetPageMethodInfo
instance (signature ~ (m WebKit2WebExtension.WebPage.WebPage), MonadIO m, IsWebEditor a) => O.MethodInfo WebEditorGetPageMethodInfo a signature where
    overloadedMethod = webEditorGetPage

#endif