diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index d67e8aff..7950c811 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -708,6 +708,7 @@ cmd_ac_init(void) autocomplete_add(occupants_ac, "header"); autocomplete_add(occupants_ac, "wrap"); autocomplete_add(occupants_ac, "char"); + autocomplete_add(occupants_ac, "color"); occupants_default_ac = autocomplete_new(); autocomplete_add(occupants_default_ac, "show"); @@ -2651,6 +2652,11 @@ _occupants_autocomplete(ProfWin *window, const char *const input, gboolean previ return found; } + found = autocomplete_param_with_func(input, "/occupants color", prefs_autocomplete_boolean_choice, previous); + if (found) { + return found; + } + found = autocomplete_param_with_ac(input, "/occupants default hide", occupants_show_ac, TRUE, previous); if (found) { return found; diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 38547bbd..17b9d6cb 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -714,6 +714,7 @@ static struct cmd_t command_defs[] = CMD_SYN( "/occupants show|hide [jid]", "/occupants char |none", + "/occupants color on|off", "/occupants default show|hide [jid]", "/occupants size []", "/occupants indent ", @@ -725,6 +726,8 @@ static struct cmd_t command_defs[] = { "show", "Show the occupants panel in current room." }, { "char ", "Prefix occupants with specified character." }, { "char none", "Remove occupants character prefix." }, + { "color on", "Enable generated color names (XEP-0392) for occupants" }, + { "color off", "Disable generated color names (XEP-0392) for occupants" }, { "hide", "Hide the occupants panel in current room." }, { "show jid", "Show jid in the occupants panel in current room." }, { "hide jid", "Hide jid in the occupants panel in current room." }, diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index d55bc762..aa1f21c3 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -4442,6 +4442,12 @@ cmd_occupants(ProfWin *window, const char *const command, gchar **args) return TRUE; } + if (g_strcmp0(args[0], "color") == 0) { + _cmd_set_boolean_preference(args[1], command, "Occupants consistent colors", PREF_OCCUPANTS_COLOR_NICK); + occupantswin_occupants_all(); + return TRUE; + } + if (g_strcmp0(args[0], "default") == 0) { if (g_strcmp0(args[1], "show") == 0) { if (g_strcmp0(args[2], "jid") == 0) { diff --git a/src/config/preferences.c b/src/config/preferences.c index 8f4c4c45..a7fd4733 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1712,6 +1712,7 @@ _get_group(preference_t pref) case PREF_CONSOLE_CHAT: case PREF_COLOR_NICK: case PREF_ROSTER_COLOR_NICK: + case PREF_OCCUPANTS_COLOR_NICK: case PREF_STATUSBAR_SHOW_NAME: case PREF_STATUSBAR_SHOW_NUMBER: case PREF_STATUSBAR_SELF: @@ -1975,6 +1976,8 @@ _get_key(preference_t pref) return "color.nick"; case PREF_ROSTER_COLOR_NICK: return "color.roster.nick"; + case PREF_OCCUPANTS_COLOR_NICK: + return "color.occupants.nick"; case PREF_BOOKMARK_INVITE: return "bookmark.invite"; case PREF_PLUGINS_SOURCEPATH: diff --git a/src/config/preferences.h b/src/config/preferences.h index 2f1bf131..845168de 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -145,6 +145,7 @@ typedef enum { PREF_CONSOLE_CHAT, PREF_COLOR_NICK, PREF_ROSTER_COLOR_NICK, + PREF_OCCUPANTS_COLOR_NICK, PREF_BOOKMARK_INVITE, PREF_PLUGINS_SOURCEPATH, PREF_ROOM_LIST_CACHE, diff --git a/src/ui/console.c b/src/ui/console.c index 6beb3025..d3e99570 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1991,9 +1991,15 @@ cons_color_setting(void) prefs_free_string(color_pref); if (prefs_get_boolean(PREF_ROSTER_COLOR_NICK)) { - cons_show("Consistent color generation in roster (/roster) : ON"); + cons_show("Consistent color generation in roster (/roster) : ON"); } else { - cons_show("Consistent color generation in roster (/roster) : OFF"); + cons_show("Consistent color generation in roster (/roster) : OFF"); + } + + if (prefs_get_boolean(PREF_OCCUPANTS_COLOR_NICK)) { + cons_show("Consistent color generation for occupants (/occupants) : ON"); + } else { + cons_show("Consistent color generation for occupants (/occupants) : OFF"); } } diff --git a/src/ui/occupantswin.c b/src/ui/occupantswin.c index 9b6a3f62..9c0adf8b 100644 --- a/src/ui/occupantswin.c +++ b/src/ui/occupantswin.c @@ -44,9 +44,19 @@ static void _occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean showjid) { - const char *presence_str = string_from_resource_presence(occupant->presence); - theme_item_t presence_colour = theme_main_presence_attrs(presence_str); - wattron(layout->subwin, theme_attrs(presence_colour)); + int colour; + theme_item_t presence_colour; + + if (prefs_get_boolean(PREF_OCCUPANTS_COLOR_NICK)) { + colour = theme_hash_attrs(occupant->nick); + + wattron(layout->subwin, colour); + } else { + const char *presence_str = string_from_resource_presence(occupant->presence); + presence_colour = theme_main_presence_attrs(presence_str); + + wattron(layout->subwin, theme_attrs(presence_colour)); + } GString *spaces = g_string_new(" "); @@ -86,7 +96,11 @@ _occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean sh g_string_free(spaces, TRUE); - wattroff(layout->subwin, theme_attrs(presence_colour)); + if (prefs_get_boolean(PREF_OCCUPANTS_COLOR_NICK)) { + wattroff(layout->subwin, colour); + } else { + wattroff(layout->subwin, theme_attrs(presence_colour)); + } } void