about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-01-16 20:37:25 +0000
committerJames Booth <boothj5@gmail.com>2014-01-16 20:37:25 +0000
commit6c59bb26da67f2d48e0203e8df328205313d6c57 (patch)
tree70c863c2156450c7c64f48a1f0e81dc724122703
parentf0e5e585f88724b812f682b81d8a2d3bdca4ceb5 (diff)
downloadprofani-tty-6c59bb26da67f2d48e0203e8df328205313d6c57.tar.gz
Set boolean when typing in titlebar
-rw-r--r--src/ui/titlebar.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c
index f22eb43f..89d195b3 100644
--- a/src/ui/titlebar.c
+++ b/src/ui/titlebar.c
@@ -34,6 +34,7 @@ static char *current_title = NULL;
 static char *current_recipient = NULL;
 static contact_presence_t current_presence;
 
+static gboolean typing;
 static GTimer *typing_elapsed;
 
 static void _title_bar_draw(void);
@@ -56,6 +57,7 @@ _title_bar_console(void)
 {
     werase(win);
     current_recipient = NULL;
+    typing = FALSE;
     typing_elapsed = NULL;
 
     free(current_title);
@@ -84,9 +86,7 @@ _title_bar_refresh(void)
             gdouble seconds = g_timer_elapsed(typing_elapsed, NULL);
 
             if (seconds >= 10) {
-
-                free(current_title);
-                current_title = strdup(current_recipient);
+                typing = FALSE;
 
                 g_timer_destroy(typing_elapsed);
                 typing_elapsed = NULL;
@@ -110,6 +110,7 @@ _title_bar_set_recipient(const char * const recipient)
     if (typing_elapsed != NULL) {
         g_timer_destroy(typing_elapsed);
         typing_elapsed = NULL;
+        typing = FALSE;
     }
 
     free(current_recipient);
@@ -132,13 +133,8 @@ _title_bar_set_typing(gboolean is_typing)
         }
     }
 
-    free(current_title);
-    GString *new_title = g_string_new(current_recipient);
-    if (is_typing) {
-        g_string_append(new_title, " (typing...)");
-    }
-    current_title = strdup(new_title->str);
-    g_string_free(new_title, TRUE);
+    typing = is_typing;
+
 
     _title_bar_draw();
 }
@@ -154,6 +150,9 @@ _title_bar_draw(void)
     for (i = 0; i < 45; i++)
         waddch(win, ' ');
     mvwprintw(win, 0, 0, " %s", current_title);
+    if (typing) {
+        wprintw(win, " (typing...)");
+    }
 
     // show presence
     int cols = getmaxx(stdscr);