[geary: 1/2] Make the discard button red in the abort draft dialog while keeping the "Keep" button default.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary: 1/2] Make the discard button red in the abort draft dialog while keeping the "Keep" button default.
- Date: Fri, 29 Mar 2019 22:39:36 +0000 (UTC)
commit 17747950a03abf6cc03ac4a9a8ea1e896f993265
Author: Jonathan Haas <jonathan haas kappich de>
Date: Thu Mar 28 11:09:39 2019 +0100
Make the discard button red in the abort draft dialog while keeping the "Keep" button default.
Fixes Issue #342
src/client/composer/composer-widget.vala | 4 +++-
src/client/dialogs/alert-dialog.vala | 30 ++++++++++++++++++++++--------
2 files changed, 25 insertions(+), 9 deletions(-)
---
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index e4035f81..f3541f9f 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -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 ||
diff --git a/src/client/dialogs/alert-dialog.vala b/src/client/dialogs/alert-dialog.vala
index ea3c4d57..371b99d5 100644
--- a/src/client/dialogs/alert-dialog.vala
+++ b/src/client/dialogs/alert-dialog.vala
@@ -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);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]