summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2024-02-19 20:27:03 -0500
committerouwou <26526779+ouwou@users.noreply.github.com>2024-02-19 20:27:03 -0500
commit3badc04db5770defa308dc70e5ddde07828202cf (patch)
treee26c7d6f4646b1f482de77981708a0dcabd38d5b
parent473ff6f777ae3a8d1b3fa08a3ea15e2905340e03 (diff)
downloadabaddon-portaudio-3badc04db5770defa308dc70e5ddde07828202cf.tar.gz
abaddon-portaudio-3badc04db5770defa308dc70e5ddde07828202cf.zip
unread indicators for classic guilds
-rw-r--r--res/css/main.css19
-rw-r--r--src/components/channellist/classic/guildlistguilditem.cpp22
-rw-r--r--src/components/channellist/classic/guildlistguilditem.hpp3
3 files changed, 44 insertions, 0 deletions
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<Gdk::Pixbuf> &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<Gdk::Pixbuf> &pb);
+ void OnMessageCreate(const Message &msg);
+ void OnMessageAck(const MessageAckData &data);
+ void CheckUnreadStatus();
Gtk::Box m_box;
Gtk::Image m_image;