1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Fixed /close all and /close read to close extra windows

This commit is contained in:
James Booth 2013-08-30 00:33:46 +01:00
parent 48794e324c
commit 7f476b3e2c
3 changed files with 33 additions and 10 deletions

View File

@ -528,38 +528,54 @@ ui_close_connected_win(int index)
int
ui_close_all_wins(void)
{
int curr = 0, count = 0;
int count = 0;
jabber_conn_status_t conn_status = jabber_get_connection_status();
for (curr = 2; curr <= 10; curr++) {
if (ui_win_exists(curr)) {
GList *win_nums = wins_get_nums();
GList *curr = win_nums;
while (curr != NULL) {
int num = GPOINTER_TO_INT(curr->data);
if (num != 1) {
if (conn_status == JABBER_CONNECTED) {
ui_close_connected_win(curr);
ui_close_connected_win(num);
}
ui_close_win(curr);
ui_close_win(num);
count++;
}
curr = g_list_next(curr);
}
g_list_free(curr);
g_list_free(win_nums);
return count;
}
int
ui_close_read_wins(void)
{
int curr = 0, count = 0;
int count = 0;
jabber_conn_status_t conn_status = jabber_get_connection_status();
for (curr = 2; curr <= 10; curr++) {
if (ui_win_exists(curr) && (ui_win_unread(curr) == 0)) {
GList *win_nums = wins_get_nums();
GList *curr = win_nums;
while (curr != NULL) {
int num = GPOINTER_TO_INT(curr->data);
if ((num != 1) && (ui_win_unread(num) == 0)) {
if (conn_status == JABBER_CONNECTED) {
ui_close_connected_win(curr);
ui_close_connected_win(num);
}
ui_close_win(curr);
ui_close_win(num);
count++;
}
curr = g_list_next(curr);
}
g_list_free(curr);
g_list_free(win_nums);
return count;
}

View File

@ -70,6 +70,12 @@ wins_get_current(void)
return g_hash_table_lookup(windows, GINT_TO_POINTER(current));
}
GList *
wins_get_nums(void)
{
return g_hash_table_get_keys(windows);
}
void
wins_set_current_by_num(int i)
{

View File

@ -47,5 +47,6 @@ void wins_lost_connection(void);
gboolean wins_tidy(void);
GSList * wins_create_summary(void);
void wins_destroy(void);
GList * wins_get_nums(void);
#endif