blob: ca936ead8abb1109286ee6ca71133d81d5887f27 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#pragma once
#include <gtkmm.h>
#include "../discord/discord.hpp"
class ChatMessageItemContainer : public Gtk::Box {
public:
Snowflake ID;
Snowflake ChannelID;
ChatMessageItemContainer();
static ChatMessageItemContainer *FromMessage(Snowflake id);
// attributes = edited, deleted
void UpdateAttributes();
void UpdateContent();
void UpdateImage(std::string url, Glib::RefPtr<Gdk::Pixbuf> buf);
protected:
bool EmitImageLoad(std::string url);
void AddClickHandler(Gtk::Widget *widget, std::string);
Gtk::TextView *CreateTextComponent(const Message *data); // Message.Content
void UpdateTextComponent(Gtk::TextView *tv);
Gtk::EventBox *CreateEmbedComponent(const Message *data); // Message.Embeds[0]
Gtk::Image *CreateImageComponent(const AttachmentData &data);
Gtk::Box *CreateAttachmentComponent(const AttachmentData &data); // non-image attachments
void HandleImage(const AttachmentData &data, Gtk::Image *img, std::string url);
// expects content run through Glib::Markup::escape_text
std::string ParseMessageContent(std::string content);
std::string ParseMentions(std::string content);
std::unordered_map<std::string, std::pair<Gtk::Image *, AttachmentData>> m_img_loadmap;
void AttachMenuHandler(Gtk::Widget *widget);
void ShowMenu(GdkEvent *event);
Gtk::Menu m_menu;
Gtk::MenuItem *m_menu_copy_id;
Gtk::MenuItem *m_menu_delete_message;
Gtk::MenuItem *m_menu_edit_message;
void on_menu_copy_id();
void on_menu_delete_message();
void on_menu_edit_message();
Gtk::Box *m_main;
Gtk::Label *m_attrib_label = nullptr;
Gtk::Image *m_embed_img = nullptr; // yes this is hacky no i dont care (for now)
std::string m_embed_imgurl;
Gtk::TextView *m_text_component = nullptr;
Gtk::EventBox *m_embed_component = nullptr;
public:
typedef sigc::signal<void, std::string> type_signal_image_load;
typedef sigc::signal<void> type_signal_action_delete;
typedef sigc::signal<void> type_signal_action_edit;
type_signal_action_delete signal_action_delete();
type_signal_action_edit signal_action_edit();
type_signal_image_load signal_image_load();
private:
type_signal_action_delete m_signal_action_delete;
type_signal_action_edit m_signal_action_edit;
type_signal_image_load m_signal_image_load;
};
class ChatMessageHeader : public Gtk::ListBoxRow {
public:
Snowflake UserID;
Snowflake ChannelID;
ChatMessageHeader(const Message *data);
void SetAvatarFromPixbuf(Glib::RefPtr<Gdk::Pixbuf> pixbuf);
void AddContent(Gtk::Widget *widget, bool prepend);
void UpdateNameColor();
protected:
Gtk::Box *m_main_box;
Gtk::Box *m_content_box;
Gtk::Box *m_meta_box;
Gtk::Label *m_author;
Gtk::Label *m_timestamp;
Gtk::Image *m_avatar;
};
|