[polari/wip/fmuellner/combined-gsoc: 8/103] 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: 8/103] logic1 : reusing widgets while searching
- Date: Fri, 22 Jul 2016 13:34:38 +0000 (UTC)
commit 1c7dfa1a5e9eef2156ee3721dccc27fc9634edff
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]