[polari/wip/raresv/blankState: 2/4] very sloppy but working blank state prototype



commit 14e8e3ea2ce6b9db473ee0796d70c341ea5496d8
Author: Rares Visalom <rares visalom gmail com>
Date:   Tue Nov 29 00:43:37 2016 +0200

    very sloppy but working blank state prototype

 src/chatView.js |   50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 49 insertions(+), 1 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 05dbdab..93f4809 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -16,6 +16,7 @@ const Signals = imports.signals;
 const Utils = imports.utils;
 const UserTracker = imports.userTracker;
 const UserList = imports.userList;
+const RoomManager = imports.roomManager;
 
 const MAX_NICK_CHARS = 8;
 const IGNORE_STATUS_TIME = 5;
@@ -350,6 +351,8 @@ const ChatView = new Lang.Class({
         this._view.connect_after('style-updated',
                                  Lang.bind(this, this._updateIndent));
 
+        this._roomManager = RoomManager.getDefault();
+
         this._room = room;
         this._state = { lastNick: null, lastTimestamp: 0, lastStatusGroup: 0 };
         this._joinTime = 0;
@@ -361,6 +364,7 @@ const ChatView = new Lang.Class({
         this._initialPending = [];
         this._backlogTimeoutId = 0;
         this._statusCount = { left: 0, joined: 0, total: 0 };
+        this._isBlankStateInserted = false;
 
         let statusMonitor = UserTracker.getUserStatusMonitor();
         this._userTracker = statusMonitor.getUserTrackerForAccount(room.account);
@@ -459,7 +463,17 @@ const ChatView = new Lang.Class({
           { name: 'indicator-line',
             pixels_above_lines: 24 },
           { name: 'loading',
-            justification: Gtk.Justification.CENTER }
+            justification: Gtk.Justification.CENTER },
+          {
+            name: 'blank-state-header',
+            left_margin: MARGIN,
+            size: 18000
+          },
+          {
+            name: 'blank-state-topic',
+            left_margin: MARGIN,
+            size: 13000
+          }
         ];
         tags.forEach(function(tagProps) {
             tagTable.add(new Gtk.TextTag(tagProps));
@@ -731,6 +745,11 @@ const ChatView = new Lang.Class({
     },
 
     _fetchBacklog: function() {
+        if (this._logWalker.is_end() && !this._isBlankStateInserted) {
+            this._insertBlankState();
+            this._isBlankStateInserted = true;
+        }
+
         if (this.vadjustment.value != 0 ||
             this._logWalker.is_end())
             return Gdk.EVENT_PROPAGATE;
@@ -750,6 +769,35 @@ const ChatView = new Lang.Class({
         return Gdk.EVENT_STOP;
     },
 
+    _insertBlankState: function () {
+        let blankStateMark = this._view.buffer.get_mark('blank-state-mark');
+
+        if (!blankStateMark)
+            blankStateMark = this._view.buffer.create_mark('idle-status-start', 
this._view.buffer.get_start_iter(), false);
+
+        log("Inserting blank state.");
+
+        let tags = [this._lookupTag('blank-state-header')];
+        let iter = this._view.buffer.get_iter_at_mark(blankStateMark);
+
+        let header = 'Conversations in ' + this._room.channel_name + ' start here.\n';
+
+        this._insertWithTags(iter, header, tags);
+
+        let topic = 'The topic of ' + this._room.channel_name + ' is: ' + this._room.topic + '\n';
+
+        tags = [this._lookupTag('blank-state-topic')];
+        //TODO: do i need to update the iterator since i'm using a mark?
+        iter = this._view.buffer.get_iter_at_mark(blankStateMark);
+
+        this._insertWithTags(iter, topic, tags);
+
+        if (this._roomManager.isFirstRun)
+            this._insertWithTags(iter, "BLANK STATEEEEE FIRST RUN\n", tags);
+        else
+            this._insertWithTags(iter, "BLANK STATEEEEE NOT FOR THE FIRST TIME\n", tags);
+    },
+
     _onValueChanged: function() {
         if (this._valueChangedId)
             return;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]