[gnome-maps] Move completion match function to PlaceStore



commit 61b53793b6e5814b7491b9fd6641738326f29351
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Sat Feb 8 13:59:10 2014 +0100

    Move completion match function to PlaceStore
    
    This enables the use of the PlaceStore for entry completion in more
    places than MainWindow.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723895

 src/mainWindow.js |   17 +----------------
 src/placeStore.js |   17 +++++++++++++++++
 2 files changed, 18 insertions(+), 16 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 8b764d3..7ca6970 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -103,22 +103,7 @@ const MainWindow = new Lang.Class({
             this._placeStore.addRecent(place);
         }).bind(this));
 
-        this._searchCompletion.set_match_func(function(completion, key, iter) {
-            let model = completion.get_model();
-            let name = model.get_value(iter, PlaceStore.Columns.NAME);
-
-            if (name === null)
-                return false;
-
-            name = GLib.utf8_normalize (name, -1, GLib.NormalizeMode.ALL);
-            if (name === null)
-                return false;
-
-            if (!GLib.ascii_strncasecmp(name, key, key.length))
-                return true;
-            else
-                return false;
-        });
+        this._searchCompletion.set_match_func(PlaceStore.completionMatchFunc);
     },
 
     _initActions: function() {
diff --git a/src/placeStore.js b/src/placeStore.js
index cb0a98f..fd9935d 100644
--- a/src/placeStore.js
+++ b/src/placeStore.js
@@ -48,6 +48,23 @@ const Columns = {
     ADDED: 4
 };
 
+function completionMatchFunc(completion, key, iter) {
+    let model = completion.get_model();
+    let name = model.get_value(iter, Columns.NAME);
+
+    if (name === null)
+        return false;
+
+    name = GLib.utf8_normalize (name, -1, GLib.NormalizeMode.ALL);
+    if (name === null)
+        return false;
+
+    if (!GLib.ascii_strncasecmp(name, key, key.length))
+        return true;
+    else
+        return false;
+}
+
 const PlaceStore = new Lang.Class({
     Name: 'PlaceStore',
     Extends: Gtk.ListStore,


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