diff --git a/components/statusindicator.cpp b/components/statusindicator.cpp index f10d1ef..6e7e0fb 100644 --- a/components/statusindicator.cpp +++ b/components/statusindicator.cpp @@ -36,13 +36,8 @@ void StatusIndicator::CheckStatus() { get_style_context()->remove_class("dnd"); get_style_context()->remove_class("idle"); get_style_context()->remove_class("offline"); - if (status.has_value()) { - get_style_context()->add_class(GetPresenceString(*status)); - m_status = *status; - } else { - m_status = PresenceStatus::Offline; - get_style_context()->add_class("offline"); - } + get_style_context()->add_class(GetPresenceString(status)); + m_status = status; if (last_status != m_status) queue_draw(); diff --git a/discord/discord.cpp b/discord/discord.cpp index e0de3e9..c85ad6e 100644 --- a/discord/discord.cpp +++ b/discord/discord.cpp @@ -842,12 +842,12 @@ void DiscordClient::SetUserAgent(std::string agent) { m_websocket.SetUserAgent(agent); } -std::optional DiscordClient::GetUserStatus(Snowflake id) const { +PresenceStatus DiscordClient::GetUserStatus(Snowflake id) const { auto it = m_user_to_status.find(id); if (it != m_user_to_status.end()) return it->second; - return std::nullopt; + return PresenceStatus::Offline; } std::unordered_set DiscordClient::GetRelationships(RelationshipType type) const { diff --git a/discord/discord.hpp b/discord/discord.hpp index 1d732b7..2983ddf 100644 --- a/discord/discord.hpp +++ b/discord/discord.hpp @@ -176,7 +176,7 @@ public: void UpdateToken(std::string token); void SetUserAgent(std::string agent); - std::optional GetUserStatus(Snowflake id) const; + PresenceStatus GetUserStatus(Snowflake id) const; std::unordered_set GetRelationships(RelationshipType type) const; diff --git a/windows/mainwindow.cpp b/windows/mainwindow.cpp index 654d745..70f0522 100644 --- a/windows/mainwindow.cpp +++ b/windows/mainwindow.cpp @@ -124,33 +124,40 @@ MainWindow::MainWindow() { } else { m_main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); m_content_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); - m_chan_chat_paned = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_HORIZONTAL)); - m_chat_members_paned = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_HORIZONTAL)); + m_chan_content_paned = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_HORIZONTAL)); + m_content_members_paned = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_HORIZONTAL)); + m_content_stack = Gtk::manage(new Gtk::Stack); + + m_main_box->show(); m_content_box->set_hexpand(true); m_content_box->set_vexpand(true); m_content_box->show(); - m_main_box->add(m_menu_bar); - m_main_box->add(*m_content_box); - m_main_box->show(); + m_content_stack->add(*chat); + m_content_stack->set_vexpand(true); + m_content_stack->set_hexpand(true); + m_content_stack->show(); - m_chan_chat_paned->pack1(*channel_list); - m_chan_chat_paned->pack2(*m_chat_members_paned); - m_chan_chat_paned->child_property_shrink(*channel_list) = false; - m_chan_chat_paned->child_property_resize(*channel_list) = false; - m_chan_chat_paned->set_position(200); - m_chan_chat_paned->show(); - m_content_box->add(*m_chan_chat_paned); + m_chan_content_paned->pack1(*channel_list); + m_chan_content_paned->pack2(*m_content_members_paned); + m_chan_content_paned->child_property_shrink(*channel_list) = false; + m_chan_content_paned->child_property_resize(*channel_list) = false; + m_chan_content_paned->set_position(200); + m_chan_content_paned->show(); + m_content_box->add(*m_chan_content_paned); - m_chat_members_paned->pack1(*chat); - m_chat_members_paned->pack2(*member_list); - m_chat_members_paned->child_property_shrink(*member_list) = false; - m_chat_members_paned->child_property_resize(*member_list) = false; + m_content_members_paned->pack1(*m_content_stack); + m_content_members_paned->pack2(*member_list); + m_content_members_paned->child_property_shrink(*member_list) = false; + m_content_members_paned->child_property_resize(*member_list) = false; int w, h; get_default_size(w, h); // :s - m_chat_members_paned->set_position(w - m_chan_chat_paned->get_position() - 150); - m_chat_members_paned->show(); + m_content_members_paned->set_position(w - m_chan_content_paned->get_position() - 150); + m_content_members_paned->show(); + + m_main_box->add(m_menu_bar); + m_main_box->add(*m_content_box); add(*m_main_box); } diff --git a/windows/mainwindow.hpp b/windows/mainwindow.hpp index 679c683..f3980a6 100644 --- a/windows/mainwindow.hpp +++ b/windows/mainwindow.hpp @@ -69,8 +69,9 @@ protected: Gtk::Box *m_main_box; // normal Gtk::Box *m_content_box = nullptr; - Gtk::Paned *m_chan_chat_paned = nullptr; - Gtk::Paned *m_chat_members_paned = nullptr; + Gtk::Paned *m_chan_content_paned = nullptr; + Gtk::Paned *m_content_members_paned = nullptr; + Gtk::Stack *m_content_stack = nullptr; // mobile Gtk::StackSwitcher *m_switcher = nullptr;