about summary refs log tree commit diff stats
path: root/src/ui/occupantswin.c
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-12-19 19:14:59 +0100
committerMichael Vetter <jubalh@iodoru.org>2019-12-19 19:14:59 +0100
commit808850c6f5c85b0e173e922b9979ca3a09b4dc31 (patch)
treeef37d004827224fe8662b3b850d21888a950a230 /src/ui/occupantswin.c
parent6d82020a66505e9c58b26091684e5f78ac71d210 (diff)
downloadprofani-tty-808850c6f5c85b0e173e922b9979ca3a09b4dc31.tar.gz
Add /occupants color command
`/occupants color on|off` to enable or disable XEP-0392 also for the
MUC occupants.

Regards
https://github.com/profanity-im/profanity/issues/1191
Diffstat (limited to 'src/ui/occupantswin.c')
-rw-r--r--src/ui/occupantswin.c22
1 files changed, 18 insertions, 4 deletions
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