Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/commands.c @ 1360:8613d3f4ae91
Improve command /group
- Do not enter chat mode if it is disabled.
- Do not jump to the top of the roster, only jump to the
group item if needed.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 11 Nov 2007 14:21:24 +0100 |
parents | 7daf906fbcdc |
children | 9ee58f91d19e |
comparison
equal
deleted
inserted
replaced
1359:7daf906fbcdc | 1360:8613d3f4ae91 |
---|---|
997 { | 997 { |
998 gpointer group = NULL; | 998 gpointer group = NULL; |
999 guint leave_buddywindow; | 999 guint leave_buddywindow; |
1000 char **paramlst; | 1000 char **paramlst; |
1001 char *subcmd; | 1001 char *subcmd; |
1002 enum { group_unfold = 0, group_fold, group_toggle } group_state = 0; | |
1002 | 1003 |
1003 if (!*arg) { | 1004 if (!*arg) { |
1004 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); | 1005 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); |
1005 return; | 1006 return; |
1006 } | 1007 } |
1027 goto do_group_return; | 1028 goto do_group_return; |
1028 | 1029 |
1029 // We'll have to redraw the chat window if we're not currently on the group | 1030 // We'll have to redraw the chat window if we're not currently on the group |
1030 // entry itself, because it means we'll have to leave the current buddy | 1031 // entry itself, because it means we'll have to leave the current buddy |
1031 // chat window. | 1032 // chat window. |
1032 leave_buddywindow = (group != BUDDATA(current_buddy)); | 1033 leave_buddywindow = (group != BUDDATA(current_buddy) && |
1034 group == buddy_getgroup(BUDDATA(current_buddy))); | |
1035 | |
1033 | 1036 |
1034 if (!(buddy_gettype(group) & ROSTER_TYPE_GROUP)) { | 1037 if (!(buddy_gettype(group) & ROSTER_TYPE_GROUP)) { |
1035 scr_LogPrint(LPRINT_NORMAL, "You need to select a group."); | 1038 scr_LogPrint(LPRINT_NORMAL, "You need to select a group."); |
1036 goto do_group_return; | 1039 goto do_group_return; |
1037 } | 1040 } |
1038 | 1041 |
1039 if (!strcasecmp(subcmd, "expand") || !strcasecmp(subcmd, "unfold")) { | 1042 if (!strcasecmp(subcmd, "expand") || !strcasecmp(subcmd, "unfold")) |
1043 group_state = group_unfold; | |
1044 else if (!strcasecmp(subcmd, "shrink") || !strcasecmp(subcmd, "fold")) | |
1045 group_state = group_fold; | |
1046 else if (!strcasecmp(subcmd, "toggle")) | |
1047 group_state = group_toggle; | |
1048 else { | |
1049 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); | |
1050 goto do_group_return; | |
1051 } | |
1052 | |
1053 if (group_state != group_unfold && leave_buddywindow) | |
1054 scr_RosterPrevGroup(); | |
1055 | |
1056 if (group_state == group_unfold) | |
1040 buddy_setflags(group, ROSTER_FLAG_HIDE, FALSE); | 1057 buddy_setflags(group, ROSTER_FLAG_HIDE, FALSE); |
1041 } else if (!strcasecmp(subcmd, "shrink") || !strcasecmp(subcmd, "fold")) { | 1058 else if (group_state == group_fold) |
1042 buddy_setflags(group, ROSTER_FLAG_HIDE, TRUE); | 1059 buddy_setflags(group, ROSTER_FLAG_HIDE, TRUE); |
1043 } else if (!strcasecmp(subcmd, "toggle")) { | 1060 else if (group_state == group_toggle) |
1044 buddy_setflags(group, ROSTER_FLAG_HIDE, | 1061 buddy_setflags(group, ROSTER_FLAG_HIDE, |
1045 !(buddy_getflags(group) & ROSTER_FLAG_HIDE)); | 1062 !(buddy_getflags(group) & ROSTER_FLAG_HIDE)); |
1046 } else { | |
1047 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); | |
1048 goto do_group_return; | |
1049 } | |
1050 | 1063 |
1051 buddylist_build(); | 1064 buddylist_build(); |
1052 update_roster = TRUE; | 1065 update_roster = TRUE; |
1053 if (leave_buddywindow) | |
1054 scr_ShowBuddyWindow(); | |
1055 | 1066 |
1056 do_group_return: | 1067 do_group_return: |
1057 free_arg_lst(paramlst); | 1068 free_arg_lst(paramlst); |
1058 } | 1069 } |
1059 | 1070 |