Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (inaki@blueleaf.cc) |
Safe Haskell | None |
Language | Haskell2010 |
Native dialogs are platform dialogs that don't use Dialog
or
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 Dialog
functions cannot be used on such objects, but we
need a similar API in order to drive them. The 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 NativeDialog
::response
signal when the user finished
with the dialog.
There is also a nativeDialogRun
helper that makes it easy
to run any native dialog in a modal way with a recursive mainloop,
similar to dialogRun
.
Synopsis
- newtype NativeDialog = NativeDialog (ManagedPtr NativeDialog)
- class (GObject o, IsDescendantOf NativeDialog o) => IsNativeDialog o
- toNativeDialog :: (MonadIO m, IsNativeDialog o) => o -> m NativeDialog
- noNativeDialog :: Maybe NativeDialog
- nativeDialogDestroy :: (HasCallStack, MonadIO m, IsNativeDialog a) => a -> m ()
- nativeDialogGetModal :: (HasCallStack, MonadIO m, IsNativeDialog a) => a -> m Bool
- nativeDialogGetTitle :: (HasCallStack, MonadIO m, IsNativeDialog a) => a -> m (Maybe Text)
- nativeDialogGetTransientFor :: (HasCallStack, MonadIO m, IsNativeDialog a) => a -> m (Maybe Window)
- nativeDialogGetVisible :: (HasCallStack, MonadIO m, IsNativeDialog a) => a -> m Bool
- nativeDialogHide :: (HasCallStack, MonadIO m, IsNativeDialog a) => a -> m ()
- nativeDialogRun :: (HasCallStack, MonadIO m, IsNativeDialog a) => a -> m Int32
- nativeDialogSetModal :: (HasCallStack, MonadIO m, IsNativeDialog a) => a -> Bool -> m ()
- nativeDialogSetTitle :: (HasCallStack, MonadIO m, IsNativeDialog a) => a -> Text -> m ()
- nativeDialogSetTransientFor :: (HasCallStack, MonadIO m, IsNativeDialog a, IsWindow b) => a -> Maybe b -> m ()
- nativeDialogShow :: (HasCallStack, MonadIO m, IsNativeDialog a) => a -> m ()
- constructNativeDialogModal :: IsNativeDialog o => Bool -> IO (GValueConstruct o)
- getNativeDialogModal :: (MonadIO m, IsNativeDialog o) => o -> m Bool
- setNativeDialogModal :: (MonadIO m, IsNativeDialog o) => o -> Bool -> m ()
- constructNativeDialogTitle :: IsNativeDialog o => Text -> IO (GValueConstruct o)
- getNativeDialogTitle :: (MonadIO m, IsNativeDialog o) => o -> m (Maybe Text)
- setNativeDialogTitle :: (MonadIO m, IsNativeDialog o) => o -> Text -> m ()
- clearNativeDialogTransientFor :: (MonadIO m, IsNativeDialog o) => o -> m ()
- constructNativeDialogTransientFor :: (IsNativeDialog o, IsWindow a) => a -> IO (GValueConstruct o)
- getNativeDialogTransientFor :: (MonadIO m, IsNativeDialog o) => o -> m (Maybe Window)
- setNativeDialogTransientFor :: (MonadIO m, IsNativeDialog o, IsWindow a) => o -> a -> m ()
- constructNativeDialogVisible :: IsNativeDialog o => Bool -> IO (GValueConstruct o)
- getNativeDialogVisible :: (MonadIO m, IsNativeDialog o) => o -> m Bool
- setNativeDialogVisible :: (MonadIO m, IsNativeDialog o) => o -> Bool -> m ()
- type C_NativeDialogResponseCallback = Ptr () -> Int32 -> Ptr () -> IO ()
- type NativeDialogResponseCallback = Int32 -> IO ()
- afterNativeDialogResponse :: (IsNativeDialog a, MonadIO m) => a -> NativeDialogResponseCallback -> m SignalHandlerId
- genClosure_NativeDialogResponse :: MonadIO m => NativeDialogResponseCallback -> m (GClosure C_NativeDialogResponseCallback)
- mk_NativeDialogResponseCallback :: C_NativeDialogResponseCallback -> IO (FunPtr C_NativeDialogResponseCallback)
- noNativeDialogResponseCallback :: Maybe NativeDialogResponseCallback
- onNativeDialogResponse :: (IsNativeDialog a, MonadIO m) => a -> NativeDialogResponseCallback -> m SignalHandlerId
- wrap_NativeDialogResponseCallback :: NativeDialogResponseCallback -> C_NativeDialogResponseCallback
Exported types
newtype NativeDialog Source #
Memory-managed wrapper type.
Instances
GObject NativeDialog Source # | |
Defined in GI.Gtk.Objects.NativeDialog gobjectType :: IO GType # | |
HasParentTypes NativeDialog Source # | |
Defined in GI.Gtk.Objects.NativeDialog | |
type ParentTypes NativeDialog Source # | |
Defined in GI.Gtk.Objects.NativeDialog |
class (GObject o, IsDescendantOf NativeDialog o) => IsNativeDialog o Source #
Type class for types which can be safely cast to NativeDialog
, for instance with toNativeDialog
.
Instances
(GObject o, IsDescendantOf NativeDialog o) => IsNativeDialog o Source # | |
Defined in GI.Gtk.Objects.NativeDialog |
toNativeDialog :: (MonadIO m, IsNativeDialog o) => o -> m NativeDialog Source #
Cast to NativeDialog
, for types for which this is known to be safe. For general casts, use castTo
.
noNativeDialog :: Maybe NativeDialog Source #
A convenience alias for Nothing
:: Maybe
NativeDialog
.
Methods
destroy
:: (HasCallStack, MonadIO m, IsNativeDialog a) | |
=> a |
|
-> m () |
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 NativeDialog
.
Since: 3.20
getModal
:: (HasCallStack, MonadIO m, IsNativeDialog a) | |
=> a |
|
-> m Bool | Returns: |
Returns whether the dialog is modal. See nativeDialogSetModal
.
Since: 3.20
getTitle
:: (HasCallStack, MonadIO m, IsNativeDialog a) | |
=> a |
|
-> m (Maybe Text) | Returns: the title of the dialog, or |
Gets the title of the NativeDialog
.
Since: 3.20
getTransientFor
nativeDialogGetTransientFor Source #
:: (HasCallStack, MonadIO m, IsNativeDialog a) | |
=> a |
|
-> m (Maybe Window) | Returns: the transient parent for this window,
or |
Fetches the transient parent for this window. See
nativeDialogSetTransientFor
.
Since: 3.20
getVisible
nativeDialogGetVisible Source #
:: (HasCallStack, MonadIO m, IsNativeDialog a) | |
=> a |
|
-> m Bool | Returns: |
Determines whether the dialog is visible.
Since: 3.20
hide
:: (HasCallStack, MonadIO m, IsNativeDialog a) | |
=> a |
|
-> m () |
Hides the dialog if it is visilbe, aborting any interaction. Once this
is called the NativeDialog
::response
signal will not be emitted
until after the next call to nativeDialogShow
.
If the dialog is not visible this does nothing.
Since: 3.20
run
:: (HasCallStack, MonadIO m, IsNativeDialog a) | |
=> a |
|
-> m Int32 | Returns: response ID |
Blocks in a recursive main loop until self
emits the
NativeDialog
::response
signal. It then returns the response ID
from the ::response signal emission.
Before entering the recursive main loop, nativeDialogRun
calls nativeDialogShow
on the dialog for you.
After 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
setModal
:: (HasCallStack, MonadIO m, IsNativeDialog a) | |
=> a |
|
-> Bool |
|
-> m () |
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
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
setTitle
:: (HasCallStack, MonadIO m, IsNativeDialog a) | |
=> a |
|
-> Text |
|
-> m () |
Sets the title of the NativeDialog
.
Since: 3.20
setTransientFor
nativeDialogSetTransientFor Source #
:: (HasCallStack, MonadIO m, IsNativeDialog a, IsWindow b) | |
=> a |
|
-> Maybe b |
|
-> m () |
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
show
:: (HasCallStack, MonadIO m, IsNativeDialog a) | |
=> a |
|
-> m () |
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 NativeDialog
::response
signal
will be emitted.
Multiple calls while the dialog is visible will be ignored.
Since: 3.20
Properties
modal
Whether the window should be modal with respect to its transient parent.
Since: 3.20
constructNativeDialogModal :: IsNativeDialog o => Bool -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “modal
” property. This is rarely needed directly, but it is used by new
.
getNativeDialogModal :: (MonadIO m, IsNativeDialog o) => o -> m Bool Source #
Get the value of the “modal
” property.
When overloading is enabled, this is equivalent to
get
nativeDialog #modal
setNativeDialogModal :: (MonadIO m, IsNativeDialog o) => o -> Bool -> m () Source #
Set the value of the “modal
” property.
When overloading is enabled, this is equivalent to
set
nativeDialog [ #modal:=
value ]
title
The title of the dialog window
Since: 3.20
constructNativeDialogTitle :: IsNativeDialog o => Text -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “title
” property. This is rarely needed directly, but it is used by new
.
getNativeDialogTitle :: (MonadIO m, IsNativeDialog o) => o -> m (Maybe Text) Source #
Get the value of the “title
” property.
When overloading is enabled, this is equivalent to
get
nativeDialog #title
setNativeDialogTitle :: (MonadIO m, IsNativeDialog o) => o -> Text -> m () Source #
Set the value of the “title
” property.
When overloading is enabled, this is equivalent to
set
nativeDialog [ #title:=
value ]
transientFor
The transient parent of the dialog, or Nothing
for none.
Since: 3.20
clearNativeDialogTransientFor :: (MonadIO m, IsNativeDialog o) => o -> m () Source #
Set the value of the “transient-for
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#transientFor
constructNativeDialogTransientFor :: (IsNativeDialog o, IsWindow a) => a -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “transient-for
” property. This is rarely needed directly, but it is used by new
.
getNativeDialogTransientFor :: (MonadIO m, IsNativeDialog o) => o -> m (Maybe Window) Source #
Get the value of the “transient-for
” property.
When overloading is enabled, this is equivalent to
get
nativeDialog #transientFor
setNativeDialogTransientFor :: (MonadIO m, IsNativeDialog o, IsWindow a) => o -> a -> m () Source #
Set the value of the “transient-for
” property.
When overloading is enabled, this is equivalent to
set
nativeDialog [ #transientFor:=
value ]
visible
Whether the window is currenlty visible.
Since: 3.20
constructNativeDialogVisible :: IsNativeDialog o => Bool -> IO (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “visible
” property. This is rarely needed directly, but it is used by new
.
getNativeDialogVisible :: (MonadIO m, IsNativeDialog o) => o -> m Bool Source #
Get the value of the “visible
” property.
When overloading is enabled, this is equivalent to
get
nativeDialog #visible
setNativeDialogVisible :: (MonadIO m, IsNativeDialog o) => o -> Bool -> m () Source #
Set the value of the “visible
” property.
When overloading is enabled, this is equivalent to
set
nativeDialog [ #visible:=
value ]
Signals
response
type C_NativeDialogResponseCallback = Ptr () -> Int32 -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type NativeDialogResponseCallback Source #
Emitted when the user responds to the dialog.
When this is called the dialog has been hidden.
If you call nativeDialogHide
before the user responds to
the dialog this signal will not be emitted.
Since: 3.20
afterNativeDialogResponse :: (IsNativeDialog a, MonadIO m) => a -> NativeDialogResponseCallback -> m SignalHandlerId Source #
Connect a signal handler for the “response
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
nativeDialog #response callback
genClosure_NativeDialogResponse :: MonadIO m => NativeDialogResponseCallback -> m (GClosure C_NativeDialogResponseCallback) Source #
Wrap the callback into a GClosure
.
mk_NativeDialogResponseCallback :: C_NativeDialogResponseCallback -> IO (FunPtr C_NativeDialogResponseCallback) Source #
Generate a function pointer callable from C code, from a C_NativeDialogResponseCallback
.
noNativeDialogResponseCallback :: Maybe NativeDialogResponseCallback Source #
A convenience synonym for
.Nothing
:: Maybe
NativeDialogResponseCallback
onNativeDialogResponse :: (IsNativeDialog a, MonadIO m) => a -> NativeDialogResponseCallback -> m SignalHandlerId Source #
Connect a signal handler for the “response
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
nativeDialog #response callback