diff --git a/src/command/command.c b/src/command/command.c index c57f48a9..b6935daa 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -2250,7 +2250,6 @@ cmd_init(void) autocomplete_add(roster_show_ac, "presence"); autocomplete_add(roster_show_ac, "status"); autocomplete_add(roster_show_ac, "empty"); - autocomplete_add(roster_show_ac, "count"); autocomplete_add(roster_show_ac, "priority"); autocomplete_add(roster_show_ac, "contacts"); autocomplete_add(roster_show_ac, "rooms"); diff --git a/src/command/commands.c b/src/command/commands.c index fb3024da..9447f648 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -2224,13 +2224,6 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) rosterwin_roster(); } 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 if (g_strcmp0(args[1], "priority") == 0) { cons_show("Roster priority enabled"); prefs_set_boolean(PREF_ROSTER_PRIORITY, TRUE); @@ -2299,13 +2292,6 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) rosterwin_roster(); } 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 if (g_strcmp0(args[1], "priority") == 0) { cons_show("Roster priority disabled"); prefs_set_boolean(PREF_ROSTER_PRIORITY, FALSE); @@ -2381,6 +2367,41 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args) return TRUE; } + } else if (g_strcmp0(args[0], "count") == 0) { + if (g_strcmp0(args[1], "zero") == 0) { + gboolean result = _cmd_set_boolean_preference(args[2], command, "Roster header zero count", PREF_ROSTER_COUNT_ZERO); + if (result) { + if (conn_status == JABBER_CONNECTED) { + rosterwin_roster(); + } + } + return result; + } else if (g_strcmp0(args[1], "unread") == 0) { + cons_show("Roster header count set to unread"); + prefs_set_string(PREF_ROSTER_COUNT, "unread"); + if (conn_status == JABBER_CONNECTED) { + rosterwin_roster(); + } + return TRUE; + } else if (g_strcmp0(args[1], "items") == 0) { + cons_show("Roster header count set to items"); + prefs_set_string(PREF_ROSTER_COUNT, "items"); + if (conn_status == JABBER_CONNECTED) { + rosterwin_roster(); + } + return TRUE; + } else if (g_strcmp0(args[1], "off") == 0) { + cons_show("Disabling roster header count"); + prefs_set_string(PREF_ROSTER_COUNT, "off"); + if (conn_status == JABBER_CONNECTED) { + rosterwin_roster(); + } + return TRUE; + } else { + cons_bad_cmd_usage(command); + return TRUE; + } + } else if (g_strcmp0(args[0], "unread") == 0) { if (g_strcmp0(args[1], "before") == 0) { cons_show("Roster unread message count: before"); diff --git a/src/config/preferences.c b/src/config/preferences.c index bb85c682..8a15cccd 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1112,6 +1112,7 @@ _get_group(preference_t pref) case PREF_ROSTER_ORDER: case PREF_ROSTER_UNREAD: case PREF_ROSTER_COUNT: + case PREF_ROSTER_COUNT_ZERO: case PREF_ROSTER_PRIORITY: case PREF_ROSTER_WRAP: case PREF_ROSTER_RESOURCE_JOIN: @@ -1311,6 +1312,8 @@ _get_key(preference_t pref) return "roster.unread"; case PREF_ROSTER_COUNT: return "roster.count"; + case PREF_ROSTER_COUNT_ZERO: + return "roster.count.zero"; case PREF_ROSTER_PRIORITY: return "roster.priority"; case PREF_ROSTER_WRAP: @@ -1383,7 +1386,7 @@ _get_default_boolean(preference_t pref) case PREF_ROSTER: case PREF_ROSTER_OFFLINE: case PREF_ROSTER_EMPTY: - case PREF_ROSTER_COUNT: + case PREF_ROSTER_COUNT_ZERO: case PREF_ROSTER_PRIORITY: case PREF_ROSTER_RESOURCE_JOIN: case PREF_ROSTER_CONTACTS: @@ -1415,6 +1418,8 @@ _get_default_string(preference_t pref) return "all"; case PREF_ROSTER_BY: return "presence"; + case PREF_ROSTER_COUNT: + return "unread"; case PREF_ROSTER_ORDER: return "presence"; case PREF_ROSTER_UNREAD: diff --git a/src/config/preferences.h b/src/config/preferences.h index 61ccbb11..32a924ba 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -71,6 +71,7 @@ typedef enum { PREF_ROSTER_ORDER, PREF_ROSTER_UNREAD, PREF_ROSTER_COUNT, + PREF_ROSTER_COUNT_ZERO, PREF_ROSTER_PRIORITY, PREF_ROSTER_WRAP, PREF_ROSTER_RESOURCE_JOIN, diff --git a/src/config/theme.c b/src/config/theme.c index e04a5d4a..b886f9e2 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -388,7 +388,7 @@ _load_preferences(void) _set_boolean_preference("roster.status", PREF_ROSTER_STATUS); _set_boolean_preference("roster.empty", PREF_ROSTER_EMPTY); _set_boolean_preference("roster.wrap", PREF_ROSTER_WRAP); - _set_boolean_preference("roster.count", PREF_ROSTER_COUNT); + _set_boolean_preference("roster.count.zero", PREF_ROSTER_COUNT_ZERO); _set_boolean_preference("roster.priority", PREF_ROSTER_PRIORITY); _set_boolean_preference("roster.contacts", PREF_ROSTER_CONTACTS); _set_boolean_preference("roster.rooms", PREF_ROSTER_ROOMS); @@ -417,6 +417,8 @@ _load_preferences(void) _set_string_preference("roster.rooms.unread", PREF_ROSTER_ROOMS_UNREAD); _set_string_preference("roster.rooms.pos", PREF_ROSTER_ROOMS_POS); _set_string_preference("roster.private", PREF_ROSTER_PRIVATE); + _set_string_preference("roster.count", PREF_ROSTER_COUNT); + if (g_key_file_has_key(theme, "ui", "occupants.size", NULL)) { gint occupants_size = g_key_file_get_integer(theme, "ui", "occupants.size", NULL); diff --git a/src/ui/console.c b/src/ui/console.c index a5a9800d..f2c1f35b 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1370,11 +1370,6 @@ cons_roster_setting(void) else 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"); - if (prefs_get_boolean(PREF_ROSTER_PRIORITY)) cons_show("Roster priority (/roster) : show"); else @@ -1385,6 +1380,19 @@ cons_roster_setting(void) else cons_show("Roster contacts (/roster) : hide"); + char *count = prefs_get_string(PREF_ROSTER_COUNT); + if (g_strcmp0(count, "off") == 0) { + cons_show("Roster count (/roster) : OFF"); + } else { + cons_show("Roster count (/roster) : %s", count); + } + prefs_free_string(count); + + if (prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) + cons_show("Roster count zero (/roster) : ON"); + else + cons_show("Roster count zero (/roster) : OFF"); + char *by = prefs_get_string(PREF_ROSTER_BY); cons_show("Roster by (/roster) : %s", by); prefs_free_string(by);