[smuxi: 1/7] Frontend-GNOME: Sync the marker line's position with the remote engine.
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi: 1/7] Frontend-GNOME: Sync the marker line's position with the remote engine.
- Date: Sun, 15 Mar 2015 09:28:49 +0000 (UTC)
commit 3f72df04981847d4b4cd6380eaa26fd4ec916935
Author: Sebastian Poeplau <sebastian poeplau googlemail com>
Date: Sun Feb 1 15:04:47 2015 +0100
Frontend-GNOME: Sync the marker line's position with the remote engine.
src/Engine/Chats/ChatModel.cs | 1 +
src/Frontend-GNOME/MainWindow.cs | 2 +-
src/Frontend-GNOME/Notebook.cs | 2 +-
src/Frontend-GNOME/Views/Chats/ChatView.cs | 32 +++++++++++++++++++++++++--
4 files changed, 32 insertions(+), 5 deletions(-)
---
diff --git a/src/Engine/Chats/ChatModel.cs b/src/Engine/Chats/ChatModel.cs
index 962fd55..e5afbcf 100644
--- a/src/Engine/Chats/ChatModel.cs
+++ b/src/Engine/Chats/ChatModel.cs
@@ -47,6 +47,7 @@ namespace Smuxi.Engine
public int Position { get; set; }
public IMessageBuffer MessageBuffer { get; private set; }
public int MessagesSyncCount { get; set; }
+ public DateTime LastSeenMessage { get; set; }
public string ID {
get {
diff --git a/src/Frontend-GNOME/MainWindow.cs b/src/Frontend-GNOME/MainWindow.cs
index 4b87274..4fa4d64 100644
--- a/src/Frontend-GNOME/MainWindow.cs
+++ b/src/Frontend-GNOME/MainWindow.cs
@@ -480,7 +480,7 @@ namespace Smuxi.Frontend.Gnome
return;
}
- chatView.OutputMessageTextView.UpdateMarkerline();
+ chatView.UpdateLastSeenMessage();
} catch (Exception ex) {
Frontend.ShowException(this, ex);
}
diff --git a/src/Frontend-GNOME/Notebook.cs b/src/Frontend-GNOME/Notebook.cs
index 063c506..1df0e48 100644
--- a/src/Frontend-GNOME/Notebook.cs
+++ b/src/Frontend-GNOME/Notebook.cs
@@ -199,7 +199,7 @@ namespace Smuxi.Frontend.Gnome
}
var chatView = CurrentChatView;
- chatView.OutputMessageTextView.UpdateMarkerline();
+ chatView.UpdateLastSeenMessage();
}
protected virtual void OnSwitchPage(object sender, Gtk.SwitchPageArgs e)
diff --git a/src/Frontend-GNOME/Views/Chats/ChatView.cs b/src/Frontend-GNOME/Views/Chats/ChatView.cs
index bb0fe77..48fa094 100644
--- a/src/Frontend-GNOME/Views/Chats/ChatView.cs
+++ b/src/Frontend-GNOME/Views/Chats/ChatView.cs
@@ -54,6 +54,7 @@ namespace Smuxi.Frontend.Gnome
private MessageTextView _OutputMessageTextView;
private ThemeSettings _ThemeSettings;
private TaskQueue _LastSeenHighlightQueue;
+ public DateTime SyncedLastSeenMessage { get; private set; }
public DateTime SyncedLastSeenHighlight { get; private set; }
IList<MessageModel> SyncedMessages { get; set; }
protected string SyncedName { get; set; }
@@ -519,6 +520,11 @@ namespace Smuxi.Frontend.Gnome
// REMOTING CALL
SyncedLastSeenHighlight = _ChatModel.LastSeenHighlight;
+
+ if (Frontend.EngineVersion >= new Version(0, 12)) {
+ // REMOTING CALL
+ SyncedLastSeenMessage = _ChatModel.LastSeenMessage;
+ }
DateTime start, stop;
start = DateTime.UtcNow;
@@ -556,6 +562,10 @@ namespace Smuxi.Frontend.Gnome
// GTK+ in between for blocking the GUI thread less
foreach (MessageModel msg in SyncedMessages) {
AddMessage(msg);
+ if (msg.TimeStamp <= SyncedLastSeenMessage) {
+ // let the user know at which position new messages start
+ _OutputMessageTextView.UpdateMarkerline();
+ }
}
}
}
@@ -567,9 +577,6 @@ namespace Smuxi.Frontend.Gnome
HasEvent = false;
}
- // let the user know at which position new messages start
- _OutputMessageTextView.UpdateMarkerline();
-
// reset tab icon to normal
TabImage.Pixbuf = DefaultTabImage.Pixbuf;
OnStatusChanged(EventArgs.Empty);
@@ -578,6 +585,25 @@ namespace Smuxi.Frontend.Gnome
_IsSynced = true;
}
+ public virtual void UpdateLastSeenMessage()
+ {
+ _OutputMessageTextView.UpdateMarkerline();
+
+ if (Frontend.EngineVersion >= new Version(0, 12)) {
+ var lastSeenMessage = _OutputMessageTextView.LastMessage;
+ if (lastSeenMessage != null) {
+ ThreadPool.QueueUserWorkItem(delegate {
+ try {
+ // REMOTING CALL
+ _ChatModel.LastSeenMessage = lastSeenMessage.TimeStamp;
+ } catch (Exception ex) {
+ Frontend.ShowException(ex);
+ }
+ });
+ }
+ }
+ }
+
public virtual void AddMessage(MessageModel msg)
{
switch (msg.MessageType) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]