diff options
author | James Booth <boothj5@gmail.com> | 2013-08-26 18:06:33 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-08-26 18:06:33 +0100 |
commit | 8045b949a7089be12fb7caaf2e4f355900c94e74 (patch) | |
tree | 370687318be27bdeb713e1a5a17e65e52b2a3492 /src/ui | |
parent | b6f1afcf224ba33a78fbfbc22e90fc9b043fdadb (diff) | |
download | profani-tty-8045b949a7089be12fb7caaf2e4f355900c94e74.tar.gz |
Refactor _cmd_close
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/core.c | 38 | ||||
-rw-r--r-- | src/ui/ui.h | 2 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/ui/core.c b/src/ui/core.c index 1e13de68..3186aba5 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -567,6 +567,44 @@ ui_close_connected_win(int index) } } +int +ui_close_all_wins(void) +{ + int curr = 0, count = 0; + jabber_conn_status_t conn_status = jabber_get_connection_status(); + + for (curr = 1; curr <= 9; curr++) { + if (ui_win_exists(curr)) { + if (conn_status == JABBER_CONNECTED) { + ui_close_connected_win(curr); + } + ui_close_win(curr); + count++; + } + } + + return count; +} + +int +ui_close_read_wins(void) +{ + int curr = 0, count = 0; + jabber_conn_status_t conn_status = jabber_get_connection_status(); + + for (curr = 1; curr <= 9; curr++) { + if (ui_win_exists(curr) && (ui_win_unread(curr) == 0)) { + if (conn_status == JABBER_CONNECTED) { + ui_close_connected_win(curr); + } + ui_close_win(curr); + count++; + } + } + + return count; +} + void ui_switch_win(const int i) { diff --git a/src/ui/ui.h b/src/ui/ui.h index eec4aac5..f3163b6e 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -60,6 +60,8 @@ void ui_print_error_from_recipient(const char * const from, const char *err_msg) void ui_print_system_msg_from_recipient(const char * const from, const char *message); gint ui_unread(void); void ui_close_connected_win(int index); +int ui_close_all_wins(void); +int ui_close_read_wins(void); // current window actions void ui_close_current(void); |