{- |
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.WebKit.Objects.WebHistoryItem
    ( 

-- * Exported types
    WebHistoryItem(..)                      ,
    WebHistoryItemK                         ,
    toWebHistoryItem                        ,
    noWebHistoryItem                        ,


 -- * Methods
-- ** webHistoryItemCopy
    webHistoryItemCopy                      ,


-- ** webHistoryItemGetAlternateTitle
    webHistoryItemGetAlternateTitle         ,


-- ** webHistoryItemGetLastVisitedTime
    webHistoryItemGetLastVisitedTime        ,


-- ** webHistoryItemGetOriginalUri
    webHistoryItemGetOriginalUri            ,


-- ** webHistoryItemGetTitle
    webHistoryItemGetTitle                  ,


-- ** webHistoryItemGetUri
    webHistoryItemGetUri                    ,


-- ** webHistoryItemNew
    webHistoryItemNew                       ,


-- ** webHistoryItemNewWithData
    webHistoryItemNewWithData               ,


-- ** webHistoryItemSetAlternateTitle
    webHistoryItemSetAlternateTitle         ,




 -- * Properties
-- ** AlternateTitle
    WebHistoryItemAlternateTitlePropertyInfo,
    constructWebHistoryItemAlternateTitle   ,
    getWebHistoryItemAlternateTitle         ,
    setWebHistoryItemAlternateTitle         ,


-- ** LastVisitedTime
    WebHistoryItemLastVisitedTimePropertyInfo,
    getWebHistoryItemLastVisitedTime        ,


-- ** OriginalUri
    WebHistoryItemOriginalUriPropertyInfo   ,
    getWebHistoryItemOriginalUri            ,


-- ** Title
    WebHistoryItemTitlePropertyInfo         ,
    getWebHistoryItemTitle                  ,


-- ** Uri
    WebHistoryItemUriPropertyInfo           ,
    getWebHistoryItemUri                    ,




    ) 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.WebKit.Types
import GI.WebKit.Callbacks
import qualified GI.GObject as GObject

newtype WebHistoryItem = WebHistoryItem (ForeignPtr WebHistoryItem)
foreign import ccall "webkit_web_history_item_get_type"
    c_webkit_web_history_item_get_type :: IO GType

type instance ParentTypes WebHistoryItem = WebHistoryItemParentTypes
type WebHistoryItemParentTypes = '[GObject.Object]

instance GObject WebHistoryItem where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_web_history_item_get_type
    

class GObject o => WebHistoryItemK o
instance (GObject o, IsDescendantOf WebHistoryItem o) => WebHistoryItemK o

toWebHistoryItem :: WebHistoryItemK o => o -> IO WebHistoryItem
toWebHistoryItem = unsafeCastTo WebHistoryItem

noWebHistoryItem :: Maybe WebHistoryItem
noWebHistoryItem = Nothing

-- VVV Prop "alternate-title"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable]

getWebHistoryItemAlternateTitle :: (MonadIO m, WebHistoryItemK o) => o -> m T.Text
getWebHistoryItemAlternateTitle obj = liftIO $ getObjectPropertyString obj "alternate-title"

setWebHistoryItemAlternateTitle :: (MonadIO m, WebHistoryItemK o) => o -> T.Text -> m ()
setWebHistoryItemAlternateTitle obj val = liftIO $ setObjectPropertyString obj "alternate-title" val

constructWebHistoryItemAlternateTitle :: T.Text -> IO ([Char], GValue)
constructWebHistoryItemAlternateTitle val = constructObjectPropertyString "alternate-title" val

data WebHistoryItemAlternateTitlePropertyInfo
instance AttrInfo WebHistoryItemAlternateTitlePropertyInfo where
    type AttrAllowedOps WebHistoryItemAlternateTitlePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint WebHistoryItemAlternateTitlePropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint WebHistoryItemAlternateTitlePropertyInfo = WebHistoryItemK
    type AttrGetType WebHistoryItemAlternateTitlePropertyInfo = T.Text
    type AttrLabel WebHistoryItemAlternateTitlePropertyInfo = "WebHistoryItem::alternate-title"
    attrGet _ = getWebHistoryItemAlternateTitle
    attrSet _ = setWebHistoryItemAlternateTitle
    attrConstruct _ = constructWebHistoryItemAlternateTitle

-- VVV Prop "last-visited-time"
   -- Type: TBasicType TDouble
   -- Flags: [PropertyReadable]

getWebHistoryItemLastVisitedTime :: (MonadIO m, WebHistoryItemK o) => o -> m Double
getWebHistoryItemLastVisitedTime obj = liftIO $ getObjectPropertyDouble obj "last-visited-time"

data WebHistoryItemLastVisitedTimePropertyInfo
instance AttrInfo WebHistoryItemLastVisitedTimePropertyInfo where
    type AttrAllowedOps WebHistoryItemLastVisitedTimePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint WebHistoryItemLastVisitedTimePropertyInfo = (~) ()
    type AttrBaseTypeConstraint WebHistoryItemLastVisitedTimePropertyInfo = WebHistoryItemK
    type AttrGetType WebHistoryItemLastVisitedTimePropertyInfo = Double
    type AttrLabel WebHistoryItemLastVisitedTimePropertyInfo = "WebHistoryItem::last-visited-time"
    attrGet _ = getWebHistoryItemLastVisitedTime
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "original-uri"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]

getWebHistoryItemOriginalUri :: (MonadIO m, WebHistoryItemK o) => o -> m T.Text
getWebHistoryItemOriginalUri obj = liftIO $ getObjectPropertyString obj "original-uri"

data WebHistoryItemOriginalUriPropertyInfo
instance AttrInfo WebHistoryItemOriginalUriPropertyInfo where
    type AttrAllowedOps WebHistoryItemOriginalUriPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint WebHistoryItemOriginalUriPropertyInfo = (~) ()
    type AttrBaseTypeConstraint WebHistoryItemOriginalUriPropertyInfo = WebHistoryItemK
    type AttrGetType WebHistoryItemOriginalUriPropertyInfo = T.Text
    type AttrLabel WebHistoryItemOriginalUriPropertyInfo = "WebHistoryItem::original-uri"
    attrGet _ = getWebHistoryItemOriginalUri
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "title"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]

getWebHistoryItemTitle :: (MonadIO m, WebHistoryItemK o) => o -> m T.Text
getWebHistoryItemTitle obj = liftIO $ getObjectPropertyString obj "title"

data WebHistoryItemTitlePropertyInfo
instance AttrInfo WebHistoryItemTitlePropertyInfo where
    type AttrAllowedOps WebHistoryItemTitlePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint WebHistoryItemTitlePropertyInfo = (~) ()
    type AttrBaseTypeConstraint WebHistoryItemTitlePropertyInfo = WebHistoryItemK
    type AttrGetType WebHistoryItemTitlePropertyInfo = T.Text
    type AttrLabel WebHistoryItemTitlePropertyInfo = "WebHistoryItem::title"
    attrGet _ = getWebHistoryItemTitle
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "uri"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]

getWebHistoryItemUri :: (MonadIO m, WebHistoryItemK o) => o -> m T.Text
getWebHistoryItemUri obj = liftIO $ getObjectPropertyString obj "uri"

data WebHistoryItemUriPropertyInfo
instance AttrInfo WebHistoryItemUriPropertyInfo where
    type AttrAllowedOps WebHistoryItemUriPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint WebHistoryItemUriPropertyInfo = (~) ()
    type AttrBaseTypeConstraint WebHistoryItemUriPropertyInfo = WebHistoryItemK
    type AttrGetType WebHistoryItemUriPropertyInfo = T.Text
    type AttrLabel WebHistoryItemUriPropertyInfo = "WebHistoryItem::uri"
    attrGet _ = getWebHistoryItemUri
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList WebHistoryItem = WebHistoryItemAttributeList
type WebHistoryItemAttributeList = ('[ '("alternate-title", WebHistoryItemAlternateTitlePropertyInfo), '("last-visited-time", WebHistoryItemLastVisitedTimePropertyInfo), '("original-uri", WebHistoryItemOriginalUriPropertyInfo), '("title", WebHistoryItemTitlePropertyInfo), '("uri", WebHistoryItemUriPropertyInfo)] :: [(Symbol, *)])

type instance SignalList WebHistoryItem = WebHistoryItemSignalList
type WebHistoryItemSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method WebHistoryItem::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "WebKit" "WebHistoryItem"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_history_item_new" webkit_web_history_item_new :: 
    IO (Ptr WebHistoryItem)


webHistoryItemNew ::
    (MonadIO m) =>
    m WebHistoryItem
webHistoryItemNew  = liftIO $ do
    result <- webkit_web_history_item_new
    checkUnexpectedReturnNULL "webkit_web_history_item_new" result
    result' <- (wrapObject WebHistoryItem) result
    return result'

-- method WebHistoryItem::new_with_data
-- method type : Constructor
-- Args : [Arg {argName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "title", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "title", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "WebKit" "WebHistoryItem"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_history_item_new_with_data" webkit_web_history_item_new_with_data :: 
    CString ->                              -- uri : TBasicType TUTF8
    CString ->                              -- title : TBasicType TUTF8
    IO (Ptr WebHistoryItem)


webHistoryItemNewWithData ::
    (MonadIO m) =>
    T.Text ->                               -- uri
    T.Text ->                               -- title
    m WebHistoryItem
webHistoryItemNewWithData uri title = liftIO $ do
    uri' <- textToCString uri
    title' <- textToCString title
    result <- webkit_web_history_item_new_with_data uri' title'
    checkUnexpectedReturnNULL "webkit_web_history_item_new_with_data" result
    result' <- (wrapObject WebHistoryItem) result
    freeMem uri'
    freeMem title'
    return result'

-- method WebHistoryItem::copy
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebHistoryItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebHistoryItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "WebKit" "WebHistoryItem"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_history_item_copy" webkit_web_history_item_copy :: 
    Ptr WebHistoryItem ->                   -- _obj : TInterface "WebKit" "WebHistoryItem"
    IO (Ptr WebHistoryItem)


webHistoryItemCopy ::
    (MonadIO m, WebHistoryItemK a) =>
    a ->                                    -- _obj
    m WebHistoryItem
webHistoryItemCopy _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_history_item_copy _obj'
    checkUnexpectedReturnNULL "webkit_web_history_item_copy" result
    result' <- (wrapObject WebHistoryItem) result
    touchManagedPtr _obj
    return result'

-- method WebHistoryItem::get_alternate_title
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebHistoryItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebHistoryItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_history_item_get_alternate_title" webkit_web_history_item_get_alternate_title :: 
    Ptr WebHistoryItem ->                   -- _obj : TInterface "WebKit" "WebHistoryItem"
    IO CString


webHistoryItemGetAlternateTitle ::
    (MonadIO m, WebHistoryItemK a) =>
    a ->                                    -- _obj
    m T.Text
webHistoryItemGetAlternateTitle _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_history_item_get_alternate_title _obj'
    checkUnexpectedReturnNULL "webkit_web_history_item_get_alternate_title" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method WebHistoryItem::get_last_visited_time
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebHistoryItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebHistoryItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TDouble
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_history_item_get_last_visited_time" webkit_web_history_item_get_last_visited_time :: 
    Ptr WebHistoryItem ->                   -- _obj : TInterface "WebKit" "WebHistoryItem"
    IO CDouble


webHistoryItemGetLastVisitedTime ::
    (MonadIO m, WebHistoryItemK a) =>
    a ->                                    -- _obj
    m Double
webHistoryItemGetLastVisitedTime _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_history_item_get_last_visited_time _obj'
    let result' = realToFrac result
    touchManagedPtr _obj
    return result'

-- method WebHistoryItem::get_original_uri
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebHistoryItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebHistoryItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_history_item_get_original_uri" webkit_web_history_item_get_original_uri :: 
    Ptr WebHistoryItem ->                   -- _obj : TInterface "WebKit" "WebHistoryItem"
    IO CString


webHistoryItemGetOriginalUri ::
    (MonadIO m, WebHistoryItemK a) =>
    a ->                                    -- _obj
    m T.Text
webHistoryItemGetOriginalUri _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_history_item_get_original_uri _obj'
    checkUnexpectedReturnNULL "webkit_web_history_item_get_original_uri" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method WebHistoryItem::get_title
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebHistoryItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebHistoryItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_history_item_get_title" webkit_web_history_item_get_title :: 
    Ptr WebHistoryItem ->                   -- _obj : TInterface "WebKit" "WebHistoryItem"
    IO CString


webHistoryItemGetTitle ::
    (MonadIO m, WebHistoryItemK a) =>
    a ->                                    -- _obj
    m T.Text
webHistoryItemGetTitle _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_history_item_get_title _obj'
    checkUnexpectedReturnNULL "webkit_web_history_item_get_title" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method WebHistoryItem::get_uri
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebHistoryItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebHistoryItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_history_item_get_uri" webkit_web_history_item_get_uri :: 
    Ptr WebHistoryItem ->                   -- _obj : TInterface "WebKit" "WebHistoryItem"
    IO CString


webHistoryItemGetUri ::
    (MonadIO m, WebHistoryItemK a) =>
    a ->                                    -- _obj
    m T.Text
webHistoryItemGetUri _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_web_history_item_get_uri _obj'
    checkUnexpectedReturnNULL "webkit_web_history_item_get_uri" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method WebHistoryItem::set_alternate_title
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebHistoryItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "title", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "WebHistoryItem", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "title", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_history_item_set_alternate_title" webkit_web_history_item_set_alternate_title :: 
    Ptr WebHistoryItem ->                   -- _obj : TInterface "WebKit" "WebHistoryItem"
    CString ->                              -- title : TBasicType TUTF8
    IO ()


webHistoryItemSetAlternateTitle ::
    (MonadIO m, WebHistoryItemK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- title
    m ()
webHistoryItemSetAlternateTitle _obj title = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    title' <- textToCString title
    webkit_web_history_item_set_alternate_title _obj' title'
    touchManagedPtr _obj
    freeMem title'
    return ()