add menus to dm channels + close/leave dm

This commit is contained in:
ouwou
2021-02-18 18:37:25 -05:00
parent 901028cec9
commit c5bc3455b1
4 changed files with 31 additions and 0 deletions

View File

@@ -54,6 +54,26 @@ ChannelListRowDMChannel::ChannelListRowDMChannel(const ChannelData *data) {
m_lbl = Gtk::manage(new Gtk::TextView);
MakeReadOnly(m_lbl);
AddWidgetMenuHandler(m_ev, m_menu);
AddWidgetMenuHandler(m_lbl, m_menu);
m_menu_copy_id = Gtk::manage(new Gtk::MenuItem("_Copy ID", true));
m_menu_copy_id->signal_activate().connect([this] {
Gtk::Clipboard::get()->set_text(std::to_string(ID));
});
if (data->Type == ChannelType::GROUP_DM)
m_menu_close = Gtk::manage(new Gtk::MenuItem("_Leave DM", true));
else
m_menu_close = Gtk::manage(new Gtk::MenuItem("_Close DM", true));
m_menu_close->signal_activate().connect([this] {
Abaddon::Get().GetDiscordClient().CloseDM(ID);
});
m_menu.append(*m_menu_copy_id);
m_menu.append(*m_menu_close);
m_menu.show_all();
get_style_context()->add_class("channel-row");
m_lbl->get_style_context()->add_class("channel-row-label");

View File

@@ -44,6 +44,10 @@ protected:
StatusIndicator *m_status = nullptr;
Gtk::TextView *m_lbl;
Gtk::Image *m_icon = nullptr;
Gtk::Menu m_menu;
Gtk::MenuItem *m_menu_close; // leave if group
Gtk::MenuItem *m_menu_copy_id;
};
class ChannelListRowGuild : public ChannelListRow {