Allow brief notifications
This change allows certain notifications to be displayed only briefly. The new DConf key brief-notification-duration is the number of seconds for which brief notifications should be displayed. At the moment the only brief notifications are "Message sent", "Conversation archived" and "Message archived". Closes #602
This commit is contained in:
parent
bc4f208d36
commit
02c65476ea
7 changed files with 36 additions and 4 deletions
|
|
@ -128,6 +128,13 @@
|
||||||
email. Set to zero or less to disable.</description>
|
email. Set to zero or less to disable.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
|
<key name="brief-notification-duration" type="i">
|
||||||
|
<default>5</default>
|
||||||
|
<summary>Brief notification display time</summary>
|
||||||
|
<description>The length of time in seconds for which brief notifications should
|
||||||
|
be displayed.</description>
|
||||||
|
</key>
|
||||||
|
|
||||||
<key name="migrated-config" type="b">
|
<key name="migrated-config" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
<summary>Whether we migrated the old settings</summary>
|
<summary>Whether we migrated the old settings</summary>
|
||||||
|
|
|
||||||
|
|
@ -243,8 +243,12 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane, CommandPane {
|
||||||
|
|
||||||
private void on_execute(Application.Command command) {
|
private void on_execute(Application.Command command) {
|
||||||
if (command.executed_label != null) {
|
if (command.executed_label != null) {
|
||||||
|
int notification_time =
|
||||||
|
command.executed_notification_brief ?
|
||||||
|
editor.application.config.brief_notification_duration : 0;
|
||||||
Components.InAppNotification ian =
|
Components.InAppNotification ian =
|
||||||
new Components.InAppNotification(command.executed_label);
|
new Components.InAppNotification(
|
||||||
|
command.executed_label, notification_time);
|
||||||
ian.set_button(_("Undo"), Action.Edit.prefix(Action.Edit.UNDO));
|
ian.set_button(_("Undo"), Action.Edit.prefix(Action.Edit.UNDO));
|
||||||
this.editor.add_notification(ian);
|
this.editor.add_notification(ian);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,14 @@ public abstract class Application.Command : GLib.Object {
|
||||||
*/
|
*/
|
||||||
public string? executed_label { get; protected set; default = null; }
|
public string? executed_label { get; protected set; default = null; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if executed_label should be displayed only briefly to the user.
|
||||||
|
* Set this to true for very frequent notifications.
|
||||||
|
*/
|
||||||
|
public bool executed_notification_brief {
|
||||||
|
get; protected set; default = false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A human-readable label describing the result of calling {@link undo}.
|
* A human-readable label describing the result of calling {@link undo}.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ public class Application.Configuration : Geary.BaseObject {
|
||||||
|
|
||||||
public const string ASK_OPEN_ATTACHMENT_KEY = "ask-open-attachment";
|
public const string ASK_OPEN_ATTACHMENT_KEY = "ask-open-attachment";
|
||||||
public const string AUTOSELECT_KEY = "autoselect";
|
public const string AUTOSELECT_KEY = "autoselect";
|
||||||
|
public const string BRIEF_NOTIFICATION_DURATION = "brief-notification-duration";
|
||||||
public const string COMPOSER_WINDOW_SIZE_KEY = "composer-window-size";
|
public const string COMPOSER_WINDOW_SIZE_KEY = "composer-window-size";
|
||||||
public const string COMPOSE_AS_HTML_KEY = "compose-as-html";
|
public const string COMPOSE_AS_HTML_KEY = "compose-as-html";
|
||||||
public const string CONVERSATION_VIEWER_ZOOM_KEY = "conversation-viewer-zoom";
|
public const string CONVERSATION_VIEWER_ZOOM_KEY = "conversation-viewer-zoom";
|
||||||
|
|
@ -154,6 +155,10 @@ public class Application.Configuration : Geary.BaseObject {
|
||||||
get { return settings.get_int(UNDO_SEND_DELAY); }
|
get { return settings.get_int(UNDO_SEND_DELAY); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The number of seconds for which brief notifications should be displayed. */
|
||||||
|
public int brief_notification_duration {
|
||||||
|
get { return settings.get_int(BRIEF_NOTIFICATION_DURATION); }
|
||||||
|
}
|
||||||
|
|
||||||
// Creates a configuration object.
|
// Creates a configuration object.
|
||||||
public Configuration(string schema_id) {
|
public Configuration(string schema_id) {
|
||||||
|
|
|
||||||
|
|
@ -1558,7 +1558,9 @@ internal class Application.Controller : Geary.BaseObject {
|
||||||
"Email sent to %s"
|
"Email sent to %s"
|
||||||
).printf(Util.Email.to_short_recipient_display(sent));
|
).printf(Util.Email.to_short_recipient_display(sent));
|
||||||
Components.InAppNotification notification =
|
Components.InAppNotification notification =
|
||||||
new Components.InAppNotification(message);
|
new Components.InAppNotification(
|
||||||
|
message, application.config.brief_notification_duration
|
||||||
|
);
|
||||||
foreach (MainWindow window in this.application.get_main_windows()) {
|
foreach (MainWindow window in this.application.get_main_windows()) {
|
||||||
window.add_notification(notification);
|
window.add_notification(notification);
|
||||||
}
|
}
|
||||||
|
|
@ -2324,6 +2326,7 @@ private class Application.ArchiveEmailCommand : RevokableCommand {
|
||||||
base(source, conversations, messages);
|
base(source, conversations, messages);
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.executed_label = executed_label;
|
this.executed_label = executed_label;
|
||||||
|
this.executed_notification_brief = true;
|
||||||
this.undone_label = undone_label;
|
this.undone_label = undone_label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2032,8 +2032,11 @@ public class Application.MainWindow :
|
||||||
private void on_command_redo(Command command) {
|
private void on_command_redo(Command command) {
|
||||||
update_command_actions();
|
update_command_actions();
|
||||||
if (command.executed_label != null) {
|
if (command.executed_label != null) {
|
||||||
|
int notification_time =
|
||||||
|
command.executed_notification_brief ?
|
||||||
|
application.config.brief_notification_duration : 0;
|
||||||
Components.InAppNotification ian =
|
Components.InAppNotification ian =
|
||||||
new Components.InAppNotification(command.executed_label);
|
new Components.InAppNotification(command.executed_label, notification_time);
|
||||||
ian.set_button(_("Undo"), Action.Edit.prefix(Action.Edit.UNDO));
|
ian.set_button(_("Undo"), Action.Edit.prefix(Action.Edit.UNDO));
|
||||||
add_notification(ian);
|
add_notification(ian);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,9 @@ public class Components.InAppNotification : Gtk.Revealer {
|
||||||
* @param message The message that should be displayed.
|
* @param message The message that should be displayed.
|
||||||
* @param keepalive The amount of seconds that the notification should stay visible.
|
* @param keepalive The amount of seconds that the notification should stay visible.
|
||||||
*/
|
*/
|
||||||
public InAppNotification(string message, uint keepalive = DEFAULT_KEEPALIVE) {
|
public InAppNotification(string message, uint keepalive = 0) {
|
||||||
|
if (keepalive == 0)
|
||||||
|
keepalive = DEFAULT_KEEPALIVE;
|
||||||
this.transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN;
|
this.transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN;
|
||||||
this.message_label.label = message;
|
this.message_label.label = message;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue