about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-01-20 01:48:41 +0000
committerJames Booth <boothj5@gmail.com>2016-01-20 01:48:41 +0000
commit5bccee93cc0c8c2426d5f5acc462dca15467cb08 (patch)
treee96737b02a68115dfb15ca588772241d7cc7de99
parent10507b687b21a6827f0a60d6c92a778bdc91070b (diff)
downloadprofani-tty-5bccee93cc0c8c2426d5f5acc462dca15467cb08.tar.gz
Added /roster show|hide contacts
-rw-r--r--src/command/command.c7
-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.c112
-rw-r--r--theme_template2
-rw-r--r--themes/boothj51
-rw-r--r--themes/complex1
-rw-r--r--themes/simple1
11 files changed, 92 insertions, 57 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 9052e8cf..8bda6d4b 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -278,8 +278,8 @@ static struct cmd_t command_defs[] =
         CMD_SYN(
             "/roster",
             "/roster online",
-            "/roster show [offline|resource|presence|status|empty|count|priority|rooms]",
-            "/roster hide [offline|resource|presence|status|empty|count|priority|rooms]",
+            "/roster show [offline|resource|presence|status|empty|count|priority|contacts|rooms]",
+            "/roster hide [offline|resource|presence|status|empty|count|priority|contacts|rooms]",
             "/roster by group|presence|none",
             "/roster order name|presence",
             "/roster unread before|after|off",
@@ -313,6 +313,7 @@ static struct cmd_t command_defs[] =
             { "show empty",                 "When grouping by presence, show empty presence groups." },
             { "show count",                 "Show number of contacts in group/presence." },
             { "show priority",              "Show resource priority." },
+            { "show contacts",              "Show contacts in roster panel." },
             { "show rooms",                 "Show chat rooms in roster panel." },
             { "hide",                       "Hide the roster panel." },
             { "hide offline",               "Hide offline contacts in the roster panel." },
@@ -322,6 +323,7 @@ static struct cmd_t command_defs[] =
             { "hide empty",                 "When grouping by presence, hide empty presence groups." },
             { "hide count",                 "Hide number of contacts in group/presence." },
             { "hide priority",              "Hide resource priority." },
+            { "hide contacts",              "Hide contacts in roster panel." },
             { "hide rooms",                 "Hide chat rooms in roster panel." },
             { "by group",                   "Group contacts in the roster panel by roster group." },
             { "by presence",                "Group contacts in the roster panel by presence." },
@@ -2215,6 +2217,7 @@ cmd_init(void)
     autocomplete_add(roster_show_ac, "empty");
     autocomplete_add(roster_show_ac, "count");
     autocomplete_add(roster_show_ac, "priority");
+    autocomplete_add(roster_show_ac, "contacts");
     autocomplete_add(roster_show_ac, "rooms");
 
     roster_by_ac = autocomplete_new();
diff --git a/src/command/commands.c b/src/command/commands.c
index 2c42835e..ba84b4bc 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -2181,6 +2181,13 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
                 rosterwin_roster();
             }
             return TRUE;
+        } else if (g_strcmp0(args[1], "contacts") == 0) {
+            cons_show("Roster contacts enabled");
+            prefs_set_boolean(PREF_ROSTER_CONTACTS, TRUE);
+            if (conn_status == JABBER_CONNECTED) {
+                rosterwin_roster();
+            }
+            return TRUE;
         } else if (g_strcmp0(args[1], "rooms") == 0) {
             cons_show("Roster rooms enabled");
             prefs_set_boolean(PREF_ROSTER_ROOMS, TRUE);
@@ -2249,6 +2256,13 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
                 rosterwin_roster();
             }
             return TRUE;
+        } else if (g_strcmp0(args[1], "contacts") == 0) {
+            cons_show("Roster contacts disabled");
+            prefs_set_boolean(PREF_ROSTER_CONTACTS, FALSE);
+            if (conn_status == JABBER_CONNECTED) {
+                rosterwin_roster();
+            }
+            return TRUE;
         } else if (g_strcmp0(args[1], "rooms") == 0) {
             cons_show("Roster rooms disabled");
             prefs_set_boolean(PREF_ROSTER_ROOMS, FALSE);
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 15b7be45..02bf959e 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -1047,6 +1047,7 @@ _get_group(preference_t pref)
         case PREF_ROSTER_PRIORITY:
         case PREF_ROSTER_WRAP:
         case PREF_ROSTER_RESOURCE_JOIN:
+        case PREF_ROSTER_CONTACTS:
         case PREF_ROSTER_ROOMS:
         case PREF_ROSTER_ROOMS_POS:
         case PREF_ROSTER_ROOMS_ORDER:
@@ -1247,6 +1248,8 @@ _get_key(preference_t pref)
             return "roster.wrap";
         case PREF_ROSTER_RESOURCE_JOIN:
             return "roster.resource.join";
+        case PREF_ROSTER_CONTACTS:
+            return "roster.contacts";
         case PREF_ROSTER_ROOMS:
             return "roster.rooms";
         case PREF_ROSTER_ROOMS_POS:
@@ -1312,6 +1315,7 @@ _get_default_boolean(preference_t pref)
         case PREF_ROSTER_COUNT:
         case PREF_ROSTER_PRIORITY:
         case PREF_ROSTER_RESOURCE_JOIN:
+        case PREF_ROSTER_CONTACTS:
         case PREF_ROSTER_ROOMS:
         case PREF_TLS_SHOW:
         case PREF_LASTACTIVITY:
diff --git a/src/config/preferences.h b/src/config/preferences.h
index a7884f16..b8b77040 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -74,6 +74,7 @@ typedef enum {
     PREF_ROSTER_PRIORITY,
     PREF_ROSTER_WRAP,
     PREF_ROSTER_RESOURCE_JOIN,
+    PREF_ROSTER_CONTACTS,
     PREF_ROSTER_ROOMS,
     PREF_ROSTER_ROOMS_POS,
     PREF_ROSTER_ROOMS_ORDER,
diff --git a/src/config/theme.c b/src/config/theme.c
index fe176ab9..3d28a129 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -320,6 +320,7 @@ _load_preferences(void)
     _set_string_preference("roster.unread", PREF_ROSTER_UNREAD);
     _set_boolean_preference("roster.count", PREF_ROSTER_COUNT);
     _set_boolean_preference("roster.priority", PREF_ROSTER_PRIORITY);
+    _set_boolean_preference("roster.contacts", PREF_ROSTER_CONTACTS);
     _set_boolean_preference("roster.rooms", PREF_ROSTER_ROOMS);
     _set_string_preference("roster.rooms.order", PREF_ROSTER_ROOMS_ORDER);
     _set_string_preference("roster.rooms.unread", PREF_ROSTER_ROOMS_UNREAD);
diff --git a/src/ui/console.c b/src/ui/console.c
index 76adc58a..39de1ae7 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1324,6 +1324,11 @@ cons_roster_setting(void)
     else
         cons_show("Roster priority (/roster)        : hide");
 
+    if (prefs_get_boolean(PREF_ROSTER_CONTACTS))
+        cons_show("Roster contacts (/roster)        : show");
+    else
+        cons_show("Roster contacts (/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 2771420b..86472d48 100644
--- a/src/ui/rosterwin.c
+++ b/src/ui/rosterwin.c
@@ -614,68 +614,70 @@ rosterwin_roster(void)
         newline = TRUE;
     }
 
-    char *by = prefs_get_string(PREF_ROSTER_BY);
-    if (g_strcmp0(by, "presence") == 0) {
-        _rosterwin_contacts_by_presence(layout, "chat", "Available for chat", newline);
-        _rosterwin_contacts_by_presence(layout, "online", "Online", TRUE);
-        _rosterwin_contacts_by_presence(layout, "away", "Away", TRUE);
-        _rosterwin_contacts_by_presence(layout, "xa", "Extended Away", TRUE);
-        _rosterwin_contacts_by_presence(layout, "dnd", "Do not disturb", TRUE);
-        if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) {
-            _rosterwin_contacts_by_presence(layout, "offline", "Offline", TRUE);
-        }
-    } else if (g_strcmp0(by, "group") == 0) {
-        GSList *groups = roster_get_groups();
-        GSList *curr_group = groups;
-        while (curr_group) {
-            _rosterwin_contacts_by_group(layout, curr_group->data, newline);
-            newline = TRUE;
-            curr_group = g_slist_next(curr_group);
-        }
-        g_slist_free_full(groups, free);
-        _rosterwin_contacts_by_no_group(layout, newline);
-    } else {
-        GSList *contacts = NULL;
-
-        char *order = prefs_get_string(PREF_ROSTER_ORDER);
-        gboolean offline = prefs_get_boolean(PREF_ROSTER_OFFLINE);
-        if (g_strcmp0(order, "presence") == 0) {
-            contacts = roster_get_contacts(ROSTER_ORD_PRESENCE, offline);
+    if (prefs_get_boolean(PREF_ROSTER_CONTACTS)) {
+        char *by = prefs_get_string(PREF_ROSTER_BY);
+        if (g_strcmp0(by, "presence") == 0) {
+            _rosterwin_contacts_by_presence(layout, "chat", "Available for chat", newline);
+            _rosterwin_contacts_by_presence(layout, "online", "Online", TRUE);
+            _rosterwin_contacts_by_presence(layout, "away", "Away", TRUE);
+            _rosterwin_contacts_by_presence(layout, "xa", "Extended Away", TRUE);
+            _rosterwin_contacts_by_presence(layout, "dnd", "Do not disturb", TRUE);
+            if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) {
+                _rosterwin_contacts_by_presence(layout, "offline", "Offline", TRUE);
+            }
+        } else if (g_strcmp0(by, "group") == 0) {
+            GSList *groups = roster_get_groups();
+            GSList *curr_group = groups;
+            while (curr_group) {
+                _rosterwin_contacts_by_group(layout, curr_group->data, newline);
+                newline = TRUE;
+                curr_group = g_slist_next(curr_group);
+            }
+            g_slist_free_full(groups, free);
+            _rosterwin_contacts_by_no_group(layout, newline);
         } else {
-            contacts = roster_get_contacts(ROSTER_ORD_NAME, offline);
-        }
-        prefs_free_string(order);
+            GSList *contacts = NULL;
 
-        wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
-        GString *title = g_string_new(" ");
-        char ch = prefs_get_roster_header_char();
-        if (ch) {
-            g_string_append_printf(title, "%c", ch);
-        }
-        if (newline) {
-            win_sub_newline_lazy(layout->subwin);
-        }
+            char *order = prefs_get_string(PREF_ROSTER_ORDER);
+            gboolean offline = prefs_get_boolean(PREF_ROSTER_OFFLINE);
+            if (g_strcmp0(order, "presence") == 0) {
+                contacts = roster_get_contacts(ROSTER_ORD_PRESENCE, offline);
+            } else {
+                contacts = roster_get_contacts(ROSTER_ORD_NAME, offline);
+            }
+            prefs_free_string(order);
 
-        g_string_append(title, "Roster");
-        if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
-            g_string_append_printf(title, " (%d)", g_slist_length(contacts));
-        }
-        gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
-        win_sub_print(layout->subwin, title->str, FALSE, wrap, 1);
-        g_string_free(title, TRUE);
-        wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
+            wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
+            GString *title = g_string_new(" ");
+            char ch = prefs_get_roster_header_char();
+            if (ch) {
+                g_string_append_printf(title, "%c", ch);
+            }
+            if (newline) {
+                win_sub_newline_lazy(layout->subwin);
+            }
 
-        if (contacts) {
-            GSList *curr_contact = contacts;
-            while (curr_contact) {
-                PContact contact = curr_contact->data;
-                _rosterwin_contact(layout, contact);
-                curr_contact = g_slist_next(curr_contact);
+            g_string_append(title, "Roster");
+            if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
+                g_string_append_printf(title, " (%d)", g_slist_length(contacts));
             }
+            gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
+            win_sub_print(layout->subwin, title->str, FALSE, wrap, 1);
+            g_string_free(title, TRUE);
+            wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
+
+            if (contacts) {
+                GSList *curr_contact = contacts;
+                while (curr_contact) {
+                    PContact contact = curr_contact->data;
+                    _rosterwin_contact(layout, contact);
+                    curr_contact = g_slist_next(curr_contact);
+                }
+            }
+            g_slist_free(contacts);
         }
-        g_slist_free(contacts);
+        prefs_free_string(by);
     }
-    prefs_free_string(by);
 
     if (prefs_get_boolean(PREF_ROSTER_ROOMS) && (g_strcmp0(roomspos, "last") == 0)) {
         _rosterwin_rooms(layout, TRUE);
diff --git a/theme_template b/theme_template
index 70d2a765..2ae5d9c1 100644
--- a/theme_template
+++ b/theme_template
@@ -111,9 +111,11 @@ roster.resource.join=
 roster.presence=
 roster.presence.indent=
 roster.status=
+roster.contacts=
 roster.rooms=
 roster.rooms.order=
 roster.rooms.unread=
+roster.rooms.pos=
 occupants=
 occupants.size=
 occupants.jid=
diff --git a/themes/boothj5 b/themes/boothj5
index ce998ca3..0576fc91 100644
--- a/themes/boothj5
+++ b/themes/boothj5
@@ -110,6 +110,7 @@ roster.resource.join=true
 roster.presence=true
 roster.presence.indent=-1
 roster.status=true
+roster.contacts=true
 roster.rooms=true
 roster.rooms.order=name
 roster.rooms.unread=before
diff --git a/themes/complex b/themes/complex
index 7f2ee7c1..a63ab8ea 100644
--- a/themes/complex
+++ b/themes/complex
@@ -38,6 +38,7 @@ roster.resource.join=false
 roster.presence=true
 roster.presence.indent=1
 roster.status=true
+roster.contacts=true
 roster.rooms=true
 roster.rooms.order=unread
 roster.rooms.unread=after
diff --git a/themes/simple b/themes/simple
index debfe45a..79914b5e 100644
--- a/themes/simple
+++ b/themes/simple
@@ -31,6 +31,7 @@ roster.contact.indent=0
 roster.resource=false
 roster.presence=false
 roster.status=false
+roster.contacts=true
 roster.rooms=false
 roster.rooms.unread=off
 privileges=false