[gnome-maps] placeEntry: Add parseOnFocusOut option



commit b839089cf79aa6c6842a21582cc57721519e9d74
Author: Damián Nohales <damiannohales gmail com>
Date:   Fri Sep 5 18:16:57 2014 -0300

    placeEntry: Add parseOnFocusOut option
    
    This fix a usability issue related to plain coordinates support and
    sidebar place entries, where user writes a plain coordinate in
    the entry and jump to the next entry without pressing INTRO to
    confirm the place.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735842

 src/placeEntry.js |   23 ++++++++++++++++++++---
 src/sidebar.js    |    3 ++-
 2 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/src/placeEntry.js b/src/placeEntry.js
index 7cc07cb..698fed7 100644
--- a/src/placeEntry.js
+++ b/src/placeEntry.js
@@ -88,6 +88,9 @@ const PlaceEntry = new Lang.Class({
             props.primary_icon_name = null;
         delete props.loupe;
 
+        let parseOnFocusOut = props.parseOnFocusOut;
+        delete props.parseOnFocusOut;
+
         props.completion = this._createCompletion();
         this.parent(props);
 
@@ -100,6 +103,13 @@ const PlaceEntry = new Lang.Class({
             if (this.text.length === 0)
                 this.place = null;
         }).bind(this));
+
+        if (parseOnFocusOut) {
+            this.connect('focus-out-event', (function() {
+                this._parse();
+                return false;
+            }).bind(this));
+        }
     },
 
     _createCompletion: function() {
@@ -156,18 +166,25 @@ const PlaceEntry = new Lang.Class({
             return null;
     },
 
-    _onActivate: function() {
+    _parse: function() {
         if (this.text.length === 0) {
             this.place = null;
-            return;
+            return true;
         }
 
         let parsedLocation = this._parseCoordinates(this.text);
         if (parsedLocation) {
             this.place = new Geocode.Place({ location: parsedLocation });
-            return;
+            return true;
         }
 
+        return false;
+    },
+
+    _onActivate: function() {
+        if (this._parse())
+            return;
+
         let bbox = this._mapView.view.get_bounding_box();
 
         this._popover.showSpinner();
diff --git a/src/sidebar.js b/src/sidebar.js
index 37ba572..7e6d356 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -124,7 +124,8 @@ const Sidebar = new Lang.Class({
                                            can_focus: true,
                                            hexpand: true,
                                            receives_default: true,
-                                           mapView: this._mapView });
+                                           mapView: this._mapView,
+                                           parseOnFocusOut: true });
     },
 
     _createViaRow: function(listbox) {


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