mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Removed _rosterwin_contacts_by_no_group function
This commit is contained in:
parent
7c4a63f3c2
commit
2092273474
@ -493,41 +493,6 @@ roster_fulljid_autocomplete(const char *const search_str)
|
|||||||
return autocomplete_complete(roster->fulljid_ac, search_str, TRUE);
|
return autocomplete_complete(roster->fulljid_ac, search_str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
GSList*
|
|
||||||
roster_get_nogroup(roster_ord_t order, gboolean include_offline)
|
|
||||||
{
|
|
||||||
assert(roster != NULL);
|
|
||||||
|
|
||||||
GSList *result = NULL;
|
|
||||||
GHashTableIter iter;
|
|
||||||
gpointer key;
|
|
||||||
gpointer value;
|
|
||||||
|
|
||||||
GCompareFunc cmp_func;
|
|
||||||
if (order == ROSTER_ORD_PRESENCE) {
|
|
||||||
cmp_func = (GCompareFunc) _compare_presence;
|
|
||||||
} else {
|
|
||||||
cmp_func = (GCompareFunc) _compare_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_hash_table_iter_init(&iter, roster->contacts);
|
|
||||||
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
|
||||||
PContact contact = value;
|
|
||||||
const char *presence = p_contact_presence(contact);
|
|
||||||
if (!include_offline && (g_strcmp0(presence, "offline") == 0)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
GSList *groups = p_contact_groups(value);
|
|
||||||
if (groups == NULL) {
|
|
||||||
result = g_slist_insert_sorted(result, value, cmp_func);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// return all contact structs
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
GSList*
|
GSList*
|
||||||
roster_get_group(const char *const group, roster_ord_t order, gboolean include_offline)
|
roster_get_group(const char *const group, roster_ord_t order, gboolean include_offline)
|
||||||
{
|
{
|
||||||
@ -554,12 +519,18 @@ roster_get_group(const char *const group, roster_ord_t order, gboolean include_o
|
|||||||
}
|
}
|
||||||
|
|
||||||
GSList *groups = p_contact_groups(value);
|
GSList *groups = p_contact_groups(value);
|
||||||
while (groups) {
|
if (group == NULL) {
|
||||||
if (strcmp(groups->data, group) == 0) {
|
if (groups == NULL) {
|
||||||
result = g_slist_insert_sorted(result, value, cmp_func);
|
result = g_slist_insert_sorted(result, value, cmp_func);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
groups = g_slist_next(groups);
|
} else {
|
||||||
|
while (groups) {
|
||||||
|
if (strcmp(groups->data, group) == 0) {
|
||||||
|
result = g_slist_insert_sorted(result, value, cmp_func);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
groups = g_slist_next(groups);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,6 @@ GSList* roster_get_groups(void);
|
|||||||
char* roster_group_autocomplete(const char *const search_str);
|
char* roster_group_autocomplete(const char *const search_str);
|
||||||
char* roster_barejid_autocomplete(const char *const search_str);
|
char* roster_barejid_autocomplete(const char *const search_str);
|
||||||
GSList* roster_get_contacts_by_presence(const char *const presence);
|
GSList* roster_get_contacts_by_presence(const char *const presence);
|
||||||
GSList* roster_get_nogroup(roster_ord_t order, gboolean include_offline);
|
|
||||||
char* roster_get_msg_display_name(const char *const barejid, const char *const resource);
|
char* roster_get_msg_display_name(const char *const barejid, const char *const resource);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -442,76 +442,11 @@ _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group, gboolean newl
|
|||||||
if (ch) {
|
if (ch) {
|
||||||
g_string_append_printf(title, "%c", ch);
|
g_string_append_printf(title, "%c", ch);
|
||||||
}
|
}
|
||||||
g_string_append(title, group);
|
if (group) {
|
||||||
|
g_string_append(title, group);
|
||||||
char *countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
} else {
|
||||||
if (g_strcmp0(countpref, "items") == 0) {
|
g_string_append(title, "no group");
|
||||||
int itemcount = g_slist_length(contacts);
|
|
||||||
if (itemcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
|
||||||
g_string_append_printf(title, " (%d)", itemcount);
|
|
||||||
} else if (itemcount > 0) {
|
|
||||||
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));
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_rosterwin_contacts_by_no_group(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_nogroup(ROSTER_ORD_PRESENCE, offline);
|
|
||||||
} else {
|
|
||||||
contacts = roster_get_nogroup(ROSTER_ORD_NAME, offline);
|
|
||||||
}
|
|
||||||
prefs_free_string(order);
|
|
||||||
|
|
||||||
if (contacts || prefs_get_boolean(PREF_ROSTER_EMPTY)) {
|
|
||||||
if (newline) {
|
|
||||||
win_sub_newline_lazy(layout->subwin);
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
g_string_append(title, "no group");
|
|
||||||
|
|
||||||
char *countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
char *countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
||||||
if (g_strcmp0(countpref, "items") == 0) {
|
if (g_strcmp0(countpref, "items") == 0) {
|
||||||
@ -924,7 +859,7 @@ rosterwin_roster(void)
|
|||||||
curr_group = g_slist_next(curr_group);
|
curr_group = g_slist_next(curr_group);
|
||||||
}
|
}
|
||||||
g_slist_free_full(groups, free);
|
g_slist_free_full(groups, free);
|
||||||
_rosterwin_contacts_by_no_group(layout, newline);
|
_rosterwin_contacts_by_group(layout, NULL, newline);
|
||||||
} else {
|
} else {
|
||||||
GSList *contacts = NULL;
|
GSList *contacts = NULL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user