summaryrefslogtreecommitdiff
path: root/src/components/channeltabswitcherhandy.cpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2022-04-21 14:41:45 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2022-04-21 14:41:45 -0400
commitb4ab88f7086d87736848fc026bc87db651f8732e (patch)
treea1069413ae1345f65be23b95bd0248ef17d99a83 /src/components/channeltabswitcherhandy.cpp
parent2dab59547617f7830a4fecd3de380396b47de33f (diff)
downloadabaddon-portaudio-b4ab88f7086d87736848fc026bc87db651f8732e.tar.gz
abaddon-portaudio-b4ab88f7086d87736848fc026bc87db651f8732e.zip
add opened tabs to state
Diffstat (limited to 'src/components/channeltabswitcherhandy.cpp')
-rw-r--r--src/components/channeltabswitcherhandy.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/components/channeltabswitcherhandy.cpp b/src/components/channeltabswitcherhandy.cpp
index a9d2aef..bb28272 100644
--- a/src/components/channeltabswitcherhandy.cpp
+++ b/src/components/channeltabswitcherhandy.cpp
@@ -81,6 +81,28 @@ void ChannelTabSwitcherHandy::ReplaceActiveTab(Snowflake id) {
}
}
+TabsState ChannelTabSwitcherHandy::GetTabsState() {
+ TabsState state;
+
+ const gint num_pages = hdy_tab_view_get_n_pages(m_tab_view);
+ for (gint i = 0; i < num_pages; i++) {
+ auto *page = hdy_tab_view_get_nth_page(m_tab_view, i);
+ if (page != nullptr) {
+ if (const auto it = m_pages_rev.find(page); it != m_pages_rev.end()) {
+ state.Channels.push_back(it->second);
+ }
+ }
+ }
+
+ return state;
+}
+
+void ChannelTabSwitcherHandy::UseTabsState(const TabsState &state) {
+ for (auto id : state.Channels) {
+ AddChannelTab(id);
+ }
+}
+
void ChannelTabSwitcherHandy::CheckUnread(Snowflake id) {
if (auto it = m_pages.find(id); it != m_pages.end()) {
hdy_tab_page_set_needs_attention(it->second, Abaddon::Get().GetDiscordClient().GetUnreadStateForChannel(id) > -1);