[Xfce4-commits] <postler:master> Implement Restore/ Empty infobar in favour of menu
Christian Dywan
noreply at xfce.org
Thu Mar 31 22:30:01 CEST 2011
Updating branch refs/heads/master
to a9cbcdd3679ae88ef3fed13bf540f0848f7656a8 (commit)
from ad79ce5cb53c8bf4c97e5a63a4a4c4df6ae56c33 (commit)
commit a9cbcdd3679ae88ef3fed13bf540f0848f7656a8
Author: Christian Dywan <christian at twotoasts.de>
Date: Thu Mar 31 22:22:58 2011 +0200
Implement Restore/ Empty infobar in favour of menu
The 'Empty folder' menuitem is hard to discover and possibly
confusing.
Now an infobar appears when viewing the Trash, with buttons to
restore messages and empty the Trash.
Delete in the toolbar now always deletes, and permanently
when viewing the Trash. Like the Delete key.
postler/postler-bureau.vala | 54 ++++++++++++++++++++++++++++++++---------
postler/postler-folders.vala | 13 +--------
2 files changed, 44 insertions(+), 23 deletions(-)
diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index 751083d..3153f8e 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -26,6 +26,7 @@ public class Postler.Bureau : Gtk.Window {
Gtk.ProgressBar progressbar;
Gtk.Label statuslabel;
Gtk.VBox messages_box;
+ Gtk.InfoBar? trash_action_infobar = null;
public Postler.Messages messages;
Postler.Content content;
@@ -218,11 +219,7 @@ public class Postler.Bureau : Gtk.Window {
}
void action_delete () {
- string folder = Path.get_basename (folders.selected_location);
- if (folder == messages.account_info.get_folder (FolderType.TRASH))
- messages.move_selected (FolderType.INBOX);
- else
- messages.move_selected (FolderType.TRASH);
+ messages.delete_selected ();
}
void action_previous_unread () {
@@ -518,6 +515,42 @@ public class Postler.Bureau : Gtk.Window {
}
}
+ void show_trash_action_infobar (AccountInfo info) {
+ if (trash_action_infobar == null) {
+ var infobar = new Gtk.InfoBar ();
+ infobar.set_message_type (Gtk.MessageType.OTHER);
+ var action_area = infobar.get_action_area () as Gtk.Box;
+ action_area.set_orientation (Gtk.Orientation.HORIZONTAL);
+ infobar.add_button (_("_Restore selected messages"), 1);
+ infobar.add_button (_("_Empty Trash"), 2);
+ infobar.show_all ();
+ messages_box.pack_start (infobar, false, false, 0);
+ /* Infobar closes on empty or folder change */
+ infobar.response.connect ((response) => {
+ switch (response) {
+ case 1:
+ messages.move_selected (FolderType.INBOX);
+ break;
+ case 2:
+ folders.empty_folder (messages.location);
+ infobar.hide ();
+ break;
+ default:
+ assert_not_reached ();
+ }
+ });
+ messages.notify["selected-location"].connect ((object, pspec) => {
+ infobar.set_response_sensitive (1,
+ messages.get_selection ().count_selected_rows () > 0);
+ });
+ trash_action_infobar = infobar;
+ }
+
+ trash_action_infobar.set_response_sensitive (1,
+ messages.get_selection ().count_selected_rows () > 0);
+ trash_action_infobar.show ();
+ }
+
Gtk.InfoBar show_fetch_error_infobar (string account, string error_message) {
var infobar = new Gtk.InfoBar ();
infobar.set_message_type (Gtk.MessageType.ERROR);
@@ -713,13 +746,10 @@ public class Postler.Bureau : Gtk.Window {
action.tooltip = _("Archive message");
}
action = actions.get_action ("MessageDelete");
- if (folder == folders.get_selected_account ().get_folder (FolderType.TRASH)) {
- action.stock_id = Gtk.STOCK_UNDELETE;
- action.tooltip = _("Restore message");
- } else {
- action.stock_id = Gtk.STOCK_DELETE;
- action.tooltip = _("Delete message");
- }
+ if (folder == folders.get_selected_account ().get_folder (FolderType.TRASH))
+ show_trash_action_infobar (folders.get_selected_account ());
+ else if (trash_action_infobar != null)
+ trash_action_infobar.hide ();
});
var folderbox = new Gtk.HBox (false, 4);
var scrolled = new Postler.ScrolledWindow (folders);
diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala
index cc64af3..e9c6543 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -608,14 +608,12 @@ public class Postler.Folders : Gtk.TreeView {
}
messages.populate (location, account_info);
} catch (GLib.Error error) {
- GLib.critical (_("Failed to empty folder \"%s\": %s"),
+ GLib.critical (_("Failed to import folder \"%s\": %s"),
location, error.message);
}
}
- void empty_folder (Gtk.TreeIter iter) {
- string location;
- store.get (iter, Columns.LOCATION, out location);
+ public void empty_folder (string location) {
try {
string[] folders = { "cur", "new" };
foreach (var folder in folders) {
@@ -686,13 +684,6 @@ public class Postler.Folders : Gtk.TreeView {
import_folder (iter);
});
menu.append (menuitem);
- menuitem = new Gtk.MenuItem.with_mnemonic (_("_Empty Folder"));
- menuitem.activate.connect ((menuitem) => {
- Gtk.TreeIter iter;
- if (get_selection ().get_selected (null, out iter))
- empty_folder (iter);
- });
- menu.append (menuitem);
}
if (!is_account && !is_local) {
More information about the Xfce4-commits
mailing list