about summary refs log tree commit diff stats
path: root/src/command/command.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-08-26 18:06:33 +0100
committerJames Booth <boothj5@gmail.com>2013-08-26 18:06:33 +0100
commit8045b949a7089be12fb7caaf2e4f355900c94e74 (patch)
tree370687318be27bdeb713e1a5a17e65e52b2a3492 /src/command/command.c
parentb6f1afcf224ba33a78fbfbc22e90fc9b043fdadb (diff)
downloadprofani-tty-8045b949a7089be12fb7caaf2e4f355900c94e74.tar.gz
Refactor _cmd_close
Diffstat (limited to 'src/command/command.c')
-rw-r--r--src/command/command.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/src/command/command.c b/src/command/command.c
index ad9b28b2..c8304736 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -3035,21 +3035,12 @@ _cmd_close(gchar **args, struct cmd_help_t help)
 {
     jabber_conn_status_t conn_status = jabber_get_connection_status();
     int index = 0;
-    int curr = 0;
     int count = 0;
 
     if (args[0] == NULL) {
         index = ui_current_win_index();
     } else if (strcmp(args[0], "all") == 0) {
-        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++;
-            }
-        }
+        count = ui_close_all_wins();
         if (count == 0) {
             cons_show("No windows to close.");
         } else if (count == 1) {
@@ -3059,15 +3050,7 @@ _cmd_close(gchar **args, struct cmd_help_t help)
         }
         return TRUE;
     } else if (strcmp(args[0], "read") == 0) {
-        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++;
-            }
-        }
+        count = ui_close_read_wins();
         if (count == 0) {
             cons_show("No windows to close.");
         } else if (count == 1) {