diff mcabber/src/screen.c @ 119:d7fbd5293385

[/trunk] Changeset 132 by mikael * Current buddy should not be removed from the buddylist * It should be removed if it is offline and the cursor moves.
author mikael
date Mon, 25 Apr 2005 20:34:59 +0000
parents 33bff2c57293
children cfd3df636d5f
line wrap: on
line diff
--- a/mcabber/src/screen.c	Mon Apr 25 19:02:07 2005 +0000
+++ b/mcabber/src/screen.c	Mon Apr 25 20:34:59 2005 +0000
@@ -288,6 +288,7 @@
     currentWindow = win_entry;
     chatmode = TRUE;
     roster_setflags(winId, ROSTER_FLAG_MSG, FALSE);
+    roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE);
     update_roster = TRUE;
 
     // Refresh the window
@@ -564,29 +565,61 @@
 
 void scr_RosterTop(void)
 {
+  enum imstatus prev_st;
+
+  if (current_buddy) {
+    prev_st = buddy_getstatus(BUDDATA(current_buddy));
+    if (chatmode)
+      buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE);
+  }
   current_buddy = buddylist;
-  // XXX We should rebuild the buddylist but perhaps not everytime?
+  if (chatmode && current_buddy)
+    buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
+
+  // We should rebuild the buddylist but not everytime
+  if (current_buddy && prev_st == offline)
+    buddylist_build();
   if (chatmode)
     scr_ShowBuddyWindow();
 }
 
 void scr_RosterBottom(void)
 {
+  enum imstatus prev_st;
+
+  if (current_buddy) {
+    prev_st = buddy_getstatus(BUDDATA(current_buddy));
+    if (chatmode)
+      buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE);
+  }
   current_buddy = g_list_last(buddylist);
-  // XXX We should rebuild the buddylist but perhaps not everytime?
+  if (chatmode && current_buddy)
+    buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
+
+  // We should rebuild the buddylist but not everytime
+  if (current_buddy && prev_st == offline)
+    buddylist_build();
   if (chatmode)
     scr_ShowBuddyWindow();
 }
 
 void scr_RosterUp(void)
 {
+  enum imstatus prev_st;
+
   if (current_buddy) {
+    prev_st = buddy_getstatus(BUDDATA(current_buddy));
     if (g_list_previous(current_buddy)) {
+      buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE);
       current_buddy = g_list_previous(current_buddy);
+      if (chatmode)
+        buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
+      // We should rebuild the buddylist but not everytime
+      if (prev_st == offline)
+        buddylist_build();
       scr_DrawRoster();
     }
   }
-  // XXX We should rebuild the buddylist but perhaps not everytime?
 
   if (chatmode)
     scr_ShowBuddyWindow();
@@ -594,13 +627,21 @@
 
 void scr_RosterDown(void)
 {
+  enum imstatus prev_st;
+
   if (current_buddy) {
+    prev_st = buddy_getstatus(BUDDATA(current_buddy));
     if (g_list_next(current_buddy)) {
+      buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE);
       current_buddy = g_list_next(current_buddy);
+      if (chatmode)
+        buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
+      // We should rebuild the buddylist but not everytime
+      if (prev_st == offline)
+        buddylist_build();
       scr_DrawRoster();
     }
   }
-  // XXX We should rebuild the buddylist but perhaps not everytime?
 
   if (chatmode)
     scr_ShowBuddyWindow();
@@ -931,6 +972,8 @@
           break;
       case '\n':  // Enter
           chatmode = TRUE;
+          if (current_buddy)
+            buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
           if (inputLine[0] == 0) {
             scr_ShowBuddyWindow();
             break;
@@ -981,6 +1024,8 @@
       case 27:  // ESC
           currentWindow = NULL;
           chatmode = FALSE;
+          if (current_buddy)
+            buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE);
           top_panel(chatPanel);
           top_panel(inputPanel);
           break;