[gnome-maps] mainWindow: add custom match func to completion
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] mainWindow: add custom match func to completion
- Date: Fri, 24 Jan 2014 08:45:32 +0000 (UTC)
commit 3029c7d6bd65fae53e657602541d0c4e68d15282
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Wed Jan 22 09:40:52 2014 +0100
mainWindow: add custom match func to completion
GtkEntryCompletion has changed. Now if you call set_text_column
or set the property text_column all manually added renderers will
be removed. Also when you add renderers manually the text renderer
added by set_text_column will be removed and text_column set to -1.
So in order to have custom renderers for the GtkEntryCompletion we
cannot set text_column and instead need to have our own match func.
https://bugzilla.gnome.org/show_bug.cgi?id=722102
src/main-window.ui | 4 +++-
src/mainWindow.js | 14 ++++++++++++++
2 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/src/main-window.ui b/src/main-window.ui
index 189bdd6..ac50e0c 100644
--- a/src/main-window.ui
+++ b/src/main-window.ui
@@ -17,7 +17,6 @@
</menu>
<object class="GtkEntryCompletion" id="search-completion">
<property name="minimum_key_length">2</property>
- <property name="text_column">2</property>
<child>
<object class="GtkCellRendererPixbuf" id="iconCellRenderer">
<property name="xpad">2</property>
@@ -30,6 +29,9 @@
<object class="GtkCellRendererText" id="textCellRenderer">
<property name="ypad">4</property>
</object>
+ <attributes>
+ <attribute name="text">2</attribute>
+ </attributes>
</child>
</object>
<object class="GtkApplicationWindow" id="app-window">
diff --git a/src/mainWindow.js b/src/mainWindow.js
index c936107..61a740d 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -119,6 +119,20 @@ const MainWindow = new Lang.Class({
let place = m.get_value(iter, PlaceStore.Columns.PLACE);
this.mapView.showNGotoLocation(place.location);
}).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);
+
+ 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;
+ });
},
_initActions: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]