mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added _rosterwin_contacts_all function
This commit is contained in:
parent
7c1db22fac
commit
20659b9841
@ -817,6 +817,76 @@ _rosterwin_rooms(ProfLayoutSplit *layout, gboolean newline)
|
|||||||
prefs_free_string(privpref);
|
prefs_free_string(privpref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_rosterwin_contacts_all(ProfLayoutSplit *layout, gboolean newline)
|
||||||
|
{
|
||||||
|
GSList *contacts = NULL;
|
||||||
|
|
||||||
|
char *order = prefs_get_string(PREF_ROSTER_ORDER);
|
||||||
|
gboolean offline = prefs_get_boolean(PREF_ROSTER_OFFLINE);
|
||||||
|
if (g_strcmp0(order, "presence") == 0) {
|
||||||
|
contacts = roster_get_contacts(ROSTER_ORD_PRESENCE, offline);
|
||||||
|
} else {
|
||||||
|
contacts = roster_get_contacts(ROSTER_ORD_NAME, offline);
|
||||||
|
}
|
||||||
|
prefs_free_string(order);
|
||||||
|
|
||||||
|
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
|
GString *title = g_string_new(" ");
|
||||||
|
char ch = prefs_get_roster_header_char();
|
||||||
|
if (ch) {
|
||||||
|
g_string_append_printf(title, "%c", ch);
|
||||||
|
}
|
||||||
|
if (newline) {
|
||||||
|
win_sub_newline_lazy(layout->subwin);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_string_append(title, "Roster");
|
||||||
|
|
||||||
|
char *countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
||||||
|
if (g_strcmp0(countpref, "items") == 0) {
|
||||||
|
int itemcount = g_slist_length(contacts);
|
||||||
|
if (itemcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||||
|
g_string_append_printf(title, " (%d)", itemcount);
|
||||||
|
} else {
|
||||||
|
g_string_append_printf(title, " (%d)", itemcount);
|
||||||
|
}
|
||||||
|
} else if (g_strcmp0(countpref, "unread") == 0) {
|
||||||
|
int unreadcount = 0;
|
||||||
|
GSList *curr = contacts;
|
||||||
|
while (curr) {
|
||||||
|
PContact contact = curr->data;
|
||||||
|
const char *barejid = p_contact_barejid(contact);
|
||||||
|
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||||
|
if (chatwin) {
|
||||||
|
unreadcount += chatwin->unread;
|
||||||
|
}
|
||||||
|
curr = g_slist_next(curr);
|
||||||
|
}
|
||||||
|
if (unreadcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||||
|
g_string_append_printf(title, " (%d)", unreadcount);
|
||||||
|
} else if (unreadcount > 0) {
|
||||||
|
g_string_append_printf(title, " (%d)", unreadcount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prefs_free_string(countpref);
|
||||||
|
|
||||||
|
gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
|
||||||
|
win_sub_print(layout->subwin, title->str, FALSE, wrap, 1);
|
||||||
|
g_string_free(title, TRUE);
|
||||||
|
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
|
|
||||||
|
if (contacts) {
|
||||||
|
GSList *curr_contact = contacts;
|
||||||
|
while (curr_contact) {
|
||||||
|
PContact contact = curr_contact->data;
|
||||||
|
_rosterwin_contact(layout, contact);
|
||||||
|
curr_contact = g_slist_next(curr_contact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_slist_free(contacts);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rosterwin_roster(void)
|
rosterwin_roster(void)
|
||||||
{
|
{
|
||||||
@ -861,71 +931,7 @@ rosterwin_roster(void)
|
|||||||
g_slist_free_full(groups, free);
|
g_slist_free_full(groups, free);
|
||||||
_rosterwin_contacts_by_group(layout, NULL, newline);
|
_rosterwin_contacts_by_group(layout, NULL, newline);
|
||||||
} else {
|
} else {
|
||||||
GSList *contacts = NULL;
|
_rosterwin_contacts_all(layout, newline);
|
||||||
|
|
||||||
char *order = prefs_get_string(PREF_ROSTER_ORDER);
|
|
||||||
gboolean offline = prefs_get_boolean(PREF_ROSTER_OFFLINE);
|
|
||||||
if (g_strcmp0(order, "presence") == 0) {
|
|
||||||
contacts = roster_get_contacts(ROSTER_ORD_PRESENCE, offline);
|
|
||||||
} else {
|
|
||||||
contacts = roster_get_contacts(ROSTER_ORD_NAME, offline);
|
|
||||||
}
|
|
||||||
prefs_free_string(order);
|
|
||||||
|
|
||||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
|
||||||
GString *title = g_string_new(" ");
|
|
||||||
char ch = prefs_get_roster_header_char();
|
|
||||||
if (ch) {
|
|
||||||
g_string_append_printf(title, "%c", ch);
|
|
||||||
}
|
|
||||||
if (newline) {
|
|
||||||
win_sub_newline_lazy(layout->subwin);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_string_append(title, "Roster");
|
|
||||||
|
|
||||||
char *countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
|
||||||
if (g_strcmp0(countpref, "items") == 0) {
|
|
||||||
int itemcount = g_slist_length(contacts);
|
|
||||||
if (itemcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
|
||||||
g_string_append_printf(title, " (%d)", itemcount);
|
|
||||||
} else {
|
|
||||||
g_string_append_printf(title, " (%d)", itemcount);
|
|
||||||
}
|
|
||||||
} else if (g_strcmp0(countpref, "unread") == 0) {
|
|
||||||
int unreadcount = 0;
|
|
||||||
GSList *curr = contacts;
|
|
||||||
while (curr) {
|
|
||||||
PContact contact = curr->data;
|
|
||||||
const char *barejid = p_contact_barejid(contact);
|
|
||||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
|
||||||
if (chatwin) {
|
|
||||||
unreadcount += chatwin->unread;
|
|
||||||
}
|
|
||||||
curr = g_slist_next(curr);
|
|
||||||
}
|
|
||||||
if (unreadcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
|
||||||
g_string_append_printf(title, " (%d)", unreadcount);
|
|
||||||
} else if (unreadcount > 0) {
|
|
||||||
g_string_append_printf(title, " (%d)", unreadcount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
prefs_free_string(countpref);
|
|
||||||
|
|
||||||
gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
|
|
||||||
win_sub_print(layout->subwin, title->str, FALSE, wrap, 1);
|
|
||||||
g_string_free(title, TRUE);
|
|
||||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
|
||||||
|
|
||||||
if (contacts) {
|
|
||||||
GSList *curr_contact = contacts;
|
|
||||||
while (curr_contact) {
|
|
||||||
PContact contact = curr_contact->data;
|
|
||||||
_rosterwin_contact(layout, contact);
|
|
||||||
curr_contact = g_slist_next(curr_contact);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_slist_free(contacts);
|
|
||||||
}
|
}
|
||||||
prefs_free_string(by);
|
prefs_free_string(by);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user