diff --git a/dist/treebird20.css b/dist/treebird20.css index 7eb52a5..79d581b 100644 --- a/dist/treebird20.css +++ b/dist/treebird20.css @@ -213,11 +213,25 @@ ul li:first-child a.sidebarbtn border-bottom: 1px solid #dadada; } +.pfp-compact-td +{ + width: 16px; +} + .pfp-compact-td img { border-radius: 3px; } +.notification-compact +{ + min-width: 100%; +} + +.notification-compact p +{ + margin: 0; +} .notification-compact .notification-info { font-size: 12px; diff --git a/src/l10n.h b/src/l10n.h index c716113..8986ee3 100644 --- a/src/l10n.h +++ b/src/l10n.h @@ -88,12 +88,14 @@ enum l10n_string L10N_NOTIF_REPEATED, L10N_NOTIF_FOLLOW, L10N_NOTIF_FOLLOW_REQUEST, + L10N_NOTIF_POLL, L10N_NOTIF_COMPACT_LIKED, L10N_NOTIF_COMPACT_REACTED_WITH, L10N_NOTIF_COMPACT_REPEATED, L10N_NOTIF_COMPACT_FOLLOW, L10N_NOTIF_COMPACT_FOLLOW_REQUEST, + L10N_NOTIF_COMPACT_POLL, _L10N_LEN, }; @@ -149,7 +151,7 @@ static const char* const L10N[][_L10N_LEN] = { /* LOGIN */ "Login", - "Register" + "Register", "Username", "Password", "Login", @@ -162,12 +164,14 @@ static const char* const L10N[][_L10N_LEN] = { "repeated your status", "followed you", "wants to follow you", + "poll results", "liked", "reacted", "repeated", "followed", - "follows?" + "follows?", + "poll", }, // ES_ES @@ -220,7 +224,7 @@ static const char* const L10N[][_L10N_LEN] = { /* LOGIN */ "Login", - "Register" + "Register", "Username", "Password", "Login", @@ -233,12 +237,14 @@ static const char* const L10N[][_L10N_LEN] = { "repeated your status", "followed you", "wants to follow you", + "poll results", "liked", "reacted", "repeated", "followed", "follows?", + "poll", }, }; diff --git a/src/notifications.c b/src/notifications.c index 286076a..09b4eb4 100644 --- a/src/notifications.c +++ b/src/notifications.c @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include #include #include "notifications.h" #include "base_page.h" @@ -34,11 +35,52 @@ char* construct_notification(struct mstdnt_notification* notif, int* size) return notif_html; } +/* https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightLinear */ +static unsigned trail_bits(unsigned int v) +{ + unsigned int c; // output: c will count v's trailing zero bits, + // so if v is 1101000 (base 2), then c will be 3 + if (v) + { + v = (v ^ (v - 1)) >> 1; // Set v's trailing 0s to 1s and zero rest + for (c = 0; v; c++) + { + v >>= 1; + } + } + else + { + c = CHAR_BIT * sizeof(v); + } + return c; +} + +const char* notification_type_str(mstdnt_notification_t type) +{ + /* Taking advantage of the bitshift in the definitions, + * we create a table based on the index + * See: mastodont_c/include/mastodont_notif_types.h */ + char* notif_type_table[] = { + L10N[L10N_EN_US][L10N_NOTIF_COMPACT_FOLLOW], + L10N[L10N_EN_US][L10N_NOTIF_COMPACT_FOLLOW_REQUEST], + "", + L10N[L10N_EN_US][L10N_NOTIF_COMPACT_REPEATED], + L10N[L10N_EN_US][L10N_NOTIF_COMPACT_LIKED], + L10N[L10N_EN_US][L10N_NOTIF_COMPACT_POLL], + "", + L10N[L10N_EN_US][L10N_NOTIF_COMPACT_REACTED_WITH], + }; + + return notif_type_table[trail_bits((unsigned)type)]; +} + char* construct_notification_compact(struct mstdnt_notification* notif, int* size) { char* notif_html; char* notif_stats = NULL; + const char* type_str = notification_type_str(notif->type); + if (notif->status) easprintf(¬if_stats, "%d - %d - %d", notif->status->replies_count, @@ -49,7 +91,7 @@ char* construct_notification_compact(struct mstdnt_notification* notif, int* siz size_t s = easprintf(¬if_html, data_notification_compact_html, notif->account->avatar, notif->account->display_name, - "interacted", + type_str, notif->status ? notif->status->content : "", notif_stats ? notif_stats : ""); diff --git a/src/notifications.h b/src/notifications.h index 8fd5b85..1eaee88 100644 --- a/src/notifications.h +++ b/src/notifications.h @@ -20,6 +20,7 @@ #define NOTIFICATIONS_H #include +const char* notification_type_str(mstdnt_notification_t type); char* construct_notification(struct mstdnt_notification* notif, int* size); char* construct_notification_compact(struct mstdnt_notification* notif, int* size);