[geary] Dialog: use suggested-action (blue buttons) and destructive-action (red buttons) when necessary. Bug
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Dialog: use suggested-action (blue buttons) and destructive-action (red buttons) when necessary. Bug
- Date: Fri, 14 Oct 2016 00:24:05 +0000 (UTC)
commit 8c20f92409cff1521e2e5fb65912a73cb59f003e
Author: Gautier Pelloux-Prayer <gautier+git damsy net>
Date: Fri Oct 7 15:03:12 2016 +0200
Dialog: use suggested-action (blue buttons) and destructive-action (red buttons) when necessary. Bug
772514
src/client/application/geary-controller.vala | 18 +++++-----
src/client/composer/composer-widget.vala | 12 +++----
src/client/dialogs/alert-dialog.vala | 49 ++++++++++++++-----------
3 files changed, 41 insertions(+), 38 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index b5dcefe..eabdb00 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -1119,7 +1119,7 @@ public class GearyController : Geary.BaseObject {
// give the user two options: reset the Account local store, or exit Geary. A third
// could be done to leave the Account in an unopened state, but we don't currently
// have provisions for that.
- AlertDialog dialog = new QuestionDialog(main_window,
+ QuestionDialog dialog = new QuestionDialog(main_window,
_("Unable to open the database for %s").printf(account.information.id),
_("There was an error opening the local mail database for this account. This is possibly due to
corruption of the database file in this directory:\n\n%s\n\nGeary can rebuild the database and re-synchronize
with the server or exit.\n\nRebuilding the database will destroy all local email and its attachments. <b>The
mail on the your server will not be affected.</b>")
.printf(account.information.data_dir.get_path()),
@@ -1131,10 +1131,10 @@ public class GearyController : Geary.BaseObject {
try {
yield account.rebuild_async();
} catch (Error err) {
- dialog = new ErrorDialog(main_window,
+ ErrorDialog errdialog = new ErrorDialog(main_window,
_("Unable to rebuild database for \"%s\"").printf(account.information.id),
_("Error during rebuild:\n\n%s").printf(err.message));
- dialog.run();
+ errdialog.run();
retry = false;
}
@@ -2004,7 +2004,7 @@ public class GearyController : Geary.BaseObject {
string secondary = _("The file already exists in \"%s\". Replacing it will overwrite its
contents.").printf(
to_overwrite.get_parent().get_basename());
- ConfirmationDialog dialog = new ConfirmationDialog(main_window, primary, secondary, _("_Replace"));
+ ConfirmationDialog dialog = new ConfirmationDialog(main_window, primary, secondary, _("_Replace"),
"destructive-action");
return (dialog.run() == Gtk.ResponseType.OK);
}
@@ -2347,8 +2347,8 @@ public class GearyController : Geary.BaseObject {
// Find out what to do with the inline composers.
// TODO: Remove this in favor of automatically saving drafts
main_window.present();
- QuestionDialog dialog = new QuestionDialog(main_window, _("Close open draft messages?"), null,
- Stock._CLOSE, Stock._CANCEL);
+ ConfirmationDialog dialog = new ConfirmationDialog(main_window, _("Close open draft messages?"),
+ null, Stock._CLOSE, "destructive-action");
if (dialog.run() == Gtk.ResponseType.OK) {
Gee.List<ComposerWidget> composers_to_destroy = new Gee.ArrayList<ComposerWidget>();
foreach (ComposerWidget cw in composer_widgets) {
@@ -2472,7 +2472,7 @@ public class GearyController : Geary.BaseObject {
_("Empty all email from your %s folder?").printf(special_folder_type.get_display_name()),
_("This removes the email from Geary and your email server.")
+ " <b>" + _("This cannot be undone.") + "</b>",
- _("Empty %s").printf(special_folder_type.get_display_name()));
+ _("Empty %s").printf(special_folder_type.get_display_name()), "destructive-action");
dialog.use_secondary_markup(true);
dialog.set_focus_response(Gtk.ResponseType.CANCEL);
@@ -2518,10 +2518,10 @@ public class GearyController : Geary.BaseObject {
public bool confirm_delete(int num_messages) {
main_window.present();
- AlertDialog dialog = new ConfirmationDialog(main_window, ngettext(
+ ConfirmationDialog dialog = new ConfirmationDialog(main_window, ngettext(
"Do you want to permanently delete this message?",
"Do you want to permanently delete these messages?", num_messages),
- null, _("Delete"));
+ null, _("Delete"), "destructive-action");
return (dialog.run() == Gtk.ResponseType.OK);
}
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 88e9585..188b425 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -1168,14 +1168,13 @@ public class ComposerWidget : Gtk.EventBox {
this.container.present();
AlertDialog dialog;
-
if (try_to_save) {
dialog = new TernaryConfirmationDialog(container.top_window,
- _("Do you want to discard this message?"), null, Stock._KEEP, Stock._DISCARD,
- Gtk.ResponseType.CLOSE);
+ _("Do you want to discard this message?"), null, Stock._KEEP, Stock._DISCARD,
+ Gtk.ResponseType.CLOSE, "suggested-action");
} else {
dialog = new ConfirmationDialog(container.top_window,
- _("Do you want to discard this message?"), null, Stock._DISCARD);
+ _("Do you want to discard this message?"), null, Stock._DISCARD, "destructive-action");
}
Gtk.ResponseType response = dialog.run();
@@ -1352,9 +1351,8 @@ public class ComposerWidget : Gtk.EventBox {
}
if (confirmation != null) {
ConfirmationDialog dialog = new ConfirmationDialog(container.top_window,
- confirmation, null, Stock._OK);
- if (dialog.run() != Gtk.ResponseType.OK)
- return false;
+ confirmation, null, Stock._OK, "suggested-action");
+ return (dialog.run() == Gtk.ResponseType.OK);
}
return true;
}
diff --git a/src/client/dialogs/alert-dialog.vala b/src/client/dialogs/alert-dialog.vala
index af3452a..fa48325 100644
--- a/src/client/dialogs/alert-dialog.vala
+++ b/src/client/dialogs/alert-dialog.vala
@@ -7,14 +7,14 @@
class AlertDialog : Object {
private Gtk.MessageDialog dialog;
- public AlertDialog(Gtk.Window? parent, Gtk.MessageType message_type, string primary, string? secondary,
+ 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) {
+ Gtk.ResponseType tertiary_response_type, string? ok_action_type) {
dialog = new Gtk.MessageDialog(parent, Gtk.DialogFlags.DESTROY_WITH_PARENT, message_type,
Gtk.ButtonsType.NONE, "");
- dialog.text = primary;
- dialog.secondary_text = secondary;
+ dialog.text = title;
+ dialog.secondary_text = description;
if (!Geary.String.is_empty_or_whitespace(tertiary_button))
dialog.add_button(tertiary_button, tertiary_response_type);
@@ -22,8 +22,12 @@ class AlertDialog : Object {
if (!Geary.String.is_empty_or_whitespace(cancel_button))
dialog.add_button(cancel_button, Gtk.ResponseType.CANCEL);
- if (!Geary.String.is_empty_or_whitespace(ok_button))
- dialog.add_button(ok_button, Gtk.ResponseType.OK);
+ if (!Geary.String.is_empty_or_whitespace(ok_button)) {
+ Gtk.Widget? button = dialog.add_button(ok_button, Gtk.ResponseType.OK);
+ if (!Geary.String.is_empty_or_whitespace(ok_action_type)) {
+ button.get_style_context().add_class(ok_action_type);
+ }
+ }
}
public void use_secondary_markup(bool markup) {
@@ -51,24 +55,25 @@ class AlertDialog : Object {
}
class ConfirmationDialog : AlertDialog {
- public ConfirmationDialog(Gtk.Window? parent, string primary, string? secondary, string? ok_button) {
- base (parent, Gtk.MessageType.WARNING, primary, secondary, ok_button, Stock._CANCEL,
- null, Gtk.ResponseType.NONE);
+ public ConfirmationDialog(Gtk.Window? parent, string title, string? description,
+ string? ok_button, string? ok_action_type = "") {
+ base (parent, Gtk.MessageType.WARNING, title, description, ok_button, Stock._CANCEL,
+ null, Gtk.ResponseType.NONE, ok_action_type);
}
}
class TernaryConfirmationDialog : AlertDialog {
- public TernaryConfirmationDialog(Gtk.Window? parent, string primary, string? secondary,
- string? ok_button, string? tertiary_button, Gtk.ResponseType tertiary_response_type) {
- base (parent, Gtk.MessageType.WARNING, primary, secondary, ok_button, Stock._CANCEL,
- tertiary_button, tertiary_response_type);
+ 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, tertiary_button, Stock._CANCEL,
+ tertiary_response_type, ok_action_type);
}
}
class ErrorDialog : AlertDialog {
- public ErrorDialog(Gtk.Window? parent, string primary, string? secondary) {
- base (parent, Gtk.MessageType.ERROR, primary, secondary, Stock._OK, null, null,
- Gtk.ResponseType.NONE);
+ public ErrorDialog(Gtk.Window? parent, string title, string? description) {
+ base (parent, Gtk.MessageType.ERROR, title, description, Stock._OK, null, null,
+ Gtk.ResponseType.NONE, null);
}
}
@@ -77,15 +82,15 @@ class QuestionDialog : AlertDialog {
private Gtk.CheckButton? checkbutton = null;
- public QuestionDialog(Gtk.Window? parent, string primary, string? secondary, string yes_button,
- string no_button) {
- base (parent, Gtk.MessageType.QUESTION, primary, secondary, yes_button, no_button, null,
- Gtk.ResponseType.NONE);
+ public QuestionDialog(Gtk.Window? parent, string title, string? description,
+ string yes_button, string no_button) {
+ base (parent, Gtk.MessageType.QUESTION, title, description, yes_button, no_button, null,
+ Gtk.ResponseType.NONE, "suggested-action");
}
- public QuestionDialog.with_checkbox(Gtk.Window? parent, string primary, string? secondary,
+ public QuestionDialog.with_checkbox(Gtk.Window? parent, string title, string? description,
string yes_button, string no_button, string checkbox_label, bool checkbox_default) {
- this (parent, primary, secondary, yes_button, no_button);
+ this (parent, title, description, yes_button, no_button);
checkbutton = new Gtk.CheckButton.with_mnemonic(checkbox_label);
checkbutton.active = checkbox_default;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]