about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-01-08 20:11:53 +0000
committerJames Booth <boothj5@gmail.com>2014-01-08 20:11:53 +0000
commitd99f1536ec4a3327a0a695d3034c5c1bfa7cf87a (patch)
tree69c010bac0d5e0be3c40daf4a2fc77d5a9802c64 /src/ui
parent71356967ab1b3cd433619d5f29b6f0ee32e83751 (diff)
downloadprofani-tty-d99f1536ec4a3327a0a695d3034c5c1bfa7cf87a.tar.gz
Removed print message function from ProfWin
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/core.c4
-rw-r--r--src/ui/window.c30
-rw-r--r--src/ui/window.h4
3 files changed, 26 insertions, 12 deletions
diff --git a/src/ui/core.c b/src/ui/core.c
index c06f025e..44491d67 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -252,7 +252,7 @@ _ui_incoming_msg(const char * const from, const char * const message,
 
     // currently viewing chat window with sender
     if (wins_is_current(window)) {
-        window->print_incoming_message(window, tv_stamp, display_from, message);
+        win_print_incoming_message(window, tv_stamp, display_from, message);
         title_bar_set_typing(FALSE);
         title_bar_draw();
         status_bar_active(num);
@@ -278,7 +278,7 @@ _ui_incoming_msg(const char * const from, const char * const message,
             }
         }
 
-        window->print_incoming_message(window, tv_stamp, display_from, message);
+        win_print_incoming_message(window, tv_stamp, display_from, message);
     }
 
     int ui_index = num;
diff --git a/src/ui/window.c b/src/ui/window.c
index 135eac17..25df66d4 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -24,6 +24,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <assert.h>
 
 #include <glib.h>
 #ifdef HAVE_NCURSESW_NCURSES_H
@@ -38,7 +39,7 @@
 
 static gboolean _default_handle_error_message(ProfWin *self, const char * const from,
     const char * const err_msg);
-static void _print_incoming_message(ProfWin *self, GTimeVal *tv_stamp,
+static void _win_chat_print_incoming_message(ProfWin *self, GTimeVal *tv_stamp,
     const char * const from, const char * const message);
 
 ProfWin*
@@ -58,27 +59,21 @@ win_create(const char * const title, int cols, win_type_t type)
     {
         case WIN_CONSOLE:
             new_win->handle_error_message = _default_handle_error_message;
-            new_win->print_incoming_message = NULL;
             break;
         case WIN_CHAT:
             new_win->handle_error_message = _default_handle_error_message;
-            new_win->print_incoming_message = _print_incoming_message;
             break;
         case WIN_MUC:
             new_win->handle_error_message = muc_handle_error_message;
-            new_win->print_incoming_message = NULL;
             break;
         case WIN_PRIVATE:
             new_win->handle_error_message = _default_handle_error_message;
-            new_win->print_incoming_message = _print_incoming_message;
             break;
         case WIN_DUCK:
             new_win->handle_error_message = _default_handle_error_message;
-            new_win->print_incoming_message = NULL;
             break;
         default:
             new_win->handle_error_message = _default_handle_error_message;
-            new_win->print_incoming_message = NULL;
             break;
     }
 
@@ -314,6 +309,25 @@ win_show_status_string(ProfWin *window, const char * const from,
     }
 }
 
+void
+win_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
+    const char * const from, const char * const message)
+{
+    switch (window->type)
+    {
+        case WIN_CHAT:
+        case WIN_PRIVATE:
+            _win_chat_print_incoming_message(window, tv_stamp, from, message);
+            break;
+        case WIN_DUCK:
+        case WIN_CONSOLE:
+        case WIN_MUC:
+        default:
+            assert(FALSE);
+            break;
+    }
+}
+
 static gboolean
 _default_handle_error_message(ProfWin *self, const char * const from,
     const char * const err_msg)
@@ -322,7 +336,7 @@ _default_handle_error_message(ProfWin *self, const char * const from,
 }
 
 static void
-_print_incoming_message(ProfWin *self, GTimeVal *tv_stamp,
+_win_chat_print_incoming_message(ProfWin *self, GTimeVal *tv_stamp,
     const char * const from, const char * const message)
 {
     if (tv_stamp == NULL) {
diff --git a/src/ui/window.h b/src/ui/window.h
index 69e446fa..5cca430e 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -54,8 +54,6 @@ typedef struct prof_win_t {
     int history_shown;
     gboolean (*handle_error_message)(struct prof_win_t *self,
         const char * const from, const char * const err_msg);
-    void (*print_incoming_message)(struct prof_win_t *self, GTimeVal *tv_stamp,
-        const char * const from, const char * const message);
 } ProfWin;
 
 ProfWin* win_create(const char * const title, int cols, win_type_t type);
@@ -72,5 +70,7 @@ void win_show_status_string(ProfWin *window, const char * const from,
     const char * const show, const char * const status,
     GDateTime *last_activity, const char * const pre,
     const char * const default_show);
+void win_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
+    const char * const from, const char * const message);
 
 #endif