about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-09-11 00:17:42 +0100
committerJames Booth <boothj5@gmail.com>2014-09-11 00:17:42 +0100
commit2fc9e3e1cfafcac2fffd26834d21ef1d4af558dd (patch)
tree5542641285733e2550f0a91cb87bac361e3ee1de /src
parent1e26b7a4ffb1fb0e07e7e8c4c4451d6c610e4f9b (diff)
downloadprofani-tty-2fc9e3e1cfafcac2fffd26834d21ef1d4af558dd.tar.gz
Close config window on submit/cancel
Diffstat (limited to 'src')
-rw-r--r--src/command/commands.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index 1d3c3241..f74731a6 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1830,14 +1830,14 @@ cmd_room(gchar **args, struct cmd_help_t help)
     }
 
     char *room = ui_current_recipient();
+    ProfWin *window = wins_get_by_recipient(room);
+    int num = wins_get_num(window);
 
     // commands available in room
     if ((g_strcmp0(args[0], "accept") == 0) ||
             (g_strcmp0(args[0], "destroy") == 0) ||
             (g_strcmp0(args[0], "config") == 0)) {
 
-        ProfWin *window = wins_get_by_recipient(room);
-        int num = wins_get_num(window);
         int ui_index = num;
         if (ui_index == 10) {
             ui_index = 0;
@@ -1881,19 +1881,28 @@ cmd_room(gchar **args, struct cmd_help_t help)
     if ((g_strcmp0(args[0], "submit") == 0) ||
             (g_strcmp0(args[0], "cancel") == 0)) {
 
+        ProfWin *current = wins_get_current();
+        gchar **split_recipient = g_strsplit(room, " ", 2);
+        room = split_recipient[0];
+
         if (g_strcmp0(args[0], "submit") == 0) {
-            ProfWin *current = wins_get_current();
-            gchar **split_recipient = g_strsplit(room, " ", 2);
-            room = split_recipient[0];
             iq_submit_room_config(room, current->form);
-            g_strfreev(split_recipient);
-            return TRUE;
-        }
 
+        }
         if (g_strcmp0(args[0], "cancel") == 0) {
             iq_room_config_cancel(room);
-            return TRUE;
         }
+
+        current = wins_get_by_recipient(room);
+        if (current == NULL) {
+            current = wins_get_console();
+        }
+        num = wins_get_num(current);
+        ui_switch_win(num);
+
+        g_strfreev(split_recipient);
+
+        return TRUE;
     }
 
     return TRUE;