response_cb (task, response);
}
+static GtkWidget *
+create_message_dialog (GtkAlertDialog *self,
+ GtkWindow *parent)
+{
+ GtkWidget *window;
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ window = g_object_new (GTK_TYPE_MESSAGE_DIALOG,
+ "transient-for", parent,
+ "destroy-with-parent", TRUE,
+ "modal", self->modal,
+ "text", self->message,
+ "secondary-text", self->detail,
+ NULL);
+
+ if (self->buttons && self->buttons[0])
+ {
+ self->cancel_return = -1;
+ for (int i = 0; self->buttons[i]; i++)
+ {
+ gtk_dialog_add_button (GTK_DIALOG (window), self->buttons[i], i);
+ if (self->default_button == i)
+ gtk_dialog_set_default_response (GTK_DIALOG (window), i);
+ if (self->cancel_button == i)
+ self->cancel_return = i;
+ }
+ }
+ else
+ {
+ gtk_dialog_add_button (GTK_DIALOG (window), _("_Close"), 0);
+ gtk_dialog_set_default_response (GTK_DIALOG (window), 0);
+ self->cancel_return = 0;
+ }
+G_GNUC_END_IGNORE_DEPRECATIONS
+
+ return window;
+}
+
/* }}} */
/* {{{ Async API */
* Since: 4.10
*/
void
-gtk_alert_dialog_choose (GtkAlertDialog *self,
+gtk_alert_dialog_choose (GtkAlertDialog *self,
GtkWindow *parent,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GtkMessageDialog *window;
+ GtkWidget *window;
GTask *task;
g_return_if_fail (GTK_IS_ALERT_DIALOG (self));
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- window = g_object_new (GTK_TYPE_MESSAGE_DIALOG,
- "transient-for", parent,
- "destroy-with-parent", TRUE,
- "modal", self->modal,
- "text", self->message,
- "secondary-text", self->detail,
- NULL);
-
- if (self->buttons && self->buttons[0])
- {
- self->cancel_return = -1;
- for (int i = 0; self->buttons[i]; i++)
- {
- gtk_dialog_add_button (GTK_DIALOG (window), self->buttons[i], i);
- if (self->default_button == i)
- gtk_dialog_set_default_response (GTK_DIALOG (window), i);
- if (self->cancel_button == i)
- self->cancel_return = i;
- }
- }
- else
- {
- gtk_dialog_add_button (GTK_DIALOG (window), _("_Close"), 0);
- gtk_dialog_set_default_response (GTK_DIALOG (window), 0);
- self->cancel_return = 0;
- }
-G_GNUC_END_IGNORE_DEPRECATIONS
+ window = create_message_dialog (self, parent);
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, gtk_alert_dialog_choose);