#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Handy.Objects.ValueObject
(
ValueObject(..) ,
IsValueObject ,
toValueObject ,
noValueObject ,
#if ENABLE_OVERLOADING
ValueObjectCopyValueMethodInfo ,
#endif
valueObjectCopyValue ,
#if ENABLE_OVERLOADING
ValueObjectDupStringMethodInfo ,
#endif
valueObjectDupString ,
#if ENABLE_OVERLOADING
ValueObjectGetStringMethodInfo ,
#endif
valueObjectGetString ,
#if ENABLE_OVERLOADING
ValueObjectGetValueMethodInfo ,
#endif
valueObjectGetValue ,
valueObjectNew ,
#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
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
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]
toValueObject :: (MonadIO m, IsValueObject o) => o -> m ValueObject
toValueObject = liftIO . unsafeCastTo 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
getValueObjectValue :: (MonadIO m, IsValueObject o) => o -> m GValue
getValueObjectValue obj = liftIO $ checkUnexpectedNothing "getValueObjectValue" $ B.Properties.getObjectPropertyBoxed obj "value" GValue
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
foreign import ccall "hdy_value_object_new" hdy_value_object_new ::
Ptr GValue ->
IO (Ptr ValueObject)
valueObjectNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
GValue
-> m 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
foreign import ccall "hdy_value_object_copy_value" hdy_value_object_copy_value ::
Ptr ValueObject ->
Ptr GValue ->
IO ()
valueObjectCopyValue ::
(B.CallStack.HasCallStack, MonadIO m, IsValueObject a) =>
a
-> GValue
-> 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
foreign import ccall "hdy_value_object_dup_string" hdy_value_object_dup_string ::
Ptr ValueObject ->
IO CString
valueObjectDupString ::
(B.CallStack.HasCallStack, MonadIO m, IsValueObject a) =>
a
-> m T.Text
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
foreign import ccall "hdy_value_object_get_string" hdy_value_object_get_string ::
Ptr ValueObject ->
IO CString
valueObjectGetString ::
(B.CallStack.HasCallStack, MonadIO m, IsValueObject a) =>
a
-> m T.Text
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
foreign import ccall "hdy_value_object_get_value" hdy_value_object_get_value ::
Ptr ValueObject ->
IO (Ptr GValue)
valueObjectGetValue ::
(B.CallStack.HasCallStack, MonadIO m, IsValueObject a) =>
a
-> m GValue
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