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.c5
-rw-r--r--src/command/commands.c16
-rw-r--r--src/config/preferences.c22
-rw-r--r--src/config/preferences.h2
-rw-r--r--src/ui/console.c3
-rw-r--r--src/ui/rosterwin.c22
6 files changed, 61 insertions, 9 deletions
diff --git a/src/command/command.c b/src/command/command.c
index aaf0c555..37e963c9 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -282,6 +282,7 @@ static struct cmd_t command_defs[] =
             "/roster char contact <char>|none",
             "/roster indent contact <indent>",
             "/roster indent resource <indent>",
+            "/roster indent presence <indent>",
             "/roster size <percent>",
             "/roster add <jid> [<nick>]",
             "/roster remove <jid>",
@@ -319,7 +320,8 @@ static struct cmd_t command_defs[] =
             { "char contact <char>",        "Prefix roster contacts with specificed character." },
             { "char contact none",          "Remove roster contact character prefix." },
             { "indent contact <indent>",    "Indent contact line by <indent> spaces." },
-            { "indent resource <indent>",   "Indent roster line by <indent> spaces." },
+            { "indent resource <indent>",   "Indent resource line by <indent> spaces." },
+            { "indent presence <indent>",   "Indent presence line by <indent> spaces." },
             { "size <precent>",             "Percentage of the screen taken up by the roster (1-99)." },
             { "add <jid> [<nick>]",         "Add a new item to the roster." },
             { "remove <jid>",               "Removes an item from the roster." },
@@ -2050,6 +2052,7 @@ cmd_init(void)
     roster_indent_ac = autocomplete_new();
     autocomplete_add(roster_indent_ac, "contact");
     autocomplete_add(roster_indent_ac, "resource");
+    autocomplete_add(roster_indent_ac, "presence");
 
     roster_option_ac = autocomplete_new();
     autocomplete_add(roster_option_ac, "offline");
diff --git a/src/command/commands.c b/src/command/commands.c
index 8de6a6df..18fa1bd9 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1815,6 +1815,22 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
                     free(err_msg);
                 }
             }
+        } else if (g_strcmp0(args[1], "presence") == 0) {
+            if (!args[2]) {
+                cons_bad_cmd_usage(command);
+            } else {
+                int intval = 0;
+                char *err_msg = NULL;
+                gboolean res = strtoi_range(args[2], &intval, 0, 10, &err_msg);
+                if (res) {
+                    prefs_set_roster_presence_indent(intval);
+                    cons_show("Roster presence indent set to: %d", intval);
+                    rosterwin_roster();
+                } else {
+                    cons_show(err_msg);
+                    free(err_msg);
+                }
+            }
         } else {
             cons_bad_cmd_usage(command);
         }
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 1de2ac64..d1adfdc4 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -550,6 +550,28 @@ prefs_set_roster_resource_indent(gint value)
     _save_prefs();
 }
 
+gint
+prefs_get_roster_presence_indent(void)
+{
+    if (!g_key_file_has_key(prefs, PREF_GROUP_UI, "roster.presence.indent", NULL)) {
+        return 2;
+    }
+
+    gint result = g_key_file_get_integer(prefs, PREF_GROUP_UI, "roster.presence.indent", NULL);
+    if (result < 0) {
+        result = 0;
+    }
+
+    return result;
+}
+
+void
+prefs_set_roster_presence_indent(gint value)
+{
+    g_key_file_set_integer(prefs, PREF_GROUP_UI, "roster.presence.indent", value);
+    _save_prefs();
+}
+
 gboolean
 prefs_add_alias(const char *const name, const char *const value)
 {
diff --git a/src/config/preferences.h b/src/config/preferences.h
index 8daa0a99..02ea8505 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -176,6 +176,8 @@ gint prefs_get_roster_contact_indent(void);
 void prefs_set_roster_contact_indent(gint value);
 gint prefs_get_roster_resource_indent(void);
 void prefs_set_roster_resource_indent(gint value);
+gint prefs_get_roster_presence_indent(void);
+void prefs_set_roster_presence_indent(gint value);
 
 void prefs_add_login(const char *jid);
 
diff --git a/src/ui/console.c b/src/ui/console.c
index c72a34ea..5f1b5ec4 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1260,6 +1260,9 @@ cons_roster_setting(void)
 
     gint resource_indent = prefs_get_roster_resource_indent();
     cons_show("Roster resource indent (/roster) : %d", resource_indent);
+
+    gint presence_indent = prefs_get_roster_presence_indent();
+    cons_show("Roster presence indent (/roster) : %d", presence_indent);
 }
 
 void
diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c
index b0cc317f..cc31ef55 100644
--- a/src/ui/rosterwin.c
+++ b/src/ui/rosterwin.c
@@ -43,7 +43,8 @@
 #include "roster_list.h"
 
 static void
-_rosterwin_presence(ProfLayoutSplit *layout, int indent, theme_item_t colour, const char *presence, const char *status)
+_rosterwin_presence(ProfLayoutSplit *layout, theme_item_t colour, const char *presence, const char *status,
+    int current_indent)
 {
     // don't show presence for offline contacts
     gboolean is_offline = g_strcmp0(presence, "offline") == 0;
@@ -55,14 +56,19 @@ _rosterwin_presence(ProfLayoutSplit *layout, int indent, theme_item_t colour, co
     gboolean by_presence = g_strcmp0(by, "presence") == 0;
     prefs_free_string(by);
 
+    int presence_indent = prefs_get_roster_presence_indent();
+    if (presence_indent > 0) {
+        current_indent += presence_indent;
+    }
+
     // show only status when grouped by presence
     if (by_presence) {
         if (status && prefs_get_boolean(PREF_ROSTER_STATUS)) {
             wattron(layout->subwin, theme_attrs(colour));
             GString *msg = g_string_new(" ");
-            while (indent > 0) {
+            while (current_indent > 0) {
                 g_string_append(msg, " ");
-                indent--;
+                current_indent--;
             }
             g_string_append_printf(msg, "\"%s\"", status);
             win_print_nowrap(layout->subwin, msg->str, TRUE);
@@ -74,9 +80,9 @@ _rosterwin_presence(ProfLayoutSplit *layout, int indent, theme_item_t colour, co
     } else if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || (status && prefs_get_boolean(PREF_ROSTER_STATUS))) {
         wattron(layout->subwin, theme_attrs(colour));
         GString *msg = g_string_new(" ");
-        while (indent > 0) {
+        while (current_indent > 0) {
             g_string_append(msg, " ");
-            indent--;
+            current_indent--;
         }
         if (prefs_get_boolean(PREF_ROSTER_PRESENCE)) {
             g_string_append(msg, presence);
@@ -124,7 +130,7 @@ _rosterwin_resource(ProfLayoutSplit *layout, PContact contact, int current_inden
             wattroff(layout->subwin, theme_attrs(resource_presence_colour));
 
             if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || prefs_get_boolean(PREF_ROSTER_STATUS)) {
-                _rosterwin_presence(layout, 6, resource_presence_colour, resource_presence, resource->status);
+                _rosterwin_presence(layout, resource_presence_colour, resource_presence, resource->status, current_indent);
             }
 
             curr_resource = g_list_next(curr_resource);
@@ -133,7 +139,7 @@ _rosterwin_resource(ProfLayoutSplit *layout, PContact contact, int current_inden
         const char *presence = p_contact_presence(contact);
         const char *status = p_contact_status(contact);
         theme_item_t presence_colour = theme_main_presence_attrs(presence);
-        _rosterwin_presence(layout, 4, presence_colour, presence, status);
+        _rosterwin_presence(layout, presence_colour, presence, status, current_indent);
     }
     g_list_free(resources);
 
@@ -171,7 +177,7 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
     if (prefs_get_boolean(PREF_ROSTER_RESOURCE)) {
         _rosterwin_resource(layout, contact, current_indent);
     } else if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || prefs_get_boolean(PREF_ROSTER_STATUS)) {
-        _rosterwin_presence(layout, 4, presence_colour, presence, status);
+        _rosterwin_presence(layout, presence_colour, presence, status, current_indent);
     }
 }