From 8b22c7c2cf3f85d6664d97c29a98df7e4bbe8981 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 3 May 2021 00:47:43 -0400 Subject: [PATCH 1/4] pull central pane (chat) into a stack --- windows/mainwindow.cpp | 36 +++++++++++++++++++++--------------- windows/mainwindow.hpp | 6 ++++-- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/windows/mainwindow.cpp b/windows/mainwindow.cpp index d1598c6..1ab79ec 100644 --- a/windows/mainwindow.cpp +++ b/windows/mainwindow.cpp @@ -1,11 +1,12 @@ #include "mainwindow.hpp" #include "../abaddon.hpp" +#include "../components/friendslist.hpp" MainWindow::MainWindow() : m_main_box(Gtk::ORIENTATION_VERTICAL) , m_content_box(Gtk::ORIENTATION_HORIZONTAL) - , m_chan_chat_paned(Gtk::ORIENTATION_HORIZONTAL) - , m_chat_members_paned(Gtk::ORIENTATION_HORIZONTAL) { + , m_chan_content_paned(Gtk::ORIENTATION_HORIZONTAL) + , m_content_members_paned(Gtk::ORIENTATION_HORIZONTAL) { set_default_size(1200, 800); get_style_context()->add_class("app-window"); @@ -110,22 +111,27 @@ MainWindow::MainWindow() member_list->set_vexpand(true); member_list->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_content_stack.add(*chat); + m_content_stack.set_vexpand(true); + m_content_stack.set_hexpand(true); + m_content_stack.show(); - 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_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_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(); add(m_main_box); } diff --git a/windows/mainwindow.hpp b/windows/mainwindow.hpp index b1803ad..0be4bc0 100644 --- a/windows/mainwindow.hpp +++ b/windows/mainwindow.hpp @@ -68,13 +68,15 @@ protected: protected: Gtk::Box m_main_box; Gtk::Box m_content_box; - Gtk::Paned m_chan_chat_paned; - Gtk::Paned m_chat_members_paned; + Gtk::Paned m_chan_content_paned; + Gtk::Paned m_content_members_paned; ChannelList m_channel_list; ChatWindow m_chat; MemberList m_members; + Gtk::Stack m_content_stack; + Gtk::MenuBar m_menu_bar; Gtk::MenuItem m_menu_discord; Gtk::Menu m_menu_discord_sub; From ff2d92c92ae23ce259bdf900d8d4f0aa12b1dd6b Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Wed, 5 May 2021 04:22:30 -0400 Subject: [PATCH 2/4] GetUserStatus returns offline instead of nullopt --- components/statusindicator.cpp | 9 ++------- discord/discord.cpp | 4 ++-- discord/discord.hpp | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) 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; From 2b45a04911cf030df21384e0ab1026325141b7f2 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Wed, 5 May 2021 04:28:54 -0400 Subject: [PATCH 3/4] GetUserStatus returns offline instead of nullopt --- components/statusindicator.cpp | 9 ++------- discord/discord.cpp | 4 ++-- discord/discord.hpp | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) 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; From 47b051ba9ee95d7716914cf8aa3db99568b52648 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Wed, 5 May 2021 04:30:21 -0400 Subject: [PATCH 4/4] fix build --- windows/mainwindow.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/windows/mainwindow.cpp b/windows/mainwindow.cpp index 1ab79ec..b6d3ca5 100644 --- a/windows/mainwindow.cpp +++ b/windows/mainwindow.cpp @@ -1,6 +1,5 @@ #include "mainwindow.hpp" #include "../abaddon.hpp" -#include "../components/friendslist.hpp" MainWindow::MainWindow() : m_main_box(Gtk::ORIENTATION_VERTICAL)