about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/command.c15
-rw-r--r--src/command/commands.c21
-rw-r--r--src/command/commands.h2
-rw-r--r--src/config/preferences.c5
-rw-r--r--src/config/preferences.h1
-rw-r--r--src/config/theme.c1
-rw-r--r--src/ui/console.c4
-rw-r--r--src/ui/rosterwin.c24
-rw-r--r--themes/boothj51
-rw-r--r--themes/complex1
10 files changed, 66 insertions, 9 deletions
diff --git a/src/command/command.c b/src/command/command.c
index f3c4d3bb..9052e8cf 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -283,6 +283,7 @@ static struct cmd_t command_defs[] =
             "/roster by group|presence|none",
             "/roster order name|presence",
             "/roster unread before|after|off",
+            "/roster room position first|last",
             "/roster room order name|unread",
             "/roster room unread before|after|off",
             "/roster header char <char>|none",
@@ -330,6 +331,8 @@ static struct cmd_t command_defs[] =
             { "unread before",              "Show unread message count before contact in roster." },
             { "unread after",               "Show unread message count after contact in roster." },
             { "unread off",                 "Do not show unread message count for contacts in roster." },
+            { "room position first",        "Show rooms first in roster." },
+            { "room position last",         "Show rooms last in roster." },
             { "room order name",            "Order roster rooms by name." },
             { "room order unread",          "Order roster rooms by unread messages, and then by name." },
             { "room unread before",         "Show unread message count before room in roster." },
@@ -1918,6 +1921,7 @@ static Autocomplete roster_presence_ac;
 static Autocomplete roster_char_ac;
 static Autocomplete roster_remove_all_ac;
 static Autocomplete roster_room_ac;
+static Autocomplete roster_room_position_ac;
 static Autocomplete roster_room_order_ac;
 static Autocomplete roster_unread_ac;
 static Autocomplete group_ac;
@@ -2228,6 +2232,7 @@ cmd_init(void)
     autocomplete_add(roster_unread_ac, "off");
 
     roster_room_ac = autocomplete_new();
+    autocomplete_add(roster_room_ac, "position");
     autocomplete_add(roster_room_ac, "order");
     autocomplete_add(roster_room_ac, "unread");
 
@@ -2235,6 +2240,10 @@ cmd_init(void)
     autocomplete_add(roster_room_order_ac, "name");
     autocomplete_add(roster_room_order_ac, "unread");
 
+    roster_room_position_ac = autocomplete_new();
+    autocomplete_add(roster_room_position_ac, "first");
+    autocomplete_add(roster_room_position_ac, "last");
+
     roster_remove_all_ac = autocomplete_new();
     autocomplete_add(roster_remove_all_ac, "contacts");
 
@@ -2509,6 +2518,7 @@ cmd_uninit(void)
     autocomplete_free(roster_order_ac);
     autocomplete_free(roster_room_ac);
     autocomplete_free(roster_unread_ac);
+    autocomplete_free(roster_room_position_ac);
     autocomplete_free(roster_room_order_ac);
     autocomplete_free(roster_remove_all_ac);
     autocomplete_free(group_ac);
@@ -2720,6 +2730,7 @@ cmd_reset_autocomplete(ProfWin *window)
     autocomplete_reset(roster_order_ac);
     autocomplete_reset(roster_room_ac);
     autocomplete_reset(roster_unread_ac);
+    autocomplete_reset(roster_room_position_ac);
     autocomplete_reset(roster_room_order_ac);
     autocomplete_reset(roster_remove_all_ac);
     autocomplete_reset(group_ac);
@@ -3129,6 +3140,10 @@ _roster_autocomplete(ProfWin *window, const char *const input)
     if (result) {
         return result;
     }
+    result = autocomplete_param_with_ac(input, "/roster room position", roster_room_position_ac, TRUE);
+    if (result) {
+        return result;
+    }
     result = autocomplete_param_with_ac(input, "/roster room order", roster_room_order_ac, TRUE);
     if (result) {
         return result;
diff --git a/src/command/commands.c b/src/command/commands.c
index 76904ef0..2c42835e 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -2338,7 +2338,26 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
         }
 
     } else if (g_strcmp0(args[0], "room") == 0) {
-        if (g_strcmp0(args[1], "order") == 0) {
+        if (g_strcmp0(args[1], "position") == 0) {
+            if (g_strcmp0(args[2], "first") == 0) {
+                cons_show("Showing rooms first in roster.");
+                prefs_set_string(PREF_ROSTER_ROOMS_POS, "first");
+                if (conn_status == JABBER_CONNECTED) {
+                    rosterwin_roster();
+                }
+                return TRUE;
+            } else if (g_strcmp0(args[2], "last") == 0) {
+                cons_show("Showing rooms last in roster.");
+                prefs_set_string(PREF_ROSTER_ROOMS_POS, "last");
+                if (conn_status == JABBER_CONNECTED) {
+                    rosterwin_roster();
+                }
+                return TRUE;
+            } else {
+                cons_bad_cmd_usage(command);
+                return TRUE;
+            }
+        } else if (g_strcmp0(args[1], "order") == 0) {
             if (g_strcmp0(args[2], "name") == 0) {
                 cons_show("Ordering roster rooms by name");
                 prefs_set_string(PREF_ROSTER_ROOMS_ORDER, "name");
diff --git a/src/command/commands.h b/src/command/commands.h
index 69d7ea89..5972e224 100644
--- a/src/command/commands.h
+++ b/src/command/commands.h
@@ -42,7 +42,7 @@ typedef struct cmd_help_t {
     const gchar *tags[20];
     const gchar *synopsis[50];
     const gchar *desc;
-    const gchar *args[50][2];
+    const gchar *args[64][2];
     const gchar *examples[20];
 } CommandHelp;
 
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 54bc5516..15b7be45 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -1048,6 +1048,7 @@ _get_group(preference_t pref)
         case PREF_ROSTER_WRAP:
         case PREF_ROSTER_RESOURCE_JOIN:
         case PREF_ROSTER_ROOMS:
+        case PREF_ROSTER_ROOMS_POS:
         case PREF_ROSTER_ROOMS_ORDER:
         case PREF_ROSTER_ROOMS_UNREAD:
         case PREF_RESOURCE_TITLE:
@@ -1248,6 +1249,8 @@ _get_key(preference_t pref)
             return "roster.resource.join";
         case PREF_ROSTER_ROOMS:
             return "roster.rooms";
+        case PREF_ROSTER_ROOMS_POS:
+            return "roster.rooms.pos";
         case PREF_ROSTER_ROOMS_ORDER:
             return "roster.rooms.order";
         case PREF_ROSTER_ROOMS_UNREAD:
@@ -1341,6 +1344,8 @@ _get_default_string(preference_t pref)
             return "presence";
         case PREF_ROSTER_UNREAD:
             return "after";
+        case PREF_ROSTER_ROOMS_POS:
+            return "last";
         case PREF_ROSTER_ROOMS_ORDER:
             return "name";
         case PREF_ROSTER_ROOMS_UNREAD:
diff --git a/src/config/preferences.h b/src/config/preferences.h
index df6cd482..a7884f16 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -75,6 +75,7 @@ typedef enum {
     PREF_ROSTER_WRAP,
     PREF_ROSTER_RESOURCE_JOIN,
     PREF_ROSTER_ROOMS,
+    PREF_ROSTER_ROOMS_POS,
     PREF_ROSTER_ROOMS_ORDER,
     PREF_ROSTER_ROOMS_UNREAD,
     PREF_MUC_PRIVILEGES,
diff --git a/src/config/theme.c b/src/config/theme.c
index 6ba31107..fe176ab9 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -323,6 +323,7 @@ _load_preferences(void)
     _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);
+    _set_string_preference("roster.rooms.pos", PREF_ROSTER_ROOMS_POS);
     if (g_key_file_has_key(theme, "ui", "roster.size", NULL)) {
         gint roster_size = g_key_file_get_integer(theme, "ui", "roster.size", NULL);
         prefs_set_roster_size(roster_size);
diff --git a/src/ui/console.c b/src/ui/console.c
index 78ab8d2a..76adc58a 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1346,6 +1346,10 @@ cons_roster_setting(void)
     else
         cons_show("Roster rooms (/roster)           : hide");
 
+    char *rooms_pos = prefs_get_string(PREF_ROSTER_ROOMS_POS);
+    cons_show("Roster rooms position (/roster)  : %s", rooms_pos);
+    prefs_free_string(rooms_pos);
+
     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 7593b9ab..2771420b 100644
--- a/src/ui/rosterwin.c
+++ b/src/ui/rosterwin.c
@@ -315,6 +315,7 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
     char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
     if ((g_strcmp0(unreadpos, "before") == 0) && unread > 0) {
         g_string_append_printf(msg, "(%d) ", unread);
+        unread = 0;
     }
     g_string_append(msg, name);
     if (g_strcmp0(unreadpos, "after") == 0) {
@@ -604,11 +605,18 @@ rosterwin_roster(void)
 
     ProfLayoutSplit *layout = (ProfLayoutSplit*)console->layout;
     assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK);
+    werase(layout->subwin);
+
+    gboolean newline = FALSE;
+    char *roomspos = prefs_get_string(PREF_ROSTER_ROOMS_POS);
+    if (prefs_get_boolean(PREF_ROSTER_ROOMS) && (g_strcmp0(roomspos, "first") == 0)) {
+        _rosterwin_rooms(layout, newline);
+        newline = TRUE;
+    }
 
     char *by = prefs_get_string(PREF_ROSTER_BY);
     if (g_strcmp0(by, "presence") == 0) {
-        werase(layout->subwin);
-        _rosterwin_contacts_by_presence(layout, "chat", "Available for chat", FALSE);
+        _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);
@@ -617,8 +625,6 @@ rosterwin_roster(void)
             _rosterwin_contacts_by_presence(layout, "offline", "Offline", TRUE);
         }
     } else if (g_strcmp0(by, "group") == 0) {
-        werase(layout->subwin);
-        gboolean newline = FALSE;
         GSList *groups = roster_get_groups();
         GSList *curr_group = groups;
         while (curr_group) {
@@ -640,14 +646,16 @@ rosterwin_roster(void)
         }
         prefs_free_string(order);
 
-        werase(layout->subwin);
-
         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);
+        }
+
         g_string_append(title, "Roster");
         if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
             g_string_append_printf(title, " (%d)", g_slist_length(contacts));
@@ -669,7 +677,9 @@ rosterwin_roster(void)
     }
     prefs_free_string(by);
 
-    if (prefs_get_boolean(PREF_ROSTER_ROOMS)) {
+    if (prefs_get_boolean(PREF_ROSTER_ROOMS) && (g_strcmp0(roomspos, "last") == 0)) {
         _rosterwin_rooms(layout, TRUE);
     }
+
+    prefs_free_string(roomspos);
 }
diff --git a/themes/boothj5 b/themes/boothj5
index c01354fa..ce998ca3 100644
--- a/themes/boothj5
+++ b/themes/boothj5
@@ -113,6 +113,7 @@ roster.status=true
 roster.rooms=true
 roster.rooms.order=name
 roster.rooms.unread=before
+roster.rooms.pos=last
 occupants=true
 occupants.size=15
 occupants.jid=false
diff --git a/themes/complex b/themes/complex
index b509e242..7f2ee7c1 100644
--- a/themes/complex
+++ b/themes/complex
@@ -41,6 +41,7 @@ roster.status=true
 roster.rooms=true
 roster.rooms.order=unread
 roster.rooms.unread=after
+roster.rooms.pos=last
 privileges=true
 presence=true
 intype=true