about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-04-21 23:35:37 +0100
committerJames Booth <boothj5@gmail.com>2015-04-21 23:35:37 +0100
commitbc445ccdfb0f8e210e793925e120b01bd0d9b918 (patch)
tree72c6fe466ed140cac3f04def74d88fdba20d54b4 /src/ui
parentebca38e22483ec7054596a8ecf0bdccd85e76e0a (diff)
parent88739d5c59022b4d1f1b67da3128cb4a3266ecf9 (diff)
downloadprofani-tty-bc445ccdfb0f8e210e793925e120b01bd0d9b918.tar.gz
Merge branch 'master' into pgp
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/core.c80
-rw-r--r--src/ui/inputwin.c20
-rw-r--r--src/ui/ui.h5
-rw-r--r--src/ui/windows.c6
4 files changed, 55 insertions, 56 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index 9f8ac806..78faff18 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -878,7 +878,14 @@ ui_win_has_unsaved_form(int num)
 }
 
 gboolean
-ui_switch_win(const int i)
+ui_switch_win(ProfWin *win)
+{
+    int num = wins_get_num(win);
+    return ui_switch_win_num(num);
+}
+
+gboolean
+ui_switch_win_num(const int i)
 {
     if (ui_win_exists(i)) {
         ProfWin *old_current = wins_get_current();
@@ -1358,53 +1365,45 @@ ui_recipient_gone(const char * const barejid, const char * const resource)
     }
 }
 
-void
-ui_new_private_win(const char * const fulljid)
+ProfWin*
+ui_new_chat_win(const char * const barejid)
 {
-    ProfWin *window = (ProfWin*)wins_get_private(fulljid);
-    int num = 0;
+    ProfWin* window = wins_new_chat(barejid);
 
-    // create new window
-    if (window == NULL) {
-        window = wins_new_private(fulljid);
-        num = wins_get_num(window);
-    } else {
-        num = wins_get_num(window);
+    int num = wins_get_num(window);
+
+    if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
+        _win_show_history(num, barejid);
+    }
+
+    // if the contact is offline, show a message
+    PContact contact = roster_get_contact(barejid);
+    if (contact != NULL) {
+        if (strcmp(p_contact_presence(contact), "offline") == 0) {
+            const char * const show = p_contact_presence(contact);
+            const char * const status = p_contact_status(contact);
+            win_show_status_string(window, barejid, show, status, NULL, "--", "offline");
+        }
     }
 
-    ui_switch_win(num);
+    return window;
 }
 
 void
-ui_new_chat_win(const char * const barejid)
+ui_new_private_win(const char * const fulljid)
 {
-    ProfWin *window = (ProfWin*)wins_get_chat(barejid);
+    ProfWin *window = (ProfWin*)wins_get_private(fulljid);
     int num = 0;
 
     // create new window
     if (window == NULL) {
-        window = wins_new_chat(barejid);
-
+        window = wins_new_private(fulljid);
         num = wins_get_num(window);
-
-        if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
-            _win_show_history(num, barejid);
-        }
-
-        // if the contact is offline, show a message
-        PContact contact = roster_get_contact(barejid);
-        if (contact != NULL) {
-            if (strcmp(p_contact_presence(contact), "offline") == 0) {
-                const char * const show = p_contact_presence(contact);
-                const char * const status = p_contact_status(contact);
-                win_show_status_string(window, barejid, show, status, NULL, "--", "offline");
-            }
-        }
     } else {
         num = wins_get_num(window);
     }
 
-    ui_switch_win(num);
+    ui_switch_win_num(num);
 }
 
 void
@@ -1412,7 +1411,7 @@ ui_create_xmlconsole_win(void)
 {
     ProfWin *window = wins_new_xmlconsole();
     int num = wins_get_num(window);
-    ui_switch_win(num);
+    ui_switch_win_num(num);
 }
 
 void
@@ -1421,7 +1420,7 @@ ui_open_xmlconsole_win(void)
     ProfXMLWin *xmlwin = wins_get_xmlconsole();
     if (xmlwin != NULL) {
         int num = wins_get_num((ProfWin*)xmlwin);
-        ui_switch_win(num);
+        ui_switch_win_num(num);
     }
 }
 
@@ -1467,7 +1466,7 @@ ui_outgoing_chat_msg(const char * const barejid, const char * const message, cha
     } else {
         win_print(window, '-', NULL, 0, THEME_TEXT_ME, "me", message);
     }
-    ui_switch_win(num);
+    ui_switch_win_num(num);
 }
 
 void
@@ -1528,7 +1527,7 @@ ui_outgoing_private_msg(const char * const fulljid, const char * const message)
     }
 
     win_print(window, '-', NULL, 0, THEME_TEXT_ME, "me", message);
-    ui_switch_win(num);
+    ui_switch_win_num(num);
 }
 
 void
@@ -1559,7 +1558,7 @@ ui_room_join(const char * const roomjid, gboolean focus)
     num = wins_get_num(window);
 
     if (focus) {
-        ui_switch_win(num);
+        ui_switch_win_num(num);
     } else {
         status_bar_active(num);
         ProfWin *console = wins_get_console();
@@ -1573,8 +1572,7 @@ ui_switch_to_room(const char * const roomjid)
 {
     ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
     int num = wins_get_num(window);
-    num = wins_get_num(window);
-    ui_switch_win(num);
+    ui_switch_win_num(num);
 }
 
 void
@@ -2747,7 +2745,7 @@ ui_handle_room_configuration(const char * const roomjid, DataForm *form)
     assert(confwin->memcheck == PROFCONFWIN_MEMCHECK);
 
     int num = wins_get_num(window);
-    ui_switch_win(num);
+    ui_switch_win_num(num);
 
     ui_show_form(confwin);
 
@@ -2804,10 +2802,10 @@ ui_handle_room_config_submit_result(const char * const roomjid)
 
         if (muc_window) {
             int num = wins_get_num(muc_window);
-            ui_switch_win(num);
+            ui_switch_win_num(num);
             win_print(muc_window, '!', NULL, 0, THEME_ROOMINFO, "", "Room configuration successful");
         } else {
-            ui_switch_win(1);
+            ui_switch_win_num(1);
             cons_show("Room configuration successful: %s", roomjid);
         }
     } else {
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index f55be0f1..935fd4ce 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -452,70 +452,70 @@ _inp_rl_tab_handler(int count, int key)
 static int
 _inp_rl_win1_handler(int count, int key)
 {
-    ui_switch_win(1);
+    ui_switch_win_num(1);
     return 0;
 }
 
 static int
 _inp_rl_win2_handler(int count, int key)
 {
-    ui_switch_win(2);
+    ui_switch_win_num(2);
     return 0;
 }
 
 static int
 _inp_rl_win3_handler(int count, int key)
 {
-    ui_switch_win(3);
+    ui_switch_win_num(3);
     return 0;
 }
 
 static int
 _inp_rl_win4_handler(int count, int key)
 {
-    ui_switch_win(4);
+    ui_switch_win_num(4);
     return 0;
 }
 
 static int
 _inp_rl_win5_handler(int count, int key)
 {
-    ui_switch_win(5);
+    ui_switch_win_num(5);
     return 0;
 }
 
 static int
 _inp_rl_win6_handler(int count, int key)
 {
-    ui_switch_win(6);
+    ui_switch_win_num(6);
     return 0;
 }
 
 static int
 _inp_rl_win7_handler(int count, int key)
 {
-    ui_switch_win(7);
+    ui_switch_win_num(7);
     return 0;
 }
 
 static int
 _inp_rl_win8_handler(int count, int key)
 {
-    ui_switch_win(8);
+    ui_switch_win_num(8);
     return 0;
 }
 
 static int
 _inp_rl_win9_handler(int count, int key)
 {
-    ui_switch_win(9);
+    ui_switch_win_num(9);
     return 0;
 }
 
 static int
 _inp_rl_win0_handler(int count, int key)
 {
-    ui_switch_win(0);
+    ui_switch_win_num(0);
     return 0;
 }
 
diff --git a/src/ui/ui.h b/src/ui/ui.h
index fc1485ff..d5e9c28c 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -59,7 +59,8 @@ void ui_close(void);
 void ui_redraw(void);
 void ui_resize(void);
 GSList* ui_get_chat_recipients(void);
-gboolean ui_switch_win(const int i);
+gboolean ui_switch_win_num(const int i);
+gboolean ui_switch_win(ProfWin *win);
 void ui_next_win(void);
 void ui_previous_win(void);
 void ui_sigwinch_handler(int sig);
@@ -86,8 +87,8 @@ void ui_handle_otr_error(const char * const barejid, const char * const message)
 
 unsigned long ui_get_idle_time(void);
 void ui_reset_idle_time(void);
-void ui_new_chat_win(const char * const barejid);
 void ui_new_private_win(const char * const fulljid);
+ProfWin* ui_new_chat_win(const char * const barejid);
 void ui_print_system_msg_from_recipient(const char * const barejid, const char *message);
 gint ui_unread(void);
 void ui_close_connected_win(int index);
diff --git a/src/ui/windows.c b/src/ui/windows.c
index 993a51c1..269bea1d 100644
--- a/src/ui/windows.c
+++ b/src/ui/windows.c
@@ -660,7 +660,7 @@ wins_swap(int source_win, int target_win)
             }
             if (wins_get_current_num() == source_win) {
                 wins_set_current_by_num(target_win);
-                ui_switch_win(1);
+                ui_switch_win_num(1);
             }
             return TRUE;
 
@@ -681,7 +681,7 @@ wins_swap(int source_win, int target_win)
                 status_bar_active(source_win);
             }
             if ((wins_get_current_num() == source_win) || (wins_get_current_num() == target_win)) {
-                ui_switch_win(1);
+                ui_switch_win_num(1);
             }
             return TRUE;
         }
@@ -740,7 +740,7 @@ wins_tidy(void)
 
         windows = new_windows;
         current = 1;
-        ui_switch_win(1);
+        ui_switch_win_num(1);
         g_list_free(keys);
         return TRUE;
     } else {