mark guild as read (shift+esc)

This commit is contained in:
ouwou 2021-12-08 19:12:35 -05:00
parent a1b662a325
commit bcfb2146cd
2 changed files with 19 additions and 1 deletions

View File

@ -5,10 +5,13 @@ MainWindow::MainWindow()
: m_main_box(Gtk::ORIENTATION_VERTICAL)
, m_content_box(Gtk::ORIENTATION_HORIZONTAL)
, m_chan_content_paned(Gtk::ORIENTATION_HORIZONTAL)
, m_content_members_paned(Gtk::ORIENTATION_HORIZONTAL) {
, m_content_members_paned(Gtk::ORIENTATION_HORIZONTAL)
, m_accels(Gtk::AccelGroup::create()) {
set_default_size(1200, 800);
get_style_context()->add_class("app-window");
add_accel_group(m_accels);
m_menu_discord.set_label("Discord");
m_menu_discord.set_submenu(m_menu_discord_sub);
m_menu_discord_connect.set_label("Connect");
@ -42,9 +45,12 @@ MainWindow::MainWindow()
m_menu_view_friends.set_label("Friends");
m_menu_view_pins.set_label("Pins");
m_menu_view_threads.set_label("Threads");
m_menu_view_mark_guild_as_read.set_label("Mark Server as Read");
m_menu_view_mark_guild_as_read.add_accelerator("activate", m_accels, GDK_KEY_Escape, Gdk::SHIFT_MASK, Gtk::ACCEL_VISIBLE);
m_menu_view_sub.append(m_menu_view_friends);
m_menu_view_sub.append(m_menu_view_pins);
m_menu_view_sub.append(m_menu_view_threads);
m_menu_view_sub.append(m_menu_view_mark_guild_as_read);
m_menu_view_sub.signal_popped_up().connect(sigc::mem_fun(*this, &MainWindow::OnViewSubmenuPopup));
m_menu_bar.append(m_menu_file);
@ -98,6 +104,15 @@ MainWindow::MainWindow()
m_signal_action_view_threads.emit(GetChatActiveChannel());
});
m_menu_view_mark_guild_as_read.signal_activate().connect([this] {
auto &discord = Abaddon::Get().GetDiscordClient();
const auto channel_id = GetChatActiveChannel();
const auto channel = discord.GetChannel(channel_id);
if (channel.has_value() && channel->GuildID.has_value()) {
discord.MarkGuildAsRead(*channel->GuildID, [](...) {});
}
});
m_content_box.set_hexpand(true);
m_content_box.set_vexpand(true);
m_content_box.show();

View File

@ -74,6 +74,8 @@ protected:
Gtk::Stack m_content_stack;
Glib::RefPtr<Gtk::AccelGroup> m_accels;
Gtk::MenuBar m_menu_bar;
Gtk::MenuItem m_menu_discord;
Gtk::Menu m_menu_discord_sub;
@ -95,5 +97,6 @@ protected:
Gtk::MenuItem m_menu_view_friends;
Gtk::MenuItem m_menu_view_pins;
Gtk::MenuItem m_menu_view_threads;
Gtk::MenuItem m_menu_view_mark_guild_as_read;
void OnViewSubmenuPopup(const Gdk::Rectangle *flipped_rect, const Gdk::Rectangle *final_rect, bool flipped_x, bool flipped_y);
};