[tracker] Make search entry grab focus on Ctrl+S



commit a56b17760616a476ca487c11408d5c2244901853
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Mar 23 18:05:23 2010 +0100

    Make search entry grab focus on Ctrl+S
    
    Now TrackerEntry implements GtkActivatable, grabbing focus in this case.
    Since there is no GtkAction interfacing, a new GtkAccelGroup has been added
    to the main window to deal with this.

 src/tracker-search-tool/tracker-entry.gs       |   17 +++++++++++++----
 src/tracker-search-tool/tracker-search-tool.gs |   10 +++++++++-
 2 files changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/src/tracker-search-tool/tracker-entry.gs b/src/tracker-search-tool/tracker-entry.gs
index 156f307..88ebc7b 100644
--- a/src/tracker-search-tool/tracker-entry.gs
+++ b/src/tracker-search-tool/tracker-entry.gs
@@ -27,16 +27,17 @@ uses
     
 const static RUN_DELAY : int = 500
     
-class TrackerSearchEntry  : Gtk.Entry
+class TrackerSearchEntry  : Gtk.Entry implements Gtk.Activatable
     id_invoker : uint = 0
 
-    prop Query : TrackerQuery 
+    prop Query : TrackerQuery
 
     init
         set_icon_from_stock (EntryIconPosition.SECONDARY, STOCK_CLEAR)
         set_icon_sensitive (EntryIconPosition.PRIMARY, false)
         set_icon_sensitive (EntryIconPosition.SECONDARY, false)
         set_icon_tooltip_text (EntryIconPosition.SECONDARY, _("Clear the search text"))
+        activate += entry_activate
         changed += entry_changed
         icon_press += def (p0, p1)
             if p0 is EntryIconPosition.SECONDARY
@@ -55,7 +56,10 @@ class TrackerSearchEntry  : Gtk.Entry
                 if id_invoker != 0
                     Source.remove (id_invoker)
                 id_invoker = Timeout.add (RUN_DELAY, run_query)
-        
+
+    def private entry_activate (entry : TrackerSearchEntry)
+        entry.grab_focus ()
+
     def private run_query () : bool
         if Query is not null
             if (text is null) or (text is "")
@@ -65,4 +69,9 @@ class TrackerSearchEntry  : Gtk.Entry
                 set_icon_sensitive (EntryIconPosition.SECONDARY, true)
                 Query.SearchTerms = EscapeSparql (text, true)
         return false
-    
+
+    def sync_action_properties (action : Action)
+        return
+
+    def update (action : Action, prop : string)
+        return
diff --git a/src/tracker-search-tool/tracker-search-tool.gs b/src/tracker-search-tool/tracker-search-tool.gs
index c1de0af..c9dcd24 100644
--- a/src/tracker-search-tool/tracker-search-tool.gs
+++ b/src/tracker-search-tool/tracker-search-tool.gs
@@ -116,12 +116,14 @@ init
 
     window = builder.get_object ("window") as Window
     window.destroy += Gtk.main_quit
-    
+
     window.set_app_paintable (true)
 
     /* create tracker widgets */
 
     var
+        accel_group = new AccelGroup
+
         query = new TrackerQuery
         entry = new TrackerSearchEntry ()
         grid = new TrackerResultGrid ()
@@ -133,11 +135,17 @@ init
         category_box = builder.get_object ("CategoryBox") as Container
         main_box = builder.get_object ("MainBox") as VBox
 
+    window.add_accel_group (accel_group)
 
     query.Connect ()
     entry.Query = query
     entry_box.add (entry)
 
+    keyval : uint
+    mods : Gdk.ModifierType
+    accelerator_parse ("<Ctrl>s", out keyval, out mods)
+    entry.add_accelerator ("activate", accel_group, keyval, mods, AccelFlags.VISIBLE | AccelFlags.LOCKED)
+
     grid.Query = query
     grid_box.add (grid)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]