[gnome-maps] placeEntry: Clean up place setter



commit 23166c6fdfae6a1061308b4ce5dd6c99b3024f9c
Author: Jonas Danielsson <jonas danielsson threetimestwo org>
Date:   Fri Sep 5 05:49:29 2014 -0400

    placeEntry: Clean up place setter
    
    https://bugzilla.gnome.org/show_bug.cgi?id=736107

 src/placeEntry.js |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/src/placeEntry.js b/src/placeEntry.js
index bc422b4..a995ff7 100644
--- a/src/placeEntry.js
+++ b/src/placeEntry.js
@@ -31,6 +31,11 @@ const PlaceStore = imports.placeStore;
 const SearchPopup = imports.searchPopup;
 const Utils = imports.utils;
 
+Geocode.Location.prototype.equals = function(location) {
+    return (location.latitude === this.latitude &&
+            location.longitude === this.longitude);
+};
+
 const PlaceEntry = new Lang.Class({
     Name: 'PlaceEntry',
     Extends: Gtk.SearchEntry,
@@ -43,20 +48,21 @@ const PlaceEntry = new Lang.Class({
     },
 
     set place(p) {
-        if (p) {
-            if (!this.place ||
-                (this.place.location.latitude != p.location.latitude ||
-                 this.place.location.longitude != p.location.longitude)) {
-                this._place = p;
-                this.text   = p.name;
-                this.notify("place");
-            }
-        } else {
-            this._place = p;
-            this.text   = "";
-            this.notify("place");
-        }
+        if (!this._place && !p)
+            return;
+
+        if (this._place && p && this._place.location.equals(p.location))
+            return;
+
+        if (p)
+            this.text = p.name;
+        else
+            this.text = '';
+
+        this._place = p;
+        this.notify('place');
     },
+
     get place() {
         return this._place;
     },


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