{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) Meta-data to be passed to 'GI.Gtk.Objects.RecentManager.recentManagerAddFull' when registering a recently used resource. -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.Gtk.Structs.RecentData ( -- * Exported types RecentData(..) , newZeroRecentData , noRecentData , -- * Properties -- ** appExec #attr:appExec# {- | command line used to launch this resource; may contain the “%f” and “%u” escape characters which will be expanded to the resource file path and URI respectively when the command line is retrieved; -} clearRecentDataAppExec , getRecentDataAppExec , #if ENABLE_OVERLOADING recentData_appExec , #endif setRecentDataAppExec , -- ** appName #attr:appName# {- | the name of the application that is registering this recently used resource; -} clearRecentDataAppName , getRecentDataAppName , #if ENABLE_OVERLOADING recentData_appName , #endif setRecentDataAppName , -- ** description #attr:description# {- | a UTF-8 encoded string, containing a short description of the resource, or 'Nothing'; -} clearRecentDataDescription , getRecentDataDescription , #if ENABLE_OVERLOADING recentData_description , #endif setRecentDataDescription , -- ** displayName #attr:displayName# {- | a UTF-8 encoded string, containing the name of the recently used resource to be displayed, or 'Nothing'; -} clearRecentDataDisplayName , getRecentDataDisplayName , #if ENABLE_OVERLOADING recentData_displayName , #endif setRecentDataDisplayName , -- ** groups #attr:groups# {- | a vector of strings containing groups names; -} clearRecentDataGroups , getRecentDataGroups , #if ENABLE_OVERLOADING recentData_groups , #endif setRecentDataGroups , -- ** isPrivate #attr:isPrivate# {- | whether this resource should be displayed only by the applications that have registered it or not. -} getRecentDataIsPrivate , #if ENABLE_OVERLOADING recentData_isPrivate , #endif setRecentDataIsPrivate , -- ** mimeType #attr:mimeType# {- | the MIME type of the resource; -} clearRecentDataMimeType , getRecentDataMimeType , #if ENABLE_OVERLOADING recentData_mimeType , #endif setRecentDataMimeType , ) 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 -- | Memory-managed wrapper type. newtype RecentData = RecentData (ManagedPtr RecentData) instance WrappedPtr RecentData where wrappedPtrCalloc = callocBytes 56 wrappedPtrCopy = \p -> withManagedPtr p (copyBytes 56 >=> wrapPtr RecentData) wrappedPtrFree = Just ptr_to_g_free -- | Construct a `RecentData` struct initialized to zero. newZeroRecentData :: MonadIO m => m RecentData newZeroRecentData = liftIO $ wrappedPtrCalloc >>= wrapPtr RecentData instance tag ~ 'AttrSet => Constructible RecentData tag where new _ attrs = do o <- newZeroRecentData GI.Attributes.set o attrs return o -- | A convenience alias for `Nothing` :: `Maybe` `RecentData`. noRecentData :: Maybe RecentData noRecentData = Nothing {- | Get the value of the “@display_name@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.get' recentData #displayName @ -} getRecentDataDisplayName :: MonadIO m => RecentData -> m (Maybe T.Text) getRecentDataDisplayName s = liftIO $ withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 0) :: IO CString result <- SP.convertIfNonNull val $ \val' -> do val'' <- cstringToText val' return val'' return result {- | Set the value of the “@display_name@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.set' recentData [ #displayName 'Data.GI.Base.Attributes.:=' value ] @ -} setRecentDataDisplayName :: MonadIO m => RecentData -> CString -> m () setRecentDataDisplayName s val = liftIO $ withManagedPtr s $ \ptr -> do poke (ptr `plusPtr` 0) (val :: CString) {- | Set the value of the “@display_name@” field to `Nothing`. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.clear' #displayName @ -} clearRecentDataDisplayName :: MonadIO m => RecentData -> m () clearRecentDataDisplayName s = liftIO $ withManagedPtr s $ \ptr -> do poke (ptr `plusPtr` 0) (FP.nullPtr :: CString) #if ENABLE_OVERLOADING data RecentDataDisplayNameFieldInfo instance AttrInfo RecentDataDisplayNameFieldInfo where type AttrAllowedOps RecentDataDisplayNameFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear] type AttrSetTypeConstraint RecentDataDisplayNameFieldInfo = (~) CString type AttrBaseTypeConstraint RecentDataDisplayNameFieldInfo = (~) RecentData type AttrGetType RecentDataDisplayNameFieldInfo = Maybe T.Text type AttrLabel RecentDataDisplayNameFieldInfo = "display_name" type AttrOrigin RecentDataDisplayNameFieldInfo = RecentData attrGet _ = getRecentDataDisplayName attrSet _ = setRecentDataDisplayName attrConstruct = undefined attrClear _ = clearRecentDataDisplayName recentData_displayName :: AttrLabelProxy "displayName" recentData_displayName = AttrLabelProxy #endif {- | Get the value of the “@description@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.get' recentData #description @ -} getRecentDataDescription :: MonadIO m => RecentData -> m (Maybe T.Text) getRecentDataDescription s = liftIO $ withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 8) :: IO CString result <- SP.convertIfNonNull val $ \val' -> do val'' <- cstringToText val' return val'' return result {- | Set the value of the “@description@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.set' recentData [ #description 'Data.GI.Base.Attributes.:=' value ] @ -} setRecentDataDescription :: MonadIO m => RecentData -> CString -> m () setRecentDataDescription s val = liftIO $ withManagedPtr s $ \ptr -> do poke (ptr `plusPtr` 8) (val :: CString) {- | Set the value of the “@description@” field to `Nothing`. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.clear' #description @ -} clearRecentDataDescription :: MonadIO m => RecentData -> m () clearRecentDataDescription s = liftIO $ withManagedPtr s $ \ptr -> do poke (ptr `plusPtr` 8) (FP.nullPtr :: CString) #if ENABLE_OVERLOADING data RecentDataDescriptionFieldInfo instance AttrInfo RecentDataDescriptionFieldInfo where type AttrAllowedOps RecentDataDescriptionFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear] type AttrSetTypeConstraint RecentDataDescriptionFieldInfo = (~) CString type AttrBaseTypeConstraint RecentDataDescriptionFieldInfo = (~) RecentData type AttrGetType RecentDataDescriptionFieldInfo = Maybe T.Text type AttrLabel RecentDataDescriptionFieldInfo = "description" type AttrOrigin RecentDataDescriptionFieldInfo = RecentData attrGet _ = getRecentDataDescription attrSet _ = setRecentDataDescription attrConstruct = undefined attrClear _ = clearRecentDataDescription recentData_description :: AttrLabelProxy "description" recentData_description = AttrLabelProxy #endif {- | Get the value of the “@mime_type@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.get' recentData #mimeType @ -} getRecentDataMimeType :: MonadIO m => RecentData -> m (Maybe T.Text) getRecentDataMimeType s = liftIO $ withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 16) :: IO CString result <- SP.convertIfNonNull val $ \val' -> do val'' <- cstringToText val' return val'' return result {- | Set the value of the “@mime_type@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.set' recentData [ #mimeType 'Data.GI.Base.Attributes.:=' value ] @ -} setRecentDataMimeType :: MonadIO m => RecentData -> CString -> m () setRecentDataMimeType s val = liftIO $ withManagedPtr s $ \ptr -> do poke (ptr `plusPtr` 16) (val :: CString) {- | Set the value of the “@mime_type@” field to `Nothing`. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.clear' #mimeType @ -} clearRecentDataMimeType :: MonadIO m => RecentData -> m () clearRecentDataMimeType s = liftIO $ withManagedPtr s $ \ptr -> do poke (ptr `plusPtr` 16) (FP.nullPtr :: CString) #if ENABLE_OVERLOADING data RecentDataMimeTypeFieldInfo instance AttrInfo RecentDataMimeTypeFieldInfo where type AttrAllowedOps RecentDataMimeTypeFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear] type AttrSetTypeConstraint RecentDataMimeTypeFieldInfo = (~) CString type AttrBaseTypeConstraint RecentDataMimeTypeFieldInfo = (~) RecentData type AttrGetType RecentDataMimeTypeFieldInfo = Maybe T.Text type AttrLabel RecentDataMimeTypeFieldInfo = "mime_type" type AttrOrigin RecentDataMimeTypeFieldInfo = RecentData attrGet _ = getRecentDataMimeType attrSet _ = setRecentDataMimeType attrConstruct = undefined attrClear _ = clearRecentDataMimeType recentData_mimeType :: AttrLabelProxy "mimeType" recentData_mimeType = AttrLabelProxy #endif {- | Get the value of the “@app_name@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.get' recentData #appName @ -} getRecentDataAppName :: MonadIO m => RecentData -> m (Maybe T.Text) getRecentDataAppName s = liftIO $ withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 24) :: IO CString result <- SP.convertIfNonNull val $ \val' -> do val'' <- cstringToText val' return val'' return result {- | Set the value of the “@app_name@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.set' recentData [ #appName 'Data.GI.Base.Attributes.:=' value ] @ -} setRecentDataAppName :: MonadIO m => RecentData -> CString -> m () setRecentDataAppName s val = liftIO $ withManagedPtr s $ \ptr -> do poke (ptr `plusPtr` 24) (val :: CString) {- | Set the value of the “@app_name@” field to `Nothing`. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.clear' #appName @ -} clearRecentDataAppName :: MonadIO m => RecentData -> m () clearRecentDataAppName s = liftIO $ withManagedPtr s $ \ptr -> do poke (ptr `plusPtr` 24) (FP.nullPtr :: CString) #if ENABLE_OVERLOADING data RecentDataAppNameFieldInfo instance AttrInfo RecentDataAppNameFieldInfo where type AttrAllowedOps RecentDataAppNameFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear] type AttrSetTypeConstraint RecentDataAppNameFieldInfo = (~) CString type AttrBaseTypeConstraint RecentDataAppNameFieldInfo = (~) RecentData type AttrGetType RecentDataAppNameFieldInfo = Maybe T.Text type AttrLabel RecentDataAppNameFieldInfo = "app_name" type AttrOrigin RecentDataAppNameFieldInfo = RecentData attrGet _ = getRecentDataAppName attrSet _ = setRecentDataAppName attrConstruct = undefined attrClear _ = clearRecentDataAppName recentData_appName :: AttrLabelProxy "appName" recentData_appName = AttrLabelProxy #endif {- | Get the value of the “@app_exec@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.get' recentData #appExec @ -} getRecentDataAppExec :: MonadIO m => RecentData -> m (Maybe T.Text) getRecentDataAppExec s = liftIO $ withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 32) :: IO CString result <- SP.convertIfNonNull val $ \val' -> do val'' <- cstringToText val' return val'' return result {- | Set the value of the “@app_exec@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.set' recentData [ #appExec 'Data.GI.Base.Attributes.:=' value ] @ -} setRecentDataAppExec :: MonadIO m => RecentData -> CString -> m () setRecentDataAppExec s val = liftIO $ withManagedPtr s $ \ptr -> do poke (ptr `plusPtr` 32) (val :: CString) {- | Set the value of the “@app_exec@” field to `Nothing`. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.clear' #appExec @ -} clearRecentDataAppExec :: MonadIO m => RecentData -> m () clearRecentDataAppExec s = liftIO $ withManagedPtr s $ \ptr -> do poke (ptr `plusPtr` 32) (FP.nullPtr :: CString) #if ENABLE_OVERLOADING data RecentDataAppExecFieldInfo instance AttrInfo RecentDataAppExecFieldInfo where type AttrAllowedOps RecentDataAppExecFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear] type AttrSetTypeConstraint RecentDataAppExecFieldInfo = (~) CString type AttrBaseTypeConstraint RecentDataAppExecFieldInfo = (~) RecentData type AttrGetType RecentDataAppExecFieldInfo = Maybe T.Text type AttrLabel RecentDataAppExecFieldInfo = "app_exec" type AttrOrigin RecentDataAppExecFieldInfo = RecentData attrGet _ = getRecentDataAppExec attrSet _ = setRecentDataAppExec attrConstruct = undefined attrClear _ = clearRecentDataAppExec recentData_appExec :: AttrLabelProxy "appExec" recentData_appExec = AttrLabelProxy #endif {- | Get the value of the “@groups@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.get' recentData #groups @ -} getRecentDataGroups :: MonadIO m => RecentData -> m (Maybe [T.Text]) getRecentDataGroups s = liftIO $ withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 40) :: IO (Ptr CString) result <- SP.convertIfNonNull val $ \val' -> do val'' <- unpackZeroTerminatedUTF8CArray val' return val'' return result {- | Set the value of the “@groups@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.set' recentData [ #groups 'Data.GI.Base.Attributes.:=' value ] @ -} setRecentDataGroups :: MonadIO m => RecentData -> Ptr CString -> m () setRecentDataGroups s val = liftIO $ withManagedPtr s $ \ptr -> do poke (ptr `plusPtr` 40) (val :: Ptr CString) {- | Set the value of the “@groups@” field to `Nothing`. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.clear' #groups @ -} clearRecentDataGroups :: MonadIO m => RecentData -> m () clearRecentDataGroups s = liftIO $ withManagedPtr s $ \ptr -> do poke (ptr `plusPtr` 40) (FP.nullPtr :: Ptr CString) #if ENABLE_OVERLOADING data RecentDataGroupsFieldInfo instance AttrInfo RecentDataGroupsFieldInfo where type AttrAllowedOps RecentDataGroupsFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear] type AttrSetTypeConstraint RecentDataGroupsFieldInfo = (~) (Ptr CString) type AttrBaseTypeConstraint RecentDataGroupsFieldInfo = (~) RecentData type AttrGetType RecentDataGroupsFieldInfo = Maybe [T.Text] type AttrLabel RecentDataGroupsFieldInfo = "groups" type AttrOrigin RecentDataGroupsFieldInfo = RecentData attrGet _ = getRecentDataGroups attrSet _ = setRecentDataGroups attrConstruct = undefined attrClear _ = clearRecentDataGroups recentData_groups :: AttrLabelProxy "groups" recentData_groups = AttrLabelProxy #endif {- | Get the value of the “@is_private@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.get' recentData #isPrivate @ -} getRecentDataIsPrivate :: MonadIO m => RecentData -> m Bool getRecentDataIsPrivate s = liftIO $ withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 48) :: IO CInt let val' = (/= 0) val return val' {- | Set the value of the “@is_private@” field. When is enabled, this is equivalent to @ 'Data.GI.Base.Attributes.set' recentData [ #isPrivate 'Data.GI.Base.Attributes.:=' value ] @ -} setRecentDataIsPrivate :: MonadIO m => RecentData -> Bool -> m () setRecentDataIsPrivate s val = liftIO $ withManagedPtr s $ \ptr -> do let val' = (fromIntegral . fromEnum) val poke (ptr `plusPtr` 48) (val' :: CInt) #if ENABLE_OVERLOADING data RecentDataIsPrivateFieldInfo instance AttrInfo RecentDataIsPrivateFieldInfo where type AttrAllowedOps RecentDataIsPrivateFieldInfo = '[ 'AttrSet, 'AttrGet] type AttrSetTypeConstraint RecentDataIsPrivateFieldInfo = (~) Bool type AttrBaseTypeConstraint RecentDataIsPrivateFieldInfo = (~) RecentData type AttrGetType RecentDataIsPrivateFieldInfo = Bool type AttrLabel RecentDataIsPrivateFieldInfo = "is_private" type AttrOrigin RecentDataIsPrivateFieldInfo = RecentData attrGet _ = getRecentDataIsPrivate attrSet _ = setRecentDataIsPrivate attrConstruct = undefined attrClear _ = undefined recentData_isPrivate :: AttrLabelProxy "isPrivate" recentData_isPrivate = AttrLabelProxy #endif #if ENABLE_OVERLOADING instance O.HasAttributeList RecentData type instance O.AttributeList RecentData = RecentDataAttributeList type RecentDataAttributeList = ('[ '("displayName", RecentDataDisplayNameFieldInfo), '("description", RecentDataDescriptionFieldInfo), '("mimeType", RecentDataMimeTypeFieldInfo), '("appName", RecentDataAppNameFieldInfo), '("appExec", RecentDataAppExecFieldInfo), '("groups", RecentDataGroupsFieldInfo), '("isPrivate", RecentDataIsPrivateFieldInfo)] :: [(Symbol, *)]) #endif #if ENABLE_OVERLOADING type family ResolveRecentDataMethod (t :: Symbol) (o :: *) :: * where ResolveRecentDataMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveRecentDataMethod t RecentData, O.MethodInfo info RecentData p) => OL.IsLabel t (RecentData -> 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