about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-11-18 02:02:49 +0000
committerJames Booth <boothj5@gmail.com>2015-11-18 02:02:49 +0000
commit4505102fa83e00c70d1ee15967b977957dcf3aa5 (patch)
tree9f8556fc7e9bd8c0abec75a6cca3f00c283c32de /src/ui
parentedbd2d5843fe7cefd730899aace631416715bb8f (diff)
downloadprofani-tty-4505102fa83e00c70d1ee15967b977957dcf3aa5.tar.gz
Added roster count option
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/console.c5
-rw-r--r--src/ui/rosterwin.c24
2 files changed, 26 insertions, 3 deletions
diff --git a/src/ui/console.c b/src/ui/console.c
index 03e944d0..b145aa6d 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1222,6 +1222,11 @@ 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");
+
     char *by = prefs_get_string(PREF_ROSTER_BY);
     cons_show("Roster by (/roster)           : %s", by);
     prefs_free_string(by);
diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c
index a8f24e0e..28ac25ce 100644
--- a/src/ui/rosterwin.c
+++ b/src/ui/rosterwin.c
@@ -140,7 +140,12 @@ _rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char *const prese
     // if this group has contacts, or if we want to show empty groups
     if (contacts || prefs_get_boolean(PREF_ROSTER_EMPTY)) {
         wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
-        win_printline_nowrap(layout->subwin, title);
+        GString *title_str = g_string_new(title);
+        if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
+            g_string_append_printf(title_str, " (%d)", g_slist_length(contacts));
+        }
+        win_printline_nowrap(layout->subwin, title_str->str);
+        g_string_free(title_str, TRUE);
         wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
     }
 
@@ -172,6 +177,9 @@ _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group)
         wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
         GString *title = g_string_new(" -");
         g_string_append(title, group);
+        if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
+            g_string_append_printf(title, " (%d)", g_slist_length(contacts));
+        }
         win_printline_nowrap(layout->subwin, title->str);
         g_string_free(title, TRUE);
         wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
@@ -201,7 +209,12 @@ _rosterwin_contacts_by_no_group(ProfLayoutSplit *layout)
 
     if (contacts || prefs_get_boolean(PREF_ROSTER_EMPTY)) {
         wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
-        win_printline_nowrap(layout->subwin, " -no group");
+        GString *title = g_string_new(" -no group");
+        if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
+            g_string_append_printf(title, " (%d)", g_slist_length(contacts));
+        }
+        win_printline_nowrap(layout->subwin, title->str);
+        g_string_free(title, TRUE);
         wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
 
         GSList *curr_contact = contacts;
@@ -257,7 +270,12 @@ rosterwin_roster(void)
             werase(layout->subwin);
 
             wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
-            win_printline_nowrap(layout->subwin, " -Roster");
+            GString *title = g_string_new(" -Roster");
+            if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
+                g_string_append_printf(title, " (%d)", g_slist_length(contacts));
+            }
+            win_printline_nowrap(layout->subwin, title->str);
+            g_string_free(title, TRUE);
             wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
 
             if (contacts) {