diff options
Diffstat (limited to 'src/ChatMessage.cpp')
-rw-r--r-- | src/ChatMessage.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/ChatMessage.cpp b/src/ChatMessage.cpp index db5fad2..93b52e9 100644 --- a/src/ChatMessage.cpp +++ b/src/ChatMessage.cpp @@ -1,4 +1,6 @@ #include "../include/ChatMessage.hpp" +#include "../include/GlobalCache.hpp" +#include "../include/GtkGif.hpp" namespace dchat { @@ -8,6 +10,9 @@ namespace dchat timestampSeconds(_timestampSeconds), user(_user) { + avatar.set_halign(Gtk::ALIGN_START); + avatar.set_valign(Gtk::ALIGN_START); + username.set_selectable(true); username.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START); username.get_style_context()->add_class("chat-message-username"); @@ -18,8 +23,31 @@ namespace dchat text.set_line_wrap_mode(Pango::WRAP_WORD_CHAR); text.get_style_context()->add_class("chat-message-text"); - attach(username, 0, 0, 1, 1); - attach(text, 0, 1, 1, 1); + attach(avatar, 0, 0, 1, 2); + attach_next_to(username, avatar, Gtk::POS_RIGHT, 1, 1); + attach_next_to(text, username, Gtk::POS_BOTTOM, 1, 1); get_style_context()->add_class("chat-message"); + + signal_draw().connect(sigc::mem_fun(*this, &ChatMessage::updateContent)); + } + + bool ChatMessage::updateContent(const Cairo::RefPtr<Cairo::Context> &cairo) + { + #if 0 + auto result = getGlobalCache().getContentByUrl("https://discordemoji.com/assets/emoji/3644_epicKirby.gif"); + printf("result type: %d\n", result.type); + if(result.type == ContentByUrlResult::Type::CACHED && result.gif) + { + Gtk::Widget *child = avatar.get_child_at(0, 0); + if(!child) + { + printf("add gif!\n"); + //GtkGif *gif = new GtkGif(GtkGif*)result.gif; + //gif->copy + //avatar.attach(*(GtkGif*)result.gif, 0, 0, 1, 1); + } + } + #endif + return true; } }
\ No newline at end of file |