diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-09-21 21:01:32 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-09-21 21:01:32 -0400 |
commit | af8058c9cb391a9c51b1d16a9313562f13c4427e (patch) | |
tree | a1b668e43e50544e35cdb4c10bca43a93fc9822c /components | |
parent | 74526d16c9a4834c98b137cd5dac803a526f9448 (diff) | |
download | abaddon-portaudio-af8058c9cb391a9c51b1d16a9313562f13c4427e.tar.gz abaddon-portaudio-af8058c9cb391a9c51b1d16a9313562f13c4427e.zip |
add user joined messages
Diffstat (limited to 'components')
-rw-r--r-- | components/chatmessage.cpp | 23 | ||||
-rw-r--r-- | components/chatmessage.hpp | 13 | ||||
-rw-r--r-- | components/chatwindow.cpp | 4 |
3 files changed, 40 insertions, 0 deletions
diff --git a/components/chatmessage.cpp b/components/chatmessage.cpp index 5fd9db7..98bbcdc 100644 --- a/components/chatmessage.cpp +++ b/components/chatmessage.cpp @@ -381,3 +381,26 @@ void ChatMessageEmbedItem::UpdateAttributes() { void ChatMessageEmbedItem::Update() { UpdateAttributes(); } + +ChatMessageUserEventItem::ChatMessageUserEventItem(const Message *data) { + ID = data->ID; + + m_label = Gtk::manage(new Gtk::Label); + + get_style_context()->add_class("message-text"); + get_style_context()->add_class("message-text-user-event"); + + set_can_focus(false); + set_halign(Gtk::ALIGN_FILL); + set_hexpand(true); + m_label->set_halign(Gtk::ALIGN_START); + m_label->set_use_markup(); + if (data->Type == MessageType::GUILD_MEMBER_JOIN) + m_label->set_markup("<span color='#999999'><i>[user joined]</i></span>"); + add(*m_label); + show_all(); + + AttachMenuHandler(this); +} + +void ChatMessageUserEventItem::Update() {} diff --git a/components/chatmessage.hpp b/components/chatmessage.hpp index 94428b3..35cdcd1 100644 --- a/components/chatmessage.hpp +++ b/components/chatmessage.hpp @@ -9,6 +9,7 @@ enum class ChatDisplayType { Text, Embed, Image, + GuildMemberJoin, }; // contains the username and timestamp, chat items get stuck into its box @@ -109,3 +110,15 @@ protected: Gtk::Box *m_main; Gtk::Label *m_attrib_label = nullptr; }; + +class ChatMessageUserEventItem + : public Gtk::EventBox + , public ChatMessageItem { +public: + ChatMessageUserEventItem(const Message *data); + + virtual void Update(); + +protected: + Gtk::Label *m_label; +}; diff --git a/components/chatwindow.cpp b/components/chatwindow.cpp index 74c917b..c0a09a5 100644 --- a/components/chatwindow.cpp +++ b/components/chatwindow.cpp @@ -87,6 +87,8 @@ ChatDisplayType ChatWindow::GetMessageDisplayType(const Message *data) { return ChatDisplayType::Text; else if (data->Type == MessageType::DEFAULT && data->Embeds.size() > 0) return ChatDisplayType::Embed; + else if (data->Type == MessageType::GUILD_MEMBER_JOIN) + return ChatDisplayType::GuildMemberJoin; return ChatDisplayType::Unknown; } @@ -106,6 +108,8 @@ ChatMessageItem *ChatWindow::CreateMessageComponent(const Message *data) { }); } else if (type == ChatDisplayType::Embed) { widget = Gtk::manage(new ChatMessageEmbedItem(data)); + } else if (type == ChatDisplayType::GuildMemberJoin) { + widget = Gtk::manage(new ChatMessageUserEventItem(data)); } if (widget == nullptr) return nullptr; |