[gnome-boxes/gnome-3-32] wizard-window: Grab focus only once in "Download an OS" search



commit 77bd7bacda1e64d14b7fb3546437dc90be5be903
Author: Felipe Borges <felipeborges gnome org>
Date:   Mon May 13 13:14:19 2019 +0200

    wizard-window: Grab focus only once in "Download an OS" search
    
    We provide some sort of "type-ahead" search in the "Download an OS"
    page, where users can just type any letter in their keyboard and that
    will perform a search in the available OSes for Download.
    
    When a new key is pressed, the key-press-event handler was constantly
    calling downloads_search.grab_focus (), which makes the GtkSearchEntry
    select its text, causing any following key presses to overwrite the
    existing ones.
    
    The solution to this issue is to only grab_focus () the search
    entry when it doesn't have focus yet. In other words:
    
    if (!downloads_search.has_focus) {
        downloads_search.grab_focus ();
    }
    
    Fixes #357

 src/wizard-window.vala | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/src/wizard-window.vala b/src/wizard-window.vala
index cd0f36ee..f3d30371 100644
--- a/src/wizard-window.vala
+++ b/src/wizard-window.vala
@@ -194,7 +194,8 @@ private bool on_key_pressed (Widget widget, Gdk.EventKey event) {
         }
 
         if (page == WizardWindowPage.DOWNLOADS) {
-            topbar.downloads_search.grab_focus ();
+            if (!topbar.downloads_search.has_focus)
+                topbar.downloads_search.grab_focus ();
 
             return topbar.downloads_search.key_press_event (event);
         }


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