{- |
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.Gtk.Objects.Application
    ( 

-- * Exported types
    Application(..)                         ,
    ApplicationK                            ,
    toApplication                           ,
    noApplication                           ,


 -- * Methods
-- ** applicationAddAccelerator
    applicationAddAccelerator               ,


-- ** applicationAddWindow
    applicationAddWindow                    ,


-- ** applicationGetAccelsForAction
    applicationGetAccelsForAction           ,


-- ** applicationGetActionsForAccel
    applicationGetActionsForAccel           ,


-- ** applicationGetActiveWindow
    applicationGetActiveWindow              ,


-- ** applicationGetAppMenu
    applicationGetAppMenu                   ,


-- ** applicationGetMenuById
    applicationGetMenuById                  ,


-- ** applicationGetMenubar
    applicationGetMenubar                   ,


-- ** applicationGetWindowById
    applicationGetWindowById                ,


-- ** applicationGetWindows
    applicationGetWindows                   ,


-- ** applicationInhibit
    applicationInhibit                      ,


-- ** applicationIsInhibited
    applicationIsInhibited                  ,


-- ** applicationListActionDescriptions
    applicationListActionDescriptions       ,


-- ** applicationNew
    applicationNew                          ,


-- ** applicationPrefersAppMenu
    applicationPrefersAppMenu               ,


-- ** applicationRemoveAccelerator
    applicationRemoveAccelerator            ,


-- ** applicationRemoveWindow
    applicationRemoveWindow                 ,


-- ** applicationSetAccelsForAction
    applicationSetAccelsForAction           ,


-- ** applicationSetAppMenu
    applicationSetAppMenu                   ,


-- ** applicationSetMenubar
    applicationSetMenubar                   ,


-- ** applicationUninhibit
    applicationUninhibit                    ,




 -- * Properties
-- ** ActiveWindow
    ApplicationActiveWindowPropertyInfo     ,
    getApplicationActiveWindow              ,


-- ** AppMenu
    ApplicationAppMenuPropertyInfo          ,
    constructApplicationAppMenu             ,
    getApplicationAppMenu                   ,
    setApplicationAppMenu                   ,


-- ** Menubar
    ApplicationMenubarPropertyInfo          ,
    constructApplicationMenubar             ,
    getApplicationMenubar                   ,
    setApplicationMenubar                   ,


-- ** RegisterSession
    ApplicationRegisterSessionPropertyInfo  ,
    constructApplicationRegisterSession     ,
    getApplicationRegisterSession           ,
    setApplicationRegisterSession           ,




 -- * Signals
-- ** WindowAdded
    ApplicationWindowAddedCallback          ,
    ApplicationWindowAddedCallbackC         ,
    ApplicationWindowAddedSignalInfo        ,
    afterApplicationWindowAdded             ,
    applicationWindowAddedCallbackWrapper   ,
    applicationWindowAddedClosure           ,
    mkApplicationWindowAddedCallback        ,
    noApplicationWindowAddedCallback        ,
    onApplicationWindowAdded                ,


-- ** WindowRemoved
    ApplicationWindowRemovedCallback        ,
    ApplicationWindowRemovedCallbackC       ,
    ApplicationWindowRemovedSignalInfo      ,
    afterApplicationWindowRemoved           ,
    applicationWindowRemovedCallbackWrapper ,
    applicationWindowRemovedClosure         ,
    mkApplicationWindowRemovedCallback      ,
    noApplicationWindowRemovedCallback      ,
    onApplicationWindowRemoved              ,




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

newtype Application = Application (ForeignPtr Application)
foreign import ccall "gtk_application_get_type"
    c_gtk_application_get_type :: IO GType

type instance ParentTypes Application = ApplicationParentTypes
type ApplicationParentTypes = '[Gio.Application, GObject.Object, Gio.ActionGroup, Gio.ActionMap]

instance GObject Application where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_gtk_application_get_type
    

class GObject o => ApplicationK o
instance (GObject o, IsDescendantOf Application o) => ApplicationK o

toApplication :: ApplicationK o => o -> IO Application
toApplication = unsafeCastTo Application

noApplication :: Maybe Application
noApplication = Nothing

-- signal Application::window-added
type ApplicationWindowAddedCallback =
    Window ->
    IO ()

noApplicationWindowAddedCallback :: Maybe ApplicationWindowAddedCallback
noApplicationWindowAddedCallback = Nothing

type ApplicationWindowAddedCallbackC =
    Ptr () ->                               -- object
    Ptr Window ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mkApplicationWindowAddedCallback :: ApplicationWindowAddedCallbackC -> IO (FunPtr ApplicationWindowAddedCallbackC)

applicationWindowAddedClosure :: ApplicationWindowAddedCallback -> IO Closure
applicationWindowAddedClosure cb = newCClosure =<< mkApplicationWindowAddedCallback wrapped
    where wrapped = applicationWindowAddedCallbackWrapper cb

applicationWindowAddedCallbackWrapper ::
    ApplicationWindowAddedCallback ->
    Ptr () ->
    Ptr Window ->
    Ptr () ->
    IO ()
applicationWindowAddedCallbackWrapper _cb _ window _ = do
    window' <- (newObject Window) window
    _cb  window'

onApplicationWindowAdded :: (GObject a, MonadIO m) => a -> ApplicationWindowAddedCallback -> m SignalHandlerId
onApplicationWindowAdded obj cb = liftIO $ connectApplicationWindowAdded obj cb SignalConnectBefore
afterApplicationWindowAdded :: (GObject a, MonadIO m) => a -> ApplicationWindowAddedCallback -> m SignalHandlerId
afterApplicationWindowAdded obj cb = connectApplicationWindowAdded obj cb SignalConnectAfter

connectApplicationWindowAdded :: (GObject a, MonadIO m) =>
                                 a -> ApplicationWindowAddedCallback -> SignalConnectMode -> m SignalHandlerId
connectApplicationWindowAdded obj cb after = liftIO $ do
    cb' <- mkApplicationWindowAddedCallback (applicationWindowAddedCallbackWrapper cb)
    connectSignalFunPtr obj "window-added" cb' after

-- signal Application::window-removed
type ApplicationWindowRemovedCallback =
    Window ->
    IO ()

noApplicationWindowRemovedCallback :: Maybe ApplicationWindowRemovedCallback
noApplicationWindowRemovedCallback = Nothing

type ApplicationWindowRemovedCallbackC =
    Ptr () ->                               -- object
    Ptr Window ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mkApplicationWindowRemovedCallback :: ApplicationWindowRemovedCallbackC -> IO (FunPtr ApplicationWindowRemovedCallbackC)

applicationWindowRemovedClosure :: ApplicationWindowRemovedCallback -> IO Closure
applicationWindowRemovedClosure cb = newCClosure =<< mkApplicationWindowRemovedCallback wrapped
    where wrapped = applicationWindowRemovedCallbackWrapper cb

applicationWindowRemovedCallbackWrapper ::
    ApplicationWindowRemovedCallback ->
    Ptr () ->
    Ptr Window ->
    Ptr () ->
    IO ()
applicationWindowRemovedCallbackWrapper _cb _ window _ = do
    window' <- (newObject Window) window
    _cb  window'

onApplicationWindowRemoved :: (GObject a, MonadIO m) => a -> ApplicationWindowRemovedCallback -> m SignalHandlerId
onApplicationWindowRemoved obj cb = liftIO $ connectApplicationWindowRemoved obj cb SignalConnectBefore
afterApplicationWindowRemoved :: (GObject a, MonadIO m) => a -> ApplicationWindowRemovedCallback -> m SignalHandlerId
afterApplicationWindowRemoved obj cb = connectApplicationWindowRemoved obj cb SignalConnectAfter

connectApplicationWindowRemoved :: (GObject a, MonadIO m) =>
                                   a -> ApplicationWindowRemovedCallback -> SignalConnectMode -> m SignalHandlerId
connectApplicationWindowRemoved obj cb after = liftIO $ do
    cb' <- mkApplicationWindowRemovedCallback (applicationWindowRemovedCallbackWrapper cb)
    connectSignalFunPtr obj "window-removed" cb' after

-- VVV Prop "active-window"
   -- Type: TInterface "Gtk" "Window"
   -- Flags: [PropertyReadable]

getApplicationActiveWindow :: (MonadIO m, ApplicationK o) => o -> m Window
getApplicationActiveWindow obj = liftIO $ getObjectPropertyObject obj "active-window" Window

data ApplicationActiveWindowPropertyInfo
instance AttrInfo ApplicationActiveWindowPropertyInfo where
    type AttrAllowedOps ApplicationActiveWindowPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint ApplicationActiveWindowPropertyInfo = (~) ()
    type AttrBaseTypeConstraint ApplicationActiveWindowPropertyInfo = ApplicationK
    type AttrGetType ApplicationActiveWindowPropertyInfo = Window
    type AttrLabel ApplicationActiveWindowPropertyInfo = "Application::active-window"
    attrGet _ = getApplicationActiveWindow
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "app-menu"
   -- Type: TInterface "Gio" "MenuModel"
   -- Flags: [PropertyReadable,PropertyWritable]

getApplicationAppMenu :: (MonadIO m, ApplicationK o) => o -> m Gio.MenuModel
getApplicationAppMenu obj = liftIO $ getObjectPropertyObject obj "app-menu" Gio.MenuModel

setApplicationAppMenu :: (MonadIO m, ApplicationK o, Gio.MenuModelK a) => o -> a -> m ()
setApplicationAppMenu obj val = liftIO $ setObjectPropertyObject obj "app-menu" val

constructApplicationAppMenu :: (Gio.MenuModelK a) => a -> IO ([Char], GValue)
constructApplicationAppMenu val = constructObjectPropertyObject "app-menu" val

data ApplicationAppMenuPropertyInfo
instance AttrInfo ApplicationAppMenuPropertyInfo where
    type AttrAllowedOps ApplicationAppMenuPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint ApplicationAppMenuPropertyInfo = Gio.MenuModelK
    type AttrBaseTypeConstraint ApplicationAppMenuPropertyInfo = ApplicationK
    type AttrGetType ApplicationAppMenuPropertyInfo = Gio.MenuModel
    type AttrLabel ApplicationAppMenuPropertyInfo = "Application::app-menu"
    attrGet _ = getApplicationAppMenu
    attrSet _ = setApplicationAppMenu
    attrConstruct _ = constructApplicationAppMenu

-- VVV Prop "menubar"
   -- Type: TInterface "Gio" "MenuModel"
   -- Flags: [PropertyReadable,PropertyWritable]

getApplicationMenubar :: (MonadIO m, ApplicationK o) => o -> m Gio.MenuModel
getApplicationMenubar obj = liftIO $ getObjectPropertyObject obj "menubar" Gio.MenuModel

setApplicationMenubar :: (MonadIO m, ApplicationK o, Gio.MenuModelK a) => o -> a -> m ()
setApplicationMenubar obj val = liftIO $ setObjectPropertyObject obj "menubar" val

constructApplicationMenubar :: (Gio.MenuModelK a) => a -> IO ([Char], GValue)
constructApplicationMenubar val = constructObjectPropertyObject "menubar" val

data ApplicationMenubarPropertyInfo
instance AttrInfo ApplicationMenubarPropertyInfo where
    type AttrAllowedOps ApplicationMenubarPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint ApplicationMenubarPropertyInfo = Gio.MenuModelK
    type AttrBaseTypeConstraint ApplicationMenubarPropertyInfo = ApplicationK
    type AttrGetType ApplicationMenubarPropertyInfo = Gio.MenuModel
    type AttrLabel ApplicationMenubarPropertyInfo = "Application::menubar"
    attrGet _ = getApplicationMenubar
    attrSet _ = setApplicationMenubar
    attrConstruct _ = constructApplicationMenubar

-- VVV Prop "register-session"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]

getApplicationRegisterSession :: (MonadIO m, ApplicationK o) => o -> m Bool
getApplicationRegisterSession obj = liftIO $ getObjectPropertyBool obj "register-session"

setApplicationRegisterSession :: (MonadIO m, ApplicationK o) => o -> Bool -> m ()
setApplicationRegisterSession obj val = liftIO $ setObjectPropertyBool obj "register-session" val

constructApplicationRegisterSession :: Bool -> IO ([Char], GValue)
constructApplicationRegisterSession val = constructObjectPropertyBool "register-session" val

data ApplicationRegisterSessionPropertyInfo
instance AttrInfo ApplicationRegisterSessionPropertyInfo where
    type AttrAllowedOps ApplicationRegisterSessionPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint ApplicationRegisterSessionPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint ApplicationRegisterSessionPropertyInfo = ApplicationK
    type AttrGetType ApplicationRegisterSessionPropertyInfo = Bool
    type AttrLabel ApplicationRegisterSessionPropertyInfo = "Application::register-session"
    attrGet _ = getApplicationRegisterSession
    attrSet _ = setApplicationRegisterSession
    attrConstruct _ = constructApplicationRegisterSession

type instance AttributeList Application = ApplicationAttributeList
type ApplicationAttributeList = ('[ '("action-group", Gio.ApplicationActionGroupPropertyInfo), '("active-window", ApplicationActiveWindowPropertyInfo), '("app-menu", ApplicationAppMenuPropertyInfo), '("application-id", Gio.ApplicationApplicationIdPropertyInfo), '("flags", Gio.ApplicationFlagsPropertyInfo), '("inactivity-timeout", Gio.ApplicationInactivityTimeoutPropertyInfo), '("is-busy", Gio.ApplicationIsBusyPropertyInfo), '("is-registered", Gio.ApplicationIsRegisteredPropertyInfo), '("is-remote", Gio.ApplicationIsRemotePropertyInfo), '("menubar", ApplicationMenubarPropertyInfo), '("register-session", ApplicationRegisterSessionPropertyInfo), '("resource-base-path", Gio.ApplicationResourceBasePathPropertyInfo)] :: [(Symbol, *)])

data ApplicationWindowAddedSignalInfo
instance SignalInfo ApplicationWindowAddedSignalInfo where
    type HaskellCallbackType ApplicationWindowAddedSignalInfo = ApplicationWindowAddedCallback
    connectSignal _ = connectApplicationWindowAdded

data ApplicationWindowRemovedSignalInfo
instance SignalInfo ApplicationWindowRemovedSignalInfo where
    type HaskellCallbackType ApplicationWindowRemovedSignalInfo = ApplicationWindowRemovedCallback
    connectSignal _ = connectApplicationWindowRemoved

type instance SignalList Application = ApplicationSignalList
type ApplicationSignalList = ('[ '("action-added", Gio.ActionGroupActionAddedSignalInfo), '("action-enabled-changed", Gio.ActionGroupActionEnabledChangedSignalInfo), '("action-removed", Gio.ActionGroupActionRemovedSignalInfo), '("action-state-changed", Gio.ActionGroupActionStateChangedSignalInfo), '("activate", Gio.ApplicationActivateSignalInfo), '("command-line", Gio.ApplicationCommandLineSignalInfo), '("handle-local-options", Gio.ApplicationHandleLocalOptionsSignalInfo), '("notify", GObject.ObjectNotifySignalInfo), '("open", Gio.ApplicationOpenSignalInfo), '("shutdown", Gio.ApplicationShutdownSignalInfo), '("startup", Gio.ApplicationStartupSignalInfo), '("window-added", ApplicationWindowAddedSignalInfo), '("window-removed", ApplicationWindowRemovedSignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

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

foreign import ccall "gtk_application_new" gtk_application_new :: 
    CString ->                              -- application_id : TBasicType TUTF8
    CUInt ->                                -- flags : TInterface "Gio" "ApplicationFlags"
    IO (Ptr Application)


applicationNew ::
    (MonadIO m) =>
    Maybe (T.Text) ->                       -- application_id
    [Gio.ApplicationFlags] ->               -- flags
    m Application
applicationNew application_id flags = liftIO $ do
    maybeApplication_id <- case application_id of
        Nothing -> return nullPtr
        Just jApplication_id -> do
            jApplication_id' <- textToCString jApplication_id
            return jApplication_id'
    let flags' = gflagsToWord flags
    result <- gtk_application_new maybeApplication_id flags'
    checkUnexpectedReturnNULL "gtk_application_new" result
    result' <- (wrapObject Application) result
    freeMem maybeApplication_id
    return result'

-- method Application::add_accelerator
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "accelerator", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "action_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "parameter", argType = TVariant, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "accelerator", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "action_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "parameter", 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 "gtk_application_add_accelerator" gtk_application_add_accelerator :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    CString ->                              -- accelerator : TBasicType TUTF8
    CString ->                              -- action_name : TBasicType TUTF8
    Ptr GVariant ->                         -- parameter : TVariant
    IO ()

{-# DEPRECATED applicationAddAccelerator ["(Since version 3.14)","Use gtk_application_set_accels_for_action() instead"]#-}
applicationAddAccelerator ::
    (MonadIO m, ApplicationK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- accelerator
    T.Text ->                               -- action_name
    Maybe (GVariant) ->                     -- parameter
    m ()
applicationAddAccelerator _obj accelerator action_name parameter = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    accelerator' <- textToCString accelerator
    action_name' <- textToCString action_name
    maybeParameter <- case parameter of
        Nothing -> return nullPtr
        Just jParameter -> do
            let jParameter' = unsafeManagedPtrGetPtr jParameter
            return jParameter'
    gtk_application_add_accelerator _obj' accelerator' action_name' maybeParameter
    touchManagedPtr _obj
    freeMem accelerator'
    freeMem action_name'
    return ()

-- method Application::add_window
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "window", argType = TInterface "Gtk" "Window", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "window", argType = TInterface "Gtk" "Window", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gtk_application_add_window" gtk_application_add_window :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    Ptr Window ->                           -- window : TInterface "Gtk" "Window"
    IO ()


applicationAddWindow ::
    (MonadIO m, ApplicationK a, WindowK b) =>
    a ->                                    -- _obj
    b ->                                    -- window
    m ()
applicationAddWindow _obj window = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let window' = unsafeManagedPtrCastPtr window
    gtk_application_add_window _obj' window'
    touchManagedPtr _obj
    touchManagedPtr window
    return ()

-- method Application::get_accels_for_action
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "detailed_action_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "detailed_action_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TCArray True (-1) (-1) (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_application_get_accels_for_action" gtk_application_get_accels_for_action :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    CString ->                              -- detailed_action_name : TBasicType TUTF8
    IO (Ptr CString)


applicationGetAccelsForAction ::
    (MonadIO m, ApplicationK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- detailed_action_name
    m [T.Text]
applicationGetAccelsForAction _obj detailed_action_name = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    detailed_action_name' <- textToCString detailed_action_name
    result <- gtk_application_get_accels_for_action _obj' detailed_action_name'
    checkUnexpectedReturnNULL "gtk_application_get_accels_for_action" result
    result' <- unpackZeroTerminatedUTF8CArray result
    mapZeroTerminatedCArray freeMem result
    freeMem result
    touchManagedPtr _obj
    freeMem detailed_action_name'
    return result'

-- method Application::get_actions_for_accel
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "accel", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "accel", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TCArray True (-1) (-1) (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_application_get_actions_for_accel" gtk_application_get_actions_for_accel :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    CString ->                              -- accel : TBasicType TUTF8
    IO (Ptr CString)


applicationGetActionsForAccel ::
    (MonadIO m, ApplicationK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- accel
    m [T.Text]
applicationGetActionsForAccel _obj accel = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    accel' <- textToCString accel
    result <- gtk_application_get_actions_for_accel _obj' accel'
    checkUnexpectedReturnNULL "gtk_application_get_actions_for_accel" result
    result' <- unpackZeroTerminatedUTF8CArray result
    mapZeroTerminatedCArray freeMem result
    freeMem result
    touchManagedPtr _obj
    freeMem accel'
    return result'

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

foreign import ccall "gtk_application_get_active_window" gtk_application_get_active_window :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    IO (Ptr Window)


applicationGetActiveWindow ::
    (MonadIO m, ApplicationK a) =>
    a ->                                    -- _obj
    m Window
applicationGetActiveWindow _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gtk_application_get_active_window _obj'
    checkUnexpectedReturnNULL "gtk_application_get_active_window" result
    result' <- (newObject Window) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "gtk_application_get_app_menu" gtk_application_get_app_menu :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    IO (Ptr Gio.MenuModel)


applicationGetAppMenu ::
    (MonadIO m, ApplicationK a) =>
    a ->                                    -- _obj
    m Gio.MenuModel
applicationGetAppMenu _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gtk_application_get_app_menu _obj'
    checkUnexpectedReturnNULL "gtk_application_get_app_menu" result
    result' <- (newObject Gio.MenuModel) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "gtk_application_get_menu_by_id" gtk_application_get_menu_by_id :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    CString ->                              -- id : TBasicType TUTF8
    IO (Ptr Gio.Menu)


applicationGetMenuById ::
    (MonadIO m, ApplicationK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- id
    m Gio.Menu
applicationGetMenuById _obj id = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    id' <- textToCString id
    result <- gtk_application_get_menu_by_id _obj' id'
    checkUnexpectedReturnNULL "gtk_application_get_menu_by_id" result
    result' <- (newObject Gio.Menu) result
    touchManagedPtr _obj
    freeMem id'
    return result'

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

foreign import ccall "gtk_application_get_menubar" gtk_application_get_menubar :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    IO (Ptr Gio.MenuModel)


applicationGetMenubar ::
    (MonadIO m, ApplicationK a) =>
    a ->                                    -- _obj
    m Gio.MenuModel
applicationGetMenubar _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gtk_application_get_menubar _obj'
    checkUnexpectedReturnNULL "gtk_application_get_menubar" result
    result' <- (newObject Gio.MenuModel) result
    touchManagedPtr _obj
    return result'

-- method Application::get_window_by_id
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "id", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "id", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gtk" "Window"
-- throws : False
-- Skip return : False

foreign import ccall "gtk_application_get_window_by_id" gtk_application_get_window_by_id :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    Word32 ->                               -- id : TBasicType TUInt32
    IO (Ptr Window)


applicationGetWindowById ::
    (MonadIO m, ApplicationK a) =>
    a ->                                    -- _obj
    Word32 ->                               -- id
    m Window
applicationGetWindowById _obj id = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gtk_application_get_window_by_id _obj' id
    checkUnexpectedReturnNULL "gtk_application_get_window_by_id" result
    result' <- (newObject Window) result
    touchManagedPtr _obj
    return result'

-- method Application::get_windows
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TGList (TInterface "Gtk" "Window")
-- throws : False
-- Skip return : False

foreign import ccall "gtk_application_get_windows" gtk_application_get_windows :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    IO (Ptr (GList (Ptr Window)))


applicationGetWindows ::
    (MonadIO m, ApplicationK a) =>
    a ->                                    -- _obj
    m [Window]
applicationGetWindows _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gtk_application_get_windows _obj'
    checkUnexpectedReturnNULL "gtk_application_get_windows" result
    result' <- unpackGList result
    result'' <- mapM (newObject Window) result'
    touchManagedPtr _obj
    return result''

-- method Application::inhibit
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "window", argType = TInterface "Gtk" "Window", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gtk" "ApplicationInhibitFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "reason", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "window", argType = TInterface "Gtk" "Window", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gtk" "ApplicationInhibitFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "reason", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "gtk_application_inhibit" gtk_application_inhibit :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    Ptr Window ->                           -- window : TInterface "Gtk" "Window"
    CUInt ->                                -- flags : TInterface "Gtk" "ApplicationInhibitFlags"
    CString ->                              -- reason : TBasicType TUTF8
    IO Word32


applicationInhibit ::
    (MonadIO m, ApplicationK a, WindowK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- window
    [ApplicationInhibitFlags] ->            -- flags
    Maybe (T.Text) ->                       -- reason
    m Word32
applicationInhibit _obj window flags reason = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeWindow <- case window of
        Nothing -> return nullPtr
        Just jWindow -> do
            let jWindow' = unsafeManagedPtrCastPtr jWindow
            return jWindow'
    let flags' = gflagsToWord flags
    maybeReason <- case reason of
        Nothing -> return nullPtr
        Just jReason -> do
            jReason' <- textToCString jReason
            return jReason'
    result <- gtk_application_inhibit _obj' maybeWindow flags' maybeReason
    touchManagedPtr _obj
    whenJust window touchManagedPtr
    freeMem maybeReason
    return result

-- method Application::is_inhibited
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gtk" "ApplicationInhibitFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "flags", argType = TInterface "Gtk" "ApplicationInhibitFlags", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "gtk_application_is_inhibited" gtk_application_is_inhibited :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    CUInt ->                                -- flags : TInterface "Gtk" "ApplicationInhibitFlags"
    IO CInt


applicationIsInhibited ::
    (MonadIO m, ApplicationK a) =>
    a ->                                    -- _obj
    [ApplicationInhibitFlags] ->            -- flags
    m Bool
applicationIsInhibited _obj flags = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let flags' = gflagsToWord flags
    result <- gtk_application_is_inhibited _obj' flags'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Application::list_action_descriptions
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TCArray True (-1) (-1) (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_application_list_action_descriptions" gtk_application_list_action_descriptions :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    IO (Ptr CString)


applicationListActionDescriptions ::
    (MonadIO m, ApplicationK a) =>
    a ->                                    -- _obj
    m [T.Text]
applicationListActionDescriptions _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gtk_application_list_action_descriptions _obj'
    checkUnexpectedReturnNULL "gtk_application_list_action_descriptions" result
    result' <- unpackZeroTerminatedUTF8CArray result
    mapZeroTerminatedCArray freeMem result
    freeMem result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "gtk_application_prefers_app_menu" gtk_application_prefers_app_menu :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    IO CInt


applicationPrefersAppMenu ::
    (MonadIO m, ApplicationK a) =>
    a ->                                    -- _obj
    m Bool
applicationPrefersAppMenu _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- gtk_application_prefers_app_menu _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Application::remove_accelerator
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "action_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "parameter", argType = TVariant, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "action_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "parameter", 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 "gtk_application_remove_accelerator" gtk_application_remove_accelerator :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    CString ->                              -- action_name : TBasicType TUTF8
    Ptr GVariant ->                         -- parameter : TVariant
    IO ()

{-# DEPRECATED applicationRemoveAccelerator ["(Since version 3.14)","Use gtk_application_set_accels_for_action() instead"]#-}
applicationRemoveAccelerator ::
    (MonadIO m, ApplicationK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- action_name
    Maybe (GVariant) ->                     -- parameter
    m ()
applicationRemoveAccelerator _obj action_name parameter = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    action_name' <- textToCString action_name
    maybeParameter <- case parameter of
        Nothing -> return nullPtr
        Just jParameter -> do
            let jParameter' = unsafeManagedPtrGetPtr jParameter
            return jParameter'
    gtk_application_remove_accelerator _obj' action_name' maybeParameter
    touchManagedPtr _obj
    freeMem action_name'
    return ()

-- method Application::remove_window
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "window", argType = TInterface "Gtk" "Window", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "window", argType = TInterface "Gtk" "Window", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gtk_application_remove_window" gtk_application_remove_window :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    Ptr Window ->                           -- window : TInterface "Gtk" "Window"
    IO ()


applicationRemoveWindow ::
    (MonadIO m, ApplicationK a, WindowK b) =>
    a ->                                    -- _obj
    b ->                                    -- window
    m ()
applicationRemoveWindow _obj window = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let window' = unsafeManagedPtrCastPtr window
    gtk_application_remove_window _obj' window'
    touchManagedPtr _obj
    touchManagedPtr window
    return ()

-- method Application::set_accels_for_action
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "detailed_action_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "accels", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "detailed_action_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "accels", argType = TCArray True (-1) (-1) (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 "gtk_application_set_accels_for_action" gtk_application_set_accels_for_action :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    CString ->                              -- detailed_action_name : TBasicType TUTF8
    Ptr CString ->                          -- accels : TCArray True (-1) (-1) (TBasicType TUTF8)
    IO ()


applicationSetAccelsForAction ::
    (MonadIO m, ApplicationK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- detailed_action_name
    [T.Text] ->                             -- accels
    m ()
applicationSetAccelsForAction _obj detailed_action_name accels = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    detailed_action_name' <- textToCString detailed_action_name
    accels' <- packZeroTerminatedUTF8CArray accels
    gtk_application_set_accels_for_action _obj' detailed_action_name' accels'
    touchManagedPtr _obj
    freeMem detailed_action_name'
    mapZeroTerminatedCArray freeMem accels'
    freeMem accels'
    return ()

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

foreign import ccall "gtk_application_set_app_menu" gtk_application_set_app_menu :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    Ptr Gio.MenuModel ->                    -- app_menu : TInterface "Gio" "MenuModel"
    IO ()


applicationSetAppMenu ::
    (MonadIO m, ApplicationK a, Gio.MenuModelK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- app_menu
    m ()
applicationSetAppMenu _obj app_menu = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeApp_menu <- case app_menu of
        Nothing -> return nullPtr
        Just jApp_menu -> do
            let jApp_menu' = unsafeManagedPtrCastPtr jApp_menu
            return jApp_menu'
    gtk_application_set_app_menu _obj' maybeApp_menu
    touchManagedPtr _obj
    whenJust app_menu touchManagedPtr
    return ()

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

foreign import ccall "gtk_application_set_menubar" gtk_application_set_menubar :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    Ptr Gio.MenuModel ->                    -- menubar : TInterface "Gio" "MenuModel"
    IO ()


applicationSetMenubar ::
    (MonadIO m, ApplicationK a, Gio.MenuModelK b) =>
    a ->                                    -- _obj
    Maybe (b) ->                            -- menubar
    m ()
applicationSetMenubar _obj menubar = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    maybeMenubar <- case menubar of
        Nothing -> return nullPtr
        Just jMenubar -> do
            let jMenubar' = unsafeManagedPtrCastPtr jMenubar
            return jMenubar'
    gtk_application_set_menubar _obj' maybeMenubar
    touchManagedPtr _obj
    whenJust menubar touchManagedPtr
    return ()

-- method Application::uninhibit
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cookie", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gtk" "Application", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cookie", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "gtk_application_uninhibit" gtk_application_uninhibit :: 
    Ptr Application ->                      -- _obj : TInterface "Gtk" "Application"
    Word32 ->                               -- cookie : TBasicType TUInt32
    IO ()


applicationUninhibit ::
    (MonadIO m, ApplicationK a) =>
    a ->                                    -- _obj
    Word32 ->                               -- cookie
    m ()
applicationUninhibit _obj cookie = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    gtk_application_uninhibit _obj' cookie
    touchManagedPtr _obj
    return ()