{- |
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.Gio.Objects.Notification
    ( 

-- * Exported types
    Notification(..)                        ,
    NotificationK                           ,
    toNotification                          ,
    noNotification                          ,


 -- * Methods
-- ** notificationAddButton
    notificationAddButton                   ,


-- ** notificationAddButtonWithTarget
    notificationAddButtonWithTarget         ,


-- ** notificationNew
    notificationNew                         ,


-- ** notificationSetBody
    notificationSetBody                     ,


-- ** notificationSetDefaultAction
    notificationSetDefaultAction            ,


-- ** notificationSetDefaultActionAndTarget
    notificationSetDefaultActionAndTarget   ,


-- ** notificationSetIcon
    notificationSetIcon                     ,


-- ** notificationSetPriority
    notificationSetPriority                 ,


-- ** notificationSetTitle
    notificationSetTitle                    ,


-- ** notificationSetUrgent
    notificationSetUrgent                   ,




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

newtype Notification = Notification (ForeignPtr Notification)
foreign import ccall "g_notification_get_type"
    c_g_notification_get_type :: IO GType

type instance ParentTypes Notification = NotificationParentTypes
type NotificationParentTypes = '[GObject.Object]

instance GObject Notification where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_notification_get_type
    

class GObject o => NotificationK o
instance (GObject o, IsDescendantOf Notification o) => NotificationK o

toNotification :: NotificationK o => o -> IO Notification
toNotification = unsafeCastTo Notification

noNotification :: Maybe Notification
noNotification = Nothing

type instance AttributeList Notification = NotificationAttributeList
type NotificationAttributeList = ('[ ] :: [(Symbol, *)])

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

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

foreign import ccall "g_notification_new" g_notification_new :: 
    CString ->                              -- title : TBasicType TUTF8
    IO (Ptr Notification)


notificationNew ::
    (MonadIO m) =>
    T.Text ->                               -- title
    m Notification
notificationNew title = liftIO $ do
    title' <- textToCString title
    result <- g_notification_new title'
    checkUnexpectedReturnNULL "g_notification_new" result
    result' <- (wrapObject Notification) result
    freeMem title'
    return result'

-- method Notification::add_button
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Notification", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "label", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "detailed_action", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Notification", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "label", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "detailed_action", 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 "g_notification_add_button" g_notification_add_button :: 
    Ptr Notification ->                     -- _obj : TInterface "Gio" "Notification"
    CString ->                              -- label : TBasicType TUTF8
    CString ->                              -- detailed_action : TBasicType TUTF8
    IO ()


notificationAddButton ::
    (MonadIO m, NotificationK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- label
    T.Text ->                               -- detailed_action
    m ()
notificationAddButton _obj label detailed_action = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    label' <- textToCString label
    detailed_action' <- textToCString detailed_action
    g_notification_add_button _obj' label' detailed_action'
    touchManagedPtr _obj
    freeMem label'
    freeMem detailed_action'
    return ()

-- method Notification::add_button_with_target
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Notification", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "label", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "action", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "target", argType = TVariant, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Notification", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "label", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "action", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "target", argType = TVariant, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_notification_add_button_with_target_value" g_notification_add_button_with_target_value :: 
    Ptr Notification ->                     -- _obj : TInterface "Gio" "Notification"
    CString ->                              -- label : TBasicType TUTF8
    CString ->                              -- action : TBasicType TUTF8
    Ptr GVariant ->                         -- target : TVariant
    IO ()


notificationAddButtonWithTarget ::
    (MonadIO m, NotificationK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- label
    T.Text ->                               -- action
    Maybe (GVariant) ->                     -- target
    m ()
notificationAddButtonWithTarget _obj label action target = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    label' <- textToCString label
    action' <- textToCString action
    maybeTarget <- case target of
        Nothing -> return nullPtr
        Just jTarget -> do
            let jTarget' = unsafeManagedPtrGetPtr jTarget
            return jTarget'
    g_notification_add_button_with_target_value _obj' label' action' maybeTarget
    touchManagedPtr _obj
    freeMem label'
    freeMem action'
    return ()

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

foreign import ccall "g_notification_set_body" g_notification_set_body :: 
    Ptr Notification ->                     -- _obj : TInterface "Gio" "Notification"
    CString ->                              -- body : TBasicType TUTF8
    IO ()


notificationSetBody ::
    (MonadIO m, NotificationK a) =>
    a ->                                    -- _obj
    Maybe (T.Text) ->                       -- body
    m ()
notificationSetBody _obj body = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeBody <- case body of
        Nothing -> return nullPtr
        Just jBody -> do
            jBody' <- textToCString jBody
            return jBody'
    g_notification_set_body _obj' maybeBody
    touchManagedPtr _obj
    freeMem maybeBody
    return ()

-- method Notification::set_default_action
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Notification", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "detailed_action", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Notification", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "detailed_action", 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 "g_notification_set_default_action" g_notification_set_default_action :: 
    Ptr Notification ->                     -- _obj : TInterface "Gio" "Notification"
    CString ->                              -- detailed_action : TBasicType TUTF8
    IO ()


notificationSetDefaultAction ::
    (MonadIO m, NotificationK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- detailed_action
    m ()
notificationSetDefaultAction _obj detailed_action = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    detailed_action' <- textToCString detailed_action
    g_notification_set_default_action _obj' detailed_action'
    touchManagedPtr _obj
    freeMem detailed_action'
    return ()

-- method Notification::set_default_action_and_target
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Notification", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "action", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "target", argType = TVariant, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Notification", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "action", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "target", argType = TVariant, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_notification_set_default_action_and_target_value" g_notification_set_default_action_and_target_value :: 
    Ptr Notification ->                     -- _obj : TInterface "Gio" "Notification"
    CString ->                              -- action : TBasicType TUTF8
    Ptr GVariant ->                         -- target : TVariant
    IO ()


notificationSetDefaultActionAndTarget ::
    (MonadIO m, NotificationK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- action
    Maybe (GVariant) ->                     -- target
    m ()
notificationSetDefaultActionAndTarget _obj action target = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    action' <- textToCString action
    maybeTarget <- case target of
        Nothing -> return nullPtr
        Just jTarget -> do
            let jTarget' = unsafeManagedPtrGetPtr jTarget
            return jTarget'
    g_notification_set_default_action_and_target_value _obj' action' maybeTarget
    touchManagedPtr _obj
    freeMem action'
    return ()

-- method Notification::set_icon
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Notification", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "icon", argType = TInterface "Gio" "Icon", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Notification", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "icon", argType = TInterface "Gio" "Icon", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_notification_set_icon" g_notification_set_icon :: 
    Ptr Notification ->                     -- _obj : TInterface "Gio" "Notification"
    Ptr Icon ->                             -- icon : TInterface "Gio" "Icon"
    IO ()


notificationSetIcon ::
    (MonadIO m, NotificationK a, IconK b) =>
    a ->                                    -- _obj
    b ->                                    -- icon
    m ()
notificationSetIcon _obj icon = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let icon' = unsafeManagedPtrCastPtr icon
    g_notification_set_icon _obj' icon'
    touchManagedPtr _obj
    touchManagedPtr icon
    return ()

-- method Notification::set_priority
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Notification", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "priority", argType = TInterface "Gio" "NotificationPriority", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Notification", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "priority", argType = TInterface "Gio" "NotificationPriority", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_notification_set_priority" g_notification_set_priority :: 
    Ptr Notification ->                     -- _obj : TInterface "Gio" "Notification"
    CUInt ->                                -- priority : TInterface "Gio" "NotificationPriority"
    IO ()


notificationSetPriority ::
    (MonadIO m, NotificationK a) =>
    a ->                                    -- _obj
    NotificationPriority ->                 -- priority
    m ()
notificationSetPriority _obj priority = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let priority' = (fromIntegral . fromEnum) priority
    g_notification_set_priority _obj' priority'
    touchManagedPtr _obj
    return ()

-- method Notification::set_title
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Notification", 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 "Gio" "Notification", 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 "g_notification_set_title" g_notification_set_title :: 
    Ptr Notification ->                     -- _obj : TInterface "Gio" "Notification"
    CString ->                              -- title : TBasicType TUTF8
    IO ()


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

-- method Notification::set_urgent
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Notification", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "urgent", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Notification", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "urgent", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_notification_set_urgent" g_notification_set_urgent :: 
    Ptr Notification ->                     -- _obj : TInterface "Gio" "Notification"
    CInt ->                                 -- urgent : TBasicType TBoolean
    IO ()


notificationSetUrgent ::
    (MonadIO m, NotificationK a) =>
    a ->                                    -- _obj
    Bool ->                                 -- urgent
    m ()
notificationSetUrgent _obj urgent = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let urgent' = (fromIntegral . fromEnum) urgent
    g_notification_set_urgent _obj' urgent'
    touchManagedPtr _obj
    return ()