[gnome-maps/wip/places: 5/6] mainWindow: add search completion from PlaceStore
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/places: 5/6] mainWindow: add search completion from PlaceStore
- Date: Tue, 14 Jan 2014 20:50:33 +0000 (UTC)
commit 08c7a049e5c1c5e24f82e8cfee03214bd6d2d7a6
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Mon Jan 13 13:48:00 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]