Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/screen.c @ 2324:4ddd6f5c3ffc
Add support for displaying the number of unread messages for each roster entry
author | Michał Kępień <bitbucket@kempniu.pl> |
---|---|
date | Sun, 23 Sep 2018 22:52:29 +0200 |
parents | 70f8ae7d690e |
children | c5665d3191aa |
comparison
equal
deleted
inserted
replaced
2323:d2111a776b66 | 2324:4ddd6f5c3ffc |
---|---|
1459 top_panel(inputPanel); | 1459 top_panel(inputPanel); |
1460 currentWindow = NULL; | 1460 currentWindow = NULL; |
1461 return; | 1461 return; |
1462 } | 1462 } |
1463 | 1463 |
1464 roster_msg_update_unread(bjid, FALSE); | |
1464 scr_show_window(bjid, FALSE); | 1465 scr_show_window(bjid, FALSE); |
1465 } | 1466 } |
1466 | 1467 |
1467 // scr_update_buddy_window() | 1468 // scr_update_buddy_window() |
1468 // (Re)Display the current window. | 1469 // (Re)Display the current window. |
1574 } else if (!(prefix_flags & HBB_PREFIX_NOFLAG)) { | 1575 } else if (!(prefix_flags & HBB_PREFIX_NOFLAG)) { |
1575 setmsgflg = TRUE; | 1576 setmsgflg = TRUE; |
1576 } | 1577 } |
1577 if (!special) { | 1578 if (!special) { |
1578 if (clearmsgflg) { | 1579 if (clearmsgflg) { |
1580 roster_msg_update_unread(winId, FALSE); | |
1579 roster_msg_setflag(winId, FALSE, FALSE); | 1581 roster_msg_setflag(winId, FALSE, FALSE); |
1580 scr_update_roster(); | 1582 scr_update_roster(); |
1581 } else if (setmsgflg) { | 1583 } else if (setmsgflg) { |
1584 roster_msg_update_unread(winId, TRUE); | |
1582 roster_msg_setflag(winId, FALSE, TRUE); | 1585 roster_msg_setflag(winId, FALSE, TRUE); |
1583 scr_update_roster(); | 1586 scr_update_roster(); |
1584 } | 1587 } |
1585 } | 1588 } |
1586 } | 1589 } |
2093 // scr_draw_roster() | 2096 // scr_draw_roster() |
2094 // Display the buddylist (not really the roster) on the screen | 2097 // Display the buddylist (not really the roster) on the screen |
2095 void scr_draw_roster(void) | 2098 void scr_draw_roster(void) |
2096 { | 2099 { |
2097 static int offset = 0; | 2100 static int offset = 0; |
2098 char *name, *rline; | 2101 char *name, *rline, *unread; |
2099 int maxx, maxy; | 2102 int maxx, maxy; |
2100 GList *buddy; | 2103 GList *buddy; |
2101 int i, n; | 2104 int i, n; |
2102 int rOffset; | 2105 int rOffset; |
2103 int cursor_backup; | 2106 int cursor_backup; |
2172 } else { | 2175 } else { |
2173 prefix_length = 7; | 2176 prefix_length = 7; |
2174 } | 2177 } |
2175 | 2178 |
2176 name = g_new0(char, 4*Roster_Width); | 2179 name = g_new0(char, 4*Roster_Width); |
2180 unread = g_new0(char, Roster_Width+1);; | |
2177 rline = g_new0(char, 4*Roster_Width+1); | 2181 rline = g_new0(char, 4*Roster_Width+1); |
2178 | 2182 |
2179 buddy = buddylist; | 2183 buddy = buddylist; |
2180 rOffset = offset; | 2184 rOffset = offset; |
2181 | 2185 |
2265 } | 2269 } |
2266 wattrset(rosterWnd, color); | 2270 wattrset(rosterWnd, color); |
2267 } | 2271 } |
2268 } | 2272 } |
2269 | 2273 |
2270 if (Roster_Width > prefix_length) | 2274 name[0] = 0; |
2275 unread[0] = 0; | |
2276 if (Roster_Width > prefix_length) { | |
2271 g_utf8_strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-prefix_length); | 2277 g_utf8_strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-prefix_length); |
2272 else | 2278 if (settings_opt_get_int("roster_show_unread_count")) { |
2273 name[0] = 0; | 2279 guint unread_count = buddy_getunread(BUDDATA(buddy)); |
2280 glong name_length = g_utf8_strlen(name, 4*Roster_Width); | |
2281 if (unread_count > 0 && Roster_Width > prefix_length + name_length) { | |
2282 snprintf(unread, Roster_Width-(prefix_length+name_length)+1, " (%u)", unread_count); | |
2283 } | |
2284 } | |
2285 } | |
2274 | 2286 |
2275 if (pending == '#') { | 2287 if (pending == '#') { |
2276 // Attention sign? | 2288 // Attention sign? |
2277 if ((ismuc && isurg >= ui_attn_sign_prio_level_muc) || | 2289 if ((ismuc && isurg >= ui_attn_sign_prio_level_muc) || |
2278 (!ismuc && isurg >= ui_attn_sign_prio_level)) | 2290 (!ismuc && isurg >= ui_attn_sign_prio_level)) |
2304 if (!(subtype & sub_from)) { | 2316 if (!(subtype & sub_from)) { |
2305 sepleft = '{'; | 2317 sepleft = '{'; |
2306 sepright = '}'; | 2318 sepright = '}'; |
2307 } | 2319 } |
2308 } | 2320 } |
2309 snprintf(rline, 4*Roster_Width, "%s%lc%c%c%c %s", | 2321 snprintf(rline, 4*Roster_Width, "%s%lc%c%c%c %s%s", |
2310 space, pending, sepleft, status, sepright, name); | 2322 space, pending, sepleft, status, sepright, name, unread); |
2311 } | 2323 } |
2312 | 2324 |
2313 rline_locale = from_utf8(rline); | 2325 rline_locale = from_utf8(rline); |
2314 mvwprintw(rosterWnd, i, x_pos, "%s", rline_locale); | 2326 mvwprintw(rosterWnd, i, x_pos, "%s", rline_locale); |
2315 g_free(rline_locale); | 2327 g_free(rline_locale); |
2316 i++; | 2328 i++; |
2317 } | 2329 } |
2318 | 2330 |
2319 g_free(rline); | 2331 g_free(rline); |
2332 g_free(unread); | |
2320 g_free(name); | 2333 g_free(name); |
2321 top_panel(inputPanel); | 2334 top_panel(inputPanel); |
2322 update_panels(); | 2335 update_panels(); |
2323 curs_set(cursor_backup); | 2336 curs_set(cursor_backup); |
2324 } | 2337 } |