From e166c83d33bbf5aebe172111c8a7614c1dece48c Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 11 Jun 2021 01:24:23 -0400 Subject: basic pins window --- windows/pinnedwindow.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 windows/pinnedwindow.cpp (limited to 'windows/pinnedwindow.cpp') diff --git a/windows/pinnedwindow.cpp b/windows/pinnedwindow.cpp new file mode 100644 index 0000000..0d677ee --- /dev/null +++ b/windows/pinnedwindow.cpp @@ -0,0 +1,32 @@ +#include "pinnedwindow.hpp" +#include "../abaddon.hpp" + +PinnedWindow::PinnedWindow(const ChannelData &data) + : ChannelID(data.ID) { + if (data.GuildID.has_value()) + GuildID = *data.GuildID; + + set_name("pinned-messages"); + set_default_size(450, 375); + set_title("#" + *data.Name + " - Pinned Messages"); + set_position(Gtk::WIN_POS_CENTER); + get_style_context()->add_class("app-window"); + get_style_context()->add_class("app-popup"); + get_style_context()->add_class("pinned-messages-window"); + + add(m_chat); + m_chat.show(); + + m_chat.SetActiveChannel(ChannelID); + + FetchPinned(); +} + +void PinnedWindow::FetchPinned() { + Abaddon::Get().GetDiscordClient().FetchPinned(ChannelID, sigc::mem_fun(*this, &PinnedWindow::OnFetchedPinned)); +} + +void PinnedWindow::OnFetchedPinned(const std::vector &msgs, DiscordError code) { + if (code != DiscordError::NONE) return; + m_chat.SetMessages(msgs.begin(), msgs.end()); +} -- cgit v1.2.3