Merge branch 'brief-notifications' into 'mainline'
Allow brief notifications Closes #602 See merge request GNOME/geary!400
This commit is contained in:
commit
bcc6f8d56b
7 changed files with 44 additions and 6 deletions
|
|
@ -128,6 +128,13 @@
|
|||
email. Set to zero or less to disable.</description>
|
||||
</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">
|
||||
<default>false</default>
|
||||
<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) {
|
||||
if (command.executed_label != null) {
|
||||
int notification_time =
|
||||
command.executed_notification_brief ?
|
||||
editor.application.config.brief_notification_duration : 0;
|
||||
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));
|
||||
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; }
|
||||
|
||||
/**
|
||||
* 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}.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ public class Application.Configuration : Geary.BaseObject {
|
|||
|
||||
public const string ASK_OPEN_ATTACHMENT_KEY = "ask-open-attachment";
|
||||
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 COMPOSE_AS_HTML_KEY = "compose-as-html";
|
||||
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); }
|
||||
}
|
||||
|
||||
/** 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.
|
||||
public Configuration(string schema_id) {
|
||||
|
|
|
|||
|
|
@ -1558,7 +1558,9 @@ internal class Application.Controller : Geary.BaseObject {
|
|||
"Email sent to %s"
|
||||
).printf(Util.Email.to_short_recipient_display(sent));
|
||||
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()) {
|
||||
window.add_notification(notification);
|
||||
}
|
||||
|
|
@ -2324,6 +2326,7 @@ private class Application.ArchiveEmailCommand : RevokableCommand {
|
|||
base(source, conversations, messages);
|
||||
this.source = source;
|
||||
this.executed_label = executed_label;
|
||||
this.executed_notification_brief = true;
|
||||
this.undone_label = undone_label;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2035,8 +2035,11 @@ public class Application.MainWindow :
|
|||
private void on_command_redo(Command command) {
|
||||
update_command_actions();
|
||||
if (command.executed_label != null) {
|
||||
int notification_time =
|
||||
command.executed_notification_brief ?
|
||||
application.config.brief_notification_duration : 0;
|
||||
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));
|
||||
add_notification(ian);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,13 @@ public class Components.InAppNotification : Gtk.Revealer {
|
|||
* @param message The message that should be displayed.
|
||||
* @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 = -1) {
|
||||
if (keepalive == 0) {
|
||||
this.message_label.label = "";
|
||||
return; // skip the notification
|
||||
}
|
||||
if (keepalive == -1)
|
||||
keepalive = DEFAULT_KEEPALIVE;
|
||||
this.transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN;
|
||||
this.message_label.label = message;
|
||||
|
||||
|
|
@ -44,8 +50,10 @@ public class Components.InAppNotification : Gtk.Revealer {
|
|||
}
|
||||
|
||||
public override void show() {
|
||||
base.show();
|
||||
this.reveal_child = true;
|
||||
if (this.message_label.label != "") {
|
||||
base.show();
|
||||
this.reveal_child = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue