mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added private chat roster group
This commit is contained in:
parent
6d8a3e2020
commit
7cacee8781
@ -576,7 +576,7 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin)
|
||||
|
||||
win_sub_print(layout->subwin, privmsg->str, FALSE, wrap, current_indent);
|
||||
|
||||
if (mucwin->unread > 0) {
|
||||
if (privwin->unread > 0) {
|
||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_UNREAD));
|
||||
} else {
|
||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM));
|
||||
@ -610,6 +610,77 @@ _compare_rooms_unread(ProfMucWin *a, ProfMucWin *b)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_rosterwin_private_chats(ProfLayoutSplit *layout)
|
||||
{
|
||||
GList *privs = wins_get_private_chats(NULL);
|
||||
if (privs || prefs_get_boolean(PREF_ROSTER_EMPTY)) {
|
||||
win_sub_newline_lazy(layout->subwin);
|
||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||
GString *title_str = g_string_new(" ");
|
||||
char ch = prefs_get_roster_header_char();
|
||||
if (ch) {
|
||||
g_string_append_printf(title_str, "%c", ch);
|
||||
}
|
||||
g_string_append(title_str, "Private chats");
|
||||
if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
|
||||
g_string_append_printf(title_str, " (%d)", g_list_length(privs));
|
||||
}
|
||||
gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
|
||||
win_sub_print(layout->subwin, title_str->str, FALSE, wrap, 1);
|
||||
g_string_free(title_str, TRUE);
|
||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||
|
||||
GList *curr = privs;
|
||||
while (curr) {
|
||||
ProfPrivateWin *privwin = curr->data;
|
||||
win_sub_newline_lazy(layout->subwin);
|
||||
|
||||
GString *privmsg = g_string_new(" ");
|
||||
int indent = prefs_get_roster_contact_indent();
|
||||
int current_indent = 0;
|
||||
if (indent > 0) {
|
||||
current_indent += indent;
|
||||
while (indent > 0) {
|
||||
g_string_append(privmsg, " ");
|
||||
indent--;
|
||||
}
|
||||
}
|
||||
|
||||
char *unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD);
|
||||
if ((g_strcmp0(unreadpos, "before") == 0) && privwin->unread > 0) {
|
||||
g_string_append_printf(privmsg, "(%d) ", privwin->unread);
|
||||
}
|
||||
|
||||
g_string_append(privmsg, privwin->fulljid);
|
||||
|
||||
if ((g_strcmp0(unreadpos, "after") == 0) && privwin->unread > 0) {
|
||||
g_string_append_printf(privmsg, " (%d)", privwin->unread);
|
||||
}
|
||||
prefs_free_string(unreadpos);
|
||||
|
||||
if (privwin->unread > 0) {
|
||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_UNREAD));
|
||||
} else {
|
||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM));
|
||||
}
|
||||
|
||||
win_sub_print(layout->subwin, privmsg->str, FALSE, wrap, current_indent);
|
||||
|
||||
if (privwin->unread > 0) {
|
||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_UNREAD));
|
||||
} else {
|
||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM));
|
||||
}
|
||||
|
||||
g_string_free(privmsg, TRUE);
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
g_list_free(privs);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_rosterwin_rooms(ProfLayoutSplit *layout, gboolean newline)
|
||||
{
|
||||
@ -659,6 +730,12 @@ _rosterwin_rooms(ProfLayoutSplit *layout, gboolean newline)
|
||||
}
|
||||
|
||||
g_list_free(rooms_sorted);
|
||||
|
||||
char *privpref = prefs_get_string(PREF_ROSTER_PRIVATE);
|
||||
if (g_strcmp0(privpref, "group") == 0) {
|
||||
_rosterwin_private_chats(layout);
|
||||
}
|
||||
prefs_free_string(privpref);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -185,7 +185,7 @@ wins_get_private_chats(const char *const roomjid)
|
||||
ProfWin *window = curr->data;
|
||||
if (window->type == WIN_PRIVATE) {
|
||||
ProfPrivateWin *privatewin = (ProfPrivateWin*)window;
|
||||
if (g_str_has_prefix(privatewin->fulljid, prefix->str)) {
|
||||
if (roomjid == NULL || g_str_has_prefix(privatewin->fulljid, prefix->str)) {
|
||||
result = g_list_append(result, privatewin);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user