diff --git a/res/css/main.css b/res/css/main.css index 71434cf1..db548ac1 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 ee6b35a5..5acad02f 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 e5504f6d..6e2b2415 100644 --- a/src/components/channellist/classic/guildlistguilditem.hpp +++ b/src/components/channellist/classic/guildlistguilditem.hpp @@ -13,6 +13,9 @@ class GuildListGuildItem : public Gtk::EventBox { 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;