[gnome-maps/wip/mlundblad/search-as-you-type: 16/18] placeListRow:	Add a function to update existing row
- From: Marcus Lundblad <mlundblad src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [gnome-maps/wip/mlundblad/search-as-you-type: 16/18] placeListRow:	Add a function to update existing row
 
- Date: Sun,  2 Jun 2019 13:38:29 +0000 (UTC)
 
commit 5403a476e7762c68dfbe5d2ab0a9657036bd106d
Author: Marcus Lundblad <ml update uu se>
Date:   Thu May 30 10:51:20 2019 +0200
    placeListRow: Add a function to update existing row
    
    Adds a function to update an existing row with
    a new place.
 src/placeListRow.js | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/placeListRow.js b/src/placeListRow.js
index da19041..836c36f 100644
--- a/src/placeListRow.js
+++ b/src/placeListRow.js
@@ -36,13 +36,13 @@ var PlaceListRow = GObject.registerClass({
 }, class PlaceListRow extends Gtk.ListBoxRow {
 
     _init(params) {
-        this.place = params.place;
+        let place = params.place;
         delete params.place;
 
         let searchString = params.searchString || '';
         delete params.searchString;
 
-        let maxChars = params.maxChars || 40;
+        this._maxChars = params.maxChars || 40;
         delete params.maxChars;
 
         let type = params.type;
@@ -50,15 +50,19 @@ var PlaceListRow = GObject.registerClass({
 
         params.height_request = ROW_HEIGHT;
         super._init(params);
+        this.update(place, type, searchString);
+    }
 
+    update(place, type, searchString) {
+        this.place = place;
         let formatter = new PlaceFormatter.PlaceFormatter(this.place);
         this.title = formatter.title;
         let markup = GLib.markup_escape_text(formatter.title, -1);
 
         this._name.label = this._boldMatch(markup, searchString);
-        this._details.max_width_chars = maxChars;
+        this._details.max_width_chars = this._maxChars;
         this._details.label = GLib.markup_escape_text(formatter.getDetailsString(),-1);
-        this._icon.gicon = this.place.icon;
+        this._icon.gicon = place.icon;
 
         if (type === PlaceStore.PlaceType.RECENT ||
             type === PlaceStore.PlaceType.RECENT_ROUTE)
@@ -67,7 +71,8 @@ var PlaceListRow = GObject.registerClass({
             this._typeIcon.icon_name = 'starred-symbolic';
         else if (type === PlaceStore.PlaceType.CONTACT)
             this._typeIcon.icon_name = 'avatar-default-symbolic';
-
+        else
+            this._typeIcon.icon_name = null;
     }
 
     _boldMatch(title, string) {
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]