module Graphics.UI.Gtk.General.CssProvider (
CssProvider,
CssProviderClass,
castToCssProvider, gTypeCssProvider,
toCssProvider,
CssProviderError(..),
cssProviderNew,
cssProviderGetDefault,
cssProviderGetNamed,
cssProviderLoadFromData,
cssProviderLoadFromString,
cssProviderLoadFromPath,
cssProviderToString,
) where
import System.Glib.FFI
import System.Glib.UTFString
import Graphics.UI.Gtk.Types
import System.Glib.GError (propagateGError)
data CssProviderError = CssProviderErrorFailed
| CssProviderErrorSyntax
| CssProviderErrorImport
| CssProviderErrorName
| CssProviderErrorDeprecated
| CssProviderErrorUnknownValue
deriving (Enum,Bounded,Eq,Show)
instance StyleProviderClass CssProvider
cssProviderNew :: IO CssProvider
cssProviderNew =
wrapNewGObject mkCssProvider gtk_css_provider_new
cssProviderGetDefault :: IO CssProvider
cssProviderGetDefault =
makeNewGObject mkCssProvider gtk_css_provider_get_default
cssProviderGetNamed :: GlibString string
=> string
-> Maybe string
-> IO (Maybe CssProvider)
cssProviderGetNamed name variant =
maybeNull (makeNewGObject mkCssProvider) $
withUTFString name $ \namePtr ->
maybeWith withUTFString variant $ \variantPtr ->
gtk_css_provider_get_named namePtr variantPtr
cssProviderLoadFromData :: CssProviderClass cssProvider
=> cssProvider
-> Ptr CChar
-> Int
-> IO ()
cssProviderLoadFromData cssProvider _data length =
propagateGError $ \errPtrPtr ->
(\(CssProvider arg1) arg2 arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->gtk_css_provider_load_from_data argPtr1 arg2 arg3 arg4)
(toCssProvider cssProvider)
_data
(fromIntegral length)
errPtrPtr >> return ()
cssProviderLoadFromString :: (CssProviderClass cssProvider, GlibString string)
=> cssProvider
-> string
-> IO ()
cssProviderLoadFromString cssProvider css =
withUTFStringLen css $ \(cssPtr, len) ->
cssProviderLoadFromData cssProvider cssPtr len
cssProviderLoadFromPath :: (CssProviderClass cssProvider, GlibFilePath fp)
=> cssProvider
-> fp
-> IO ()
cssProviderLoadFromPath cssProvider path =
propagateGError $ \errPtrPtr ->
withUTFFilePath path $ \pathPtr ->
(\(CssProvider arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_css_provider_load_from_path argPtr1 arg2 arg3)
(toCssProvider cssProvider)
pathPtr
errPtrPtr >> return ()
cssProviderToString :: (CssProviderClass cssProvider, GlibString string)
=> cssProvider
-> IO string
cssProviderToString provider =
(\(CssProvider arg1) -> withForeignPtr arg1 $ \argPtr1 ->gtk_css_provider_to_string argPtr1)
(toCssProvider provider) >>= peekUTFString
foreign import ccall safe "gtk_css_provider_new"
gtk_css_provider_new :: (IO (Ptr CssProvider))
foreign import ccall safe "gtk_css_provider_get_default"
gtk_css_provider_get_default :: (IO (Ptr CssProvider))
foreign import ccall safe "gtk_css_provider_get_named"
gtk_css_provider_get_named :: ((Ptr CChar) -> ((Ptr CChar) -> (IO (Ptr CssProvider))))
foreign import ccall safe "gtk_css_provider_load_from_data"
gtk_css_provider_load_from_data :: ((Ptr CssProvider) -> ((Ptr CChar) -> (CLong -> ((Ptr (Ptr ())) -> (IO CInt)))))
foreign import ccall safe "gtk_css_provider_load_from_path"
gtk_css_provider_load_from_path :: ((Ptr CssProvider) -> ((Ptr CChar) -> ((Ptr (Ptr ())) -> (IO CInt))))
foreign import ccall safe "gtk_css_provider_to_string"
gtk_css_provider_to_string :: ((Ptr CssProvider) -> (IO (Ptr CChar)))