about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-12-19 18:53:22 +0100
committerMichael Vetter <jubalh@iodoru.org>2019-12-19 18:53:22 +0100
commit0af54d8a72c0c218e5fa847e61a5c98589662b79 (patch)
treeb6ebf24c8fcab9a8cabbdb307f682ecd632ac6e1
parentc302af99b757257d07ebebc97cd2de0a516754e2 (diff)
downloadprofani-tty-0af54d8a72c0c218e5fa847e61a5c98589662b79.tar.gz
Add /roster color command
`/roster color on|off` to enable or disable XEP-0392 also for the
roster.

Regards https://github.com/profanity-im/profanity/issues/1191
-rw-r--r--src/command/cmd_ac.c5
-rw-r--r--src/command/cmd_defs.c3
-rw-r--r--src/command/cmd_funcs.c5
-rw-r--r--src/config/preferences.c3
-rw-r--r--src/ui/console.c6
5 files changed, 22 insertions, 0 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 9399aa8d..d67e8aff 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -433,6 +433,7 @@ cmd_ac_init(void)
     autocomplete_add(roster_ac, "hide");
     autocomplete_add(roster_ac, "by");
     autocomplete_add(roster_ac, "count");
+    autocomplete_add(roster_ac, "color");
     autocomplete_add(roster_ac, "order");
     autocomplete_add(roster_ac, "unread");
     autocomplete_add(roster_ac, "room");
@@ -1821,6 +1822,10 @@ _roster_autocomplete(ProfWin *window, const char *const input, gboolean previous
         if (result) {
             return result;
         }
+        result = autocomplete_param_with_func(input, "/roster color", prefs_autocomplete_boolean_choice, previous);
+        if (result) {
+            return result;
+        }
     }
 
     result = autocomplete_param_with_ac(input, "/roster remove_all", roster_remove_all_ac, TRUE, previous);
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index a1dde57b..38547bbd 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -280,6 +280,7 @@ static struct cmd_t command_defs[] =
             "/roster by group|presence|none",
             "/roster count unread|items|off",
             "/roster count zero on|off",
+            "/roster color on|off",
             "/roster order name|presence",
             "/roster unread before|after|off",
             "/roster room char <char>|none",
@@ -341,6 +342,8 @@ static struct cmd_t command_defs[] =
             { "count off",                      "Do not show any count with roster headers." },
             { "count zero on",                  "Show roster header count when 0." },
             { "count zero off",                 "Hide roster header count when 0." },
+            { "color on",                       "Enable generated color names (XEP-0392)" },
+            { "color off",                      "Disable generated color names (XEP-0392)" },
             { "order name",                     "Order roster contacts by name only." },
             { "order presence",                 "Order roster contacts by presence, and then by name." },
             { "unread before",                  "Show unread message count before contact." },
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 2b9acb02..d55bc762 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -2739,6 +2739,11 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
             return TRUE;
         }
 
+    } else if (g_strcmp0(args[0], "color") == 0) {
+        _cmd_set_boolean_preference(args[1], command, "Roster consistent colors", PREF_ROSTER_COLOR_NICK);
+        ui_show_roster();
+        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 a5893623..8f4c4c45 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -1711,6 +1711,7 @@ _get_group(preference_t pref)
         case PREF_CONSOLE_PRIVATE:
         case PREF_CONSOLE_CHAT:
         case PREF_COLOR_NICK:
+        case PREF_ROSTER_COLOR_NICK:
         case PREF_STATUSBAR_SHOW_NAME:
         case PREF_STATUSBAR_SHOW_NUMBER:
         case PREF_STATUSBAR_SELF:
@@ -1972,6 +1973,8 @@ _get_key(preference_t pref)
             return "console.chat";
         case PREF_COLOR_NICK:
             return "color.nick";
+        case PREF_ROSTER_COLOR_NICK:
+            return "color.roster.nick";
         case PREF_BOOKMARK_INVITE:
             return "bookmark.invite";
         case PREF_PLUGINS_SOURCEPATH:
diff --git a/src/ui/console.c b/src/ui/console.c
index 28381ba9..6beb3025 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1989,6 +1989,12 @@ 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");
+    } else {
+        cons_show("Consistent color generation in roster (/roster)               : OFF");
+    }
 }
 
 void