Commit 598a1d02 authored by Michael Gratton's avatar Michael Gratton 🤞

Merge branch 'draft-alert-dialog' into 'master'

Make the discard button red in the abort draft dialog while keeping the "Keep" button default.

Closes #342

See merge request !184
parents 5d79e542 17747950
Pipeline #71789 failed with stages
in 18 minutes and 23 seconds
......@@ -1136,7 +1136,9 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
null,
Stock._KEEP,
Stock._DISCARD, Gtk.ResponseType.CLOSE,
"suggested-action"
"",
"destructive-action",
Gtk.ResponseType.OK // Default == Keep
);
Gtk.ResponseType response = dialog.run();
if (response == Gtk.ResponseType.CANCEL ||
......
......@@ -7,17 +7,23 @@
class AlertDialog : Object {
private Gtk.MessageDialog dialog;
public AlertDialog(Gtk.Window? parent, Gtk.MessageType message_type, string title, string? description,
string? ok_button, string? cancel_button, string? tertiary_button,
Gtk.ResponseType tertiary_response_type, string? ok_action_type) {
public AlertDialog(Gtk.Window? parent, Gtk.MessageType message_type, string title,
string? description, string? ok_button, string? cancel_button, string? tertiary_button,
Gtk.ResponseType tertiary_response_type, string? ok_action_type,
string? tertiary_action_type = "", Gtk.ResponseType? default_response = null) {
dialog = new Gtk.MessageDialog(parent, Gtk.DialogFlags.DESTROY_WITH_PARENT, message_type,
Gtk.ButtonsType.NONE, "");
dialog.text = title;
dialog.secondary_text = description;
if (!Geary.String.is_empty_or_whitespace(tertiary_button))
dialog.add_button(tertiary_button, tertiary_response_type);
if (!Geary.String.is_empty_or_whitespace(tertiary_button)) {
Gtk.Widget? button = dialog.add_button(tertiary_button, tertiary_response_type);
if (!Geary.String.is_empty_or_whitespace(tertiary_action_type)) {
button.get_style_context().add_class(tertiary_action_type);
}
}
if (!Geary.String.is_empty_or_whitespace(cancel_button))
dialog.add_button(cancel_button, Gtk.ResponseType.CANCEL);
......@@ -28,6 +34,10 @@ class AlertDialog : Object {
button.get_style_context().add_class(ok_action_type);
}
}
if (default_response != null) {
dialog.set_default_response(default_response);
}
}
public void use_secondary_markup(bool markup) {
......@@ -64,9 +74,13 @@ class ConfirmationDialog : AlertDialog {
class TernaryConfirmationDialog : AlertDialog {
public TernaryConfirmationDialog(Gtk.Window? parent, string title, string? description,
string? ok_button, string? tertiary_button, Gtk.ResponseType tertiary_response_type, string? ok_action_type = "") {
base (parent, Gtk.MessageType.WARNING, title, description, ok_button, Stock._CANCEL, tertiary_button,
tertiary_response_type, ok_action_type);
string? ok_button, string? tertiary_button, Gtk.ResponseType tertiary_response_type,
string? ok_action_type = "", string? tertiary_action_type = "",
Gtk.ResponseType? default_response = null) {
base (parent, Gtk.MessageType.WARNING, title, description, ok_button, Stock._CANCEL,
tertiary_button, tertiary_response_type, ok_action_type, tertiary_action_type,
default_response);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment