handle mutable categories

This commit is contained in:
ouwou
2022-01-05 03:52:20 -05:00
parent 8695562cb4
commit 40106ddeb1
9 changed files with 94 additions and 3 deletions

View File

@@ -116,7 +116,15 @@ ChannelList::ChannelList()
m_menu_category_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_category_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_category.append(m_menu_category_toggle_mute);
m_menu_category.append(m_menu_category_copy_id);
m_menu_category.show_all();
@@ -177,6 +185,7 @@ ChannelList::ChannelList()
m_menu_thread.show_all();
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_thread.signal_popped_up().connect(sigc::mem_fun(*this, &ChannelList::OnThreadSubmenuPopup));
@@ -857,6 +866,16 @@ void ChannelList::OnGuildSubmenuPopup(const Gdk::Rectangle *flipped_rect, const
m_menu_guild_toggle_mute.set_label("Mute");
}
void ChannelList::OnCategorySubmenuPopup(const Gdk::Rectangle *flipped_rect, const Gdk::Rectangle *final_rect, bool flipped_x, bool flipped_y) {
const 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_category_toggle_mute.set_label("Unmute");
else
m_menu_category_toggle_mute.set_label("Mute");
}
void ChannelList::OnChannelSubmenuPopup(const Gdk::Rectangle *flipped_rect, const Gdk::Rectangle *final_rect, bool flipped_x, bool flipped_y) {
const auto iter = m_model->get_iter(m_path_for_menu);
if (!iter) return;