module GI.WebKit2.Objects.FaviconDatabase
(
FaviconDatabase(..) ,
FaviconDatabaseK ,
toFaviconDatabase ,
noFaviconDatabase ,
faviconDatabaseClear ,
faviconDatabaseGetFavicon ,
faviconDatabaseGetFaviconFinish ,
faviconDatabaseGetFaviconUri ,
FaviconDatabaseFaviconChangedCallback ,
FaviconDatabaseFaviconChangedCallbackC ,
FaviconDatabaseFaviconChangedSignalInfo ,
afterFaviconDatabaseFaviconChanged ,
faviconDatabaseFaviconChangedCallbackWrapper,
faviconDatabaseFaviconChangedClosure ,
mkFaviconDatabaseFaviconChangedCallback ,
noFaviconDatabaseFaviconChangedCallback ,
onFaviconDatabaseFaviconChanged ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.WebKit2.Types
import GI.WebKit2.Callbacks
import qualified GI.GObject as GObject
import qualified GI.Gio as Gio
import qualified GI.Cairo as Cairo
newtype FaviconDatabase = FaviconDatabase (ForeignPtr FaviconDatabase)
foreign import ccall "webkit_favicon_database_get_type"
c_webkit_favicon_database_get_type :: IO GType
type instance ParentTypes FaviconDatabase = FaviconDatabaseParentTypes
type FaviconDatabaseParentTypes = '[GObject.Object]
instance GObject FaviconDatabase where
gobjectIsInitiallyUnowned _ = False
gobjectType _ = c_webkit_favicon_database_get_type
class GObject o => FaviconDatabaseK o
instance (GObject o, IsDescendantOf FaviconDatabase o) => FaviconDatabaseK o
toFaviconDatabase :: FaviconDatabaseK o => o -> IO FaviconDatabase
toFaviconDatabase = unsafeCastTo FaviconDatabase
noFaviconDatabase :: Maybe FaviconDatabase
noFaviconDatabase = Nothing
type FaviconDatabaseFaviconChangedCallback =
T.Text ->
T.Text ->
IO ()
noFaviconDatabaseFaviconChangedCallback :: Maybe FaviconDatabaseFaviconChangedCallback
noFaviconDatabaseFaviconChangedCallback = Nothing
type FaviconDatabaseFaviconChangedCallbackC =
Ptr () ->
CString ->
CString ->
Ptr () ->
IO ()
foreign import ccall "wrapper"
mkFaviconDatabaseFaviconChangedCallback :: FaviconDatabaseFaviconChangedCallbackC -> IO (FunPtr FaviconDatabaseFaviconChangedCallbackC)
faviconDatabaseFaviconChangedClosure :: FaviconDatabaseFaviconChangedCallback -> IO Closure
faviconDatabaseFaviconChangedClosure cb = newCClosure =<< mkFaviconDatabaseFaviconChangedCallback wrapped
where wrapped = faviconDatabaseFaviconChangedCallbackWrapper cb
faviconDatabaseFaviconChangedCallbackWrapper ::
FaviconDatabaseFaviconChangedCallback ->
Ptr () ->
CString ->
CString ->
Ptr () ->
IO ()
faviconDatabaseFaviconChangedCallbackWrapper _cb _ page_uri favicon_uri _ = do
page_uri' <- cstringToText page_uri
favicon_uri' <- cstringToText favicon_uri
_cb page_uri' favicon_uri'
onFaviconDatabaseFaviconChanged :: (GObject a, MonadIO m) => a -> FaviconDatabaseFaviconChangedCallback -> m SignalHandlerId
onFaviconDatabaseFaviconChanged obj cb = liftIO $ connectFaviconDatabaseFaviconChanged obj cb SignalConnectBefore
afterFaviconDatabaseFaviconChanged :: (GObject a, MonadIO m) => a -> FaviconDatabaseFaviconChangedCallback -> m SignalHandlerId
afterFaviconDatabaseFaviconChanged obj cb = connectFaviconDatabaseFaviconChanged obj cb SignalConnectAfter
connectFaviconDatabaseFaviconChanged :: (GObject a, MonadIO m) =>
a -> FaviconDatabaseFaviconChangedCallback -> SignalConnectMode -> m SignalHandlerId
connectFaviconDatabaseFaviconChanged obj cb after = liftIO $ do
cb' <- mkFaviconDatabaseFaviconChangedCallback (faviconDatabaseFaviconChangedCallbackWrapper cb)
connectSignalFunPtr obj "favicon-changed" cb' after
type instance AttributeList FaviconDatabase = FaviconDatabaseAttributeList
type FaviconDatabaseAttributeList = ('[ ] :: [(Symbol, *)])
data FaviconDatabaseFaviconChangedSignalInfo
instance SignalInfo FaviconDatabaseFaviconChangedSignalInfo where
type HaskellCallbackType FaviconDatabaseFaviconChangedSignalInfo = FaviconDatabaseFaviconChangedCallback
connectSignal _ = connectFaviconDatabaseFaviconChanged
type instance SignalList FaviconDatabase = FaviconDatabaseSignalList
type FaviconDatabaseSignalList = ('[ '("favicon-changed", FaviconDatabaseFaviconChangedSignalInfo), '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])
foreign import ccall "webkit_favicon_database_clear" webkit_favicon_database_clear ::
Ptr FaviconDatabase ->
IO ()
faviconDatabaseClear ::
(MonadIO m, FaviconDatabaseK a) =>
a ->
m ()
faviconDatabaseClear _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
webkit_favicon_database_clear _obj'
touchManagedPtr _obj
return ()
foreign import ccall "webkit_favicon_database_get_favicon" webkit_favicon_database_get_favicon ::
Ptr FaviconDatabase ->
CString ->
Ptr Gio.Cancellable ->
FunPtr Gio.AsyncReadyCallbackC ->
Ptr () ->
IO ()
faviconDatabaseGetFavicon ::
(MonadIO m, FaviconDatabaseK a, Gio.CancellableK b) =>
a ->
T.Text ->
Maybe (b) ->
Maybe (Gio.AsyncReadyCallback) ->
m ()
faviconDatabaseGetFavicon _obj page_uri cancellable callback = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
page_uri' <- textToCString page_uri
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
let jCancellable' = unsafeManagedPtrCastPtr jCancellable
return jCancellable'
ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.AsyncReadyCallbackC))
maybeCallback <- case callback of
Nothing -> return (castPtrToFunPtr nullPtr)
Just jCallback -> do
jCallback' <- Gio.mkAsyncReadyCallback (Gio.asyncReadyCallbackWrapper (Just ptrcallback) jCallback)
poke ptrcallback jCallback'
return jCallback'
let user_data = nullPtr
webkit_favicon_database_get_favicon _obj' page_uri' maybeCancellable maybeCallback user_data
touchManagedPtr _obj
whenJust cancellable touchManagedPtr
freeMem page_uri'
return ()
foreign import ccall "webkit_favicon_database_get_favicon_finish" webkit_favicon_database_get_favicon_finish ::
Ptr FaviconDatabase ->
Ptr Gio.AsyncResult ->
Ptr (Ptr GError) ->
IO (Ptr Cairo.Surface)
faviconDatabaseGetFaviconFinish ::
(MonadIO m, FaviconDatabaseK a, Gio.AsyncResultK b) =>
a ->
b ->
m Cairo.Surface
faviconDatabaseGetFaviconFinish _obj result_ = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
let result_' = unsafeManagedPtrCastPtr result_
onException (do
result <- propagateGError $ webkit_favicon_database_get_favicon_finish _obj' result_'
checkUnexpectedReturnNULL "webkit_favicon_database_get_favicon_finish" result
result' <- (wrapBoxed Cairo.Surface) result
touchManagedPtr _obj
touchManagedPtr result_
return result'
) (do
return ()
)
foreign import ccall "webkit_favicon_database_get_favicon_uri" webkit_favicon_database_get_favicon_uri ::
Ptr FaviconDatabase ->
CString ->
IO CString
faviconDatabaseGetFaviconUri ::
(MonadIO m, FaviconDatabaseK a) =>
a ->
T.Text ->
m T.Text
faviconDatabaseGetFaviconUri _obj page_uri = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
page_uri' <- textToCString page_uri
result <- webkit_favicon_database_get_favicon_uri _obj' page_uri'
checkUnexpectedReturnNULL "webkit_favicon_database_get_favicon_uri" result
result' <- cstringToText result
freeMem result
touchManagedPtr _obj
freeMem page_uri'
return result'