comparison mcabber/src/screen.c @ 329:7c53bf62a2a2

scr_RosterUnreadMessage() uses set_current_buddy()
author Mikael Berthe <mikael@lilotux.net>
date Sun, 17 Jul 2005 21:16:15 +0100
parents 83d129adde03
children a9013124ede6
comparison
equal deleted inserted replaced
328:83d129adde03 329:7c53bf62a2a2
816 /* prev_st initialized to imstatus_size, which is used as "undef" value. 816 /* prev_st initialized to imstatus_size, which is used as "undef" value.
817 * We are sure prev_st will get a different status value after the 817 * We are sure prev_st will get a different status value after the
818 * buddy_getstatus() call. 818 * buddy_getstatus() call.
819 */ 819 */
820 820
821 if (!current_buddy || !newbuddy) return; 821 if (!current_buddy || !newbuddy) return;
822 if (newbuddy == current_buddy) return;
822 823
823 prev_st = buddy_getstatus(BUDDATA(current_buddy)); 824 prev_st = buddy_getstatus(BUDDATA(current_buddy));
824 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); 825 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE);
825 current_buddy = newbuddy; 826 current_buddy = newbuddy;
826 // Lock the buddy in the buddylist if we're in chat mode 827 // Lock the buddy in the buddylist if we're in chat mode
883 // Go to a new message. If next is not null, try to go to the next new 884 // Go to a new message. If next is not null, try to go to the next new
884 // message. If it is not possible or if next is NULL, go to the first new 885 // message. If it is not possible or if next is NULL, go to the first new
885 // message from unread_list. 886 // message from unread_list.
886 void scr_RosterUnreadMessage(int next) 887 void scr_RosterUnreadMessage(int next)
887 { 888 {
888 enum imstatus prev_st = imstatus_size; // undef 889 gpointer unread_ptr;
889 890 gpointer refbuddata;
890 if (current_buddy) { 891 gpointer ngroup;
891 gpointer unread_ptr; 892 GList *nbuddy;
892 gpointer refbuddata; 893
893 gpointer ngroup; 894 if (!current_buddy) return;
894 GList *nbuddy; 895
895 896 if (next) refbuddata = BUDDATA(current_buddy);
896 if (next) refbuddata = BUDDATA(current_buddy); 897 else refbuddata = NULL;
897 else refbuddata = NULL; 898
898 899 unread_ptr = unread_msg(refbuddata);
899 unread_ptr = unread_msg(refbuddata); 900 if (!unread_ptr) return;
900 if (!unread_ptr) return; 901
901 902 // If buddy is in a folded group, we need to expand it
902 // If buddy is in a folded group, we need to expand it 903 ngroup = buddy_getgroup(unread_ptr);
903 ngroup = buddy_getgroup(unread_ptr); 904 if (buddy_getflags(ngroup) & ROSTER_FLAG_HIDE) {
904 if (buddy_getflags(ngroup) & ROSTER_FLAG_HIDE) { 905 buddy_setflags(ngroup, ROSTER_FLAG_HIDE, FALSE);
905 buddy_setflags(ngroup, ROSTER_FLAG_HIDE, FALSE); 906 buddylist_build();
906 buddylist_build(); 907 }
907 } 908
908 909 nbuddy = g_list_find(buddylist, unread_ptr);
909 nbuddy = g_list_find(buddylist, unread_ptr); 910 if (nbuddy) {
910 if (nbuddy) { 911 set_current_buddy(nbuddy);
911 prev_st = buddy_getstatus(BUDDATA(current_buddy)); 912 if (chatmode) scr_ShowBuddyWindow();
912 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); 913 } else scr_LogPrint("Error: nbuddy == NULL");
913 current_buddy = nbuddy;
914 if (chatmode)
915 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
916 // We should rebuild the buddylist but not everytime
917 // Here we check if we were locking a buddy who is actually offline,
918 // and hide_offline_buddies is TRUE. In which case we need to rebuild.
919 if (prev_st == offline && buddylist_get_hide_offline_buddies())
920 buddylist_build();
921 update_roster = TRUE;
922
923 if (chatmode) scr_ShowBuddyWindow();
924 } else scr_LogPrint("Error: nbuddy == NULL");
925 }
926 } 914 }
927 915
928 // scr_ScrollUp() 916 // scr_ScrollUp()
929 // Scroll up the current buddy window, half a screen. 917 // Scroll up the current buddy window, half a screen.
930 void scr_ScrollUp(void) 918 void scr_ScrollUp(void)