aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_summary/slashme_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/slashme_item.vala
parent7ab4752b2438fac9c07745314f7cd428103f9b4c (diff)
downloaddino-f277db6cb459c6e7456fb75722b9d57f734c4db6.tar.gz
dino-f277db6cb459c6e7456fb75722b9d57f734c4db6.zip
Display /me differently
fixes #12
Diffstat (limited to 'main/src/ui/conversation_summary/slashme_item.vala')
-rw-r--r--main/src/ui/conversation_summary/slashme_item.vala43
1 files changed, 43 insertions, 0 deletions
diff --git a/main/src/ui/conversation_summary/slashme_item.vala b/main/src/ui/conversation_summary/slashme_item.vala
new file mode 100644
index 00000000..cd387bc9
--- /dev/null
+++ b/main/src/ui/conversation_summary/slashme_item.vala
@@ -0,0 +1,43 @@
+using Gdk;
+using Gtk;
+
+using Dino.Entities;
+
+namespace Dino.Ui.ConversationSummary {
+
+public class SlashMeItem : MessageItem {
+
+ private Box box = new Box(Orientation.VERTICAL, 0) { visible=true, vexpand=true };
+ private MessageTextView textview = new MessageTextView() { visible=true };
+ private string text;
+ private TextTag nick_tag;
+
+ public SlashMeItem(StreamInteractor stream_interactor, Conversation conversation, Message message) {
+ base(stream_interactor, conversation, message);
+ box.set_center_widget(textview);
+ set_title_widget(box);
+ text = message.body.substring(3);
+
+ string display_name = Util.get_message_display_name(stream_interactor, message, conversation.account);
+ nick_tag = textview.buffer.create_tag("nick", foreground: @"#$(Util.get_name_hex_color(display_name, false))");
+ TextIter iter;
+ textview.buffer.get_start_iter(out iter);
+ textview.buffer.insert_with_tags(ref iter, display_name, display_name.length, nick_tag);
+ textview.add_text(text);
+ add_message(message);
+
+ textview.style_updated.connect(update_display_style);
+ update_display_style();
+ }
+
+ public override bool merge(Message message) {
+ return false;
+ }
+
+ private void update_display_style() {
+ string display_name = Util.get_message_display_name(stream_interactor, messages[0], conversation.account);
+ nick_tag.foreground = @"#$(Util.get_name_hex_color(display_name, Util.is_dark_theme(textview)))";
+ }
+}
+
+}