{- | 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.Handy.Objects.ValueObject ( -- * Exported types ValueObject(..) , IsValueObject , toValueObject , noValueObject , -- * Methods -- ** copyValue #method:copyValue# #if ENABLE_OVERLOADING ValueObjectCopyValueMethodInfo , #endif valueObjectCopyValue , -- ** dupString #method:dupString# #if ENABLE_OVERLOADING ValueObjectDupStringMethodInfo , #endif valueObjectDupString , -- ** getString #method:getString# #if ENABLE_OVERLOADING ValueObjectGetStringMethodInfo , #endif valueObjectGetString , -- ** getValue #method:getValue# #if ENABLE_OVERLOADING ValueObjectGetValueMethodInfo , #endif valueObjectGetValue , -- ** new #method:new# valueObjectNew , -- * Properties -- ** value #attr:value# {- | /No description available in the introspection data./ -} #if ENABLE_OVERLOADING ValueObjectValuePropertyInfo , #endif constructValueObjectValue , getValueObjectValue , #if ENABLE_OVERLOADING valueObjectValue , #endif ) 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 qualified GI.GObject.Objects.Object as GObject.Object -- | Memory-managed wrapper type. newtype ValueObject = ValueObject (ManagedPtr ValueObject) foreign import ccall "hdy_value_object_get_type" c_hdy_value_object_get_type :: IO GType instance GObject ValueObject where gobjectType = c_hdy_value_object_get_type -- | Type class for types which can be safely cast to `ValueObject`, for instance with `toValueObject`. class (GObject o, O.IsDescendantOf ValueObject o) => IsValueObject o instance (GObject o, O.IsDescendantOf ValueObject o) => IsValueObject o instance O.HasParentTypes ValueObject type instance O.ParentTypes ValueObject = '[GObject.Object.Object] -- | Cast to `ValueObject`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`. toValueObject :: (MonadIO m, IsValueObject o) => o -> m ValueObject toValueObject = liftIO . unsafeCastTo ValueObject -- | A convenience alias for `Nothing` :: `Maybe` `ValueObject`. noValueObject :: Maybe ValueObject noValueObject = Nothing #if ENABLE_OVERLOADING type family ResolveValueObjectMethod (t :: Symbol) (o :: *) :: * where ResolveValueObjectMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo ResolveValueObjectMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo ResolveValueObjectMethod "copyValue" o = ValueObjectCopyValueMethodInfo ResolveValueObjectMethod "dupString" o = ValueObjectDupStringMethodInfo ResolveValueObjectMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo ResolveValueObjectMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo ResolveValueObjectMethod "getv" o = GObject.Object.ObjectGetvMethodInfo ResolveValueObjectMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo ResolveValueObjectMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo ResolveValueObjectMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo ResolveValueObjectMethod "ref" o = GObject.Object.ObjectRefMethodInfo ResolveValueObjectMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo ResolveValueObjectMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo ResolveValueObjectMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo ResolveValueObjectMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo ResolveValueObjectMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo ResolveValueObjectMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo ResolveValueObjectMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo ResolveValueObjectMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo ResolveValueObjectMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo ResolveValueObjectMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo ResolveValueObjectMethod "getString" o = ValueObjectGetStringMethodInfo ResolveValueObjectMethod "getValue" o = ValueObjectGetValueMethodInfo ResolveValueObjectMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo ResolveValueObjectMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo ResolveValueObjectMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveValueObjectMethod t ValueObject, O.MethodInfo info ValueObject p) => OL.IsLabel t (ValueObject -> 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 -- VVV Prop "value" -- Type: TInterface (Name {namespace = "GObject", name = "Value"}) -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly] -- Nullable: (Just False,Nothing) {- | Get the value of the “@value@” property. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.get' valueObject #value @ -} getValueObjectValue :: (MonadIO m, IsValueObject o) => o -> m GValue getValueObjectValue obj = liftIO $ checkUnexpectedNothing "getValueObjectValue" $ B.Properties.getObjectPropertyBoxed obj "value" GValue {- | Construct a `GValueConstruct` with valid value for the “@value@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`. -} constructValueObjectValue :: (IsValueObject o) => GValue -> IO (GValueConstruct o) constructValueObjectValue val = B.Properties.constructObjectPropertyBoxed "value" (Just val) #if ENABLE_OVERLOADING data ValueObjectValuePropertyInfo instance AttrInfo ValueObjectValuePropertyInfo where type AttrAllowedOps ValueObjectValuePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear] type AttrSetTypeConstraint ValueObjectValuePropertyInfo = (~) GValue type AttrBaseTypeConstraint ValueObjectValuePropertyInfo = IsValueObject type AttrGetType ValueObjectValuePropertyInfo = GValue type AttrLabel ValueObjectValuePropertyInfo = "value" type AttrOrigin ValueObjectValuePropertyInfo = ValueObject attrGet _ = getValueObjectValue attrSet _ = undefined attrConstruct _ = constructValueObjectValue attrClear _ = undefined #endif #if ENABLE_OVERLOADING instance O.HasAttributeList ValueObject type instance O.AttributeList ValueObject = ValueObjectAttributeList type ValueObjectAttributeList = ('[ '("value", ValueObjectValuePropertyInfo)] :: [(Symbol, *)]) #endif #if ENABLE_OVERLOADING valueObjectValue :: AttrLabelProxy "value" valueObjectValue = AttrLabelProxy #endif #if ENABLE_OVERLOADING type instance O.SignalList ValueObject = ValueObjectSignalList type ValueObjectSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)]) #endif -- method ValueObject::new -- method type : Constructor -- Args : [Arg {argCName = "value", argType = TInterface (Name {namespace = "GObject", name = "Value"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GValue to store", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Handy", name = "ValueObject"})) -- throws : False -- Skip return : False foreign import ccall "hdy_value_object_new" hdy_value_object_new :: Ptr GValue -> -- value : TInterface (Name {namespace = "GObject", name = "Value"}) IO (Ptr ValueObject) {- | Create a new 'GI.Handy.Objects.ValueObject.ValueObject'. /Since: 0.0.8/ -} valueObjectNew :: (B.CallStack.HasCallStack, MonadIO m) => GValue {- ^ /@value@/: the 'GI.GObject.Structs.Value.Value' to store -} -> m ValueObject {- ^ __Returns:__ a new 'GI.Handy.Objects.ValueObject.ValueObject' -} valueObjectNew value = liftIO $ do value' <- unsafeManagedPtrGetPtr value result <- hdy_value_object_new value' checkUnexpectedReturnNULL "valueObjectNew" result result' <- (wrapObject ValueObject) result touchManagedPtr value return result' #if ENABLE_OVERLOADING #endif -- method ValueObject::copy_value -- method type : OrdinaryMethod -- Args : [Arg {argCName = "value", argType = TInterface (Name {namespace = "Handy", name = "ValueObject"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #HdyValueObject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dest", argType = TInterface (Name {namespace = "GObject", name = "Value"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GValue with correct type to copy into", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "hdy_value_object_copy_value" hdy_value_object_copy_value :: Ptr ValueObject -> -- value : TInterface (Name {namespace = "Handy", name = "ValueObject"}) Ptr GValue -> -- dest : TInterface (Name {namespace = "GObject", name = "Value"}) IO () {- | Copy data from the contained 'GI.GObject.Structs.Value.Value' into /@dest@/. /Since: 0.0.8/ -} valueObjectCopyValue :: (B.CallStack.HasCallStack, MonadIO m, IsValueObject a) => a {- ^ /@value@/: the 'GI.Handy.Objects.ValueObject.ValueObject' -} -> GValue {- ^ /@dest@/: 'GI.GObject.Structs.Value.Value' with correct type to copy into -} -> m () valueObjectCopyValue value dest = liftIO $ do value' <- unsafeManagedPtrCastPtr value dest' <- unsafeManagedPtrGetPtr dest hdy_value_object_copy_value value' dest' touchManagedPtr value touchManagedPtr dest return () #if ENABLE_OVERLOADING data ValueObjectCopyValueMethodInfo instance (signature ~ (GValue -> m ()), MonadIO m, IsValueObject a) => O.MethodInfo ValueObjectCopyValueMethodInfo a signature where overloadedMethod _ = valueObjectCopyValue #endif -- method ValueObject::dup_string -- method type : OrdinaryMethod -- Args : [Arg {argCName = "value", argType = TInterface (Name {namespace = "Handy", name = "ValueObject"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #HdyValueObject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "hdy_value_object_dup_string" hdy_value_object_dup_string :: Ptr ValueObject -> -- value : TInterface (Name {namespace = "Handy", name = "ValueObject"}) IO CString {- | Returns a copy of the contained string if the value is of type @/G_TYPE_STRING/@. /Since: 0.0.8/ -} valueObjectDupString :: (B.CallStack.HasCallStack, MonadIO m, IsValueObject a) => a {- ^ /@value@/: the 'GI.Handy.Objects.ValueObject.ValueObject' -} -> m T.Text {- ^ __Returns:__ a copy of the contained string -} valueObjectDupString value = liftIO $ do value' <- unsafeManagedPtrCastPtr value result <- hdy_value_object_dup_string value' checkUnexpectedReturnNULL "valueObjectDupString" result result' <- cstringToText result freeMem result touchManagedPtr value return result' #if ENABLE_OVERLOADING data ValueObjectDupStringMethodInfo instance (signature ~ (m T.Text), MonadIO m, IsValueObject a) => O.MethodInfo ValueObjectDupStringMethodInfo a signature where overloadedMethod _ = valueObjectDupString #endif -- method ValueObject::get_string -- method type : OrdinaryMethod -- Args : [Arg {argCName = "value", argType = TInterface (Name {namespace = "Handy", name = "ValueObject"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #HdyValueObject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUTF8) -- throws : False -- Skip return : False foreign import ccall "hdy_value_object_get_string" hdy_value_object_get_string :: Ptr ValueObject -> -- value : TInterface (Name {namespace = "Handy", name = "ValueObject"}) IO CString {- | Returns the contained string if the value is of type @/G_TYPE_STRING/@. /Since: 0.0.8/ -} valueObjectGetString :: (B.CallStack.HasCallStack, MonadIO m, IsValueObject a) => a {- ^ /@value@/: the 'GI.Handy.Objects.ValueObject.ValueObject' -} -> m T.Text {- ^ __Returns:__ the contained string -} valueObjectGetString value = liftIO $ do value' <- unsafeManagedPtrCastPtr value result <- hdy_value_object_get_string value' checkUnexpectedReturnNULL "valueObjectGetString" result result' <- cstringToText result touchManagedPtr value return result' #if ENABLE_OVERLOADING data ValueObjectGetStringMethodInfo instance (signature ~ (m T.Text), MonadIO m, IsValueObject a) => O.MethodInfo ValueObjectGetStringMethodInfo a signature where overloadedMethod _ = valueObjectGetString #endif -- method ValueObject::get_value -- method type : OrdinaryMethod -- Args : [Arg {argCName = "value", argType = TInterface (Name {namespace = "Handy", name = "ValueObject"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #HdyValueObject", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "GObject", name = "Value"})) -- throws : False -- Skip return : False foreign import ccall "hdy_value_object_get_value" hdy_value_object_get_value :: Ptr ValueObject -> -- value : TInterface (Name {namespace = "Handy", name = "ValueObject"}) IO (Ptr GValue) {- | Return the contained value. /Since: 0.0.8/ -} valueObjectGetValue :: (B.CallStack.HasCallStack, MonadIO m, IsValueObject a) => a {- ^ /@value@/: the 'GI.Handy.Objects.ValueObject.ValueObject' -} -> m GValue {- ^ __Returns:__ the contained 'GI.GObject.Structs.Value.Value' -} valueObjectGetValue value = liftIO $ do value' <- unsafeManagedPtrCastPtr value result <- hdy_value_object_get_value value' checkUnexpectedReturnNULL "valueObjectGetValue" result result' <- (newBoxed GValue) result touchManagedPtr value return result' #if ENABLE_OVERLOADING data ValueObjectGetValueMethodInfo instance (signature ~ (m GValue), MonadIO m, IsValueObject a) => O.MethodInfo ValueObjectGetValueMethodInfo a signature where overloadedMethod _ = valueObjectGetValue #endif