{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

Native dialogs are platform dialogs that don\'t use 'GI.Gtk.Objects.Dialog.Dialog' or
'GI.Gtk.Objects.Window.Window'. They are used in order to integrate better with a
platform, by looking the same as other native applications and
supporting platform specific features.

The 'GI.Gtk.Objects.Dialog.Dialog' functions cannot be used on such objects, but we
need a similar API in order to drive them. The 'GI.Gtk.Objects.NativeDialog.NativeDialog'
object is an API that allows you to do this. It allows you to set
various common properties on the dialog, as well as show and hide
it and get a 'GI.Gtk.Objects.NativeDialog.NativeDialog'::@/response/@ signal when the user finished
with the dialog.

There is also a 'GI.Gtk.Objects.NativeDialog.nativeDialogRun' helper that makes it easy
to run any native dialog in a modal way with a recursive mainloop,
similar to 'GI.Gtk.Objects.Dialog.dialogRun'.
-}

module GI.Gtk.Objects.NativeDialog
    ( 

-- * Exported types
    NativeDialog(..)                        ,
    IsNativeDialog                          ,
    toNativeDialog                          ,
    noNativeDialog                          ,


 -- * Methods
-- ** destroy #method:destroy#
    NativeDialogDestroyMethodInfo           ,
    nativeDialogDestroy                     ,


-- ** getModal #method:getModal#
    NativeDialogGetModalMethodInfo          ,
    nativeDialogGetModal                    ,


-- ** getTitle #method:getTitle#
    NativeDialogGetTitleMethodInfo          ,
    nativeDialogGetTitle                    ,


-- ** getTransientFor #method:getTransientFor#
    NativeDialogGetTransientForMethodInfo   ,
    nativeDialogGetTransientFor             ,


-- ** getVisible #method:getVisible#
    NativeDialogGetVisibleMethodInfo        ,
    nativeDialogGetVisible                  ,


-- ** hide #method:hide#
    NativeDialogHideMethodInfo              ,
    nativeDialogHide                        ,


-- ** run #method:run#
    NativeDialogRunMethodInfo               ,
    nativeDialogRun                         ,


-- ** setModal #method:setModal#
    NativeDialogSetModalMethodInfo          ,
    nativeDialogSetModal                    ,


-- ** setTitle #method:setTitle#
    NativeDialogSetTitleMethodInfo          ,
    nativeDialogSetTitle                    ,


-- ** setTransientFor #method:setTransientFor#
    NativeDialogSetTransientForMethodInfo   ,
    nativeDialogSetTransientFor             ,


-- ** show #method:show#
    NativeDialogShowMethodInfo              ,
    nativeDialogShow                        ,




 -- * Properties
-- ** modal #attr:modal#
    NativeDialogModalPropertyInfo           ,
    constructNativeDialogModal              ,
    getNativeDialogModal                    ,
    nativeDialogModal                       ,
    setNativeDialogModal                    ,


-- ** title #attr:title#
    NativeDialogTitlePropertyInfo           ,
    constructNativeDialogTitle              ,
    getNativeDialogTitle                    ,
    nativeDialogTitle                       ,
    setNativeDialogTitle                    ,


-- ** transientFor #attr:transientFor#
    NativeDialogTransientForPropertyInfo    ,
    clearNativeDialogTransientFor           ,
    constructNativeDialogTransientFor       ,
    getNativeDialogTransientFor             ,
    nativeDialogTransientFor                ,
    setNativeDialogTransientFor             ,


-- ** visible #attr:visible#
    NativeDialogVisiblePropertyInfo         ,
    constructNativeDialogVisible            ,
    getNativeDialogVisible                  ,
    nativeDialogVisible                     ,
    setNativeDialogVisible                  ,




 -- * Signals
-- ** response #signal:response#
    C_NativeDialogResponseCallback          ,
    NativeDialogResponseCallback            ,
    NativeDialogResponseSignalInfo          ,
    afterNativeDialogResponse               ,
    genClosure_NativeDialogResponse         ,
    mk_NativeDialogResponseCallback         ,
    noNativeDialogResponseCallback          ,
    onNativeDialogResponse                  ,
    wrap_NativeDialogResponseCallback       ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gtk.Objects.Window as Gtk.Window

newtype NativeDialog = NativeDialog (ManagedPtr NativeDialog)
foreign import ccall "gtk_native_dialog_get_type"
    c_gtk_native_dialog_get_type :: IO GType

instance GObject NativeDialog where
    gobjectType _ = c_gtk_native_dialog_get_type
    

class GObject o => IsNativeDialog o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError NativeDialog a) =>
    IsNativeDialog a
#endif
instance IsNativeDialog NativeDialog
instance GObject.Object.IsObject NativeDialog

toNativeDialog :: IsNativeDialog o => o -> IO NativeDialog
toNativeDialog = unsafeCastTo NativeDialog

noNativeDialog :: Maybe NativeDialog
noNativeDialog = Nothing

type family ResolveNativeDialogMethod (t :: Symbol) (o :: *) :: * where
    ResolveNativeDialogMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveNativeDialogMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveNativeDialogMethod "destroy" o = NativeDialogDestroyMethodInfo
    ResolveNativeDialogMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveNativeDialogMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveNativeDialogMethod "hide" o = NativeDialogHideMethodInfo
    ResolveNativeDialogMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveNativeDialogMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveNativeDialogMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveNativeDialogMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveNativeDialogMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveNativeDialogMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveNativeDialogMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveNativeDialogMethod "run" o = NativeDialogRunMethodInfo
    ResolveNativeDialogMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveNativeDialogMethod "show" o = NativeDialogShowMethodInfo
    ResolveNativeDialogMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveNativeDialogMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveNativeDialogMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveNativeDialogMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveNativeDialogMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveNativeDialogMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveNativeDialogMethod "getModal" o = NativeDialogGetModalMethodInfo
    ResolveNativeDialogMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveNativeDialogMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveNativeDialogMethod "getTitle" o = NativeDialogGetTitleMethodInfo
    ResolveNativeDialogMethod "getTransientFor" o = NativeDialogGetTransientForMethodInfo
    ResolveNativeDialogMethod "getVisible" o = NativeDialogGetVisibleMethodInfo
    ResolveNativeDialogMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveNativeDialogMethod "setModal" o = NativeDialogSetModalMethodInfo
    ResolveNativeDialogMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveNativeDialogMethod "setTitle" o = NativeDialogSetTitleMethodInfo
    ResolveNativeDialogMethod "setTransientFor" o = NativeDialogSetTransientForMethodInfo
    ResolveNativeDialogMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveNativeDialogMethod t NativeDialog, O.MethodInfo info NativeDialog p) => O.IsLabelProxy t (NativeDialog -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveNativeDialogMethod t NativeDialog, O.MethodInfo info NativeDialog p) => O.IsLabel t (NativeDialog -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- signal NativeDialog::response
type NativeDialogResponseCallback =
    Int32 ->
    IO ()

noNativeDialogResponseCallback :: Maybe NativeDialogResponseCallback
noNativeDialogResponseCallback = Nothing

type C_NativeDialogResponseCallback =
    Ptr () ->                               -- object
    Int32 ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_NativeDialogResponseCallback :: C_NativeDialogResponseCallback -> IO (FunPtr C_NativeDialogResponseCallback)

genClosure_NativeDialogResponse :: NativeDialogResponseCallback -> IO Closure
genClosure_NativeDialogResponse cb = do
    let cb' = wrap_NativeDialogResponseCallback cb
    mk_NativeDialogResponseCallback cb' >>= newCClosure


wrap_NativeDialogResponseCallback ::
    NativeDialogResponseCallback ->
    Ptr () ->
    Int32 ->
    Ptr () ->
    IO ()
wrap_NativeDialogResponseCallback _cb _ responseId _ = do
    _cb  responseId


onNativeDialogResponse :: (GObject a, MonadIO m) => a -> NativeDialogResponseCallback -> m SignalHandlerId
onNativeDialogResponse obj cb = liftIO $ connectNativeDialogResponse obj cb SignalConnectBefore
afterNativeDialogResponse :: (GObject a, MonadIO m) => a -> NativeDialogResponseCallback -> m SignalHandlerId
afterNativeDialogResponse obj cb = connectNativeDialogResponse obj cb SignalConnectAfter

connectNativeDialogResponse :: (GObject a, MonadIO m) =>
                               a -> NativeDialogResponseCallback -> SignalConnectMode -> m SignalHandlerId
connectNativeDialogResponse obj cb after = liftIO $ do
    let cb' = wrap_NativeDialogResponseCallback cb
    cb'' <- mk_NativeDialogResponseCallback cb'
    connectSignalFunPtr obj "response" cb'' after

-- VVV Prop "modal"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just False,Just False)

getNativeDialogModal :: (MonadIO m, IsNativeDialog o) => o -> m Bool
getNativeDialogModal obj = liftIO $ getObjectPropertyBool obj "modal"

setNativeDialogModal :: (MonadIO m, IsNativeDialog o) => o -> Bool -> m ()
setNativeDialogModal obj val = liftIO $ setObjectPropertyBool obj "modal" val

constructNativeDialogModal :: (IsNativeDialog o) => Bool -> IO (GValueConstruct o)
constructNativeDialogModal val = constructObjectPropertyBool "modal" val

data NativeDialogModalPropertyInfo
instance AttrInfo NativeDialogModalPropertyInfo where
    type AttrAllowedOps NativeDialogModalPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint NativeDialogModalPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint NativeDialogModalPropertyInfo = IsNativeDialog
    type AttrGetType NativeDialogModalPropertyInfo = Bool
    type AttrLabel NativeDialogModalPropertyInfo = "modal"
    type AttrOrigin NativeDialogModalPropertyInfo = NativeDialog
    attrGet _ = getNativeDialogModal
    attrSet _ = setNativeDialogModal
    attrConstruct _ = constructNativeDialogModal
    attrClear _ = undefined

-- VVV Prop "title"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just True,Just False)

getNativeDialogTitle :: (MonadIO m, IsNativeDialog o) => o -> m (Maybe T.Text)
getNativeDialogTitle obj = liftIO $ getObjectPropertyString obj "title"

setNativeDialogTitle :: (MonadIO m, IsNativeDialog o) => o -> T.Text -> m ()
setNativeDialogTitle obj val = liftIO $ setObjectPropertyString obj "title" (Just val)

constructNativeDialogTitle :: (IsNativeDialog o) => T.Text -> IO (GValueConstruct o)
constructNativeDialogTitle val = constructObjectPropertyString "title" (Just val)

data NativeDialogTitlePropertyInfo
instance AttrInfo NativeDialogTitlePropertyInfo where
    type AttrAllowedOps NativeDialogTitlePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint NativeDialogTitlePropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint NativeDialogTitlePropertyInfo = IsNativeDialog
    type AttrGetType NativeDialogTitlePropertyInfo = (Maybe T.Text)
    type AttrLabel NativeDialogTitlePropertyInfo = "title"
    type AttrOrigin NativeDialogTitlePropertyInfo = NativeDialog
    attrGet _ = getNativeDialogTitle
    attrSet _ = setNativeDialogTitle
    attrConstruct _ = constructNativeDialogTitle
    attrClear _ = undefined

-- VVV Prop "transient-for"
   -- Type: TInterface (Name {namespace = "Gtk", name = "Window"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]
   -- Nullable: (Just True,Just True)

getNativeDialogTransientFor :: (MonadIO m, IsNativeDialog o) => o -> m (Maybe Gtk.Window.Window)
getNativeDialogTransientFor obj = liftIO $ getObjectPropertyObject obj "transient-for" Gtk.Window.Window

setNativeDialogTransientFor :: (MonadIO m, IsNativeDialog o, Gtk.Window.IsWindow a) => o -> a -> m ()
setNativeDialogTransientFor obj val = liftIO $ setObjectPropertyObject obj "transient-for" (Just val)

constructNativeDialogTransientFor :: (IsNativeDialog o, Gtk.Window.IsWindow a) => a -> IO (GValueConstruct o)
constructNativeDialogTransientFor val = constructObjectPropertyObject "transient-for" (Just val)

clearNativeDialogTransientFor :: (MonadIO m, IsNativeDialog o) => o -> m ()
clearNativeDialogTransientFor obj = liftIO $ setObjectPropertyObject obj "transient-for" (Nothing :: Maybe Gtk.Window.Window)

data NativeDialogTransientForPropertyInfo
instance AttrInfo NativeDialogTransientForPropertyInfo where
    type AttrAllowedOps NativeDialogTransientForPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint NativeDialogTransientForPropertyInfo = Gtk.Window.IsWindow
    type AttrBaseTypeConstraint NativeDialogTransientForPropertyInfo = IsNativeDialog
    type AttrGetType NativeDialogTransientForPropertyInfo = (Maybe Gtk.Window.Window)
    type AttrLabel NativeDialogTransientForPropertyInfo = "transient-for"
    type AttrOrigin NativeDialogTransientForPropertyInfo = NativeDialog
    attrGet _ = getNativeDialogTransientFor
    attrSet _ = setNativeDialogTransientFor
    attrConstruct _ = constructNativeDialogTransientFor
    attrClear _ = clearNativeDialogTransientFor

-- VVV Prop "visible"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just False,Nothing)

getNativeDialogVisible :: (MonadIO m, IsNativeDialog o) => o -> m Bool
getNativeDialogVisible obj = liftIO $ getObjectPropertyBool obj "visible"

setNativeDialogVisible :: (MonadIO m, IsNativeDialog o) => o -> Bool -> m ()
setNativeDialogVisible obj val = liftIO $ setObjectPropertyBool obj "visible" val

constructNativeDialogVisible :: (IsNativeDialog o) => Bool -> IO (GValueConstruct o)
constructNativeDialogVisible val = constructObjectPropertyBool "visible" val

data NativeDialogVisiblePropertyInfo
instance AttrInfo NativeDialogVisiblePropertyInfo where
    type AttrAllowedOps NativeDialogVisiblePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint NativeDialogVisiblePropertyInfo = (~) Bool
    type AttrBaseTypeConstraint NativeDialogVisiblePropertyInfo = IsNativeDialog
    type AttrGetType NativeDialogVisiblePropertyInfo = Bool
    type AttrLabel NativeDialogVisiblePropertyInfo = "visible"
    type AttrOrigin NativeDialogVisiblePropertyInfo = NativeDialog
    attrGet _ = getNativeDialogVisible
    attrSet _ = setNativeDialogVisible
    attrConstruct _ = constructNativeDialogVisible
    attrClear _ = undefined

instance O.HasAttributeList NativeDialog
type instance O.AttributeList NativeDialog = NativeDialogAttributeList
type NativeDialogAttributeList = ('[ '("modal", NativeDialogModalPropertyInfo), '("title", NativeDialogTitlePropertyInfo), '("transientFor", NativeDialogTransientForPropertyInfo), '("visible", NativeDialogVisiblePropertyInfo)] :: [(Symbol, *)])

nativeDialogModal :: AttrLabelProxy "modal"
nativeDialogModal = AttrLabelProxy

nativeDialogTitle :: AttrLabelProxy "title"
nativeDialogTitle = AttrLabelProxy

nativeDialogTransientFor :: AttrLabelProxy "transientFor"
nativeDialogTransientFor = AttrLabelProxy

nativeDialogVisible :: AttrLabelProxy "visible"
nativeDialogVisible = AttrLabelProxy

data NativeDialogResponseSignalInfo
instance SignalInfo NativeDialogResponseSignalInfo where
    type HaskellCallbackType NativeDialogResponseSignalInfo = NativeDialogResponseCallback
    connectSignal _ = connectNativeDialogResponse

type instance O.SignalList NativeDialog = NativeDialogSignalList
type NativeDialogSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo), '("response", NativeDialogResponseSignalInfo)] :: [(Symbol, *)])

-- method NativeDialog::destroy
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gtk", name = "NativeDialog"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkNativeDialog", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_native_dialog_destroy" gtk_native_dialog_destroy :: 
    Ptr NativeDialog ->                     -- self : TInterface (Name {namespace = "Gtk", name = "NativeDialog"})
    IO ()

{- |
Destroys a dialog.

When a dialog is destroyed, it will break any references it holds
to other objects. If it is visible it will be hidden and any underlying
window system resources will be destroyed.

Note that this does not release any reference to the object (as opposed to
destroying a GtkWindow) because there is no reference from the windowing
system to the 'GI.Gtk.Objects.NativeDialog.NativeDialog'.

@since 3.20
-}
nativeDialogDestroy ::
    (B.CallStack.HasCallStack, MonadIO m, IsNativeDialog a) =>
    a
    {- ^ /@self@/: a 'GI.Gtk.Objects.NativeDialog.NativeDialog' -}
    -> m ()
nativeDialogDestroy self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    gtk_native_dialog_destroy self'
    touchManagedPtr self
    return ()

data NativeDialogDestroyMethodInfo
instance (signature ~ (m ()), MonadIO m, IsNativeDialog a) => O.MethodInfo NativeDialogDestroyMethodInfo a signature where
    overloadedMethod _ = nativeDialogDestroy

-- method NativeDialog::get_modal
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gtk", name = "NativeDialog"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkNativeDialog", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_native_dialog_get_modal" gtk_native_dialog_get_modal :: 
    Ptr NativeDialog ->                     -- self : TInterface (Name {namespace = "Gtk", name = "NativeDialog"})
    IO CInt

{- |
Returns whether the dialog is modal. See 'GI.Gtk.Objects.NativeDialog.nativeDialogSetModal'.

@since 3.20
-}
nativeDialogGetModal ::
    (B.CallStack.HasCallStack, MonadIO m, IsNativeDialog a) =>
    a
    {- ^ /@self@/: a 'GI.Gtk.Objects.NativeDialog.NativeDialog' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the dialog is set to be modal -}
nativeDialogGetModal self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- gtk_native_dialog_get_modal self'
    let result' = (/= 0) result
    touchManagedPtr self
    return result'

data NativeDialogGetModalMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsNativeDialog a) => O.MethodInfo NativeDialogGetModalMethodInfo a signature where
    overloadedMethod _ = nativeDialogGetModal

-- method NativeDialog::get_title
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gtk", name = "NativeDialog"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkNativeDialog", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_native_dialog_get_title" gtk_native_dialog_get_title :: 
    Ptr NativeDialog ->                     -- self : TInterface (Name {namespace = "Gtk", name = "NativeDialog"})
    IO CString

{- |
Gets the title of the 'GI.Gtk.Objects.NativeDialog.NativeDialog'.

@since 3.20
-}
nativeDialogGetTitle ::
    (B.CallStack.HasCallStack, MonadIO m, IsNativeDialog a) =>
    a
    {- ^ /@self@/: a 'GI.Gtk.Objects.NativeDialog.NativeDialog' -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ the title of the dialog, or 'Nothing' if none has
   been set explicitly. The returned string is owned by the widget
   and must not be modified or freed. -}
nativeDialogGetTitle self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- gtk_native_dialog_get_title self'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        return result''
    touchManagedPtr self
    return maybeResult

data NativeDialogGetTitleMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsNativeDialog a) => O.MethodInfo NativeDialogGetTitleMethodInfo a signature where
    overloadedMethod _ = nativeDialogGetTitle

-- method NativeDialog::get_transient_for
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gtk", name = "NativeDialog"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkNativeDialog", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gtk", name = "Window"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_native_dialog_get_transient_for" gtk_native_dialog_get_transient_for :: 
    Ptr NativeDialog ->                     -- self : TInterface (Name {namespace = "Gtk", name = "NativeDialog"})
    IO (Ptr Gtk.Window.Window)

{- |
Fetches the transient parent for this window. See
'GI.Gtk.Objects.NativeDialog.nativeDialogSetTransientFor'.

@since 3.20
-}
nativeDialogGetTransientFor ::
    (B.CallStack.HasCallStack, MonadIO m, IsNativeDialog a) =>
    a
    {- ^ /@self@/: a 'GI.Gtk.Objects.NativeDialog.NativeDialog' -}
    -> m (Maybe Gtk.Window.Window)
    {- ^ __Returns:__ the transient parent for this window,
or 'Nothing' if no transient parent has been set. -}
nativeDialogGetTransientFor self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- gtk_native_dialog_get_transient_for self'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject Gtk.Window.Window) result'
        return result''
    touchManagedPtr self
    return maybeResult

data NativeDialogGetTransientForMethodInfo
instance (signature ~ (m (Maybe Gtk.Window.Window)), MonadIO m, IsNativeDialog a) => O.MethodInfo NativeDialogGetTransientForMethodInfo a signature where
    overloadedMethod _ = nativeDialogGetTransientFor

-- method NativeDialog::get_visible
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gtk", name = "NativeDialog"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkNativeDialog", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_native_dialog_get_visible" gtk_native_dialog_get_visible :: 
    Ptr NativeDialog ->                     -- self : TInterface (Name {namespace = "Gtk", name = "NativeDialog"})
    IO CInt

{- |
Determines whether the dialog is visible.

@since 3.20
-}
nativeDialogGetVisible ::
    (B.CallStack.HasCallStack, MonadIO m, IsNativeDialog a) =>
    a
    {- ^ /@self@/: a 'GI.Gtk.Objects.NativeDialog.NativeDialog' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the dialog is visible -}
nativeDialogGetVisible self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- gtk_native_dialog_get_visible self'
    let result' = (/= 0) result
    touchManagedPtr self
    return result'

data NativeDialogGetVisibleMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsNativeDialog a) => O.MethodInfo NativeDialogGetVisibleMethodInfo a signature where
    overloadedMethod _ = nativeDialogGetVisible

-- method NativeDialog::hide
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gtk", name = "NativeDialog"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkNativeDialog", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_native_dialog_hide" gtk_native_dialog_hide :: 
    Ptr NativeDialog ->                     -- self : TInterface (Name {namespace = "Gtk", name = "NativeDialog"})
    IO ()

{- |
Hides the dialog if it is visilbe, aborting any interaction. Once this
is called the  'GI.Gtk.Objects.NativeDialog.NativeDialog'::@/response/@ signal will not be emitted
until after the next call to 'GI.Gtk.Objects.NativeDialog.nativeDialogShow'.

If the dialog is not visible this does nothing.

@since 3.20
-}
nativeDialogHide ::
    (B.CallStack.HasCallStack, MonadIO m, IsNativeDialog a) =>
    a
    {- ^ /@self@/: a 'GI.Gtk.Objects.NativeDialog.NativeDialog' -}
    -> m ()
nativeDialogHide self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    gtk_native_dialog_hide self'
    touchManagedPtr self
    return ()

data NativeDialogHideMethodInfo
instance (signature ~ (m ()), MonadIO m, IsNativeDialog a) => O.MethodInfo NativeDialogHideMethodInfo a signature where
    overloadedMethod _ = nativeDialogHide

-- method NativeDialog::run
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gtk", name = "NativeDialog"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkNativeDialog", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "gtk_native_dialog_run" gtk_native_dialog_run :: 
    Ptr NativeDialog ->                     -- self : TInterface (Name {namespace = "Gtk", name = "NativeDialog"})
    IO Int32

{- |
Blocks in a recursive main loop until /@self@/ emits the
'GI.Gtk.Objects.NativeDialog.NativeDialog'::@/response/@ signal. It then returns the response ID
from the ::response signal emission.

Before entering the recursive main loop, 'GI.Gtk.Objects.NativeDialog.nativeDialogRun'
calls 'GI.Gtk.Objects.NativeDialog.nativeDialogShow' on the dialog for you.

After 'GI.Gtk.Objects.NativeDialog.nativeDialogRun' returns, then dialog will be hidden.

Typical usage of this function might be:

=== /C code/
>
>  gint result = gtk_native_dialog_run (GTK_NATIVE_DIALOG (dialog));
>  switch (result)
>    {
>      case GTK_RESPONSE_ACCEPT:
>         do_application_specific_something ();
>         break;
>      default:
>         do_nothing_since_dialog_was_cancelled ();
>         break;
>    }
>  g_object_unref (dialog);


Note that even though the recursive main loop gives the effect of a
modal dialog (it prevents the user from interacting with other
windows in the same window group while the dialog is run), callbacks
such as timeouts, IO channel watches, DND drops, etc, will
be triggered during a @/gtk_nautilus_dialog_run()/@ call.

@since 3.20
-}
nativeDialogRun ::
    (B.CallStack.HasCallStack, MonadIO m, IsNativeDialog a) =>
    a
    {- ^ /@self@/: a 'GI.Gtk.Objects.NativeDialog.NativeDialog' -}
    -> m Int32
    {- ^ __Returns:__ response ID -}
nativeDialogRun self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- gtk_native_dialog_run self'
    touchManagedPtr self
    return result

data NativeDialogRunMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsNativeDialog a) => O.MethodInfo NativeDialogRunMethodInfo a signature where
    overloadedMethod _ = nativeDialogRun

-- method NativeDialog::set_modal
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gtk", name = "NativeDialog"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkNativeDialog", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "modal", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether the window is modal", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_native_dialog_set_modal" gtk_native_dialog_set_modal :: 
    Ptr NativeDialog ->                     -- self : TInterface (Name {namespace = "Gtk", name = "NativeDialog"})
    CInt ->                                 -- modal : TBasicType TBoolean
    IO ()

{- |
Sets a dialog modal or non-modal. Modal dialogs prevent interaction
with other windows in the same application. To keep modal dialogs
on top of main application windows, use
'GI.Gtk.Objects.NativeDialog.nativeDialogSetTransientFor' to make the dialog transient for the
parent; most [window managers][gtk-X11-arch]
will then disallow lowering the dialog below the parent.

@since 3.20
-}
nativeDialogSetModal ::
    (B.CallStack.HasCallStack, MonadIO m, IsNativeDialog a) =>
    a
    {- ^ /@self@/: a 'GI.Gtk.Objects.NativeDialog.NativeDialog' -}
    -> Bool
    {- ^ /@modal@/: whether the window is modal -}
    -> m ()
nativeDialogSetModal self modal = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    let modal' = (fromIntegral . fromEnum) modal
    gtk_native_dialog_set_modal self' modal'
    touchManagedPtr self
    return ()

data NativeDialogSetModalMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsNativeDialog a) => O.MethodInfo NativeDialogSetModalMethodInfo a signature where
    overloadedMethod _ = nativeDialogSetModal

-- method NativeDialog::set_title
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gtk", name = "NativeDialog"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkNativeDialog", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "title", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "title of the dialog", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_native_dialog_set_title" gtk_native_dialog_set_title :: 
    Ptr NativeDialog ->                     -- self : TInterface (Name {namespace = "Gtk", name = "NativeDialog"})
    CString ->                              -- title : TBasicType TUTF8
    IO ()

{- |
Sets the title of the 'GI.Gtk.Objects.NativeDialog.NativeDialog'.

@since 3.20
-}
nativeDialogSetTitle ::
    (B.CallStack.HasCallStack, MonadIO m, IsNativeDialog a) =>
    a
    {- ^ /@self@/: a 'GI.Gtk.Objects.NativeDialog.NativeDialog' -}
    -> T.Text
    {- ^ /@title@/: title of the dialog -}
    -> m ()
nativeDialogSetTitle self title = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    title' <- textToCString title
    gtk_native_dialog_set_title self' title'
    touchManagedPtr self
    freeMem title'
    return ()

data NativeDialogSetTitleMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsNativeDialog a) => O.MethodInfo NativeDialogSetTitleMethodInfo a signature where
    overloadedMethod _ = nativeDialogSetTitle

-- method NativeDialog::set_transient_for
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gtk", name = "NativeDialog"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkNativeDialog", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parent", argType = TInterface (Name {namespace = "Gtk", name = "Window"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "parent window, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_native_dialog_set_transient_for" gtk_native_dialog_set_transient_for :: 
    Ptr NativeDialog ->                     -- self : TInterface (Name {namespace = "Gtk", name = "NativeDialog"})
    Ptr Gtk.Window.Window ->                -- parent : TInterface (Name {namespace = "Gtk", name = "Window"})
    IO ()

{- |
Dialog windows should be set transient for the main application
window they were spawned from. This allows
[window managers][gtk-X11-arch] to e.g. keep the
dialog on top of the main window, or center the dialog over the
main window.

Passing 'Nothing' for /@parent@/ unsets the current transient window.

@since 3.20
-}
nativeDialogSetTransientFor ::
    (B.CallStack.HasCallStack, MonadIO m, IsNativeDialog a, Gtk.Window.IsWindow b) =>
    a
    {- ^ /@self@/: a 'GI.Gtk.Objects.NativeDialog.NativeDialog' -}
    -> Maybe (b)
    {- ^ /@parent@/: parent window, or 'Nothing' -}
    -> m ()
nativeDialogSetTransientFor self parent = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    maybeParent <- case parent of
        Nothing -> return nullPtr
        Just jParent -> do
            jParent' <- unsafeManagedPtrCastPtr jParent
            return jParent'
    gtk_native_dialog_set_transient_for self' maybeParent
    touchManagedPtr self
    whenJust parent touchManagedPtr
    return ()

data NativeDialogSetTransientForMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsNativeDialog a, Gtk.Window.IsWindow b) => O.MethodInfo NativeDialogSetTransientForMethodInfo a signature where
    overloadedMethod _ = nativeDialogSetTransientFor

-- method NativeDialog::show
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Gtk", name = "NativeDialog"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkNativeDialog", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gtk_native_dialog_show" gtk_native_dialog_show :: 
    Ptr NativeDialog ->                     -- self : TInterface (Name {namespace = "Gtk", name = "NativeDialog"})
    IO ()

{- |
Shows the dialog on the display, allowing the user to interact with
it. When the user accepts the state of the dialog the dialog will
be automatically hidden and the 'GI.Gtk.Objects.NativeDialog.NativeDialog'::@/response/@ signal
will be emitted.

Multiple calls while the dialog is visible will be ignored.

@since 3.20
-}
nativeDialogShow ::
    (B.CallStack.HasCallStack, MonadIO m, IsNativeDialog a) =>
    a
    {- ^ /@self@/: a 'GI.Gtk.Objects.NativeDialog.NativeDialog' -}
    -> m ()
nativeDialogShow self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    gtk_native_dialog_show self'
    touchManagedPtr self
    return ()

data NativeDialogShowMethodInfo
instance (signature ~ (m ()), MonadIO m, IsNativeDialog a) => O.MethodInfo NativeDialogShowMethodInfo a signature where
    overloadedMethod _ = nativeDialogShow