changeset 2007:6c02ccb14c1c

Added an option to remove the extra space before items in the roster.
author Simon Jacquin <simon@jacquin.me>
date Fri, 27 Jan 2012 21:07:56 +0100
parents aa7e03c35488
children 0d5ece2324c6
files mcabber/mcabber/screen.c mcabber/mcabberrc.example
diffstat 2 files changed, 25 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/mcabber/screen.c	Thu Jan 26 10:11:03 2012 +0100
+++ b/mcabber/mcabber/screen.c	Fri Jan 27 21:07:56 2012 +0100
@@ -127,6 +127,7 @@
 static int chatmode;
 static int multimode;
 static char *multiline, *multimode_subj;
+static int no_space_before_items;
 
 static bool Curses;
 static bool log_win_on_top;
@@ -1544,6 +1545,8 @@
   int chat_y_pos, chatstatus_y_pos, log_y_pos;
   int roster_x_pos, chat_x_pos;
 
+  no_space_before_items = settings_opt_get_int("no_space_before_items");
+
   Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT;
   requested_size = settings_opt_get_int("log_win_height");
   if (requested_size > 0) {
@@ -1943,6 +1946,8 @@
   char status, pending;
   enum imstatus currentstatus = xmpp_getstatus();
   int x_pos;
+  char *space;
+  int prefix_length;
 
   // We can reset update_roster
   update_roster = FALSE;
@@ -1999,6 +2004,14 @@
   else
     x_pos = 0;
 
+  space = g_new0(char, 2);
+  if (no_space_before_items) {
+    space[0] = '\0';
+    prefix_length = 6;
+  } else {
+    prefix_length = 7;
+  }
+
   name = g_new0(char, 4*Roster_Width);
   rline = g_new0(char, 4*Roster_Width+1);
 
@@ -2089,8 +2102,8 @@
       }
     }
 
-    if (Roster_Width > 7)
-      g_utf8_strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-7);
+    if (Roster_Width > prefix_length)
+      g_utf8_strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-prefix_length);
     else
       name[0] = 0;
 
@@ -2106,16 +2119,16 @@
         int group_count = 0;
         foreach_group_member(BUDDATA(buddy), increment_if_buddy_not_filtered,
                              &group_count);
-        snprintf(rline, 4*Roster_Width, " %c+++ %s (%i)", pending, name,
+        snprintf(rline, 4*Roster_Width, "%s%c+++ %s (%i)", space, pending, name,
                  group_count);
         /* Do not display the item count if there isn't enough space */
         if (g_utf8_strlen(rline, 4*Roster_Width) >= Roster_Width)
-          snprintf(rline, 4*Roster_Width, " %c+++ %s", pending, name);
+          snprintf(rline, 4*Roster_Width, "%s%c+++ %s", space, pending, name);
       }
       else
-        snprintf(rline, 4*Roster_Width, " %c--- %s", pending, name);
+        snprintf(rline, 4*Roster_Width, "%s%c--- %s", space, pending, name);
     } else if (isspe) {
-      snprintf(rline, 4*Roster_Width, " %c%s", pending, name);
+      snprintf(rline, 4*Roster_Width, "%s%c%s", space, pending, name);
     } else {
       char sepleft  = '[';
       char sepright = ']';
@@ -2128,9 +2141,8 @@
           sepright = '}';
         }
       }
-
       snprintf(rline, 4*Roster_Width,
-               " %c%c%c%c %s", pending, sepleft, status, sepright, name);
+               "%s%c%c%c%c %s", space, pending, sepleft, status, sepright, name);
     }
 
     rline_locale = from_utf8(rline);
@@ -2139,6 +2151,7 @@
     i++;
   }
 
+  g_free(space);
   g_free(rline);
   g_free(name);
   top_panel(inputPanel);
--- a/mcabber/mcabberrc.example	Thu Jan 26 10:11:03 2012 +0100
+++ b/mcabber/mcabberrc.example	Fri Jan 27 21:07:56 2012 +0100
@@ -129,6 +129,10 @@
 # running you can use "/roster display").
 #set roster_display_filter = ofdna_
 
+# By default, mcabber adds an extra space before each buddy in the roster
+# window for aesthetic purposes. You can remove it to gain a little space.
+#set no_space_before_items = 0
+
 # By default command line completion is case-sensitive; this can be changed
 # by setting the option 'completion_ignore_case' to 1.
 #set completion_ignore_case = 0