Skip to content

Commit

Permalink
unread indicators for classic guilds
Browse files Browse the repository at this point in the history
  • Loading branch information
ouwou committed Feb 20, 2024
1 parent 473ff6f commit 3badc04
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
19 changes: 19 additions & 0 deletions res/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
22 changes: 22 additions & 0 deletions src/components/channellist/classic/guildlistguilditem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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");
}
}
3 changes: 3 additions & 0 deletions src/components/channellist/classic/guildlistguilditem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class GuildListGuildItem : public Gtk::EventBox {
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;
Expand Down

0 comments on commit 3badc04

Please sign in to comment.