{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) -} module GI.Gtk.Interfaces.StyleProvider ( -- * Exported types StyleProvider(..) , noStyleProvider , StyleProviderK , -- * Methods -- ** styleProviderGetIconFactory styleProviderGetIconFactory , -- ** styleProviderGetStyle styleProviderGetStyle , -- ** styleProviderGetStyleProperty styleProviderGetStyleProperty , ) 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.Gtk.Types import GI.Gtk.Callbacks -- interface StyleProvider newtype StyleProvider = StyleProvider (ForeignPtr StyleProvider) noStyleProvider :: Maybe StyleProvider noStyleProvider = Nothing type instance AttributeList StyleProvider = StyleProviderAttributeList type StyleProviderAttributeList = ('[ ] :: [(Symbol, *)]) type instance SignalList StyleProvider = StyleProviderSignalList type StyleProviderSignalList = ('[ ] :: [(Symbol, *)]) class ForeignPtrNewtype a => StyleProviderK a instance (ForeignPtrNewtype o, IsDescendantOf StyleProvider o) => StyleProviderK o type instance ParentTypes StyleProvider = StyleProviderParentTypes type StyleProviderParentTypes = '[] -- method StyleProvider::get_icon_factory -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "StyleProvider", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "path", argType = TInterface "Gtk" "WidgetPath", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "StyleProvider", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "path", argType = TInterface "Gtk" "WidgetPath", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gtk" "IconFactory" -- throws : False -- Skip return : False foreign import ccall "gtk_style_provider_get_icon_factory" gtk_style_provider_get_icon_factory :: Ptr StyleProvider -> -- _obj : TInterface "Gtk" "StyleProvider" Ptr WidgetPath -> -- path : TInterface "Gtk" "WidgetPath" IO (Ptr IconFactory) {-# DEPRECATED styleProviderGetIconFactory ["(Since version 3.8)","Will always return %NULL for all GTK-provided style providers."]#-} styleProviderGetIconFactory :: (MonadIO m, StyleProviderK a) => a -> -- _obj WidgetPath -> -- path m IconFactory styleProviderGetIconFactory _obj path = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj let path' = unsafeManagedPtrGetPtr path result <- gtk_style_provider_get_icon_factory _obj' path' checkUnexpectedReturnNULL "gtk_style_provider_get_icon_factory" result result' <- (newObject IconFactory) result touchManagedPtr _obj touchManagedPtr path return result' -- method StyleProvider::get_style -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "StyleProvider", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "path", argType = TInterface "Gtk" "WidgetPath", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "StyleProvider", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "path", argType = TInterface "Gtk" "WidgetPath", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gtk" "StyleProperties" -- throws : False -- Skip return : False foreign import ccall "gtk_style_provider_get_style" gtk_style_provider_get_style :: Ptr StyleProvider -> -- _obj : TInterface "Gtk" "StyleProvider" Ptr WidgetPath -> -- path : TInterface "Gtk" "WidgetPath" IO (Ptr StyleProperties) {-# DEPRECATED styleProviderGetStyle ["(Since version 3.8)","Will always return %NULL for all GTK-provided style providers"," as the interface cannot correctly work the way CSS is specified."]#-} styleProviderGetStyle :: (MonadIO m, StyleProviderK a) => a -> -- _obj WidgetPath -> -- path m StyleProperties styleProviderGetStyle _obj path = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj let path' = unsafeManagedPtrGetPtr path result <- gtk_style_provider_get_style _obj' path' checkUnexpectedReturnNULL "gtk_style_provider_get_style" result result' <- (wrapObject StyleProperties) result touchManagedPtr _obj touchManagedPtr path return result' -- method StyleProvider::get_style_property -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "StyleProvider", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "path", argType = TInterface "Gtk" "WidgetPath", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "state", argType = TInterface "Gtk" "StateFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "pspec", argType = TParamSpec, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TInterface "GObject" "Value", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "StyleProvider", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "path", argType = TInterface "Gtk" "WidgetPath", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "state", argType = TInterface "Gtk" "StateFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "pspec", argType = TParamSpec, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : False -- Skip return : False foreign import ccall "gtk_style_provider_get_style_property" gtk_style_provider_get_style_property :: Ptr StyleProvider -> -- _obj : TInterface "Gtk" "StyleProvider" Ptr WidgetPath -> -- path : TInterface "Gtk" "WidgetPath" CUInt -> -- state : TInterface "Gtk" "StateFlags" Ptr GParamSpec -> -- pspec : TParamSpec Ptr GValue -> -- value : TInterface "GObject" "Value" IO CInt styleProviderGetStyleProperty :: (MonadIO m, StyleProviderK a) => a -> -- _obj WidgetPath -> -- path [StateFlags] -> -- state GParamSpec -> -- pspec m (Bool,GValue) styleProviderGetStyleProperty _obj path state pspec = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj let path' = unsafeManagedPtrGetPtr path let state' = gflagsToWord state let pspec' = unsafeManagedPtrGetPtr pspec value <- callocBoxedBytes 24 :: IO (Ptr GValue) result <- gtk_style_provider_get_style_property _obj' path' state' pspec' value let result' = (/= 0) result value' <- (wrapBoxed GValue) value touchManagedPtr _obj touchManagedPtr path return (result', value')