1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Added roster count option

This commit is contained in:
James Booth 2015-11-18 02:02:49 +00:00
parent edbd2d5843
commit 4505102fa8
6 changed files with 50 additions and 5 deletions

View File

@ -274,8 +274,8 @@ static struct cmd_t command_defs[] =
CMD_SYN( CMD_SYN(
"/roster", "/roster",
"/roster online", "/roster online",
"/roster show [offline|resource|presence|status|empty]", "/roster show [offline|resource|presence|status|empty|count]",
"/roster hide [offline|resource|presence|status|empty]", "/roster hide [offline|resource|presence|status|empty|count]",
"/roster by group|presence|none", "/roster by group|presence|none",
"/roster order name|presence" "/roster order name|presence"
"/roster size <percent>", "/roster size <percent>",
@ -295,12 +295,14 @@ static struct cmd_t command_defs[] =
{ "show presence", "Show contact's presence in the roster panel." }, { "show presence", "Show contact's presence in the roster panel." },
{ "show status", "Show contact's status message in the roster panel." }, { "show status", "Show contact's status message in the roster panel." },
{ "show empty", "When grouping by presence, show empty presence groups." }, { "show empty", "When grouping by presence, show empty presence groups." },
{ "show count", "Show number of contacts in group/presence." },
{ "hide", "Hide the roster panel." }, { "hide", "Hide the roster panel." },
{ "hide offline", "Hide offline contacts in the roster panel." }, { "hide offline", "Hide offline contacts in the roster panel." },
{ "hide resource", "Hide contact's connected resources in the roster panel." }, { "hide resource", "Hide contact's connected resources in the roster panel." },
{ "hide presence", "Hide contact's presence in the roster panel." }, { "hide presence", "Hide contact's presence in the roster panel." },
{ "hide status", "Hide contact's status message in the roster panel." }, { "hide status", "Hide contact's status message in the roster panel." },
{ "hide empty", "When grouping by presence, hide empty presence groups." }, { "hide empty", "When grouping by presence, hide empty presence groups." },
{ "hide count", "Hide number of contacts in group/presence." },
{ "by group", "Group contacts in the roster panel by roster group." }, { "by group", "Group contacts in the roster panel by roster group." },
{ "by presence", "Group contacts in the roster panel by presence." }, { "by presence", "Group contacts in the roster panel by presence." },
{ "by none", "No grouping in the roster panel." }, { "by none", "No grouping in the roster panel." },
@ -2027,6 +2029,7 @@ cmd_init(void)
autocomplete_add(roster_option_ac, "presence"); autocomplete_add(roster_option_ac, "presence");
autocomplete_add(roster_option_ac, "status"); autocomplete_add(roster_option_ac, "status");
autocomplete_add(roster_option_ac, "empty"); autocomplete_add(roster_option_ac, "empty");
autocomplete_add(roster_option_ac, "count");
roster_by_ac = autocomplete_new(); roster_by_ac = autocomplete_new();
autocomplete_add(roster_by_ac, "group"); autocomplete_add(roster_by_ac, "group");

View File

@ -1794,6 +1794,13 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
rosterwin_roster(); rosterwin_roster();
} }
return TRUE; return TRUE;
} else if (g_strcmp0(args[1], "count") == 0) {
cons_show("Roster count enabled");
prefs_set_boolean(PREF_ROSTER_COUNT, TRUE);
if (conn_status == JABBER_CONNECTED) {
rosterwin_roster();
}
return TRUE;
} else { } else {
cons_bad_cmd_usage(command); cons_bad_cmd_usage(command);
return TRUE; return TRUE;
@ -1841,6 +1848,13 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
rosterwin_roster(); rosterwin_roster();
} }
return TRUE; return TRUE;
} else if (g_strcmp0(args[1], "count") == 0) {
cons_show("Roster count disabled");
prefs_set_boolean(PREF_ROSTER_COUNT, FALSE);
if (conn_status == JABBER_CONNECTED) {
rosterwin_roster();
}
return TRUE;
} else { } else {
cons_bad_cmd_usage(command); cons_bad_cmd_usage(command);
return TRUE; return TRUE;

View File

@ -602,6 +602,7 @@ _get_group(preference_t pref)
case PREF_ROSTER_EMPTY: case PREF_ROSTER_EMPTY:
case PREF_ROSTER_BY: case PREF_ROSTER_BY:
case PREF_ROSTER_ORDER: case PREF_ROSTER_ORDER:
case PREF_ROSTER_COUNT:
case PREF_RESOURCE_TITLE: case PREF_RESOURCE_TITLE:
case PREF_RESOURCE_MESSAGE: case PREF_RESOURCE_MESSAGE:
case PREF_ENC_WARN: case PREF_ENC_WARN:
@ -781,6 +782,8 @@ _get_key(preference_t pref)
return "roster.by"; return "roster.by";
case PREF_ROSTER_ORDER: case PREF_ROSTER_ORDER:
return "roster.order"; return "roster.order";
case PREF_ROSTER_COUNT:
return "roster.count";
case PREF_RESOURCE_TITLE: case PREF_RESOURCE_TITLE:
return "resource.title"; return "resource.title";
case PREF_RESOURCE_MESSAGE: case PREF_RESOURCE_MESSAGE:
@ -835,6 +838,7 @@ _get_default_boolean(preference_t pref)
case PREF_ROSTER_PRESENCE: case PREF_ROSTER_PRESENCE:
case PREF_ROSTER_STATUS: case PREF_ROSTER_STATUS:
case PREF_ROSTER_EMPTY: case PREF_ROSTER_EMPTY:
case PREF_ROSTER_COUNT:
case PREF_TLS_SHOW: case PREF_TLS_SHOW:
case PREF_LASTACTIVITY: case PREF_LASTACTIVITY:
return TRUE; return TRUE;

View File

@ -69,6 +69,7 @@ typedef enum {
PREF_ROSTER_EMPTY, PREF_ROSTER_EMPTY,
PREF_ROSTER_BY, PREF_ROSTER_BY,
PREF_ROSTER_ORDER, PREF_ROSTER_ORDER,
PREF_ROSTER_COUNT,
PREF_MUC_PRIVILEGES, PREF_MUC_PRIVILEGES,
PREF_PRESENCE, PREF_PRESENCE,
PREF_WRAP, PREF_WRAP,

View File

@ -1222,6 +1222,11 @@ cons_roster_setting(void)
else else
cons_show("Roster empty (/roster) : hide"); cons_show("Roster empty (/roster) : hide");
if (prefs_get_boolean(PREF_ROSTER_COUNT))
cons_show("Roster count (/roster) : show");
else
cons_show("Roster count (/roster) : hide");
char *by = prefs_get_string(PREF_ROSTER_BY); char *by = prefs_get_string(PREF_ROSTER_BY);
cons_show("Roster by (/roster) : %s", by); cons_show("Roster by (/roster) : %s", by);
prefs_free_string(by); prefs_free_string(by);

View File

@ -140,7 +140,12 @@ _rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char *const prese
// if this group has contacts, or if we want to show empty groups // if this group has contacts, or if we want to show empty groups
if (contacts || prefs_get_boolean(PREF_ROSTER_EMPTY)) { if (contacts || prefs_get_boolean(PREF_ROSTER_EMPTY)) {
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
win_printline_nowrap(layout->subwin, title); GString *title_str = g_string_new(title);
if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
g_string_append_printf(title_str, " (%d)", g_slist_length(contacts));
}
win_printline_nowrap(layout->subwin, title_str->str);
g_string_free(title_str, TRUE);
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
} }
@ -172,6 +177,9 @@ _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group)
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
GString *title = g_string_new(" -"); GString *title = g_string_new(" -");
g_string_append(title, group); g_string_append(title, group);
if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
g_string_append_printf(title, " (%d)", g_slist_length(contacts));
}
win_printline_nowrap(layout->subwin, title->str); win_printline_nowrap(layout->subwin, title->str);
g_string_free(title, TRUE); g_string_free(title, TRUE);
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
@ -201,7 +209,12 @@ _rosterwin_contacts_by_no_group(ProfLayoutSplit *layout)
if (contacts || prefs_get_boolean(PREF_ROSTER_EMPTY)) { if (contacts || prefs_get_boolean(PREF_ROSTER_EMPTY)) {
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
win_printline_nowrap(layout->subwin, " -no group"); GString *title = g_string_new(" -no group");
if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
g_string_append_printf(title, " (%d)", g_slist_length(contacts));
}
win_printline_nowrap(layout->subwin, title->str);
g_string_free(title, TRUE);
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
GSList *curr_contact = contacts; GSList *curr_contact = contacts;
@ -257,7 +270,12 @@ rosterwin_roster(void)
werase(layout->subwin); werase(layout->subwin);
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
win_printline_nowrap(layout->subwin, " -Roster"); GString *title = g_string_new(" -Roster");
if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
g_string_append_printf(title, " (%d)", g_slist_length(contacts));
}
win_printline_nowrap(layout->subwin, title->str);
g_string_free(title, TRUE);
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
if (contacts) { if (contacts) {