{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) /No description available in the introspection data./ -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.WebKit2.Structs.UserStyleSheet ( -- * Exported types UserStyleSheet(..) , noUserStyleSheet , -- * Methods -- ** new #method:new# userStyleSheetNew , -- ** newForWorld #method:newForWorld# userStyleSheetNewForWorld , -- ** ref #method:ref# #if ENABLE_OVERLOADING UserStyleSheetRefMethodInfo , #endif userStyleSheetRef , -- ** unref #method:unref# #if ENABLE_OVERLOADING UserStyleSheetUnrefMethodInfo , #endif userStyleSheetUnref , ) 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 {-# SOURCE #-} qualified GI.WebKit2.Enums as WebKit2.Enums -- | Memory-managed wrapper type. newtype UserStyleSheet = UserStyleSheet (ManagedPtr UserStyleSheet) foreign import ccall "webkit_user_style_sheet_get_type" c_webkit_user_style_sheet_get_type :: IO GType instance BoxedObject UserStyleSheet where boxedType _ = c_webkit_user_style_sheet_get_type -- | A convenience alias for `Nothing` :: `Maybe` `UserStyleSheet`. noUserStyleSheet :: Maybe UserStyleSheet noUserStyleSheet = Nothing #if ENABLE_OVERLOADING instance O.HasAttributeList UserStyleSheet type instance O.AttributeList UserStyleSheet = UserStyleSheetAttributeList type UserStyleSheetAttributeList = ('[ ] :: [(Symbol, *)]) #endif -- method UserStyleSheet::new -- method type : Constructor -- Args : [Arg {argCName = "source", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Source code of the user style sheet.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "injected_frames", argType = TInterface (Name {namespace = "WebKit2", name = "UserContentInjectedFrames"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitUserContentInjectedFrames value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "level", argType = TInterface (Name {namespace = "WebKit2", name = "UserStyleLevel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitUserStyleLevel", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "whitelist", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A whitelist of URI patterns or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "blacklist", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A blacklist of URI patterns or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "WebKit2", name = "UserStyleSheet"})) -- throws : False -- Skip return : False foreign import ccall "webkit_user_style_sheet_new" webkit_user_style_sheet_new :: CString -> -- source : TBasicType TUTF8 CUInt -> -- injected_frames : TInterface (Name {namespace = "WebKit2", name = "UserContentInjectedFrames"}) CUInt -> -- level : TInterface (Name {namespace = "WebKit2", name = "UserStyleLevel"}) Ptr CString -> -- whitelist : TCArray True (-1) (-1) (TBasicType TUTF8) Ptr CString -> -- blacklist : TCArray True (-1) (-1) (TBasicType TUTF8) IO (Ptr UserStyleSheet) {- | Creates a new user style sheet. Style sheets can be applied to some URIs only by passing non-null values for /@whitelist@/ or /@blacklist@/. Passing a 'Nothing' whitelist implies that all URIs are on the whitelist. The style sheet is applied if an URI matches the whitelist and not the blacklist. URI patterns must be of the form @[protocol]:\/\/[host]\/[path]@, where the *host* and *path* components can contain the wildcard character (@*@) to represent zero or more other characters. /Since: 2.6/ -} userStyleSheetNew :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@source@/: Source code of the user style sheet. -} -> WebKit2.Enums.UserContentInjectedFrames {- ^ /@injectedFrames@/: A 'GI.WebKit2.Enums.UserContentInjectedFrames' value -} -> WebKit2.Enums.UserStyleLevel {- ^ /@level@/: A 'GI.WebKit2.Enums.UserStyleLevel' -} -> Maybe ([T.Text]) {- ^ /@whitelist@/: A whitelist of URI patterns or 'Nothing' -} -> Maybe ([T.Text]) {- ^ /@blacklist@/: A blacklist of URI patterns or 'Nothing' -} -> m UserStyleSheet {- ^ __Returns:__ A new 'GI.WebKit2.Structs.UserStyleSheet.UserStyleSheet' -} userStyleSheetNew source injectedFrames level whitelist blacklist = liftIO $ do source' <- textToCString source let injectedFrames' = (fromIntegral . fromEnum) injectedFrames let level' = (fromIntegral . fromEnum) level maybeWhitelist <- case whitelist of Nothing -> return nullPtr Just jWhitelist -> do jWhitelist' <- packZeroTerminatedUTF8CArray jWhitelist return jWhitelist' maybeBlacklist <- case blacklist of Nothing -> return nullPtr Just jBlacklist -> do jBlacklist' <- packZeroTerminatedUTF8CArray jBlacklist return jBlacklist' result <- webkit_user_style_sheet_new source' injectedFrames' level' maybeWhitelist maybeBlacklist checkUnexpectedReturnNULL "userStyleSheetNew" result result' <- (wrapBoxed UserStyleSheet) result freeMem source' mapZeroTerminatedCArray freeMem maybeWhitelist freeMem maybeWhitelist mapZeroTerminatedCArray freeMem maybeBlacklist freeMem maybeBlacklist return result' #if ENABLE_OVERLOADING #endif -- method UserStyleSheet::new_for_world -- method type : Constructor -- Args : [Arg {argCName = "source", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Source code of the user style sheet.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "injected_frames", argType = TInterface (Name {namespace = "WebKit2", name = "UserContentInjectedFrames"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitUserContentInjectedFrames value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "level", argType = TInterface (Name {namespace = "WebKit2", name = "UserStyleLevel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitUserStyleLevel", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "world_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of a #WebKitScriptWorld", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "whitelist", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A whitelist of URI patterns or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "blacklist", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A blacklist of URI patterns or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "WebKit2", name = "UserStyleSheet"})) -- throws : False -- Skip return : False foreign import ccall "webkit_user_style_sheet_new_for_world" webkit_user_style_sheet_new_for_world :: CString -> -- source : TBasicType TUTF8 CUInt -> -- injected_frames : TInterface (Name {namespace = "WebKit2", name = "UserContentInjectedFrames"}) CUInt -> -- level : TInterface (Name {namespace = "WebKit2", name = "UserStyleLevel"}) CString -> -- world_name : TBasicType TUTF8 Ptr CString -> -- whitelist : TCArray True (-1) (-1) (TBasicType TUTF8) Ptr CString -> -- blacklist : TCArray True (-1) (-1) (TBasicType TUTF8) IO (Ptr UserStyleSheet) {- | Creates a new user style sheet for script world with name /@worldName@/. See 'GI.WebKit2.Structs.UserStyleSheet.userStyleSheetNew' for a full description. /Since: 2.22/ -} userStyleSheetNewForWorld :: (B.CallStack.HasCallStack, MonadIO m) => T.Text {- ^ /@source@/: Source code of the user style sheet. -} -> WebKit2.Enums.UserContentInjectedFrames {- ^ /@injectedFrames@/: A 'GI.WebKit2.Enums.UserContentInjectedFrames' value -} -> WebKit2.Enums.UserStyleLevel {- ^ /@level@/: A 'GI.WebKit2.Enums.UserStyleLevel' -} -> T.Text {- ^ /@worldName@/: the name of a @/WebKitScriptWorld/@ -} -> Maybe ([T.Text]) {- ^ /@whitelist@/: A whitelist of URI patterns or 'Nothing' -} -> Maybe ([T.Text]) {- ^ /@blacklist@/: A blacklist of URI patterns or 'Nothing' -} -> m UserStyleSheet {- ^ __Returns:__ A new 'GI.WebKit2.Structs.UserStyleSheet.UserStyleSheet' -} userStyleSheetNewForWorld source injectedFrames level worldName whitelist blacklist = liftIO $ do source' <- textToCString source let injectedFrames' = (fromIntegral . fromEnum) injectedFrames let level' = (fromIntegral . fromEnum) level worldName' <- textToCString worldName maybeWhitelist <- case whitelist of Nothing -> return nullPtr Just jWhitelist -> do jWhitelist' <- packZeroTerminatedUTF8CArray jWhitelist return jWhitelist' maybeBlacklist <- case blacklist of Nothing -> return nullPtr Just jBlacklist -> do jBlacklist' <- packZeroTerminatedUTF8CArray jBlacklist return jBlacklist' result <- webkit_user_style_sheet_new_for_world source' injectedFrames' level' worldName' maybeWhitelist maybeBlacklist checkUnexpectedReturnNULL "userStyleSheetNewForWorld" result result' <- (wrapBoxed UserStyleSheet) result freeMem source' freeMem worldName' mapZeroTerminatedCArray freeMem maybeWhitelist freeMem maybeWhitelist mapZeroTerminatedCArray freeMem maybeBlacklist freeMem maybeBlacklist return result' #if ENABLE_OVERLOADING #endif -- method UserStyleSheet::ref -- method type : OrdinaryMethod -- Args : [Arg {argCName = "user_style_sheet", argType = TInterface (Name {namespace = "WebKit2", name = "UserStyleSheet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitUserStyleSheet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "WebKit2", name = "UserStyleSheet"})) -- throws : False -- Skip return : False foreign import ccall "webkit_user_style_sheet_ref" webkit_user_style_sheet_ref :: Ptr UserStyleSheet -> -- user_style_sheet : TInterface (Name {namespace = "WebKit2", name = "UserStyleSheet"}) IO (Ptr UserStyleSheet) {- | Atomically increments the reference count of /@userStyleSheet@/ by one. This function is MT-safe and may be called from any thread. /Since: 2.6/ -} userStyleSheetRef :: (B.CallStack.HasCallStack, MonadIO m) => UserStyleSheet {- ^ /@userStyleSheet@/: a 'GI.WebKit2.Structs.UserStyleSheet.UserStyleSheet' -} -> m UserStyleSheet {- ^ __Returns:__ The passed 'GI.WebKit2.Structs.UserStyleSheet.UserStyleSheet' -} userStyleSheetRef userStyleSheet = liftIO $ do userStyleSheet' <- unsafeManagedPtrGetPtr userStyleSheet result <- webkit_user_style_sheet_ref userStyleSheet' checkUnexpectedReturnNULL "userStyleSheetRef" result result' <- (wrapBoxed UserStyleSheet) result touchManagedPtr userStyleSheet return result' #if ENABLE_OVERLOADING data UserStyleSheetRefMethodInfo instance (signature ~ (m UserStyleSheet), MonadIO m) => O.MethodInfo UserStyleSheetRefMethodInfo UserStyleSheet signature where overloadedMethod _ = userStyleSheetRef #endif -- method UserStyleSheet::unref -- method type : OrdinaryMethod -- Args : [Arg {argCName = "user_style_sheet", argType = TInterface (Name {namespace = "WebKit2", name = "UserStyleSheet"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitUserStyleSheet", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "webkit_user_style_sheet_unref" webkit_user_style_sheet_unref :: Ptr UserStyleSheet -> -- user_style_sheet : TInterface (Name {namespace = "WebKit2", name = "UserStyleSheet"}) IO () {- | Atomically decrements the reference count of /@userStyleSheet@/ by one. If the reference count drops to 0, all memory allocated by 'GI.WebKit2.Structs.UserStyleSheet.UserStyleSheet' is released. This function is MT-safe and may be called from any thread. /Since: 2.6/ -} userStyleSheetUnref :: (B.CallStack.HasCallStack, MonadIO m) => UserStyleSheet {- ^ /@userStyleSheet@/: a 'GI.WebKit2.Structs.UserStyleSheet.UserStyleSheet' -} -> m () userStyleSheetUnref userStyleSheet = liftIO $ do userStyleSheet' <- unsafeManagedPtrGetPtr userStyleSheet webkit_user_style_sheet_unref userStyleSheet' touchManagedPtr userStyleSheet return () #if ENABLE_OVERLOADING data UserStyleSheetUnrefMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo UserStyleSheetUnrefMethodInfo UserStyleSheet signature where overloadedMethod _ = userStyleSheetUnref #endif #if ENABLE_OVERLOADING type family ResolveUserStyleSheetMethod (t :: Symbol) (o :: *) :: * where ResolveUserStyleSheetMethod "ref" o = UserStyleSheetRefMethodInfo ResolveUserStyleSheetMethod "unref" o = UserStyleSheetUnrefMethodInfo ResolveUserStyleSheetMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveUserStyleSheetMethod t UserStyleSheet, O.MethodInfo info UserStyleSheet p) => OL.IsLabel t (UserStyleSheet -> 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