mutt_mktemp--
[apps/madmutt.git] / lib-ui / sidebar.c
index a83505c..6668ca0 100644 (file)
@@ -32,18 +32,18 @@ static short prev_show_value;
 
 /* computes first entry to be shown */
 static void calc_boundaries (void) {
-  if (list_empty(Incoming))
+  if (!Incoming.len)
     return;
-  if (CurBuffy < 0 || CurBuffy >= Incoming->length)
+  if (CurBuffy < 0 || CurBuffy >= Incoming.len)
     CurBuffy = 0;
-  if (TopBuffy < 0 || TopBuffy >= Incoming->length)
+  if (TopBuffy < 0 || TopBuffy >= Incoming.len)
     TopBuffy = 0;
 
   if (option (OPTSIDEBARNEWMAILONLY)) {
     int i = CurBuffy;
     TopBuffy = CurBuffy - 1;
     while (i >= 0) {
-      if (((BUFFY*) Incoming->data[i])->new > 0)
+      if (Incoming.arr[i]->new > 0)
         TopBuffy = i;
       i--;
     }
@@ -97,7 +97,7 @@ static const char* sidebar_number_format (char* dest, ssize_t destlen, char op,
                                           const char* ifstr, const char* elstr,
                                           unsigned long data, format_flag flags) {
   char tmp[SHORT_STRING];
-  BUFFY* b = (BUFFY*) Incoming->data[data];
+  BUFFY* b = Incoming.arr[data];
   int opt = flags & M_FORMAT_OPTIONAL;
   int c = Context && !m_strcmp(Context->path, b->path);
 
@@ -194,7 +194,7 @@ static int make_sidebar_entry (char* sbox, int idx, ssize_t len)
     SidebarWidth = COLS;
 
   if (option (OPTSIDEBARNEWMAILONLY) && sbox && Context && Context->path && 
-      m_strcmp(Context->path, sbox) && ((BUFFY*) Incoming->data[idx])->new == 0)
+      m_strcmp(Context->path, sbox) && Incoming.arr[idx]->new == 0)
     /* if $sidebar_newmail_only is set, don't display the
      * box only if it's not the currently opened
      * (i.e. always display the currently opened) */
@@ -239,9 +239,9 @@ static int make_sidebar_entry (char* sbox, int idx, ssize_t len)
  * selected folder for <sidebar-open>
  */
 const char* sidebar_get_current (void) {
-  if (list_empty(Incoming))
+  if (!Incoming.len)
     return (NULL);
-  return ((char*) ((BUFFY*) Incoming->data[CurBuffy])->path);
+  return Incoming.arr[CurBuffy]->path;
 }
 
 /* internally sets item to buf */
@@ -259,9 +259,9 @@ void sidebar_set_current (const char* buf) {
 void sidebar_set_buffystats (CONTEXT* curContext) {
   int i = 0;
   BUFFY* tmp = NULL;
-  if (!curContext || list_empty(Incoming) || (i = buffy_lookup (curContext->path)) < 0)
+  if (!curContext || !Incoming.len || (i = buffy_lookup (curContext->path)) < 0)
     return;
-  tmp = Incoming->data[i];
+  tmp = Incoming.arr[i];
   tmp->new = curContext->new;
   tmp->msg_unread = curContext->unread;
   tmp->msgcount = curContext->msgcount;
@@ -357,12 +357,12 @@ int sidebar_draw (void) {
 
   sidebar_draw_frames();
 
-  if (list_empty(Incoming))
+  if (!Incoming.len)
     return 0;
 
   /* actually print items */
-  for (i = TopBuffy, line=first_line; i < Incoming->length && line < last_line; i++) {
-    tmp = (BUFFY*) Incoming->data[i];
+  for (i = TopBuffy, line=first_line; i < Incoming.len && line < last_line; i++) {
+    tmp = Incoming.arr[i];
 
     if (i == CurBuffy)
       SETCOLOR (MT_COLOR_INDICATOR);
@@ -391,11 +391,11 @@ int sidebar_draw (void) {
 /* returns index of new item with new mail or -1 */
 static int exist_next_new () {
   int i = 0;
-  if (list_empty(Incoming))
+  if (!Incoming.len)
     return (-1);
   i = CurBuffy + 1;
-  while (i < Incoming->length)
-    if (((BUFFY*) Incoming->data[i++])->new > 0)
+  while (i < Incoming.len)
+    if (Incoming.arr[i++]->new > 0)
       return (i-1);
   return (-1);
 }
@@ -403,11 +403,11 @@ static int exist_next_new () {
 /* returns index of prev item with new mail or -1 */
 static int exist_prev_new () {
   int i = 0;
-  if (list_empty(Incoming))
+  if (!Incoming.len)
     return (-1);
   i = CurBuffy - 1;
   while (i >= 0)
-    if (((BUFFY*) Incoming->data[i--])->new > 0)
+    if (Incoming.arr[i--]->new > 0)
       return (i+1);
   return (-1);
 }
@@ -415,13 +415,13 @@ static int exist_prev_new () {
 void sidebar_scroll (int op) {
   int i = 0;
 
-  if (!SidebarWidth || list_empty(Incoming))
+  if (!SidebarWidth || !Incoming.len)
     return;
 
   switch (op) {
   case OP_SIDEBAR_NEXT:
     if (!option (OPTSIDEBARNEWMAILONLY)) {
-      if (CurBuffy + 1 == Incoming->length) {
+      if (CurBuffy + 1 == Incoming.len) {
         mutt_error (_("You are on the last mailbox."));
         return;
       }
@@ -464,13 +464,13 @@ void sidebar_scroll (int op) {
       CurBuffy = 0;
     break;
   case OP_SIDEBAR_SCROLL_DOWN:
-    if (CurBuffy + 1 == Incoming->length) {
+    if (CurBuffy + 1 == Incoming.len) {
       mutt_error (_("You are on the last mailbox."));
       return;
     }
     CurBuffy += known_lines;
-    if (CurBuffy >= Incoming->length)
-      CurBuffy = Incoming->length - 1;
+    if (CurBuffy >= Incoming.len)
+      CurBuffy = Incoming.len - 1;
     break;
   default:
     return;