GtkNativeDialog — Integrate with native dialogs
void | gtk_native_dialog_show () |
void | gtk_native_dialog_hide () |
void | gtk_native_dialog_destroy () |
gboolean | gtk_native_dialog_get_visible () |
void | gtk_native_dialog_set_modal () |
gboolean | gtk_native_dialog_get_modal () |
void | gtk_native_dialog_set_title () |
const char * | gtk_native_dialog_get_title () |
void | gtk_native_dialog_set_transient_for () |
GtkWindow * | gtk_native_dialog_get_transient_for () |
gboolean | modal | Read / Write |
char * | title | Read / Write |
GtkWindow * | transient-for | Read / Write / Construct |
gboolean | visible | Read / Write |
void | response | Run Last |
GObject ╰── GtkNativeDialog ╰── GtkFileChooserNative
#include <gtk/gtk.h>
Native dialogs are platform dialogs that don't use GtkDialog or GtkWindow. 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 GtkDialog functions cannot be used on such objects, but we need a similar API in order to drive them. The GtkNativeDialog 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 “response” signal when the user finished with the dialog.
void
gtk_native_dialog_show (GtkNativeDialog *self
);
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 “response” signal will be emitted.
Multiple calls while the dialog is visible will be ignored.
self |
void
gtk_native_dialog_hide (GtkNativeDialog *self
);
Hides the dialog if it is visilbe, aborting any interaction. Once this is called the “response” signal will not be emitted until after the next call to gtk_native_dialog_show()
.
If the dialog is not visible this does nothing.
self |
void
gtk_native_dialog_destroy (GtkNativeDialog *self
);
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 GtkNativeDialog.
self |
gboolean
gtk_native_dialog_get_visible (GtkNativeDialog *self
);
Determines whether the dialog is visible.
self |
TRUE
if the dialog is visible
void gtk_native_dialog_set_modal (GtkNativeDialog *self
,gboolean modal
);
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 gtk_native_dialog_set_transient_for()
to make the dialog transient for the parent; most window managers will then disallow lowering the dialog below the parent.
self | ||
modal | whether the window is modal |
gboolean
gtk_native_dialog_get_modal (GtkNativeDialog *self
);
Returns whether the dialog is modal. See gtk_native_dialog_set_modal()
.
self |
TRUE
if the dialog is set to be modal
void gtk_native_dialog_set_title (GtkNativeDialog *self
,const char *title
);
Sets the title of the GtkNativeDialog.
self | ||
title | title of the dialog |
const char *
gtk_native_dialog_get_title (GtkNativeDialog *self
);
Gets the title of the GtkNativeDialog.
self |
the title of the dialog, or NULL
if none has been set explicitly. The returned string is owned by the widget and must not be modified or freed.
[nullable]
void gtk_native_dialog_set_transient_for (GtkNativeDialog *self
,GtkWindow *parent
);
Dialog windows should be set transient for the main application window they were spawned from. This allows window managers to e.g. keep the dialog on top of the main window, or center the dialog over the main window.
Passing NULL
for parent
unsets the current transient window.
self | ||
parent | parent window, or | [allow-none] |
GtkWindow *
gtk_native_dialog_get_transient_for (GtkNativeDialog *self
);
Fetches the transient parent for this window. See gtk_native_dialog_set_transient_for()
.
self |
the transient parent for this window, or NULL
if no transient parent has been set.
[nullable][transfer none]
typedef struct _GtkNativeDialog GtkNativeDialog;
struct GtkNativeDialogClass { void (* response) (GtkNativeDialog *self, int response_id); };
Class structure for GtkNativeDialog.
| class handler for the “response” signal |
“modal”
property“modal” gboolean
Whether the window should be modal with respect to its transient parent.
Owner: GtkNativeDialog
Flags: Read / Write
Default value: FALSE
“title”
property“title” char *
The title of the dialog window
Owner: GtkNativeDialog
Flags: Read / Write
Default value: NULL
“transient-for”
property“transient-for” GtkWindow *
The transient parent of the dialog, or NULL
for none.
Owner: GtkNativeDialog
Flags: Read / Write / Construct
“visible”
property“visible” gboolean
Whether the window is currently visible.
Owner: GtkNativeDialog
Flags: Read / Write
Default value: FALSE
“response”
signalvoid user_function (GtkNativeDialog *self, int response_id, gpointer user_data)
Emitted when the user responds to the dialog.
When this is called the dialog has been hidden.
If you call gtk_native_dialog_hide()
before the user responds to the dialog this signal will not be emitted.
self | the object on which the signal is emitted | |
response_id | the response ID | |
user_data | user data set when the signal handler was connected. |
Flags: Run Last
© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/GtkNativeDialog.html