[gnome-maps/wip/places: 3/4] mainWindow: add search completion from PlaceStore



commit 2a4b641f9e748cdf9e6b5a3f6601b66a1865abed
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Tue Jan 14 22:59:16 2014 +0100

    mainWindow: add search completion from PlaceStore
    
    Use the places stored in PlaceStore for popup completion while
    searching.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722102

 src/mainWindow.js |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index d2eea46..cc9039d 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -111,6 +111,28 @@ const MainWindow = new Lang.Class({
                                   this._searchPopup.hide.bind(this._searchPopup));
         this._searchEntry.connect('changed',
                                   this._searchPopup.hide.bind(this._searchPopup));
+
+        // FIXME: do as much of the following from UI file as possible
+        let completion = new Gtk.EntryCompletion({ model: this._placeStore,
+                                                   popup_completion: true,
+                                                   inline_completion: false,
+                                                   minimum_key_length: 2 });
+
+        let renderer = new Gtk.CellRendererPixbuf({ xpad: 2 });
+        completion.pack_start(renderer, false);
+        completion.add_attribute(renderer, "pixbuf", PlaceStore.Columns.PLACE_ICON);
+        completion.reorder(renderer, 0);
+        completion.set_text_column(PlaceStore.Columns.NAME);
+        let textCell = completion.get_cells()[1];
+        textCell.xpad = textCell.ypad = 4;
+
+        completion.connect('match-selected', (function(completion, model, iter) {
+            let place = model.get_value(iter, PlaceStore.Columns.PLACE);
+
+            this.mapView.showNGotoLocation(place.location);
+        }).bind(this));
+
+        this._searchEntry.set_completion(completion);
     },
 
     _initActions: function() {


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