disconnecting clears the channel listing
This commit is contained in:
10
abaddon.cpp
10
abaddon.cpp
@@ -27,7 +27,7 @@ int Abaddon::StartGTK() {
|
|||||||
m_main_window->SetAbaddon(this);
|
m_main_window->SetAbaddon(this);
|
||||||
m_main_window->set_title("Abaddon");
|
m_main_window->set_title("Abaddon");
|
||||||
m_main_window->show();
|
m_main_window->show();
|
||||||
m_main_window->UpdateMenuStatus();
|
m_main_window->UpdateComponents();
|
||||||
|
|
||||||
m_gtk_app->signal_shutdown().connect([&]() {
|
m_gtk_app->signal_shutdown().connect([&]() {
|
||||||
StopDiscord();
|
StopDiscord();
|
||||||
@@ -70,19 +70,19 @@ const DiscordClient &Abaddon::GetDiscordClient() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Abaddon::DiscordNotifyReady() {
|
void Abaddon::DiscordNotifyReady() {
|
||||||
m_main_window->UpdateChannelListing();
|
m_main_window->UpdateComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Abaddon::ActionConnect() {
|
void Abaddon::ActionConnect() {
|
||||||
if (!m_discord.IsStarted())
|
if (!m_discord.IsStarted())
|
||||||
StartDiscord();
|
StartDiscord();
|
||||||
m_main_window->UpdateMenuStatus();
|
m_main_window->UpdateComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Abaddon::ActionDisconnect() {
|
void Abaddon::ActionDisconnect() {
|
||||||
if (m_discord.IsStarted())
|
if (m_discord.IsStarted())
|
||||||
StopDiscord();
|
StopDiscord();
|
||||||
m_main_window->UpdateMenuStatus();
|
m_main_window->UpdateComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Abaddon::ActionSetToken() {
|
void Abaddon::ActionSetToken() {
|
||||||
@@ -90,7 +90,7 @@ void Abaddon::ActionSetToken() {
|
|||||||
auto response = dlg.run();
|
auto response = dlg.run();
|
||||||
if (response == Gtk::RESPONSE_OK) {
|
if (response == Gtk::RESPONSE_OK) {
|
||||||
m_discord_token = dlg.GetToken();
|
m_discord_token = dlg.GetToken();
|
||||||
m_main_window->UpdateMenuStatus();
|
m_main_window->UpdateComponents();
|
||||||
m_settings.SetSetting("discord", "token", m_discord_token);
|
m_settings.SetSetting("discord", "token", m_discord_token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,12 @@ void ChannelList::SetListingFromGuilds(const DiscordClient::Guilds_t &guilds) {
|
|||||||
m_update_dispatcher.emit();
|
m_update_dispatcher.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChannelList::ClearListing() {
|
||||||
|
std::scoped_lock<std::mutex> guard(m_update_mutex);
|
||||||
|
m_update_queue.push(DiscordClient::Guilds_t());
|
||||||
|
m_update_dispatcher.emit();
|
||||||
|
}
|
||||||
|
|
||||||
void ChannelList::on_row_activated(Gtk::ListBoxRow *row) {
|
void ChannelList::on_row_activated(Gtk::ListBoxRow *row) {
|
||||||
auto &info = m_infos[row];
|
auto &info = m_infos[row];
|
||||||
bool new_collapsed = !info.IsUserCollapsed;
|
bool new_collapsed = !info.IsUserCollapsed;
|
||||||
@@ -77,6 +83,12 @@ void ChannelList::SetListingFromGuildsInternal() {
|
|||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (guilds->empty()) {
|
||||||
|
std::scoped_lock<std::mutex> guard(m_update_mutex);
|
||||||
|
m_update_queue.pop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto &settings = m_abaddon->GetDiscordClient().GetUserSettings();
|
auto &settings = m_abaddon->GetDiscordClient().GetUserSettings();
|
||||||
|
|
||||||
std::vector<std::pair<Snowflake, GuildData>> sorted_guilds;
|
std::vector<std::pair<Snowflake, GuildData>> sorted_guilds;
|
||||||
|
@@ -12,6 +12,7 @@ public:
|
|||||||
ChannelList();
|
ChannelList();
|
||||||
Gtk::Widget *GetRoot() const;
|
Gtk::Widget *GetRoot() const;
|
||||||
void SetListingFromGuilds(const DiscordClient::Guilds_t &guilds);
|
void SetListingFromGuilds(const DiscordClient::Guilds_t &guilds);
|
||||||
|
void ClearListing();
|
||||||
|
|
||||||
void SetAbaddon(Abaddon *ptr);
|
void SetAbaddon(Abaddon *ptr);
|
||||||
|
|
||||||
|
@@ -47,14 +47,22 @@ MainWindow::MainWindow()
|
|||||||
show_all_children();
|
show_all_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::UpdateMenuStatus() {
|
void MainWindow::UpdateComponents() {
|
||||||
|
bool discord_active = m_abaddon->IsDiscordActive();
|
||||||
|
|
||||||
|
// menu
|
||||||
// Connect
|
// Connect
|
||||||
std::string token = m_abaddon->GetDiscordToken();
|
std::string token = m_abaddon->GetDiscordToken();
|
||||||
bool discord_active = m_abaddon->IsDiscordActive();
|
|
||||||
m_menu_discord_connect.set_sensitive(token.size() > 0 && !discord_active);
|
m_menu_discord_connect.set_sensitive(token.size() > 0 && !discord_active);
|
||||||
|
|
||||||
// Disconnect
|
// Disconnect
|
||||||
m_menu_discord_disconnect.set_sensitive(discord_active);
|
m_menu_discord_disconnect.set_sensitive(discord_active);
|
||||||
|
|
||||||
|
// channel listing
|
||||||
|
if (!discord_active)
|
||||||
|
m_channel_list.ClearListing();
|
||||||
|
else
|
||||||
|
UpdateChannelListing();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::UpdateChannelListing() {
|
void MainWindow::UpdateChannelListing() {
|
||||||
|
@@ -8,7 +8,7 @@ public:
|
|||||||
MainWindow();
|
MainWindow();
|
||||||
void SetAbaddon(Abaddon *ptr);
|
void SetAbaddon(Abaddon *ptr);
|
||||||
|
|
||||||
void UpdateMenuStatus();
|
void UpdateComponents();
|
||||||
void UpdateChannelListing();
|
void UpdateChannelListing();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Reference in New Issue
Block a user