about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/command/command.c3
-rw-r--r--src/command/commands.c14
-rw-r--r--src/config/preferences.c4
-rw-r--r--src/config/preferences.h1
-rw-r--r--src/config/theme.c1
-rw-r--r--src/ui/console.c5
-rw-r--r--src/ui/rosterwin.c12
7 files changed, 36 insertions, 4 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 105e41e5..8ed3a3b6 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -196,9 +196,11 @@ static struct cmd_t command_defs[] =
           "show           : Show the roster panel.",
           "show offline   : Show offline contacts in the roster panel.",
           "show resource  : Show contact's connected resources in the roster panel.",
+          "show empty     : When grouping by presence, show empty presence groups",
           "hide           : Hide the roster panel.",
           "hide offline   : Hide offline contacts in the roster panel.",
           "hide resource  : Hide contact's connected resources in the roster panel.",
+          "hide empty     : When grouping by presence, hide empty presence groups",
           "by group       : Group contacts in the roster panel by roster group.",
           "by presence    : Group contacts in the roster panel by presence.",
           "by none        : No grouping in the roster panel.",
@@ -1439,6 +1441,7 @@ cmd_init(void)
     roster_option_ac = autocomplete_new();
     autocomplete_add(roster_option_ac, "offline");
     autocomplete_add(roster_option_ac, "resource");
+    autocomplete_add(roster_option_ac, "empty");
 
     roster_by_ac = autocomplete_new();
     autocomplete_add(roster_by_ac, "group");
diff --git a/src/command/commands.c b/src/command/commands.c
index 7f13d5f5..8c071048 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1578,6 +1578,13 @@ cmd_roster(ProfWin *window, gchar **args, struct cmd_help_t help)
                 rosterwin_roster();
             }
             return TRUE;
+        } else if (g_strcmp0(args[1], "empty") == 0) {
+            cons_show("Roster empty enabled");
+            prefs_set_boolean(PREF_ROSTER_EMPTY, TRUE);
+            if (conn_status == JABBER_CONNECTED) {
+                rosterwin_roster();
+            }
+            return TRUE;
         } else {
             cons_show("Usage: %s", help.usage);
             return TRUE;
@@ -1604,6 +1611,13 @@ cmd_roster(ProfWin *window, gchar **args, struct cmd_help_t help)
                 rosterwin_roster();
             }
             return TRUE;
+        } else if (g_strcmp0(args[1], "empty") == 0) {
+            cons_show("Roster empty disabled");
+            prefs_set_boolean(PREF_ROSTER_EMPTY, FALSE);
+            if (conn_status == JABBER_CONNECTED) {
+                rosterwin_roster();
+            }
+            return TRUE;
         } else {
             cons_show("Usage: %s", help.usage);
             return TRUE;
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 43ddae6b..3662c4ca 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -522,6 +522,7 @@ _get_group(preference_t pref)
         case PREF_ROSTER:
         case PREF_ROSTER_OFFLINE:
         case PREF_ROSTER_RESOURCE:
+        case PREF_ROSTER_EMPTY:
         case PREF_ROSTER_BY:
         case PREF_RESOURCE_TITLE:
         case PREF_RESOURCE_MESSAGE:
@@ -676,6 +677,8 @@ _get_key(preference_t pref)
             return "roster.offline";
         case PREF_ROSTER_RESOURCE:
             return "roster.resource";
+        case PREF_ROSTER_EMPTY:
+            return "roster.empty";
         case PREF_ROSTER_BY:
             return "roster.by";
         case PREF_RESOURCE_TITLE:
@@ -723,6 +726,7 @@ _get_default_boolean(preference_t pref)
         case PREF_ROSTER:
         case PREF_ROSTER_OFFLINE:
         case PREF_ROSTER_RESOURCE:
+        case PREF_ROSTER_EMPTY:
             return TRUE;
         default:
             return FALSE;
diff --git a/src/config/preferences.h b/src/config/preferences.h
index 9e8d2898..933f7991 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -65,6 +65,7 @@ typedef enum {
     PREF_ROSTER_SIZE,
     PREF_ROSTER_OFFLINE,
     PREF_ROSTER_RESOURCE,
+    PREF_ROSTER_EMPTY,
     PREF_ROSTER_BY,
     PREF_MUC_PRIVILEGES,
     PREF_PRESENCE,
diff --git a/src/config/theme.c b/src/config/theme.c
index d870b371..ee6bd73f 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -452,6 +452,7 @@ _load_preferences(void)
     _set_boolean_preference("roster", PREF_ROSTER);
     _set_boolean_preference("roster.offline", PREF_ROSTER_OFFLINE);
     _set_boolean_preference("roster.resource", PREF_ROSTER_RESOURCE);
+    _set_boolean_preference("roster.empty", PREF_ROSTER_EMPTY);
     _set_string_preference("roster.by", PREF_ROSTER_BY);
     if (g_key_file_has_key(theme, "ui", "roster.size", NULL)) {
         gint roster_size = g_key_file_get_integer(theme, "ui", "roster.size", NULL);
diff --git a/src/ui/console.c b/src/ui/console.c
index 8bf873a5..ceb02e08 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1039,6 +1039,11 @@ cons_roster_setting(void)
     else
         cons_show("Roster resource (/roster)     : hide");
 
+    if (prefs_get_boolean(PREF_ROSTER_EMPTY))
+        cons_show("Roster empty (/roster)        : show");
+    else
+        cons_show("Roster empty (/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 db9a4af6..e48be866 100644
--- a/src/ui/rosterwin.c
+++ b/src/ui/rosterwin.c
@@ -84,11 +84,15 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
 static void
 _rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char * const presence, char *title)
 {
-    wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
-    win_printline_nowrap(layout->subwin, title);
-    wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
-
     GSList *contacts = roster_get_contacts_by_presence(presence);
+
+    // 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);
+        wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
+    }
+
     if (contacts) {
         GSList *curr_contact = contacts;
         while (curr_contact) {