aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_summary/conversation_item.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-03-15 21:37:49 +0100
committerfiaxh <git@mx.ax.lt>2017-03-15 21:55:26 +0100
commitf277db6cb459c6e7456fb75722b9d57f734c4db6 (patch)
treeeafe81136b237b4889623a0a0e7cf864250b689d /main/src/ui/conversation_summary/conversation_item.vala
parent7ab4752b2438fac9c07745314f7cd428103f9b4c (diff)
downloaddino-f277db6cb459c6e7456fb75722b9d57f734c4db6.tar.gz
dino-f277db6cb459c6e7456fb75722b9d57f734c4db6.zip
Display /me differently
fixes #12
Diffstat (limited to 'main/src/ui/conversation_summary/conversation_item.vala')
-rw-r--r--main/src/ui/conversation_summary/conversation_item.vala34
1 files changed, 34 insertions, 0 deletions
diff --git a/main/src/ui/conversation_summary/conversation_item.vala b/main/src/ui/conversation_summary/conversation_item.vala
new file mode 100644
index 00000000..480ccd48
--- /dev/null
+++ b/main/src/ui/conversation_summary/conversation_item.vala
@@ -0,0 +1,34 @@
+using Dino.Entities;
+
+namespace Dino.Ui.ConversationSummary {
+
+public enum MessageKind {
+ TEXT,
+ ME_COMMAND
+}
+
+public MessageKind get_message_kind(Message message) {
+ if (message.body.has_prefix("/me ")) {
+ return MessageKind.ME_COMMAND;
+ } else {
+ return MessageKind.TEXT;
+ }
+}
+
+public interface ConversationItem : Gtk.Widget {
+ public abstract bool merge(Entities.Message message);
+
+ public static ConversationItem create_for_message(StreamInteractor stream_interactor, Conversation conversation, Message message) {
+ switch (get_message_kind(message)) {
+ case MessageKind.TEXT:
+ return new MergedMessageItem(stream_interactor, conversation, message);
+ break;
+ case MessageKind.ME_COMMAND:
+ return new SlashMeItem(stream_interactor, conversation, message);
+ break;
+ }
+ return null;
+ }
+}
+
+} \ No newline at end of file