[Xfce4-commits] <postler:master> Implement Next/ Previous Message shortcuts

Christian Dywan noreply at xfce.org
Sun Mar 20 22:50:01 CET 2011


Updating branch refs/heads/master
         to 80abd311b9eae60eedfee86cd5a291728c23d259 (commit)
       from d15e3435a6083b84681d1c4eee0169a296df5bdb (commit)

commit 80abd311b9eae60eedfee86cd5a291728c23d259
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Mar 20 22:48:38 2011 +0100

    Implement Next/ Previous Message shortcuts

 postler/postler-bureau.vala   |   15 +++++++++++++++
 postler/postler-messages.vala |   25 +++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index aa994c5..91258ee 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -48,6 +48,9 @@ public class Postler.Bureau : Gtk.Window {
                     <menuitem action="MessageJunk"/>
                     <menuitem action="MessageDelete"/>
                     <separator/>
+                    <menuitem action="MessageNextUnread"/>
+                    <menuitem action="MessagePreviousUnread"/>
+                    <separator/>
                     <menuitem action="Quit"/>
                 </menu>
                 <menu action="Edit">
@@ -215,6 +218,14 @@ public class Postler.Bureau : Gtk.Window {
             messages.move_selected (FolderType.TRASH);
     }
 
+    void action_previous_unread () {
+        messages.select_next_unread (false);
+    }
+
+    void action_next_unread () {
+        messages.select_next_unread (true);
+    }
+
     void action_search () {
         search.grab_focus ();
     }
@@ -436,6 +447,10 @@ public class Postler.Bureau : Gtk.Window {
           N_("Mark message as junk"), action_junk },
         { "MessageDelete", Gtk.STOCK_DELETE, null, "<Ctrl>d",
           N_("Delete message"), action_delete },
+        { "MessagePreviousUnread", null, N_("_Previous Unread Message"), "<Alt>Up",
+          N_("Go to the previous unread message"), action_previous_unread },
+        { "MessageNextUnread", null, N_("_Next Unread Message"), "<Alt>Down",
+          N_("Go to the next unread message"), action_next_unread },
         { "Quit", Gtk.STOCK_QUIT, null, "<Ctrl>q",
           N_("Quit the application"), action_quit },
         { "Edit", null, N_("_Edit") },
diff --git a/postler/postler-messages.vala b/postler/postler-messages.vala
index a1d9510..6f03615 100644
--- a/postler/postler-messages.vala
+++ b/postler/postler-messages.vala
@@ -847,6 +847,31 @@ public class Postler.Messages : Gtk.TreeView {
         return false;
     }
 
+    bool iter_previous (ref Gtk.TreeIter iter) {
+        Gtk.TreePath path = model.get_path (iter);
+        return path.prev () && model.get_iter (out iter, path);
+    }
+
+    public void select_next_unread (bool forward) {
+        Gtk.TreeIter iter;
+        var path = get_selection ().get_selected_rows (null).nth_data (0);
+        if (path != null)
+            model.get_iter (out iter, path);
+        else if (forward)
+            model.iter_children (out iter, null);
+        else
+            model.iter_nth_child (out iter, null, model.iter_n_children (null) - 1);
+        while ((forward && model.iter_next (ref iter))
+           || (!forward && iter_previous (ref iter))) {
+            int font_weight;
+            model.get (iter, Columns.WEIGHT, out font_weight);
+            if (font_weight == Pango.Weight.BOLD) {
+                set_cursor (model.get_path (iter), null, false);
+                break;
+            }
+        }
+    }
+
     void folder_monitor_changed (File file, File? other, FileMonitorEvent event) {
         switch (event) {
         case FileMonitorEvent.CREATED:



More information about the Xfce4-commits mailing list