From 6c77e89bbe18a2f03d4f00072dc3afe6b97c8866 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 2 Aug 2021 00:52:37 -0400 Subject: leave thread via menu --- components/channels.cpp | 19 ++++++++++++++++++- components/channels.hpp | 4 ++++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'components') diff --git a/components/channels.cpp b/components/channels.cpp index e175e8c..ed5de62 100644 --- a/components/channels.cpp +++ b/components/channels.cpp @@ -17,7 +17,9 @@ ChannelList::ChannelList() , m_menu_category_copy_id("_Copy ID", true) , m_menu_channel_copy_id("_Copy ID", true) , m_menu_dm_close("") // changes depending on if group or not - , m_menu_dm_copy_id("_Copy ID", true) { + , m_menu_dm_copy_id("_Copy ID", true) + , m_menu_thread_copy_id("_Copy ID", true) + , m_menu_thread_leave("_Leave", true) { get_style_context()->add_class("channel-list"); const auto cb = [this](const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *column) { @@ -121,6 +123,17 @@ ChannelList::ChannelList() m_menu_dm.append(m_menu_dm_close); m_menu_dm.show_all(); + m_menu_thread_copy_id.signal_activate().connect([this] { + Gtk::Clipboard::get()->set_text(std::to_string((*m_model->get_iter(m_path_for_menu))[m_columns.m_id])); + }); + m_menu_thread_leave.signal_activate().connect([this] { + if (Abaddon::Get().ShowConfirm("Are you sure you want to leave this thread?")) + Abaddon::Get().GetDiscordClient().LeaveThread(static_cast((*m_model->get_iter(m_path_for_menu))[m_columns.m_id]), "Context%20Menu", [](...) {}); + }); + m_menu_thread.append(m_menu_thread_copy_id); + m_menu_thread.append(m_menu_thread_leave); + m_menu_thread.show_all(); + auto &discord = Abaddon::Get().GetDiscordClient(); discord.signal_message_create().connect(sigc::mem_fun(*this, &ChannelList::OnMessageCreate)); discord.signal_guild_create().connect(sigc::mem_fun(*this, &ChannelList::UpdateNewGuild)); @@ -578,6 +591,10 @@ bool ChannelList::OnButtonPressEvent(GdkEventButton *ev) { m_menu_dm_close.hide(); m_menu_dm.popup_at_pointer(reinterpret_cast(ev)); } break; + case RenderType::Thread: { + m_menu_thread.popup_at_pointer(reinterpret_cast(ev)); + break; + } break; default: break; } diff --git a/components/channels.hpp b/components/channels.hpp index ed87b57..c131a07 100644 --- a/components/channels.hpp +++ b/components/channels.hpp @@ -209,6 +209,10 @@ protected: Gtk::MenuItem m_menu_dm_copy_id; Gtk::MenuItem m_menu_dm_close; + Gtk::Menu m_menu_thread; + Gtk::MenuItem m_menu_thread_copy_id; + Gtk::MenuItem m_menu_thread_leave; + bool m_updating_listing = false; public: -- cgit v1.2.3