[Xfce4-commits] <postler:master> Implement inline find in message body as letters are typed

Christian Dywan noreply at xfce.org
Sun Jul 18 15:40:10 CEST 2010


Updating branch refs/heads/master
         to 0dfb73d56fad92782b85170b16ff0e5a7d80b0e4 (commit)
       from 977a764015a65387fd3e5c84cdaba4a60ad1975e (commit)

commit 0dfb73d56fad92782b85170b16ff0e5a7d80b0e4
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Jul 11 19:19:38 2010 +0200

    Implement inline find in message body as letters are typed

 postler/postler-viewer.vala |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/postler/postler-viewer.vala b/postler/postler-viewer.vala
index bb56a74..1a4df60 100644
--- a/postler/postler-viewer.vala
+++ b/postler/postler-viewer.vala
@@ -13,6 +13,8 @@ public class Postler.Viewer : Gtk.VBox {
     Gtk.InfoBar infobar;
     Postler.Content content;
     Gtk.VBox message_parts;
+    Gtk.Toolbar findbar;
+    Gtk.Entry find_entry;
 
     bool allow_external_images;
 
@@ -44,6 +46,19 @@ public class Postler.Viewer : Gtk.VBox {
         message_parts.parent.parent.set_no_show_all (true);
         notify_n_parts (content, null);
         content.notify["n-parts"].connect (notify_n_parts);
+
+        findbar = new Gtk.Toolbar ();
+        pack_start (findbar, false, false, 0);
+        find_entry = new Gtk.Entry ();
+        var toolitem = new Gtk.ToolItem ();
+        toolitem.add (find_entry);
+        toolitem.show_all ();
+        findbar.insert (toolitem, -1);
+        findbar.set_no_show_all (true);
+        key_press_event.connect (key_pressed);
+        find_entry.changed.connect (find_entry_changed);
+        find_entry.activate.connect (find_entry_changed);
+        find_entry.focus_out_event.connect (find_entry_unfocus);
     }
 
     void resource_request (WebKit.WebFrame frame, WebKit.WebResource resouce,
@@ -111,5 +126,28 @@ public class Postler.Viewer : Gtk.VBox {
         message_parts.parent.parent.set_no_show_all (false);
         scrollable.show_all ();
     }
+
+    bool key_pressed (Gdk.EventKey event) {
+        uint character = Gdk.unicode_to_keyval (event.keyval);
+        if (character == (event.keyval | 0x01000000))
+            return false;
+
+        string text = "%c".printf ((char)character);
+        find_entry.text = text;
+        findbar.show ();
+        find_entry.grab_focus ();
+        content.search_text (text, false, true, true);
+        return true;
+    }
+
+    void find_entry_changed () {
+        content.search_text (find_entry.text, false, true, true);
+    }
+
+    bool find_entry_unfocus (Gdk.EventFocus event) {
+        find_entry.text = "";
+        findbar.hide ();
+        return false;
+    }
 }
 



More information about the Xfce4-commits mailing list