From 3e0cd83dd6026dc701c548dc40b41f5accbc29db Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:31:28 -0400 Subject: start channel list refactor for server list --- src/components/channellist/classic/guildlist.cpp | 23 +++++++++++++++++ src/components/channellist/classic/guildlist.hpp | 12 +++++++++ .../channellist/classic/guildlistfolderitem.cpp | 18 ++++++++++++++ .../channellist/classic/guildlistfolderitem.hpp | 18 ++++++++++++++ .../channellist/classic/guildlistguilditem.cpp | 29 ++++++++++++++++++++++ .../channellist/classic/guildlistguilditem.hpp | 17 +++++++++++++ 6 files changed, 117 insertions(+) create mode 100644 src/components/channellist/classic/guildlist.cpp create mode 100644 src/components/channellist/classic/guildlist.hpp create mode 100644 src/components/channellist/classic/guildlistfolderitem.cpp create mode 100644 src/components/channellist/classic/guildlistfolderitem.hpp create mode 100644 src/components/channellist/classic/guildlistguilditem.cpp create mode 100644 src/components/channellist/classic/guildlistguilditem.hpp (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/classic/guildlist.cpp b/src/components/channellist/classic/guildlist.cpp new file mode 100644 index 0000000..0d5737b --- /dev/null +++ b/src/components/channellist/classic/guildlist.cpp @@ -0,0 +1,23 @@ +#include "guildlist.hpp" +#include "guildlistfolderitem.hpp" + +GuildList::GuildList() { + set_selection_mode(Gtk::SELECTION_NONE); + show_all_children(); +} + +void GuildList::AddGuild(Snowflake id) { + const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(id); + if (!guild.has_value()) return; + + auto *item = Gtk::make_managed(*guild); + item->show(); + add(*item); +} + +void GuildList::Clear() { + const auto children = get_children(); + for (auto child : children) { + delete child; + } +} diff --git a/src/components/channellist/classic/guildlist.hpp b/src/components/channellist/classic/guildlist.hpp new file mode 100644 index 0000000..244313f --- /dev/null +++ b/src/components/channellist/classic/guildlist.hpp @@ -0,0 +1,12 @@ +#pragma once +#include +#include "discord/snowflake.hpp" + +class GuildList : public Gtk::ListBox { +public: + GuildList(); + + void AddGuild(Snowflake id); + + void Clear(); +}; diff --git a/src/components/channellist/classic/guildlistfolderitem.cpp b/src/components/channellist/classic/guildlistfolderitem.cpp new file mode 100644 index 0000000..36d5a5a --- /dev/null +++ b/src/components/channellist/classic/guildlistfolderitem.cpp @@ -0,0 +1,18 @@ +#include "guildlistfolderitem.hpp" + +GuildListFolderItem::GuildListFolderItem() { + m_revealer.add(m_box); + m_revealer.set_reveal_child(true); + + m_ev.signal_button_press_event().connect([this](GdkEventButton *event) -> bool { + if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) { + m_revealer.set_reveal_child(!m_revealer.get_reveal_child()); + } + return false; + }); + + m_ev.add(m_image); + add(m_ev); + add(m_revealer); + show_all_children(); +} diff --git a/src/components/channellist/classic/guildlistfolderitem.hpp b/src/components/channellist/classic/guildlistfolderitem.hpp new file mode 100644 index 0000000..3506969 --- /dev/null +++ b/src/components/channellist/classic/guildlistfolderitem.hpp @@ -0,0 +1,18 @@ +#pragma once +#include +#include +#include +#include + +#include "guildlistguilditem.hpp" + +class GuildListFolderItem : public Gtk::VBox { +public: + GuildListFolderItem(); + +private: + Gtk::EventBox m_ev; + Gtk::Image m_image; + Gtk::Revealer m_revealer; + Gtk::VBox m_box; +}; diff --git a/src/components/channellist/classic/guildlistguilditem.cpp b/src/components/channellist/classic/guildlistguilditem.cpp new file mode 100644 index 0000000..88ed2a9 --- /dev/null +++ b/src/components/channellist/classic/guildlistguilditem.cpp @@ -0,0 +1,29 @@ +#include "guildlistguilditem.hpp" + +GuildListGuildItem::GuildListGuildItem(const GuildData &guild) + : ID(guild.ID) { + m_image.property_pixbuf() = Abaddon::Get().GetImageManager().GetPlaceholder(48); + add(m_image); + show_all_children(); + + signal_button_press_event().connect([this](GdkEventButton *event) -> bool { + if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) { + printf("Click %llu\n", (uint64_t)ID); + } + return true; + }); + + set_tooltip_text(guild.Name); + + UpdateIcon(); +} + +void GuildListGuildItem::UpdateIcon() { + const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(ID); + if (!guild.has_value()) return; + Abaddon::Get().GetImageManager().LoadFromURL(guild->GetIconURL("png", "64"), sigc::mem_fun(*this, &GuildListGuildItem::OnIconFetched)); +} + +void GuildListGuildItem::OnIconFetched(const Glib::RefPtr &pb) { + m_image.property_pixbuf() = pb->scale_simple(48, 48, Gdk::INTERP_BILINEAR); +} diff --git a/src/components/channellist/classic/guildlistguilditem.hpp b/src/components/channellist/classic/guildlistguilditem.hpp new file mode 100644 index 0000000..3114a05 --- /dev/null +++ b/src/components/channellist/classic/guildlistguilditem.hpp @@ -0,0 +1,17 @@ +#pragma once +#include +#include +#include "discord/guild.hpp" + +class GuildListGuildItem : public Gtk::EventBox { +public: + GuildListGuildItem(const GuildData &guild); + + Snowflake ID; + +private: + void UpdateIcon(); + void OnIconFetched(const Glib::RefPtr &pb); + + Gtk::Image m_image; +}; -- cgit v1.2.3 From 182128705e10adf529b39a290232f0cd27bf4837 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Tue, 24 Oct 2023 22:45:31 -0400 Subject: very very rudimentary classic channels list --- src/components/channellist/channellist.cpp | 50 +++++++++++++++++++++- src/components/channellist/channellist.hpp | 10 ++++- src/components/channellist/channellisttree.cpp | 14 +++++- src/components/channellist/channellisttree.hpp | 6 +++ src/components/channellist/classic/guildlist.cpp | 24 ++++++++++- src/components/channellist/classic/guildlist.hpp | 12 +++++- .../channellist/classic/guildlistguilditem.cpp | 7 --- src/windows/mainwindow.cpp | 2 + 8 files changed, 112 insertions(+), 13 deletions(-) (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/channellist.cpp b/src/components/channellist/channellist.cpp index 38a9ecc..6cb5321 100644 --- a/src/components/channellist/channellist.cpp +++ b/src/components/channellist/channellist.cpp @@ -1,12 +1,26 @@ #include "channellist.hpp" ChannelList::ChannelList() { + ConnectSignals(); + + m_guilds.set_halign(Gtk::ALIGN_START); + + m_guilds_scroll.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); + + m_guilds.signal_guild_selected().connect([this](Snowflake guild_id) { + m_tree.SetSelectedGuild(guild_id); + }); + + m_guilds.show(); m_tree.show(); - add(m_tree); + m_guilds_scroll.add(m_guilds); + pack_start(m_guilds_scroll, false, false); // only take the space it needs + pack_start(m_tree, true, true); // use all the remaining space } void ChannelList::UpdateListing() { m_tree.UpdateListing(); + m_guilds.UpdateListing(); } void ChannelList::SetActiveChannel(Snowflake id, bool expand_to) { @@ -18,13 +32,45 @@ void ChannelList::UseExpansionState(const ExpansionStateRoot &state) { } ExpansionStateRoot ChannelList::GetExpansionState() const { - m_tree.GetExpansionState(); + return m_tree.GetExpansionState(); } void ChannelList::UsePanedHack(Gtk::Paned &paned) { m_tree.UsePanedHack(paned); } +void ChannelList::SetClassic(bool value) { + m_tree.SetClassic(value); + m_guilds_scroll.set_visible(value); +} + +void ChannelList::ConnectSignals() { + // TODO: if these all just travel upwards to the singleton then get rid of them but mayeb they dont + m_tree.signal_action_open_new_tab().connect([this](Snowflake id) { + m_signal_action_open_new_tab.emit(id); + }); + + m_tree.signal_action_join_voice_channel().connect([this](Snowflake id) { + m_signal_action_join_voice_channel.emit(id); + }); + + m_tree.signal_action_disconnect_voice().connect([this]() { + m_signal_action_disconnect_voice.emit(); + }); + + m_tree.signal_action_channel_item_select().connect([this](Snowflake id) { + m_signal_action_channel_item_select.emit(id); + }); + + m_tree.signal_action_guild_leave().connect([this](Snowflake id) { + m_signal_action_guild_leave.emit(id); + }); + + m_tree.signal_action_guild_settings().connect([this](Snowflake id) { + m_signal_action_guild_settings.emit(id); + }); +} + ChannelList::type_signal_action_open_new_tab ChannelList::signal_action_open_new_tab() { return m_signal_action_open_new_tab; } diff --git a/src/components/channellist/channellist.hpp b/src/components/channellist/channellist.hpp index 5863485..692afa7 100644 --- a/src/components/channellist/channellist.hpp +++ b/src/components/channellist/channellist.hpp @@ -2,11 +2,12 @@ #include #include #include "channellisttree.hpp" +#include "classic/guildlist.hpp" #include "discord/snowflake.hpp" #include "state.hpp" // Contains the actual ChannelListTree and the classic listing if enabled -class ChannelList : public Gtk::Box { +class ChannelList : public Gtk::HBox { // have to proxy public and signals to underlying tree... ew!!! public: ChannelList(); @@ -20,9 +21,16 @@ public: void UsePanedHack(Gtk::Paned &paned); + void SetClassic(bool value); + private: + void ConnectSignals(); + ChannelListTree m_tree; + Gtk::ScrolledWindow m_guilds_scroll; + GuildList m_guilds; + public: using type_signal_action_channel_item_select = sigc::signal; using type_signal_action_guild_leave = sigc::signal; diff --git a/src/components/channellist/channellisttree.cpp b/src/components/channellist/channellisttree.cpp index 22f8581..b9b5c08 100644 --- a/src/components/channellist/channellisttree.cpp +++ b/src/components/channellist/channellisttree.cpp @@ -85,8 +85,10 @@ ChannelListTree::ChannelListTree() }); m_filter_model->set_visible_func([this](const Gtk::TreeModel::const_iterator &iter) -> bool { + if (!m_classic) return true; + if ((*iter)[m_columns.m_type] == RenderType::Guild) { - return (*iter)[m_columns.m_id] == 754921263616753776ULL; + return (*iter)[m_columns.m_id] == m_classic_selected_guild; } return true; }); @@ -301,6 +303,16 @@ void ChannelListTree::UsePanedHack(Gtk::Paned &paned) { paned.property_position().signal_changed().connect(sigc::mem_fun(*this, &ChannelListTree::OnPanedPositionChanged)); } +void ChannelListTree::SetClassic(bool value) { + m_classic = value; + m_filter_model->refilter(); +} + +void ChannelListTree::SetSelectedGuild(Snowflake guild_id) { + m_classic_selected_guild = guild_id; + m_filter_model->refilter(); +} + void ChannelListTree::OnPanedPositionChanged() { m_view.queue_draw(); } diff --git a/src/components/channellist/channellisttree.hpp b/src/components/channellist/channellisttree.hpp index 0cd76e0..bb7396e 100644 --- a/src/components/channellist/channellisttree.hpp +++ b/src/components/channellist/channellisttree.hpp @@ -33,6 +33,9 @@ public: void UsePanedHack(Gtk::Paned &paned); + void SetClassic(bool value); + void SetSelectedGuild(Snowflake guild_id); + protected: void OnPanedPositionChanged(); @@ -186,6 +189,9 @@ protected: bool m_updating_listing = false; + bool m_classic = false; + Snowflake m_classic_selected_guild; + Snowflake m_active_channel; public: diff --git a/src/components/channellist/classic/guildlist.cpp b/src/components/channellist/classic/guildlist.cpp index 0d5737b..6c1fbc3 100644 --- a/src/components/channellist/classic/guildlist.cpp +++ b/src/components/channellist/classic/guildlist.cpp @@ -6,18 +6,40 @@ GuildList::GuildList() { show_all_children(); } +void GuildList::UpdateListing() { + auto &discord = Abaddon::Get().GetDiscordClient(); + + Clear(); + + // does this function still even work ??lol + const auto ids = discord.GetUserSortedGuilds(); + for (const auto id : ids) { + AddGuild(id); + } +} + void GuildList::AddGuild(Snowflake id) { const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(id); if (!guild.has_value()) return; auto *item = Gtk::make_managed(*guild); + item->signal_button_press_event().connect([this, id](GdkEventButton *event) -> bool { + if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) { + m_signal_guild_selected.emit(id); + } + return true; + }); item->show(); add(*item); } void GuildList::Clear() { const auto children = get_children(); - for (auto child : children) { + for (auto *child : children) { delete child; } } + +GuildList::type_signal_guild_selected GuildList::signal_guild_selected() { + return m_signal_guild_selected; +} diff --git a/src/components/channellist/classic/guildlist.hpp b/src/components/channellist/classic/guildlist.hpp index 244313f..856cf4d 100644 --- a/src/components/channellist/classic/guildlist.hpp +++ b/src/components/channellist/classic/guildlist.hpp @@ -6,7 +6,17 @@ class GuildList : public Gtk::ListBox { public: GuildList(); - void AddGuild(Snowflake id); + void UpdateListing(); +private: + void AddGuild(Snowflake id); void Clear(); + +public: + using type_signal_guild_selected = sigc::signal; + + type_signal_guild_selected signal_guild_selected(); + +private: + type_signal_guild_selected m_signal_guild_selected; }; diff --git a/src/components/channellist/classic/guildlistguilditem.cpp b/src/components/channellist/classic/guildlistguilditem.cpp index 88ed2a9..5cec281 100644 --- a/src/components/channellist/classic/guildlistguilditem.cpp +++ b/src/components/channellist/classic/guildlistguilditem.cpp @@ -6,13 +6,6 @@ GuildListGuildItem::GuildListGuildItem(const GuildData &guild) add(m_image); show_all_children(); - signal_button_press_event().connect([this](GdkEventButton *event) -> bool { - if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) { - printf("Click %llu\n", (uint64_t)ID); - } - return true; - }); - set_tooltip_text(guild.Name); UpdateIcon(); diff --git a/src/windows/mainwindow.cpp b/src/windows/mainwindow.cpp index 8e030ed..ea67d2b 100644 --- a/src/windows/mainwindow.cpp +++ b/src/windows/mainwindow.cpp @@ -33,6 +33,8 @@ MainWindow::MainWindow() }); #endif + // TEMP TEMP TEMP TEMP!!!!!!!!!!!! AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH + m_channel_list.SetClassic(true); m_channel_list.set_vexpand(true); m_channel_list.set_size_request(-1, -1); m_channel_list.show(); -- cgit v1.2.3 From 09cfa864be6e706fd2576eee60a285d5f4431b04 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 26 Oct 2023 01:20:10 -0400 Subject: create folders in guild list --- src/components/channellist/classic/guildlist.cpp | 55 +++++++++++++++++++--- src/components/channellist/classic/guildlist.hpp | 6 +++ .../channellist/classic/guildlistfolderitem.cpp | 7 +++ .../channellist/classic/guildlistfolderitem.hpp | 4 ++ 4 files changed, 66 insertions(+), 6 deletions(-) (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/classic/guildlist.cpp b/src/components/channellist/classic/guildlist.cpp index 6c1fbc3..7a4b87c 100644 --- a/src/components/channellist/classic/guildlist.cpp +++ b/src/components/channellist/classic/guildlist.cpp @@ -12,15 +12,37 @@ void GuildList::UpdateListing() { Clear(); // does this function still even work ??lol - const auto ids = discord.GetUserSortedGuilds(); - for (const auto id : ids) { - AddGuild(id); + const auto folders = discord.GetUserSettings().GuildFolders; + const auto guild_ids = discord.GetUserSortedGuilds(); + + // same logic from ChannelListTree + + std::set foldered_guilds; + for (const auto &group : folders) { + foldered_guilds.insert(group.GuildIDs.begin(), group.GuildIDs.end()); + } + + for (auto iter = guild_ids.crbegin(); iter != guild_ids.crend(); iter++) { + if (foldered_guilds.find(*iter) == foldered_guilds.end()) { + AddGuild(*iter); + } + } + + for (const auto &group : folders) { + AddFolder(group); } } void GuildList::AddGuild(Snowflake id) { + if (auto item = CreateGuildWidget(id)) { + item->show(); + add(*item); + } +} + +GuildListGuildItem *GuildList::CreateGuildWidget(Snowflake id) { const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(id); - if (!guild.has_value()) return; + if (!guild.has_value()) return nullptr; auto *item = Gtk::make_managed(*guild); item->signal_button_press_event().connect([this, id](GdkEventButton *event) -> bool { @@ -29,8 +51,29 @@ void GuildList::AddGuild(Snowflake id) { } return true; }); - item->show(); - add(*item); + + return item; +} + +void GuildList::AddFolder(const UserSettingsGuildFoldersEntry &folder) { + // groups with no ID arent actually folders + if (!folder.ID.has_value()) { + if (!folder.GuildIDs.empty()) { + AddGuild(folder.GuildIDs[0]); + } + return; + } + + auto *folder_widget = Gtk::make_managed(); + for (const auto guild_id : folder.GuildIDs) { + if (auto *guild_widget = CreateGuildWidget(guild_id)) { + guild_widget->show(); + folder_widget->AddGuildWidget(guild_widget); + } + } + + folder_widget->show(); + add(*folder_widget); } void GuildList::Clear() { diff --git a/src/components/channellist/classic/guildlist.hpp b/src/components/channellist/classic/guildlist.hpp index 856cf4d..dc19102 100644 --- a/src/components/channellist/classic/guildlist.hpp +++ b/src/components/channellist/classic/guildlist.hpp @@ -1,6 +1,9 @@ #pragma once #include #include "discord/snowflake.hpp" +#include "discord/usersettings.hpp" + +class GuildListGuildItem; class GuildList : public Gtk::ListBox { public: @@ -10,8 +13,11 @@ public: private: void AddGuild(Snowflake id); + void AddFolder(const UserSettingsGuildFoldersEntry &folder); void Clear(); + GuildListGuildItem *CreateGuildWidget(Snowflake id); + public: using type_signal_guild_selected = sigc::signal; diff --git a/src/components/channellist/classic/guildlistfolderitem.cpp b/src/components/channellist/classic/guildlistfolderitem.cpp index 36d5a5a..aead848 100644 --- a/src/components/channellist/classic/guildlistfolderitem.cpp +++ b/src/components/channellist/classic/guildlistfolderitem.cpp @@ -1,9 +1,12 @@ #include "guildlistfolderitem.hpp" +#include "guildlistguilditem.hpp" GuildListFolderItem::GuildListFolderItem() { m_revealer.add(m_box); m_revealer.set_reveal_child(true); + m_image.property_pixbuf() = Abaddon::Get().GetImageManager().GetPlaceholder(48); + m_ev.signal_button_press_event().connect([this](GdkEventButton *event) -> bool { if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) { m_revealer.set_reveal_child(!m_revealer.get_reveal_child()); @@ -16,3 +19,7 @@ GuildListFolderItem::GuildListFolderItem() { add(m_revealer); show_all_children(); } + +void GuildListFolderItem::AddGuildWidget(GuildListGuildItem *widget) { + m_box.add(*widget); +} diff --git a/src/components/channellist/classic/guildlistfolderitem.hpp b/src/components/channellist/classic/guildlistfolderitem.hpp index 3506969..4b7ba0a 100644 --- a/src/components/channellist/classic/guildlistfolderitem.hpp +++ b/src/components/channellist/classic/guildlistfolderitem.hpp @@ -6,10 +6,14 @@ #include "guildlistguilditem.hpp" +class GuildListGuildItem; + class GuildListFolderItem : public Gtk::VBox { public: GuildListFolderItem(); + void AddGuildWidget(GuildListGuildItem *widget); + private: Gtk::EventBox m_ev; Gtk::Image m_image; -- cgit v1.2.3 From 8bd628c1776c20dbf41d2fb18f6204c4a398da0e Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 3 Nov 2023 01:00:29 -0400 Subject: show guild icon previews as grid in folder button --- src/components/channellist/classic/guildlist.cpp | 2 +- .../channellist/classic/guildlistfolderitem.cpp | 53 ++++++++++++++++++++-- .../channellist/classic/guildlistfolderitem.hpp | 3 +- 3 files changed, 53 insertions(+), 5 deletions(-) (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/classic/guildlist.cpp b/src/components/channellist/classic/guildlist.cpp index 7a4b87c..97741cf 100644 --- a/src/components/channellist/classic/guildlist.cpp +++ b/src/components/channellist/classic/guildlist.cpp @@ -64,7 +64,7 @@ void GuildList::AddFolder(const UserSettingsGuildFoldersEntry &folder) { return; } - auto *folder_widget = Gtk::make_managed(); + auto *folder_widget = Gtk::make_managed(folder); for (const auto guild_id : folder.GuildIDs) { if (auto *guild_widget = CreateGuildWidget(guild_id)) { guild_widget->show(); diff --git a/src/components/channellist/classic/guildlistfolderitem.cpp b/src/components/channellist/classic/guildlistfolderitem.cpp index aead848..acf1a2c 100644 --- a/src/components/channellist/classic/guildlistfolderitem.cpp +++ b/src/components/channellist/classic/guildlistfolderitem.cpp @@ -1,7 +1,46 @@ #include "guildlistfolderitem.hpp" #include "guildlistguilditem.hpp" -GuildListFolderItem::GuildListFolderItem() { +// doing my best to copy discord here + +const int FolderGridButtonSize = 48; +const int FolderGridImageSize = 24; + +class GuildListFolderButton : public Gtk::Grid { +public: + GuildListFolderButton() { + set_size_request(FolderGridButtonSize, FolderGridButtonSize); + } + + void SetGuilds(const std::vector &guild_ids) { + for (int y = 0; y < 2; y++) { + for (int x = 0; x < 2; x++) { + const size_t i = y * 2 + x; + auto &widget = m_images[x][y]; + widget.property_pixbuf() = Abaddon::Get().GetImageManager().GetPlaceholder(FolderGridImageSize); + attach(widget, x, y, 1, 1); + + if (i < guild_ids.size()) { + widget.show(); + + if (const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(guild_ids[i]); guild.has_value()) { + const auto cb = [&widget](const Glib::RefPtr &pb) { + widget.property_pixbuf() = pb->scale_simple(FolderGridImageSize, FolderGridImageSize, Gdk::INTERP_BILINEAR); + }; + Abaddon::Get().GetImageManager().LoadFromURL(guild->GetIconURL("png", "32"), sigc::track_obj(cb, *this)); + } + } + } + } + } + +private: + Gtk::Image m_images[2][2]; +}; + +GuildListFolderItem::GuildListFolderItem(const UserSettingsGuildFoldersEntry &folder) { + get_style_context()->add_class("classic-guild-folder"); + m_revealer.add(m_box); m_revealer.set_reveal_child(true); @@ -14,10 +53,18 @@ GuildListFolderItem::GuildListFolderItem() { return false; }); - m_ev.add(m_image); + auto *btn = Gtk::make_managed(); + btn->SetGuilds(folder.GuildIDs); + m_ev.add(*btn); add(m_ev); add(m_revealer); - show_all_children(); + + btn->show(); + m_ev.show(); + m_revealer.show(); + m_box.show(); + m_image.show(); + show(); } void GuildListFolderItem::AddGuildWidget(GuildListGuildItem *widget) { diff --git a/src/components/channellist/classic/guildlistfolderitem.hpp b/src/components/channellist/classic/guildlistfolderitem.hpp index 4b7ba0a..460fd07 100644 --- a/src/components/channellist/classic/guildlistfolderitem.hpp +++ b/src/components/channellist/classic/guildlistfolderitem.hpp @@ -5,12 +5,13 @@ #include #include "guildlistguilditem.hpp" +#include "discord/usersettings.hpp" class GuildListGuildItem; class GuildListFolderItem : public Gtk::VBox { public: - GuildListFolderItem(); + GuildListFolderItem(const UserSettingsGuildFoldersEntry &folder); void AddGuildWidget(GuildListGuildItem *widget); -- cgit v1.2.3 From 6f8417525883acfb77af856f44aee26c1477ca91 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 8 Jan 2024 02:59:34 -0500 Subject: dont reveal folders by default --- src/components/channellist/classic/guildlistfolderitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/classic/guildlistfolderitem.cpp b/src/components/channellist/classic/guildlistfolderitem.cpp index acf1a2c..b6e49f1 100644 --- a/src/components/channellist/classic/guildlistfolderitem.cpp +++ b/src/components/channellist/classic/guildlistfolderitem.cpp @@ -42,7 +42,7 @@ GuildListFolderItem::GuildListFolderItem(const UserSettingsGuildFoldersEntry &fo get_style_context()->add_class("classic-guild-folder"); m_revealer.add(m_box); - m_revealer.set_reveal_child(true); + m_revealer.set_reveal_child(false); m_image.property_pixbuf() = Abaddon::Get().GetImageManager().GetPlaceholder(48); -- cgit v1.2.3 From 9131158cbbf5800dd103d5b5fbfff96384352c77 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 8 Jan 2024 20:53:40 -0500 Subject: add stack with icon and grid for classic listing folder icon --- .../channellist/classic/guildlistfolderitem.cpp | 71 +++++++++++++--------- .../channellist/classic/guildlistfolderitem.hpp | 13 ++++ src/settings.cpp | 1 + src/settings.hpp | 1 + 4 files changed, 56 insertions(+), 30 deletions(-) (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/classic/guildlistfolderitem.cpp b/src/components/channellist/classic/guildlistfolderitem.cpp index b6e49f1..e60bd5f 100644 --- a/src/components/channellist/classic/guildlistfolderitem.cpp +++ b/src/components/channellist/classic/guildlistfolderitem.cpp @@ -6,37 +6,31 @@ const int FolderGridButtonSize = 48; const int FolderGridImageSize = 24; -class GuildListFolderButton : public Gtk::Grid { -public: - GuildListFolderButton() { - set_size_request(FolderGridButtonSize, FolderGridButtonSize); - } +GuildListFolderButton::GuildListFolderButton() { + set_size_request(FolderGridButtonSize, FolderGridButtonSize); +} + +void GuildListFolderButton::SetGuilds(const std::vector &guild_ids) { + for (int y = 0; y < 2; y++) { + for (int x = 0; x < 2; x++) { + const size_t i = y * 2 + x; + auto &widget = m_images[x][y]; + widget.property_pixbuf() = Abaddon::Get().GetImageManager().GetPlaceholder(FolderGridImageSize); + attach(widget, x, y, 1, 1); - void SetGuilds(const std::vector &guild_ids) { - for (int y = 0; y < 2; y++) { - for (int x = 0; x < 2; x++) { - const size_t i = y * 2 + x; - auto &widget = m_images[x][y]; - widget.property_pixbuf() = Abaddon::Get().GetImageManager().GetPlaceholder(FolderGridImageSize); - attach(widget, x, y, 1, 1); - - if (i < guild_ids.size()) { - widget.show(); - - if (const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(guild_ids[i]); guild.has_value()) { - const auto cb = [&widget](const Glib::RefPtr &pb) { - widget.property_pixbuf() = pb->scale_simple(FolderGridImageSize, FolderGridImageSize, Gdk::INTERP_BILINEAR); - }; - Abaddon::Get().GetImageManager().LoadFromURL(guild->GetIconURL("png", "32"), sigc::track_obj(cb, *this)); - } + if (i < guild_ids.size()) { + widget.show(); + + if (const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(guild_ids[i]); guild.has_value()) { + const auto cb = [&widget](const Glib::RefPtr &pb) { + widget.property_pixbuf() = pb->scale_simple(FolderGridImageSize, FolderGridImageSize, Gdk::INTERP_BILINEAR); + }; + Abaddon::Get().GetImageManager().LoadFromURL(guild->GetIconURL("png", "32"), sigc::track_obj(cb, *this)); } } } } - -private: - Gtk::Image m_images[2][2]; -}; +} GuildListFolderItem::GuildListFolderItem(const UserSettingsGuildFoldersEntry &folder) { get_style_context()->add_class("classic-guild-folder"); @@ -49,17 +43,34 @@ GuildListFolderItem::GuildListFolderItem(const UserSettingsGuildFoldersEntry &fo m_ev.signal_button_press_event().connect([this](GdkEventButton *event) -> bool { if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) { m_revealer.set_reveal_child(!m_revealer.get_reveal_child()); + if (!Abaddon::Get().GetSettings().FolderIconOnly) { + if (m_revealer.get_reveal_child()) { + m_stack.set_visible_child("icon", Gtk::STACK_TRANSITION_TYPE_SLIDE_DOWN); + } else { + m_stack.set_visible_child("grid", Gtk::STACK_TRANSITION_TYPE_SLIDE_UP); + } + } } + return false; }); - auto *btn = Gtk::make_managed(); - btn->SetGuilds(folder.GuildIDs); - m_ev.add(*btn); + m_grid.SetGuilds(folder.GuildIDs); + m_grid.show(); + + m_icon.property_icon_name() = "folder-symbolic"; + m_icon.property_icon_size() = Gtk::ICON_SIZE_DND; + m_icon.show(); + + m_stack.add(m_grid, "grid"); + m_stack.add(m_icon, "icon"); + m_stack.set_visible_child(Abaddon::Get().GetSettings().FolderIconOnly ? "icon" : "grid"); + m_stack.show(); + + m_ev.add(m_stack); add(m_ev); add(m_revealer); - btn->show(); m_ev.show(); m_revealer.show(); m_box.show(); diff --git a/src/components/channellist/classic/guildlistfolderitem.hpp b/src/components/channellist/classic/guildlistfolderitem.hpp index 460fd07..6a9fb50 100644 --- a/src/components/channellist/classic/guildlistfolderitem.hpp +++ b/src/components/channellist/classic/guildlistfolderitem.hpp @@ -9,6 +9,15 @@ class GuildListGuildItem; +class GuildListFolderButton : public Gtk::Grid { +public: + GuildListFolderButton(); + void SetGuilds(const std::vector &guild_ids); + +private: + Gtk::Image m_images[2][2]; +}; + class GuildListFolderItem : public Gtk::VBox { public: GuildListFolderItem(const UserSettingsGuildFoldersEntry &folder); @@ -16,6 +25,10 @@ public: void AddGuildWidget(GuildListGuildItem *widget); private: + Gtk::Stack m_stack; + GuildListFolderButton m_grid; + Gtk::Image m_icon; + Gtk::EventBox m_ev; Gtk::Image m_image; Gtk::Revealer m_revealer; diff --git a/src/settings.cpp b/src/settings.cpp index 23b2b89..6b051e7 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -96,6 +96,7 @@ void SettingsManager::DefineSettings() { AddSetting("gui", "hide_to_try", false, &Settings::HideToTray); AddSetting("gui", "show_deleted_indicator", true, &Settings::ShowDeletedIndicator); AddSetting("gui", "font_scale", -1.0, &Settings::FontScale); + AddSetting("gui", "folder_icon_only", false, &Settings::FolderIconOnly); AddSetting("http", "concurrent", 20, &Settings::CacheHTTPConcurrency); AddSetting("http", "user_agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36"s, &Settings::UserAgent); diff --git a/src/settings.hpp b/src/settings.hpp index be9660e..e508270 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -28,6 +28,7 @@ public: bool HideToTray; bool ShowDeletedIndicator; double FontScale; + bool FolderIconOnly; // [http] int CacheHTTPConcurrency; -- cgit v1.2.3 From 1e6d16f44a07da92c35b19dadf6385c2868ab295 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 8 Jan 2024 20:53:59 -0500 Subject: hide dm header unless selected in classic channel list --- src/components/channellist/channellist.cpp | 4 ++++ src/components/channellist/channellisttree.cpp | 22 ++++++++++++++++++-- src/components/channellist/channellisttree.hpp | 2 ++ src/components/channellist/classic/guildlist.cpp | 26 ++++++++++++++++++++++++ src/components/channellist/classic/guildlist.hpp | 3 +++ 5 files changed, 55 insertions(+), 2 deletions(-) (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/channellist.cpp b/src/components/channellist/channellist.cpp index de19a80..e4060a8 100644 --- a/src/components/channellist/channellist.cpp +++ b/src/components/channellist/channellist.cpp @@ -11,6 +11,10 @@ ChannelList::ChannelList() { m_tree.SetSelectedGuild(guild_id); }); + m_guilds.signal_dms_selected().connect([this]() { + m_tree.SetSelectedDMs(); + }); + m_guilds.show(); m_tree.show(); m_guilds_scroll.add(m_guilds); diff --git a/src/components/channellist/channellisttree.cpp b/src/components/channellist/channellisttree.cpp index 6741a69..cbfc8bb 100644 --- a/src/components/channellist/channellisttree.cpp +++ b/src/components/channellist/channellisttree.cpp @@ -86,10 +86,17 @@ ChannelListTree::ChannelListTree() m_filter_model->set_visible_func([this](const Gtk::TreeModel::const_iterator &iter) -> bool { if (!m_classic) return true; - if ((*iter)[m_columns.m_type] == RenderType::Guild) { + const RenderType type = (*iter)[m_columns.m_type]; + + if (m_classic_selected_dms) { + if (iter->parent()) return true; + return type == RenderType::DMHeader; + } + + if (type == RenderType::Guild) { return (*iter)[m_columns.m_id] == m_classic_selected_guild; } - return true; + return type != RenderType::DMHeader; }); m_view.show(); @@ -309,6 +316,7 @@ void ChannelListTree::SetClassic(bool value) { void ChannelListTree::SetSelectedGuild(Snowflake guild_id) { m_classic_selected_guild = guild_id; + m_classic_selected_dms = false; m_filter_model->refilter(); auto guild_iter = GetIteratorForGuildFromID(guild_id); if (guild_iter) { @@ -318,6 +326,16 @@ void ChannelListTree::SetSelectedGuild(Snowflake guild_id) { } } +void ChannelListTree::SetSelectedDMs() { + m_classic_selected_dms = true; + m_filter_model->refilter(); + if (m_dm_header) { + if (auto filter_path = m_filter_model->convert_child_path_to_path(m_dm_header)) { + m_view.expand_row(filter_path, false); + } + } +} + void ChannelListTree::OnPanedPositionChanged() { m_view.queue_draw(); } diff --git a/src/components/channellist/channellisttree.hpp b/src/components/channellist/channellisttree.hpp index a138bec..7ad0d29 100644 --- a/src/components/channellist/channellisttree.hpp +++ b/src/components/channellist/channellisttree.hpp @@ -35,6 +35,7 @@ public: void SetClassic(bool value); void SetSelectedGuild(Snowflake guild_id); + void SetSelectedDMs(); protected: void OnPanedPositionChanged(); @@ -193,6 +194,7 @@ protected: bool m_classic = false; Snowflake m_classic_selected_guild; + bool m_classic_selected_dms = false; Snowflake m_active_channel; diff --git a/src/components/channellist/classic/guildlist.cpp b/src/components/channellist/classic/guildlist.cpp index 97741cf..ca7c96f 100644 --- a/src/components/channellist/classic/guildlist.cpp +++ b/src/components/channellist/classic/guildlist.cpp @@ -1,6 +1,18 @@ #include "guildlist.hpp" #include "guildlistfolderitem.hpp" +class GuildListDMsButton : public Gtk::EventBox { +public: + GuildListDMsButton() { + m_img.property_pixbuf() = Abaddon::Get().GetImageManager().GetPlaceholder(48); + add(m_img); + show_all_children(); + } + +private: + Gtk::Image m_img; +}; + GuildList::GuildList() { set_selection_mode(Gtk::SELECTION_NONE); show_all_children(); @@ -11,6 +23,16 @@ void GuildList::UpdateListing() { Clear(); + auto *dms = Gtk::make_managed(); + dms->show(); + dms->signal_button_press_event().connect([this](GdkEventButton *ev) -> bool { + if (ev->type == GDK_BUTTON_PRESS && ev->button == GDK_BUTTON_PRIMARY) { + m_signal_dms_selected.emit(); + } + return false; + }); + add(*dms); + // does this function still even work ??lol const auto folders = discord.GetUserSettings().GuildFolders; const auto guild_ids = discord.GetUserSortedGuilds(); @@ -86,3 +108,7 @@ void GuildList::Clear() { GuildList::type_signal_guild_selected GuildList::signal_guild_selected() { return m_signal_guild_selected; } + +GuildList::type_signal_dms_selected GuildList::signal_dms_selected() { + return m_signal_dms_selected; +} diff --git a/src/components/channellist/classic/guildlist.hpp b/src/components/channellist/classic/guildlist.hpp index dc19102..d76e80d 100644 --- a/src/components/channellist/classic/guildlist.hpp +++ b/src/components/channellist/classic/guildlist.hpp @@ -20,9 +20,12 @@ private: public: using type_signal_guild_selected = sigc::signal; + using type_signal_dms_selected = sigc::signal; type_signal_guild_selected signal_guild_selected(); + type_signal_dms_selected signal_dms_selected(); private: type_signal_guild_selected m_signal_guild_selected; + type_signal_dms_selected m_signal_dms_selected; }; -- cgit v1.2.3 From 781bdc5d7a72cacb9d0ce6e2893dcbba04088417 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 8 Jan 2024 21:27:53 -0500 Subject: add folder colors to symbol icon --- src/components/channellist/classic/guildlistfolderitem.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/classic/guildlistfolderitem.cpp b/src/components/channellist/classic/guildlistfolderitem.cpp index e60bd5f..f79227b 100644 --- a/src/components/channellist/classic/guildlistfolderitem.cpp +++ b/src/components/channellist/classic/guildlistfolderitem.cpp @@ -60,6 +60,9 @@ GuildListFolderItem::GuildListFolderItem(const UserSettingsGuildFoldersEntry &fo m_icon.property_icon_name() = "folder-symbolic"; m_icon.property_icon_size() = Gtk::ICON_SIZE_DND; + if (folder.Color.has_value()) { + m_icon.override_color(IntToRGBA(*folder.Color)); + } m_icon.show(); m_stack.add(m_grid, "grid"); -- cgit v1.2.3 From fe95335d1245152bb23c6787b5d55ea5874fd78a Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Tue, 9 Jan 2024 00:26:40 -0500 Subject: set folder name tooltip --- src/components/channellist/classic/guildlistfolderitem.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/classic/guildlistfolderitem.cpp b/src/components/channellist/classic/guildlistfolderitem.cpp index f79227b..e79a5f7 100644 --- a/src/components/channellist/classic/guildlistfolderitem.cpp +++ b/src/components/channellist/classic/guildlistfolderitem.cpp @@ -35,6 +35,10 @@ void GuildListFolderButton::SetGuilds(const std::vector &guild_ids) { GuildListFolderItem::GuildListFolderItem(const UserSettingsGuildFoldersEntry &folder) { get_style_context()->add_class("classic-guild-folder"); + if (folder.Name.has_value()) { + set_tooltip_text(*folder.Name); + } + m_revealer.add(m_box); m_revealer.set_reveal_child(false); -- cgit v1.2.3 From 615f2c80f1b0cfa7b72a08112ff4ef8ae23e5bf6 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Tue, 9 Jan 2024 00:57:50 -0500 Subject: add icon to dm button in classic channels list --- src/components/channellist/classic/guildlist.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/classic/guildlist.cpp b/src/components/channellist/classic/guildlist.cpp index ca7c96f..53ba1d7 100644 --- a/src/components/channellist/classic/guildlist.cpp +++ b/src/components/channellist/classic/guildlist.cpp @@ -4,7 +4,10 @@ class GuildListDMsButton : public Gtk::EventBox { public: GuildListDMsButton() { - m_img.property_pixbuf() = Abaddon::Get().GetImageManager().GetPlaceholder(48); + set_size_request(48, 48); + + m_img.property_icon_name() = "user-available-symbolic"; // meh + m_img.property_icon_size() = Gtk::ICON_SIZE_DND; add(m_img); show_all_children(); } -- cgit v1.2.3 From d1f6e1daa99e70ab3a9d583a0de286c97ab13413 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 19 Jan 2024 01:29:25 -0500 Subject: headers --- src/components/channellist/channellist.cpp | 2 ++ src/components/channellist/channellisttree.cpp | 6 +++++- src/components/channellist/classic/guildlist.cpp | 2 ++ src/components/channellist/classic/guildlistfolderitem.cpp | 3 +++ src/components/channellist/classic/guildlistfolderitem.hpp | 2 ++ src/components/channellist/classic/guildlistguilditem.cpp | 2 ++ src/components/channellist/classic/guildlistguilditem.hpp | 1 + 7 files changed, 17 insertions(+), 1 deletion(-) (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/channellist.cpp b/src/components/channellist/channellist.cpp index 873de41..1cdf619 100644 --- a/src/components/channellist/channellist.cpp +++ b/src/components/channellist/channellist.cpp @@ -1,5 +1,7 @@ #include "channellist.hpp" +#include "abaddon.hpp" + ChannelList::ChannelList() { ConnectSignals(); diff --git a/src/components/channellist/channellisttree.cpp b/src/components/channellist/channellisttree.cpp index a509f21..8049f58 100644 --- a/src/components/channellist/channellisttree.cpp +++ b/src/components/channellist/channellisttree.cpp @@ -1,9 +1,13 @@ #include "channellisttree.hpp" -#include "imgmanager.hpp" + #include #include #include + +#include + #include "abaddon.hpp" +#include "imgmanager.hpp" #include "util.hpp" ChannelListTree::ChannelListTree() diff --git a/src/components/channellist/classic/guildlist.cpp b/src/components/channellist/classic/guildlist.cpp index 53ba1d7..ae613bf 100644 --- a/src/components/channellist/classic/guildlist.cpp +++ b/src/components/channellist/classic/guildlist.cpp @@ -1,4 +1,6 @@ #include "guildlist.hpp" + +#include "abaddon.hpp" #include "guildlistfolderitem.hpp" class GuildListDMsButton : public Gtk::EventBox { diff --git a/src/components/channellist/classic/guildlistfolderitem.cpp b/src/components/channellist/classic/guildlistfolderitem.cpp index e79a5f7..fea735c 100644 --- a/src/components/channellist/classic/guildlistfolderitem.cpp +++ b/src/components/channellist/classic/guildlistfolderitem.cpp @@ -1,5 +1,8 @@ #include "guildlistfolderitem.hpp" + +#include "abaddon.hpp" #include "guildlistguilditem.hpp" +#include "util.hpp" // doing my best to copy discord here diff --git a/src/components/channellist/classic/guildlistfolderitem.hpp b/src/components/channellist/classic/guildlistfolderitem.hpp index 6a9fb50..82a5a14 100644 --- a/src/components/channellist/classic/guildlistfolderitem.hpp +++ b/src/components/channellist/classic/guildlistfolderitem.hpp @@ -1,8 +1,10 @@ #pragma once #include #include +#include #include #include +#include #include "guildlistguilditem.hpp" #include "discord/usersettings.hpp" diff --git a/src/components/channellist/classic/guildlistguilditem.cpp b/src/components/channellist/classic/guildlistguilditem.cpp index 5cec281..c608dd9 100644 --- a/src/components/channellist/classic/guildlistguilditem.cpp +++ b/src/components/channellist/classic/guildlistguilditem.cpp @@ -1,5 +1,7 @@ #include "guildlistguilditem.hpp" +#include "abaddon.hpp" + GuildListGuildItem::GuildListGuildItem(const GuildData &guild) : ID(guild.ID) { m_image.property_pixbuf() = Abaddon::Get().GetImageManager().GetPlaceholder(48); diff --git a/src/components/channellist/classic/guildlistguilditem.hpp b/src/components/channellist/classic/guildlistguilditem.hpp index 3114a05..6bc0037 100644 --- a/src/components/channellist/classic/guildlistguilditem.hpp +++ b/src/components/channellist/classic/guildlistguilditem.hpp @@ -1,5 +1,6 @@ #pragma once #include +#include #include #include "discord/guild.hpp" -- cgit v1.2.3 From dbfdd01b13af7394c0b6117e878728d0eac097c2 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Thu, 1 Feb 2024 21:08:17 -0500 Subject: add missing guild.HasIcon checks --- src/components/channellist/classic/guildlistfolderitem.cpp | 2 +- src/components/channellist/classic/guildlistguilditem.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/classic/guildlistfolderitem.cpp b/src/components/channellist/classic/guildlistfolderitem.cpp index fea735c..2c8bc3b 100644 --- a/src/components/channellist/classic/guildlistfolderitem.cpp +++ b/src/components/channellist/classic/guildlistfolderitem.cpp @@ -24,7 +24,7 @@ void GuildListFolderButton::SetGuilds(const std::vector &guild_ids) { if (i < guild_ids.size()) { widget.show(); - if (const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(guild_ids[i]); guild.has_value()) { + if (const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(guild_ids[i]); guild.has_value() && guild->HasIcon()) { const auto cb = [&widget](const Glib::RefPtr &pb) { widget.property_pixbuf() = pb->scale_simple(FolderGridImageSize, FolderGridImageSize, Gdk::INTERP_BILINEAR); }; diff --git a/src/components/channellist/classic/guildlistguilditem.cpp b/src/components/channellist/classic/guildlistguilditem.cpp index c608dd9..2b26e73 100644 --- a/src/components/channellist/classic/guildlistguilditem.cpp +++ b/src/components/channellist/classic/guildlistguilditem.cpp @@ -15,7 +15,7 @@ GuildListGuildItem::GuildListGuildItem(const GuildData &guild) void GuildListGuildItem::UpdateIcon() { const auto guild = Abaddon::Get().GetDiscordClient().GetGuild(ID); - if (!guild.has_value()) return; + if (!guild.has_value() || !guild->HasIcon()) return; Abaddon::Get().GetImageManager().LoadFromURL(guild->GetIconURL("png", "64"), sigc::mem_fun(*this, &GuildListGuildItem::OnIconFetched)); } -- cgit v1.2.3 From b92091b97d1d43e33c3217451f72addbd0f76726 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 2 Feb 2024 02:00:32 -0500 Subject: hide scrollbar in classic guild list --- res/css/main.css | 11 +++++++++++ src/components/channellist/channellist.cpp | 1 + src/components/channellist/classic/guildlist.cpp | 1 + 3 files changed, 13 insertions(+) (limited to 'src/components/channellist/classic') diff --git a/res/css/main.css b/res/css/main.css index ae7bf60..d29174c 100644 --- a/res/css/main.css +++ b/res/css/main.css @@ -145,3 +145,14 @@ .message-text.failed { color: red; } + +.guild-list-scroll > scrollbar { + border: none; +} + +.guild-list-scroll > scrollbar slider { + border: none; + margin: 0px; + min-width: 0px; + min-height: 0px; +} diff --git a/src/components/channellist/channellist.cpp b/src/components/channellist/channellist.cpp index 87aa6ed..076a83e 100644 --- a/src/components/channellist/channellist.cpp +++ b/src/components/channellist/channellist.cpp @@ -9,6 +9,7 @@ ChannelList::ChannelList() { m_guilds.set_halign(Gtk::ALIGN_START); + m_guilds_scroll.get_style_context()->add_class("guild-list-scroll"); m_guilds_scroll.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); m_guilds.signal_guild_selected().connect([this](Snowflake guild_id) { diff --git a/src/components/channellist/classic/guildlist.cpp b/src/components/channellist/classic/guildlist.cpp index ae613bf..49ee87c 100644 --- a/src/components/channellist/classic/guildlist.cpp +++ b/src/components/channellist/classic/guildlist.cpp @@ -19,6 +19,7 @@ private: }; GuildList::GuildList() { + get_style_context()->add_class("guild-list"); set_selection_mode(Gtk::SELECTION_NONE); show_all_children(); } -- cgit v1.2.3 From bddaf99c12f5c3954504ebb8fceab192613bf9fc Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sat, 10 Feb 2024 22:28:03 -0500 Subject: add guild menus to classic guild list --- src/components/channellist/channellist.cpp | 8 ++++ src/components/channellist/classic/guildlist.cpp | 59 +++++++++++++++++++++++- src/components/channellist/classic/guildlist.hpp | 17 +++++++ 3 files changed, 83 insertions(+), 1 deletion(-) (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/channellist.cpp b/src/components/channellist/channellist.cpp index 076a83e..f409592 100644 --- a/src/components/channellist/channellist.cpp +++ b/src/components/channellist/channellist.cpp @@ -92,6 +92,14 @@ void ChannelList::ConnectSignals() { m_tree.signal_action_guild_settings().connect([this](Snowflake id) { m_signal_action_guild_settings.emit(id); }); + + m_guilds.signal_action_guild_leave().connect([this](Snowflake id) { + m_signal_action_guild_leave.emit(id); + }); + + m_guilds.signal_action_guild_settings().connect([this](Snowflake id) { + m_signal_action_guild_settings.emit(id); + }); } #ifdef WITH_LIBHANDY diff --git a/src/components/channellist/classic/guildlist.cpp b/src/components/channellist/classic/guildlist.cpp index 49ee87c..9c634f7 100644 --- a/src/components/channellist/classic/guildlist.cpp +++ b/src/components/channellist/classic/guildlist.cpp @@ -18,10 +18,41 @@ private: Gtk::Image m_img; }; -GuildList::GuildList() { +GuildList::GuildList() + : m_menu_guild_copy_id("_Copy ID", true) + , m_menu_guild_settings("View _Settings", true) + , m_menu_guild_leave("_Leave", true) + , m_menu_guild_mark_as_read("Mark as _Read", true) { get_style_context()->add_class("guild-list"); set_selection_mode(Gtk::SELECTION_NONE); show_all_children(); + + m_menu_guild_copy_id.signal_activate().connect([this] { + Gtk::Clipboard::get()->set_text(std::to_string(m_menu_guild_target)); + }); + m_menu_guild_settings.signal_activate().connect([this] { + m_signal_action_guild_settings.emit(m_menu_guild_target); + }); + m_menu_guild_leave.signal_activate().connect([this] { + m_signal_action_guild_leave.emit(m_menu_guild_target); + }); + m_menu_guild_mark_as_read.signal_activate().connect([this] { + Abaddon::Get().GetDiscordClient().MarkGuildAsRead(m_menu_guild_target, [](...) {}); + }); + m_menu_guild_toggle_mute.signal_activate().connect([this] { + const auto id = m_menu_guild_target; + auto &discord = Abaddon::Get().GetDiscordClient(); + if (discord.IsGuildMuted(id)) + discord.UnmuteGuild(id, NOOP_CALLBACK); + else + discord.MuteGuild(id, NOOP_CALLBACK); + }); + m_menu_guild.append(m_menu_guild_mark_as_read); + m_menu_guild.append(m_menu_guild_settings); + m_menu_guild.append(m_menu_guild_leave); + m_menu_guild.append(m_menu_guild_toggle_mute); + m_menu_guild.append(m_menu_guild_copy_id); + m_menu_guild.show_all(); } void GuildList::UpdateListing() { @@ -76,6 +107,10 @@ GuildListGuildItem *GuildList::CreateGuildWidget(Snowflake id) { item->signal_button_press_event().connect([this, id](GdkEventButton *event) -> bool { if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_PRIMARY) { m_signal_guild_selected.emit(id); + } else if (event->type == GDK_BUTTON_PRESS && event->button == GDK_BUTTON_SECONDARY) { + m_menu_guild_target = id; + OnGuildSubmenuPopup(); + m_menu_guild.popup_at_pointer(reinterpret_cast(event)); } return true; }); @@ -111,6 +146,20 @@ void GuildList::Clear() { } } +void GuildList::OnGuildSubmenuPopup() { + const auto id = m_menu_guild_target; + auto &discord = Abaddon::Get().GetDiscordClient(); + if (discord.IsGuildMuted(id)) { + m_menu_guild_toggle_mute.set_label("Unmute"); + } else { + m_menu_guild_toggle_mute.set_label("Mute"); + } + + const auto guild = discord.GetGuild(id); + const auto self_id = discord.GetUserData().ID; + m_menu_guild_leave.set_sensitive(!(guild.has_value() && guild->OwnerID == self_id)); +} + GuildList::type_signal_guild_selected GuildList::signal_guild_selected() { return m_signal_guild_selected; } @@ -118,3 +167,11 @@ GuildList::type_signal_guild_selected GuildList::signal_guild_selected() { GuildList::type_signal_dms_selected GuildList::signal_dms_selected() { return m_signal_dms_selected; } + +GuildList::type_signal_action_guild_leave GuildList::signal_action_guild_leave() { + return m_signal_action_guild_leave; +} + +GuildList::type_signal_action_guild_settings GuildList::signal_action_guild_settings() { + return m_signal_action_guild_settings; +} diff --git a/src/components/channellist/classic/guildlist.hpp b/src/components/channellist/classic/guildlist.hpp index d76e80d..72e88e8 100644 --- a/src/components/channellist/classic/guildlist.hpp +++ b/src/components/channellist/classic/guildlist.hpp @@ -18,14 +18,31 @@ private: GuildListGuildItem *CreateGuildWidget(Snowflake id); + // todo code duplication not good no sir + Gtk::Menu m_menu_guild; + Gtk::MenuItem m_menu_guild_copy_id; + Gtk::MenuItem m_menu_guild_settings; + Gtk::MenuItem m_menu_guild_leave; + Gtk::MenuItem m_menu_guild_mark_as_read; + Gtk::MenuItem m_menu_guild_toggle_mute; + Snowflake m_menu_guild_target; + + void OnGuildSubmenuPopup(); + public: using type_signal_guild_selected = sigc::signal; using type_signal_dms_selected = sigc::signal; + using type_signal_action_guild_leave = sigc::signal; + using type_signal_action_guild_settings = sigc::signal; type_signal_guild_selected signal_guild_selected(); type_signal_dms_selected signal_dms_selected(); + type_signal_action_guild_leave signal_action_guild_leave(); + type_signal_action_guild_settings signal_action_guild_settings(); private: type_signal_guild_selected m_signal_guild_selected; type_signal_dms_selected m_signal_dms_selected; + type_signal_action_guild_leave m_signal_action_guild_leave; + type_signal_action_guild_settings m_signal_action_guild_settings; }; -- cgit v1.2.3 From 473ff6f777ae3a8d1b3fa08a3ea15e2905340e03 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 19 Feb 2024 02:24:57 -0500 Subject: widget tweaking for styling --- src/components/channellist/classic/guildlist.cpp | 2 +- src/components/channellist/classic/guildlistfolderitem.cpp | 2 +- src/components/channellist/classic/guildlistguilditem.cpp | 6 +++++- src/components/channellist/classic/guildlistguilditem.hpp | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/classic/guildlist.cpp b/src/components/channellist/classic/guildlist.cpp index 9c634f7..d756c6f 100644 --- a/src/components/channellist/classic/guildlist.cpp +++ b/src/components/channellist/classic/guildlist.cpp @@ -23,7 +23,7 @@ GuildList::GuildList() , m_menu_guild_settings("View _Settings", true) , m_menu_guild_leave("_Leave", true) , m_menu_guild_mark_as_read("Mark as _Read", true) { - get_style_context()->add_class("guild-list"); + get_style_context()->add_class("classic-guild-list"); set_selection_mode(Gtk::SELECTION_NONE); show_all_children(); diff --git a/src/components/channellist/classic/guildlistfolderitem.cpp b/src/components/channellist/classic/guildlistfolderitem.cpp index 2c8bc3b..30e1adb 100644 --- a/src/components/channellist/classic/guildlistfolderitem.cpp +++ b/src/components/channellist/classic/guildlistfolderitem.cpp @@ -36,7 +36,7 @@ void GuildListFolderButton::SetGuilds(const std::vector &guild_ids) { } GuildListFolderItem::GuildListFolderItem(const UserSettingsGuildFoldersEntry &folder) { - get_style_context()->add_class("classic-guild-folder"); + get_style_context()->add_class("classic-guild-list-folder"); if (folder.Name.has_value()) { set_tooltip_text(*folder.Name); diff --git a/src/components/channellist/classic/guildlistguilditem.cpp b/src/components/channellist/classic/guildlistguilditem.cpp index 2b26e73..ee6b35a 100644 --- a/src/components/channellist/classic/guildlistguilditem.cpp +++ b/src/components/channellist/classic/guildlistguilditem.cpp @@ -4,8 +4,12 @@ GuildListGuildItem::GuildListGuildItem(const GuildData &guild) : ID(guild.ID) { + get_style_context()->add_class("classic-guild-list-guild"); + m_image.property_pixbuf() = Abaddon::Get().GetImageManager().GetPlaceholder(48); - add(m_image); + + add(m_box); + m_box.pack_start(m_image); show_all_children(); set_tooltip_text(guild.Name); diff --git a/src/components/channellist/classic/guildlistguilditem.hpp b/src/components/channellist/classic/guildlistguilditem.hpp index 6bc0037..e5504f6 100644 --- a/src/components/channellist/classic/guildlistguilditem.hpp +++ b/src/components/channellist/classic/guildlistguilditem.hpp @@ -14,5 +14,6 @@ private: void UpdateIcon(); void OnIconFetched(const Glib::RefPtr &pb); + Gtk::Box m_box; Gtk::Image m_image; }; -- cgit v1.2.3 From 3badc04db5770defa308dc70e5ddde07828202cf Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Mon, 19 Feb 2024 20:27:03 -0500 Subject: unread indicators for classic guilds --- res/css/main.css | 19 +++++++++++++++++++ .../channellist/classic/guildlistguilditem.cpp | 22 ++++++++++++++++++++++ .../channellist/classic/guildlistguilditem.hpp | 3 +++ 3 files changed, 44 insertions(+) (limited to 'src/components/channellist/classic') diff --git a/res/css/main.css b/res/css/main.css index 71434cf..db548ac 100644 --- a/res/css/main.css +++ b/res/css/main.css @@ -160,3 +160,22 @@ .channel-list .view:selected { background-color: @theme_selected_bg_color; } + +.classic-guild-list > row { + padding-left: 0px; + box-shadow: none; + border: none; + outline: none; +} + +.classic-guild-list > row:hover { + background: none; +} + +.classic-guild-list-guild.has-unread { + background: radial-gradient(7px circle at left, @theme_selected_bg_color 50%, transparent 20%); +} + +.classic-guild-list-guild box, .classic-guild-list-folder stack { + padding-left: 10px; +} diff --git a/src/components/channellist/classic/guildlistguilditem.cpp b/src/components/channellist/classic/guildlistguilditem.cpp index ee6b35a..5acad02 100644 --- a/src/components/channellist/classic/guildlistguilditem.cpp +++ b/src/components/channellist/classic/guildlistguilditem.cpp @@ -15,6 +15,9 @@ GuildListGuildItem::GuildListGuildItem(const GuildData &guild) set_tooltip_text(guild.Name); UpdateIcon(); + + Abaddon::Get().GetDiscordClient().signal_message_create().connect(sigc::mem_fun(*this, &GuildListGuildItem::OnMessageCreate)); + Abaddon::Get().GetDiscordClient().signal_message_ack().connect(sigc::mem_fun(*this, &GuildListGuildItem::OnMessageAck)); } void GuildListGuildItem::UpdateIcon() { @@ -26,3 +29,22 @@ void GuildListGuildItem::UpdateIcon() { void GuildListGuildItem::OnIconFetched(const Glib::RefPtr &pb) { m_image.property_pixbuf() = pb->scale_simple(48, 48, Gdk::INTERP_BILINEAR); } + +void GuildListGuildItem::OnMessageCreate(const Message &msg) { + if (msg.GuildID.has_value() && *msg.GuildID == ID) CheckUnreadStatus(); +} + +void GuildListGuildItem::OnMessageAck(const MessageAckData &data) { + CheckUnreadStatus(); +} + +void GuildListGuildItem::CheckUnreadStatus() { + auto &discord = Abaddon::Get().GetDiscordClient(); + if (!Abaddon::Get().GetSettings().Unreads) return; + int mentions; + if (!discord.IsGuildMuted(ID) && discord.GetUnreadStateForGuild(ID, mentions)) { + get_style_context()->add_class("has-unread"); + } else { + get_style_context()->remove_class("has-unread"); + } +} diff --git a/src/components/channellist/classic/guildlistguilditem.hpp b/src/components/channellist/classic/guildlistguilditem.hpp index e5504f6..6e2b241 100644 --- a/src/components/channellist/classic/guildlistguilditem.hpp +++ b/src/components/channellist/classic/guildlistguilditem.hpp @@ -13,6 +13,9 @@ public: private: void UpdateIcon(); void OnIconFetched(const Glib::RefPtr &pb); + void OnMessageCreate(const Message &msg); + void OnMessageAck(const MessageAckData &data); + void CheckUnreadStatus(); Gtk::Box m_box; Gtk::Image m_image; -- cgit v1.2.3 From 3c54ff85622ff7210f8acee00e075b12128567a9 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Fri, 23 Feb 2024 21:57:24 -0500 Subject: check unread status for classic guild on launch --- src/components/channellist/classic/guildlistguilditem.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/classic/guildlistguilditem.cpp b/src/components/channellist/classic/guildlistguilditem.cpp index 5acad02..5b578be 100644 --- a/src/components/channellist/classic/guildlistguilditem.cpp +++ b/src/components/channellist/classic/guildlistguilditem.cpp @@ -18,6 +18,8 @@ GuildListGuildItem::GuildListGuildItem(const GuildData &guild) Abaddon::Get().GetDiscordClient().signal_message_create().connect(sigc::mem_fun(*this, &GuildListGuildItem::OnMessageCreate)); Abaddon::Get().GetDiscordClient().signal_message_ack().connect(sigc::mem_fun(*this, &GuildListGuildItem::OnMessageAck)); + + CheckUnreadStatus(); } void GuildListGuildItem::UpdateIcon() { -- cgit v1.2.3 From bab713baf557de427a1f93cc377d2fe79561731d Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Wed, 6 Mar 2024 01:19:55 -0500 Subject: folder unread indicators --- .../channellist/classic/guildlistfolderitem.cpp | 36 ++++++++++++++++++++++ .../channellist/classic/guildlistfolderitem.hpp | 6 ++++ 2 files changed, 42 insertions(+) (limited to 'src/components/channellist/classic') diff --git a/src/components/channellist/classic/guildlistfolderitem.cpp b/src/components/channellist/classic/guildlistfolderitem.cpp index 30e1adb..e062d42 100644 --- a/src/components/channellist/classic/guildlistfolderitem.cpp +++ b/src/components/channellist/classic/guildlistfolderitem.cpp @@ -36,6 +36,8 @@ void GuildListFolderButton::SetGuilds(const std::vector &guild_ids) { } GuildListFolderItem::GuildListFolderItem(const UserSettingsGuildFoldersEntry &folder) { + m_guild_ids = folder.GuildIDs; + get_style_context()->add_class("classic-guild-list-folder"); if (folder.Name.has_value()) { @@ -86,8 +88,42 @@ GuildListFolderItem::GuildListFolderItem(const UserSettingsGuildFoldersEntry &fo m_box.show(); m_image.show(); show(); + + Abaddon::Get().GetDiscordClient().signal_message_create().connect(sigc::mem_fun(*this, &GuildListFolderItem::OnMessageCreate)); + Abaddon::Get().GetDiscordClient().signal_message_ack().connect(sigc::mem_fun(*this, &GuildListFolderItem::OnMessageAck)); + + CheckUnreadStatus(); } void GuildListFolderItem::AddGuildWidget(GuildListGuildItem *widget) { m_box.add(*widget); } + +void GuildListFolderItem::OnMessageCreate(const Message &msg) { + if (msg.GuildID.has_value() && std::find(m_guild_ids.begin(), m_guild_ids.end(), *msg.GuildID) != m_guild_ids.end()) CheckUnreadStatus(); +} + +void GuildListFolderItem::OnMessageAck(const MessageAckData &data) { + CheckUnreadStatus(); +} + +void GuildListFolderItem::CheckUnreadStatus() { + auto &discord = Abaddon::Get().GetDiscordClient(); + if (!Abaddon::Get().GetSettings().Unreads) return; + + bool has_any_unreads = false; + + for (auto guild_id : m_guild_ids) { + int mentions; + if (!discord.IsGuildMuted(guild_id) && discord.GetUnreadStateForGuild(guild_id, mentions)) { + has_any_unreads = true; + break; + } + } + + if (has_any_unreads) { + get_style_context()->add_class("has-unread"); + } else { + get_style_context()->remove_class("has-unread"); + } +} diff --git a/src/components/channellist/classic/guildlistfolderitem.hpp b/src/components/channellist/classic/guildlistfolderitem.hpp index 82a5a14..e5772c0 100644 --- a/src/components/channellist/classic/guildlistfolderitem.hpp +++ b/src/components/channellist/classic/guildlistfolderitem.hpp @@ -27,6 +27,12 @@ public: void AddGuildWidget(GuildListGuildItem *widget); private: + void OnMessageCreate(const Message &msg); + void OnMessageAck(const MessageAckData &data); + void CheckUnreadStatus(); + + std::vector m_guild_ids; + Gtk::Stack m_stack; GuildListFolderButton m_grid; Gtk::Image m_icon; -- cgit v1.2.3