[polari/wip/fmuellner/combined-gsoc: 18/137] logic1 : reusing widgets while searching
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/combined-gsoc: 18/137] logic1 : reusing widgets while searching
- Date: Thu, 28 Jul 2016 16:16:56 +0000 (UTC)
commit f86b3cf20e0793d09db17702d8e31c246b6931d7
Author: Kunaal Jain <kunaalus gmail com>
Date: Sat Jun 11 00:35:31 2016 +0530
logic1 : reusing widgets while searching
src/mainWindow.js | 46 ++++++++++++++++++++++++++++++++--------------
1 files changed, 32 insertions(+), 14 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 33da21b..5ba6c28 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -208,7 +208,7 @@ const MainWindow = new Lang.Class({
// search start
this._cancellable = new Gio.Cancellable();
-
+ this._widgetMap = {};
Utils.initActions(this,
[
{ name: 'search-active',
@@ -260,19 +260,38 @@ const MainWindow = new Lang.Class({
_Log: function(events) {
log(events);
+ let widgetMap = {};
+ for (let i = 0; i < events.length; i++) {
+ let message = events[i].mms;
+ let uid = events[i].id;
+
+ let row = this._widgetMap[uid];
+
+ if (row) {
+ log("REUSING!!!");
+ widgetMap[uid] = row;
+ this._results.remove(row);
+ } else {
+ let row = new Gtk.ListBoxRow({visible: true});
+ let label = new Gtk.Label({ label: events[i].mms,
+ halign: Gtk.Align.START,
+ margin_start: 6,
+ margin_end: 6,
+ visible: true,
+ ellipsize: Pango.EllipsizeMode.END,
+ max_width_chars: 18 });
+ row.add(label);
+ row.uid = events[i].id;
+ widgetMap[uid] = row;
+ }
+ }
+
+ this._widgetMap = widgetMap;
+
+ this._results.foreach(r => { r.destroy(); })
+
for (let i = 0; i < events.length; i++) {
- log(events[i].mms);
- let row = new Gtk.ListBoxRow({visible: true});
- let label = new Gtk.Label({ label: events[i].mms,
- halign: Gtk.Align.START,
- margin_start: 6,
- margin_end: 6,
- visible: true,
- ellipsize: Pango.EllipsizeMode.END,
- max_width_chars: 18 });
- row.add(label);
- row.uid = events[i].id;
- print(row.uid);
+ let row = this._widgetMap[events[i].id];
this._results.add(row);
}
},
@@ -292,7 +311,6 @@ const MainWindow = new Lang.Class({
_handleSearchChanged: function(entry) {
this._cancellable.cancel();
this._cancellable.reset();
- this._Log1();
let text = entry.get_text().replace(/^\s+|\s+$/g, '');
log(text);
let query1 = ("select ?text as ?mms ?msg as ?id where { ?msg a nmo:IMMessage . ?msg
nie:plainTextContent ?text . ?msg fts:match '%s*' }").format(text);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]