Move undo to in app notifications

This commit is contained in:
Mete Can Eris 2019-06-26 03:35:27 +00:00 committed by Michael Gratton
parent 86465bf331
commit e2896f303c
3 changed files with 16 additions and 42 deletions

View file

@ -8,7 +8,7 @@
/** /**
* Primary controller for a application instance. * Primary controller for an application instance.
* *
* @see GearyAplication * @see GearyAplication
*/ */
@ -172,6 +172,10 @@ public class Application.Controller : Geary.BaseObject {
private uint operation_count = 0; private uint operation_count = 0;
private Geary.Revokable? revokable = null; private Geary.Revokable? revokable = null;
// Store the description for the revokable for tooltip display.
// This was previously stored within the context of undo button of the main toolbar.
private string revokable_description { get; set; }
// List of windows we're waiting to close before Geary closes. // List of windows we're waiting to close before Geary closes.
private Gee.List<ComposerWidget> waiting_to_close = new Gee.ArrayList<ComposerWidget>(); private Gee.List<ComposerWidget> waiting_to_close = new Gee.ArrayList<ComposerWidget>();
@ -1702,7 +1706,7 @@ public class Application.Controller : Geary.BaseObject {
Cancellable? cancellable) { Cancellable? cancellable) {
try { try {
save_revokable(yield source_folder.move_email_async(ids, destination, cancellable), save_revokable(yield source_folder.move_email_async(ids, destination, cancellable),
_("Undo move (Ctrl+Z)")); ngettext("Moved %d message to %s", "Moved %d messages to %s", ids.size).printf(ids.size, destination.to_string()));
} catch (Error err) { } catch (Error err) {
debug("%s: Unable to move %d emails: %s", source_folder.to_string(), ids.size, debug("%s: Unable to move %d emails: %s", source_folder.to_string(), ids.size,
err.message); err.message);
@ -2302,7 +2306,7 @@ public class Application.Controller : Geary.BaseObject {
Geary.FolderPath trash_path = (yield current_account.get_required_special_folder_async( Geary.FolderPath trash_path = (yield current_account.get_required_special_folder_async(
Geary.SpecialFolderType.TRASH, cancellable)).path; Geary.SpecialFolderType.TRASH, cancellable)).path;
save_revokable(yield supports_move.move_email_async(ids, trash_path, cancellable), save_revokable(yield supports_move.move_email_async(ids, trash_path, cancellable),
_("Undo trash (Ctrl+Z)")); ngettext("Trashed %d message", "Trashed %d messages", ids.size).printf(ids.size));
} else { } else {
debug("Folder %s doesn't support move or account %s doesn't have a trash folder", debug("Folder %s doesn't support move or account %s doesn't have a trash folder",
current_folder.to_string(), current_account.to_string()); current_folder.to_string(), current_account.to_string());
@ -2352,7 +2356,7 @@ public class Application.Controller : Geary.BaseObject {
debug("Folder %s doesn't support archive", current_folder.to_string()); debug("Folder %s doesn't support archive", current_folder.to_string());
} else { } else {
save_revokable(yield supports_archive.archive_email_async(ids, cancellable), save_revokable(yield supports_archive.archive_email_async(ids, cancellable),
_("Undo archive (Ctrl+Z)")); ngettext("Archived %d message", "Archived %d messages", ids.size).printf(ids.size));
} }
return; return;
@ -2385,7 +2389,8 @@ public class Application.Controller : Geary.BaseObject {
} }
// store new revokable // store new revokable
revokable = new_revokable; this.revokable = new_revokable;
this.revokable_description = description;
// connect to new revokable // connect to new revokable
if (revokable != null) { if (revokable != null) {
@ -2395,11 +2400,11 @@ public class Application.Controller : Geary.BaseObject {
} }
if (this.main_window != null) { if (this.main_window != null) {
if (revokable != null && description != null) if (this.revokable != null && this.revokable_description != null) {
this.main_window.main_toolbar.undo_tooltip = description; InAppNotification ian = new InAppNotification(this.revokable_description);
else ian.set_button(_("Undo"), "win." + GearyApplication.ACTION_UNDO);
this.main_window.main_toolbar.undo_tooltip = _("Undo (Ctrl+Z)"); this.main_window.add_notification(ian);
}
update_revokable_action(); update_revokable_action();
} }
} }
@ -2422,8 +2427,7 @@ public class Application.Controller : Geary.BaseObject {
if (committed_revokable == null) if (committed_revokable == null)
return; return;
// use existing description save_revokable(committed_revokable, this.revokable_description);
save_revokable(committed_revokable, this.main_window.main_toolbar.undo_tooltip);
} }
private void on_revoke() { private void on_revoke() {

View file

@ -26,11 +26,6 @@ public class MainToolbar : Gtk.Box {
public int selected_conversations { get; set; } public int selected_conversations { get; set; }
// Whether to show the trash or the delete button // Whether to show the trash or the delete button
public bool show_trash_button { get; set; default = true; } public bool show_trash_button { get; set; default = true; }
// The tooltip of the Undo-button
public string undo_tooltip {
owned get { return this.undo_button.tooltip_text; }
set { this.undo_button.tooltip_text = value; }
}
// Folder header elements // Folder header elements
[GtkChild] [GtkChild]
@ -57,10 +52,6 @@ public class MainToolbar : Gtk.Box {
[GtkChild] [GtkChild]
private Gtk.ToggleButton find_button; private Gtk.ToggleButton find_button;
// Other
[GtkChild]
private Gtk.Button undo_button;
// Load these at construction time // Load these at construction time
private Gtk.Image trash_image = new Gtk.Image.from_icon_name("user-trash-symbolic", Gtk.IconSize.MENU); private Gtk.Image trash_image = new Gtk.Image.from_icon_name("user-trash-symbolic", Gtk.IconSize.MENU);
private Gtk.Image delete_image = new Gtk.Image.from_icon_name("edit-delete-symbolic", Gtk.IconSize.MENU); private Gtk.Image delete_image = new Gtk.Image.from_icon_name("edit-delete-symbolic", Gtk.IconSize.MENU);

View file

@ -277,27 +277,6 @@
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkButton" id="undo_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="receives_default">False</property>
<property name="action_name">win.undo</property>
<property name="always_show_image">True</property>
<child>
<object class="GtkImage" id="undo_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">edit-undo-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">3</property>
</packing>
</child>
<child> <child>
<object class="GtkBox" id="archive_trash_delete_buttons"> <object class="GtkBox" id="archive_trash_delete_buttons">
<property name="visible">True</property> <property name="visible">True</property>