summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-05-14 00:27:58 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2021-05-14 00:27:58 -0400
commit95eb6646415d859931532e7b22967b7c68ddb02b (patch)
treeda80f5de4607ca4c280581f887a543522b760595
parent858fd8ce626d3f3c5ef3c4349612e520f07eff6a (diff)
downloadabaddon-portaudio-95eb6646415d859931532e7b22967b7c68ddb02b.tar.gz
abaddon-portaudio-95eb6646415d859931532e7b22967b7c68ddb02b.zip
friends: friends list is now in main content stack
-rw-r--r--components/friendslist.cpp29
-rw-r--r--components/friendslist.hpp2
-rw-r--r--css/main.css9
-rw-r--r--windows/mainwindow.cpp15
-rw-r--r--windows/mainwindow.hpp2
5 files changed, 43 insertions, 14 deletions
diff --git a/components/friendslist.cpp b/components/friendslist.cpp
index 9a8efe8..7d9fc21 100644
--- a/components/friendslist.cpp
+++ b/components/friendslist.cpp
@@ -7,18 +7,15 @@ using namespace std::string_literals;
FriendsList::FriendsList()
: Gtk::Box(Gtk::ORIENTATION_VERTICAL)
, m_filter_mode(FILTER_FRIENDS) {
+ get_style_context()->add_class("friends-list");
+
auto &discord = Abaddon::Get().GetDiscordClient();
discord.signal_relationship_add().connect(sigc::mem_fun(*this, &FriendsList::OnRelationshipAdd));
discord.signal_relationship_remove().connect(sigc::mem_fun(*this, &FriendsList::OnRelationshipRemove));
- for (const auto &[id, type] : discord.GetRelationships()) {
- const auto user = discord.GetUser(id);
- if (!user.has_value()) continue;
- auto *row = MakeRow(*user, type);
- m_list.add(*row);
- row->show();
- }
+ PopulateRelationships();
+ signal_map().connect(sigc::mem_fun(*this, &FriendsList::PopulateRelationships));
constexpr static std::array<const char *, 4> strs = {
"Friends",
@@ -147,6 +144,20 @@ void FriendsList::OnActionRemove(Snowflake id) {
}
}
+void FriendsList::PopulateRelationships() {
+ for (auto child : m_list.get_children())
+ delete child;
+
+ auto &discord = Abaddon::Get().GetDiscordClient();
+ for (const auto &[id, type] : discord.GetRelationships()) {
+ const auto user = discord.GetUser(id);
+ if (!user.has_value()) continue;
+ auto *row = MakeRow(*user, type);
+ m_list.add(*row);
+ row->show();
+ }
+}
+
int FriendsList::ListSortFunc(Gtk::ListBoxRow *a_, Gtk::ListBoxRow *b_) {
auto *a = dynamic_cast<FriendsListFriendRow *>(a_);
auto *b = dynamic_cast<FriendsListFriendRow *>(b_);
@@ -238,6 +249,7 @@ FriendsListFriendRow::FriendsListFriendRow(RelationshipType type, const UserData
auto *ev = Gtk::manage(new Gtk::EventBox);
auto *box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
auto *img = Gtk::manage(new LazyImage(32, 32, true));
+ auto *namebox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
auto *namelbl = Gtk::manage(new Gtk::Label("", Gtk::ALIGN_START));
m_status_lbl = Gtk::manage(new Gtk::Label("", Gtk::ALIGN_START));
auto *lblbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
@@ -291,7 +303,8 @@ FriendsListFriendRow::FriendsListFriendRow(RelationshipType type, const UserData
img->set_margin_end(5);
- lblbox->add(*namelbl);
+ namebox->add(*namelbl);
+ lblbox->add(*namebox);
lblbox->add(*m_status_lbl);
box->add(*img);
diff --git a/components/friendslist.hpp b/components/friendslist.hpp
index 174055f..0101db6 100644
--- a/components/friendslist.hpp
+++ b/components/friendslist.hpp
@@ -33,6 +33,8 @@ private:
void OnActionAccept(Snowflake id);
void OnActionRemove(Snowflake id);
+ void PopulateRelationships();
+
enum FilterMode {
FILTER_FRIENDS,
FILTER_ONLINE,
diff --git a/css/main.css b/css/main.css
index 14e5a86..e99ccd1 100644
--- a/css/main.css
+++ b/css/main.css
@@ -341,3 +341,12 @@
.drag-hover-bottom {
background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 65%, rgba(255, 66, 66, 0.65) 100%);
}
+
+.friends-list list {
+ background: @background_color;
+ padding-left: 10px;
+}
+
+.friends-list-row-bot {
+ color: #ff0000;
+}
diff --git a/windows/mainwindow.cpp b/windows/mainwindow.cpp
index 11ca995..6565e3b 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)
@@ -88,10 +87,7 @@ MainWindow::MainWindow()
});
m_menu_view_friends.signal_activate().connect([this] {
- auto *window = new FriendsListWindow;
- window->set_position(Gtk::WIN_POS_CENTER);
- window->show();
- Abaddon::Get().ManageHeapWindow(window);
+ m_content_stack.set_visible_child("friends");
});
m_content_box.set_hexpand(true);
@@ -125,9 +121,15 @@ MainWindow::MainWindow()
member_list->set_vexpand(true);
member_list->show();
- m_content_stack.add(*chat);
+ m_friends.set_vexpand(true);
+ m_friends.set_hexpand(true);
+ m_friends.show();
+
+ m_content_stack.add(*chat, "chat");
+ m_content_stack.add(m_friends, "friends");
m_content_stack.set_vexpand(true);
m_content_stack.set_hexpand(true);
+ m_content_stack.set_visible_child("chat");
m_content_stack.show();
m_chan_content_paned.pack1(*channel_list);
@@ -222,6 +224,7 @@ void MainWindow::UpdateChatActiveChannel(Snowflake id) {
m_chat.SetActiveChannel(id);
m_members.SetActiveChannel(id);
m_channel_list.SetActiveChannel(id);
+ m_content_stack.set_visible_child("chat");
}
Snowflake MainWindow::GetChatActiveChannel() const {
diff --git a/windows/mainwindow.hpp b/windows/mainwindow.hpp
index f877018..544e9a3 100644
--- a/windows/mainwindow.hpp
+++ b/windows/mainwindow.hpp
@@ -2,6 +2,7 @@
#include "../components/channels.hpp"
#include "../components/chatwindow.hpp"
#include "../components/memberlist.hpp"
+#include "../components/friendslist.hpp"
#include <gtkmm.h>
class MainWindow : public Gtk::Window {
@@ -74,6 +75,7 @@ protected:
ChannelList m_channel_list;
ChatWindow m_chat;
MemberList m_members;
+ FriendsList m_friends;
Gtk::Stack m_content_stack;