summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2020-10-11 01:56:30 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2020-10-11 01:56:30 -0400
commit1ff177ad5a11f084acca616084021664f8201514 (patch)
tree0ecf71075af0a66a62ef58c2a395cc3dc9a06dc3
parent059146b060e9cdd57f6ddbb9d6e6a17a2d6529f9 (diff)
downloadabaddon-portaudio-1ff177ad5a11f084acca616084021664f8201514.tar.gz
abaddon-portaudio-1ff177ad5a11f084acca616084021664f8201514.zip
shift click on message author to insert mention
-rw-r--r--abaddon.cpp1
-rw-r--r--components/chatmessage.cpp18
-rw-r--r--components/chatmessage.hpp9
-rw-r--r--components/chatwindow.cpp7
-rw-r--r--components/chatwindow.hpp3
5 files changed, 37 insertions, 1 deletions
diff --git a/abaddon.cpp b/abaddon.cpp
index 2923926..70a1cf4 100644
--- a/abaddon.cpp
+++ b/abaddon.cpp
@@ -67,6 +67,7 @@ int Abaddon::StartGTK() {
m_main_window->GetChatWindow()->signal_action_chat_submit().connect(sigc::mem_fun(*this, &Abaddon::ActionChatInputSubmit));
m_main_window->GetChatWindow()->signal_action_chat_load_history().connect(sigc::mem_fun(*this, &Abaddon::ActionChatLoadHistory));
m_main_window->GetChatWindow()->signal_action_channel_click().connect(sigc::mem_fun(*this, &Abaddon::ActionListChannelItemClick)); // rename me
+ m_main_window->GetChatWindow()->signal_action_insert_mention().connect(sigc::mem_fun(*this, &Abaddon::ActionInsertMention));
m_main_window->GetMemberList()->signal_action_insert_mention().connect(sigc::mem_fun(*this, &Abaddon::ActionInsertMention));
diff --git a/components/chatmessage.cpp b/components/chatmessage.cpp
index 39b6626..f804572 100644
--- a/components/chatmessage.cpp
+++ b/components/chatmessage.cpp
@@ -586,6 +586,7 @@ ChatMessageHeader::ChatMessageHeader(const Message *data) {
m_main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
m_content_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
m_meta_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
+ m_author_ev = Gtk::manage(new Gtk::EventBox);
m_author = Gtk::manage(new Gtk::Label);
m_timestamp = Gtk::manage(new Gtk::Label);
@@ -609,6 +610,7 @@ ChatMessageHeader::ChatMessageHeader(const Message *data) {
m_author->set_ellipsize(Pango::ELLIPSIZE_END);
m_author->set_xalign(0.f);
m_author->set_can_focus(false);
+ m_author_ev->signal_button_press_event().connect(sigc::mem_fun(*this, &ChatMessageHeader::on_author_button_press));
if (data->WebhookID.IsValid()) {
m_extra = Gtk::manage(new Gtk::Label);
@@ -642,7 +644,8 @@ ChatMessageHeader::ChatMessageHeader(const Message *data) {
m_content_box->set_can_focus(false);
- m_meta_box->add(*m_author);
+ m_author_ev->add(*m_author);
+ m_meta_box->add(*m_author_ev);
if (m_extra != nullptr)
m_meta_box->add(*m_extra);
m_meta_box->add(*m_timestamp);
@@ -675,6 +678,19 @@ void ChatMessageHeader::UpdateNameColor() {
m_author->set_markup(md);
}
+bool ChatMessageHeader::on_author_button_press(GdkEventButton *ev) {
+ if (ev->button == GDK_BUTTON_PRIMARY && (ev->state & GDK_SHIFT_MASK)) {
+ m_signal_action_insert_mention.emit(UserID);
+ return true;
+ }
+
+ return false;
+}
+
+ChatMessageHeader::type_signal_action_insert_mention ChatMessageHeader::signal_action_insert_mention() {
+ return m_signal_action_insert_mention;
+}
+
void ChatMessageHeader::AddContent(Gtk::Widget *widget, bool prepend) {
m_content_box->add(*widget);
if (prepend)
diff --git a/components/chatmessage.hpp b/components/chatmessage.hpp
index 5fe60f3..35d4fea 100644
--- a/components/chatmessage.hpp
+++ b/components/chatmessage.hpp
@@ -92,11 +92,20 @@ public:
void UpdateNameColor();
protected:
+ bool on_author_button_press(GdkEventButton *ev);
+
Gtk::Box *m_main_box;
Gtk::Box *m_content_box;
Gtk::Box *m_meta_box;
+ Gtk::EventBox *m_author_ev;
Gtk::Label *m_author;
Gtk::Label *m_timestamp;
Gtk::Label *m_extra = nullptr;
Gtk::Image *m_avatar;
+
+ typedef sigc::signal<void, Snowflake> type_signal_action_insert_mention;
+ type_signal_action_insert_mention m_signal_action_insert_mention;
+
+public:
+ type_signal_action_insert_mention signal_action_insert_mention();
};
diff --git a/components/chatwindow.cpp b/components/chatwindow.cpp
index 43f61bb..3943bd5 100644
--- a/components/chatwindow.cpp
+++ b/components/chatwindow.cpp
@@ -182,6 +182,9 @@ void ChatWindow::ProcessNewMessage(Snowflake id, bool prepend) {
if (user == nullptr) return;
header = Gtk::manage(new ChatMessageHeader(data));
+ header->signal_action_insert_mention().connect([this](const Snowflake &id) {
+ m_signal_action_insert_mention.emit(id);
+ });
m_num_rows++;
Abaddon::Get().GetImageManager().LoadFromURL(user->GetAvatarURL("png", "32"), [this, user_id](Glib::RefPtr<Gdk::Pixbuf> buf) {
Glib::signal_idle().connect([this, buf, user_id]() -> bool {
@@ -334,3 +337,7 @@ ChatWindow::type_signal_action_chat_load_history ChatWindow::signal_action_chat_
ChatWindow::type_signal_action_channel_click ChatWindow::signal_action_channel_click() {
return m_signal_action_channel_click;
}
+
+ChatWindow::type_signal_action_insert_mention ChatWindow::signal_action_insert_mention() {
+ return m_signal_action_insert_mention;
+}
diff --git a/components/chatwindow.hpp b/components/chatwindow.hpp
index 2372f3d..0b0c7e0 100644
--- a/components/chatwindow.hpp
+++ b/components/chatwindow.hpp
@@ -70,12 +70,14 @@ public:
typedef sigc::signal<void, std::string, Snowflake> type_signal_action_chat_submit;
typedef sigc::signal<void, Snowflake> type_signal_action_chat_load_history;
typedef sigc::signal<void, Snowflake> type_signal_action_channel_click;
+ typedef sigc::signal<void, Snowflake> type_signal_action_insert_mention;
type_signal_action_message_delete signal_action_message_delete();
type_signal_action_message_edit signal_action_message_edit();
type_signal_action_chat_submit signal_action_chat_submit();
type_signal_action_chat_load_history signal_action_chat_load_history();
type_signal_action_channel_click signal_action_channel_click();
+ type_signal_action_insert_mention signal_action_insert_mention();
private:
type_signal_action_message_delete m_signal_action_message_delete;
@@ -83,4 +85,5 @@ private:
type_signal_action_chat_submit m_signal_action_chat_submit;
type_signal_action_chat_load_history m_signal_action_chat_load_history;
type_signal_action_channel_click m_signal_action_channel_click;
+ type_signal_action_insert_mention m_signal_action_insert_mention;
};