about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-01-17 02:17:12 +0000
committerJames Booth <boothj5@gmail.com>2016-01-17 02:17:12 +0000
commitcce01f1d75a43b943237a11f9695e8426425210a (patch)
tree1914184d93bfe801aa3dea3f16ea2db7a24b73be /src/ui
parente58be44f8185a0fbb43a3ee902acf21c89b158b6 (diff)
downloadprofani-tty-cce01f1d75a43b943237a11f9695e8426425210a.tar.gz
Added /roster unread preferrence
closes #712
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/console.c19
-rw-r--r--src/ui/rosterwin.c33
2 files changed, 38 insertions, 14 deletions
diff --git a/src/ui/console.c b/src/ui/console.c
index 4656b4e3..78ab8d2a 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1324,11 +1324,6 @@ cons_roster_setting(void)
     else
         cons_show("Roster priority (/roster)        : hide");
 
-    if (prefs_get_boolean(PREF_ROSTER_ROOMS))
-        cons_show("Roster rooms (/roster)           : show");
-    else
-        cons_show("Roster rooms (/roster)           : hide");
-
     char *by = prefs_get_string(PREF_ROSTER_BY);
     cons_show("Roster by (/roster)              : %s", by);
     prefs_free_string(by);
@@ -1337,6 +1332,20 @@ cons_roster_setting(void)
     cons_show("Roster order (/roster)           : %s", order);
     prefs_free_string(order);
 
+    char *unread = prefs_get_string(PREF_ROSTER_UNREAD);
+    if (g_strcmp0(unread, "before") == 0) {
+        cons_show("Roster unread (/roster)          : before");
+    } else if (g_strcmp0(unread, "after") == 0) {
+        cons_show("Roster unread (/roster)          : after");
+    } else {
+        cons_show("Roster unread (/roster)          : OFF");
+    }
+
+    if (prefs_get_boolean(PREF_ROSTER_ROOMS))
+        cons_show("Roster rooms (/roster)           : show");
+    else
+        cons_show("Roster rooms (/roster)           : hide");
+
     char *rooms_order = prefs_get_string(PREF_ROSTER_ROOMS_ORDER);
     cons_show("Roster rooms order (/roster)     : %s", rooms_order);
     prefs_free_string(rooms_order);
diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c
index 5b18ec95..7593b9ab 100644
--- a/src/ui/rosterwin.c
+++ b/src/ui/rosterwin.c
@@ -167,9 +167,11 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde
                 g_string_append_printf(msg, " %d", resource->priority);
             }
 
-            if (unread > 0) {
+            char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
+            if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) {
                 g_string_append_printf(msg, " (%d)", unread);
             }
+            prefs_free_string(unreadpos);
 
             gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
             win_sub_print(layout->subwin, msg->str, FALSE, wrap, 0);
@@ -182,7 +184,8 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde
         } else {
             gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
 
-            if (unread > 0) {
+            char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
+            if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) {
                 GString *unreadmsg = g_string_new("");
                 g_string_append_printf(unreadmsg, " (%d)", unread);
 
@@ -193,6 +196,7 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde
                 win_sub_print(layout->subwin, unreadmsg->str, FALSE, wrap, current_indent);
                 wattroff(layout->subwin, theme_attrs(presence_colour));
             }
+            prefs_free_string(unreadpos);
 
             int resource_indent = prefs_get_roster_resource_indent();
             if (resource_indent > 0) {
@@ -238,7 +242,8 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde
         theme_item_t presence_colour = _get_roster_theme(theme_type, presence);
         gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
 
-        if (unread > 0) {
+        char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
+        if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) {
             GString *unreadmsg = g_string_new("");
             g_string_append_printf(unreadmsg, " (%d)", unread);
 
@@ -246,11 +251,13 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde
             win_sub_print(layout->subwin, unreadmsg->str, FALSE, wrap, current_indent);
             wattroff(layout->subwin, theme_attrs(presence_colour));
         }
+        prefs_free_string(unreadpos);
         _rosterwin_presence(layout, presence_colour, presence, status, current_indent);
     } else {
         gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
 
-        if (unread > 0) {
+        char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
+        if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) {
             GString *unreadmsg = g_string_new("");
             g_string_append_printf(unreadmsg, " (%d)", unread);
             const char *presence = p_contact_presence(contact);
@@ -260,6 +267,7 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde
             win_sub_print(layout->subwin, unreadmsg->str, FALSE, wrap, current_indent);
             wattroff(layout->subwin, theme_attrs(presence_colour));
         }
+        prefs_free_string(unreadpos);
     }
 
     g_list_free(resources);
@@ -303,14 +311,21 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
     if (ch) {
         g_string_append_printf(msg, "%c", ch);
     }
-    g_string_append(msg, name);
 
-    if (!prefs_get_boolean(PREF_ROSTER_RESOURCE)) {
-        if (unread > 0) {
-            g_string_append_printf(msg, " (%d)", unread);
+    char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
+    if ((g_strcmp0(unreadpos, "before") == 0) && unread > 0) {
+        g_string_append_printf(msg, "(%d) ", unread);
+    }
+    g_string_append(msg, name);
+    if (g_strcmp0(unreadpos, "after") == 0) {
+        if (!prefs_get_boolean(PREF_ROSTER_RESOURCE)) {
+            if (unread > 0) {
+                g_string_append_printf(msg, " (%d)", unread);
+            }
+            unread = 0;
         }
-        unread = 0;
     }
+    prefs_free_string(unreadpos);
 
     win_sub_newline_lazy(layout->subwin);
     gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);