diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2022-01-15 01:51:11 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2022-01-15 01:51:11 -0500 |
commit | 6c9bf4ff81a588ba8c4fb1713217d699eba057c4 (patch) | |
tree | c2f7489ee5c6c16f4e23945ab5ba8fcd51cfeed8 /src | |
parent | 604f2ffe3dc8978aebd6aa819b73374aa32d2f0e (diff) | |
download | abaddon-portaudio-6c9bf4ff81a588ba8c4fb1713217d699eba057c4.tar.gz abaddon-portaudio-6c9bf4ff81a588ba8c4fb1713217d699eba057c4.zip |
add toggle mute dm menu item
Diffstat (limited to 'src')
-rw-r--r-- | src/components/channels.cpp | 20 | ||||
-rw-r--r-- | src/components/channels.hpp | 2 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/components/channels.cpp b/src/components/channels.cpp index 28eb288..5385b23 100644 --- a/src/components/channels.cpp +++ b/src/components/channels.cpp @@ -161,6 +161,15 @@ ChannelList::ChannelList() else if (Abaddon::Get().ShowConfirm("Are you sure you want to leave this group DM?")) Abaddon::Get().GetDiscordClient().CloseDM(id); }); + m_menu_dm_toggle_mute.signal_activate().connect([this] { + const auto id = static_cast<Snowflake>((*m_model->get_iter(m_path_for_menu))[m_columns.m_id]); + auto &discord = Abaddon::Get().GetDiscordClient(); + if (discord.IsChannelMuted(id)) + discord.UnmuteChannel(id, NOOP_CALLBACK); + else + discord.MuteChannel(id, NOOP_CALLBACK); + }); + m_menu_dm.append(m_menu_dm_toggle_mute); m_menu_dm.append(m_menu_dm_close); m_menu_dm.append(m_menu_dm_copy_id); m_menu_dm.show_all(); @@ -187,6 +196,7 @@ ChannelList::ChannelList() m_menu_guild.signal_popped_up().connect(sigc::mem_fun(*this, &ChannelList::OnGuildSubmenuPopup)); m_menu_category.signal_popped_up().connect(sigc::mem_fun(*this, &ChannelList::OnCategorySubmenuPopup)); m_menu_channel.signal_popped_up().connect(sigc::mem_fun(*this, &ChannelList::OnChannelSubmenuPopup)); + m_menu_dm.signal_popped_up().connect(sigc::mem_fun(*this, &ChannelList::OnDMSubmenuPopup)); m_menu_thread.signal_popped_up().connect(sigc::mem_fun(*this, &ChannelList::OnThreadSubmenuPopup)); auto &discord = Abaddon::Get().GetDiscordClient(); @@ -887,6 +897,16 @@ void ChannelList::OnChannelSubmenuPopup(const Gdk::Rectangle *flipped_rect, cons m_menu_channel_toggle_mute.set_label("Mute"); } +void ChannelList::OnDMSubmenuPopup(const Gdk::Rectangle *flipped_rect, const Gdk::Rectangle *final_rect, bool flipped_x, bool flipped_y) { + auto iter = m_model->get_iter(m_path_for_menu); + if (!iter) return; + const auto id = static_cast<Snowflake>((*iter)[m_columns.m_id]); + if (Abaddon::Get().GetDiscordClient().IsChannelMuted(id)) + m_menu_dm_toggle_mute.set_label("Unmute"); + else + m_menu_dm_toggle_mute.set_label("Mute"); +} + void ChannelList::OnThreadSubmenuPopup(const Gdk::Rectangle *flipped_rect, const Gdk::Rectangle *final_rect, bool flipped_x, bool flipped_y) { m_menu_thread_archive.set_visible(false); m_menu_thread_unarchive.set_visible(false); diff --git a/src/components/channels.hpp b/src/components/channels.hpp index ba75be8..4ec0587 100644 --- a/src/components/channels.hpp +++ b/src/components/channels.hpp @@ -124,6 +124,7 @@ protected: Gtk::Menu m_menu_dm; Gtk::MenuItem m_menu_dm_copy_id; Gtk::MenuItem m_menu_dm_close; + Gtk::MenuItem m_menu_dm_toggle_mute; Gtk::Menu m_menu_thread; Gtk::MenuItem m_menu_thread_copy_id; @@ -134,6 +135,7 @@ protected: void OnGuildSubmenuPopup(const Gdk::Rectangle *flipped_rect, const Gdk::Rectangle *final_rect, bool flipped_x, bool flipped_y); void OnCategorySubmenuPopup(const Gdk::Rectangle *flipped_rect, const Gdk::Rectangle *final_rect, bool flipped_x, bool flipped_y); void OnChannelSubmenuPopup(const Gdk::Rectangle *flipped_rect, const Gdk::Rectangle *final_rect, bool flipped_x, bool flipped_y); + void OnDMSubmenuPopup(const Gdk::Rectangle *flipped_rect, const Gdk::Rectangle *final_rect, bool flipped_x, bool flipped_y); void OnThreadSubmenuPopup(const Gdk::Rectangle *flipped_rect, const Gdk::Rectangle *final_rect, bool flipped_x, bool flipped_y); bool m_updating_listing = false; |