From a1e67bd4feaab4ac44d9df618059f4b5fccfd447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jerzy=20Mansarli=C5=84ski?= Date: Fri, 31 Jul 2009 22:38:06 +0200 Subject: Add terminal-like chat input history. Fixes bug #586098. --- libempathy-gtk/empathy-chat.c | 248 +++++++++++++++++++++++++++++++++++------- 1 file changed, 211 insertions(+), 37 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 3931115be..a6d83ebef 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -73,8 +73,8 @@ typedef struct { EmpathyLogManager *log_manager; EmpathyAccountManager *account_manager; - GSList *sent_messages; - gint sent_messages_index; + GSList *input_history; + gint input_history_index; GList *compositors; GCompletion *completion; guint composing_stop_timeout_id; @@ -94,6 +94,11 @@ typedef struct { GtkWidget *contact_list_view; } EmpathyChatPriv; +typedef struct { + gchar *text; + gchar *modified_text; +} InputHistoryEntry; + enum { COMPOSING, NEW_MESSAGE, @@ -291,23 +296,151 @@ chat_composing_stop (EmpathyChat *chat) TP_CHANNEL_CHAT_STATE_ACTIVE); } +static gint +chat_input_history_entry_cmp (InputHistoryEntry *entry, + const gchar *text) +{ + gint result = strcmp (entry->text, text); + if (!result) { + if (entry->modified_text) { + /* Modified entry and single string cannot be equal. */ + return 1; + } + } + return result; +} + +static InputHistoryEntry * +chat_input_history_entry_new_with_text (const gchar *text) +{ + InputHistoryEntry *entry; + entry = g_new0 (InputHistoryEntry, 1); + entry->text = g_strdup (text); + + return entry; +} + +static void +chat_input_history_entry_free (InputHistoryEntry *entry) +{ + g_free (entry->text); + g_free (entry->modified_text); + g_free (entry); +} + +static void +chat_input_history_entry_revert (InputHistoryEntry *entry) +{ + g_free (entry->modified_text); + entry->modified_text = NULL; +} + +static void +chat_input_history_entry_update_text (InputHistoryEntry *entry, + const gchar *text) +{ + gchar *old; + + if (!strcmp (text, entry->text)) { + g_free (entry->modified_text); + entry->modified_text = NULL; + return; + } + + old = entry->modified_text; + entry->modified_text = g_strdup (text); + g_free (old); +} + +static const gchar * +chat_input_history_entry_get_text (InputHistoryEntry *entry) +{ + if (!entry) { + return NULL; + } + + if (entry->modified_text) { + return entry->modified_text; + } + return entry->text; +} + static void -chat_sent_message_add (EmpathyChat *chat, - const gchar *str) +chat_input_history_revert (EmpathyChat *chat) +{ + EmpathyChatPriv *priv; + GSList *list; + GSList *item1; + GSList *item2; + InputHistoryEntry *entry; + + priv = GET_PRIV (chat); + list = priv->input_history; + + if (!list) { + DEBUG ("No input history"); + return; + } + + /* Delete temporary entry */ + if (priv->input_history_index != -1) { + item1 = list; + list = g_slist_remove_link (list, item1); + chat_input_history_entry_free (item1->data); + g_slist_free_1 (item1); + priv->input_history_index--; + } + + /* Restore the current history message to original value */ + if (priv->input_history_index >= 0) { + item1 = g_slist_nth (list, priv->input_history_index); + entry = item1->data; + chat_input_history_entry_revert (entry); + + /* Remove restored entry if there is other occurance before this entry */ + item2 = g_slist_find_custom (list, chat_input_history_entry_get_text (entry), + (GCompareFunc) chat_input_history_entry_cmp); + if (item2 != item1) { + list = g_slist_remove_link (list, item1); + chat_input_history_entry_free (item1->data); + g_slist_free1 (item1); + } + else { + /* Remove other occurance of the restored entry */ + item2 = g_slist_find_custom (item1->next, + chat_input_history_entry_get_text (entry), + (GCompareFunc) chat_input_history_entry_cmp); + if (item2 != NULL) { + list = g_slist_remove_link (list, item2); + chat_input_history_entry_free (item2->data); + g_slist_free1 (item2); + } + } + + } + + priv->input_history_index = -1; + priv->input_history = list; + +} + +static void +chat_input_history_add (EmpathyChat *chat, + const gchar *str) { EmpathyChatPriv *priv; GSList *list; GSList *item; + InputHistoryEntry *entry; priv = GET_PRIV (chat); - /* Save the sent message in our repeat buffer */ - list = priv->sent_messages; + list = priv->input_history; - /* Remove any other occurances of this msg */ - while ((item = g_slist_find_custom (list, str, (GCompareFunc) strcmp)) != NULL) { + /* Remove any other occurances of this entry */ + while ((item = g_slist_find_custom (list, str, (GCompareFunc) chat_input_history_entry_cmp)) != NULL) { list = g_slist_remove_link (list, item); - g_free (item->data); + chat_input_history_entry_free (item->data); g_slist_free1 (item); } @@ -316,64 +449,102 @@ chat_sent_message_add (EmpathyChat *chat, item = g_slist_last (list); if (item) { list = g_slist_remove_link (list, item); - g_free (item->data); + chat_input_history_entry_free (item->data); g_slist_free1 (item); } } - /* Add new message */ - list = g_slist_prepend (list, g_strdup (str)); + /* Add new entry */ + entry = chat_input_history_entry_new_with_text (str); + list = g_slist_prepend (list, entry); /* Set list and reset the index */ - priv->sent_messages = list; - priv->sent_messages_index = -1; + priv->input_history = list; + priv->input_history_index = -1; } static const gchar * -chat_sent_message_get_next (EmpathyChat *chat) +chat_input_history_get_next (EmpathyChat *chat) { EmpathyChatPriv *priv; gint max; + InputHistoryEntry *entry; priv = GET_PRIV (chat); - if (!priv->sent_messages) { - DEBUG ("No sent messages, next message is NULL"); + if (!priv->input_history) { + DEBUG ("No input history, next entry is NULL"); return NULL; } - max = g_slist_length (priv->sent_messages) - 1; + max = g_slist_length (priv->input_history) - 1; - if (priv->sent_messages_index < max) { - priv->sent_messages_index++; + if (priv->input_history_index < max) { + priv->input_history_index++; } - DEBUG ("Returning next message index:%d", priv->sent_messages_index); + DEBUG ("Returning next entry index:%d", priv->input_history_index); - return g_slist_nth_data (priv->sent_messages, priv->sent_messages_index); + entry = g_slist_nth_data (priv->input_history, priv->input_history_index); + return chat_input_history_entry_get_text (entry); } static const gchar * -chat_sent_message_get_last (EmpathyChat *chat) +chat_input_history_get_last (EmpathyChat *chat) { EmpathyChatPriv *priv; + InputHistoryEntry *entry; g_return_val_if_fail (EMPATHY_IS_CHAT (chat), NULL); priv = GET_PRIV (chat); - if (!priv->sent_messages) { - DEBUG ("No sent messages, last message is NULL"); + if (!priv->input_history) { + DEBUG ("No input history, last entry is NULL"); return NULL; } - - if (priv->sent_messages_index >= 0) { - priv->sent_messages_index--; + + if (priv->input_history_index > 0) { + priv->input_history_index--; } + + DEBUG ("Returning last entry index:%d", priv->input_history_index); + + entry = g_slist_nth_data (priv->input_history, priv->input_history_index); + return chat_input_history_entry_get_text (entry); +} + +static void +chat_input_history_update (EmpathyChat *chat, + GtkTextBuffer *buffer) +{ + EmpathyChatPriv *priv; + GtkTextIter start, end; + gchar *text; + InputHistoryEntry *entry; + + priv = GET_PRIV (chat); + + gtk_text_buffer_get_bounds (buffer, &start, &end); + text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE); - DEBUG ("Returning last message index:%d", priv->sent_messages_index); + if (priv->input_history_index == -1) { + /* Add the current text temporarily to the history */ + chat_input_history_add (chat, text); + priv->input_history_index++; - return g_slist_nth_data (priv->sent_messages, priv->sent_messages_index); + g_free (text); + return; + } + + /* Save the changes in the history */ + entry = g_slist_nth_data (priv->input_history, priv->input_history_index); + if (strcmp (chat_input_history_entry_get_text (entry), text)) { + chat_input_history_entry_update_text (entry, text); + } + + g_free (text); + } static void @@ -389,7 +560,7 @@ chat_send (EmpathyChat *chat, priv = GET_PRIV (chat); - chat_sent_message_add (chat, msg); + chat_input_history_add (chat, msg); if (strcmp (msg, "/clear") == 0) { empathy_chat_view_clear (chat->view); @@ -424,6 +595,8 @@ chat_input_text_view_send (EmpathyChat *chat) /* clear the input field */ gtk_text_buffer_set_text (buffer, "", -1); + /* delete input history modifications */ + chat_input_history_revert (chat); chat_send (chat, msg); g_free (msg); @@ -695,11 +868,12 @@ chat_input_key_press_event_cb (GtkWidget *widget, const gchar *str; buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (chat->input_text_view)); + chat_input_history_update (chat, buffer); if (event->keyval == GDK_Up) { - str = chat_sent_message_get_next (chat); + str = chat_input_history_get_next (chat); } else { - str = chat_sent_message_get_last (chat); + str = chat_input_history_get_last (chat); } g_signal_handlers_block_by_func (buffer, @@ -1532,8 +1706,8 @@ chat_finalize (GObject *object) DEBUG ("Finalized: %p", object); - g_slist_foreach (priv->sent_messages, (GFunc) g_free, NULL); - g_slist_free (priv->sent_messages); + g_slist_foreach (priv->input_history, (GFunc) chat_input_history_entry_free, NULL); + g_slist_free (priv->input_history); g_list_foreach (priv->compositors, (GFunc) g_object_unref, NULL); g_list_free (priv->compositors); @@ -1707,8 +1881,8 @@ empathy_chat_init (EmpathyChat *chat) chat->priv = priv; priv->log_manager = empathy_log_manager_dup_singleton (); priv->contacts_width = -1; - priv->sent_messages = NULL; - priv->sent_messages_index = -1; + priv->input_history = NULL; + priv->input_history_index = -1; priv->account_manager = empathy_account_manager_dup_singleton (); g_signal_connect (priv->account_manager, -- cgit v1.2.3 From c415943206357644af15d4dfd3d8fa3f610ef3c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jerzy=20Mansarli=C5=84ski?= Date: Thu, 29 Oct 2009 23:44:14 +0100 Subject: Fix coding style --- libempathy-gtk/empathy-chat.c | 73 ++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 36 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index a6d83ebef..a9f4c499e 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -95,8 +95,10 @@ typedef struct { } EmpathyChatPriv; typedef struct { - gchar *text; - gchar *modified_text; + gchar *text; /* Original message that was specified + * upon entry creation. */ + gchar *modified_text; /* Message that was modified by user. + * When no modifications were made, it is NULL */ } InputHistoryEntry; enum { @@ -297,24 +299,24 @@ chat_composing_stop (EmpathyChat *chat) } static gint -chat_input_history_entry_cmp (InputHistoryEntry *entry, +chat_input_history_entry_cmp (InputHistoryEntry *entry, const gchar *text) { - gint result = strcmp (entry->text, text); - if (!result) { - if (entry->modified_text) { + if (!tp_strdiff (entry->text, text)) { + if (entry->modified_text != NULL) { /* Modified entry and single string cannot be equal. */ return 1; - } + } + return 0; } - return result; + return 1; } static InputHistoryEntry * chat_input_history_entry_new_with_text (const gchar *text) { InputHistoryEntry *entry; - entry = g_new0 (InputHistoryEntry, 1); + entry = g_slice_new0 (InputHistoryEntry); entry->text = g_strdup (text); return entry; @@ -325,7 +327,7 @@ chat_input_history_entry_free (InputHistoryEntry *entry) { g_free (entry->text); g_free (entry->modified_text); - g_free (entry); + g_slice_free (InputHistoryEntry, entry); } static void @@ -339,9 +341,9 @@ static void chat_input_history_entry_update_text (InputHistoryEntry *entry, const gchar *text) { - gchar *old; - - if (!strcmp (text, entry->text)) { + gchar *old; + + if (!tp_strdiff (text, entry->text)) { g_free (entry->modified_text); entry->modified_text = NULL; return; @@ -355,11 +357,11 @@ chat_input_history_entry_update_text (InputHistoryEntry *entry, static const gchar * chat_input_history_entry_get_text (InputHistoryEntry *entry) { - if (!entry) { + if (entry == NULL) { return NULL; } - - if (entry->modified_text) { + + if (entry->modified_text != NULL) { return entry->modified_text; } return entry->text; @@ -373,11 +375,11 @@ chat_input_history_revert (EmpathyChat *chat) GSList *item1; GSList *item2; InputHistoryEntry *entry; - + priv = GET_PRIV (chat); list = priv->input_history; - - if (!list) { + + if (list == NULL) { DEBUG ("No input history"); return; } @@ -390,7 +392,7 @@ chat_input_history_revert (EmpathyChat *chat) g_slist_free_1 (item1); priv->input_history_index--; } - + /* Restore the current history message to original value */ if (priv->input_history_index >= 0) { item1 = g_slist_nth (list, priv->input_history_index); @@ -407,7 +409,7 @@ chat_input_history_revert (EmpathyChat *chat) } else { /* Remove other occurance of the restored entry */ - item2 = g_slist_find_custom (item1->next, + item2 = g_slist_find_custom (item1->next, chat_input_history_entry_get_text (entry), (GCompareFunc) chat_input_history_entry_cmp); if (item2 != NULL) { @@ -416,12 +418,12 @@ chat_input_history_revert (EmpathyChat *chat) g_slist_free1 (item2); } } - - } - + + } + priv->input_history_index = -1; priv->input_history = list; - + } static void @@ -447,7 +449,7 @@ chat_input_history_add (EmpathyChat *chat, /* Trim the list to the last 10 items */ while (g_slist_length (list) > 10) { item = g_slist_last (list); - if (item) { + if (item != NULL) { list = g_slist_remove_link (list, item); chat_input_history_entry_free (item->data); g_slist_free1 (item); @@ -472,7 +474,7 @@ chat_input_history_get_next (EmpathyChat *chat) priv = GET_PRIV (chat); - if (!priv->input_history) { + if (priv->input_history == NULL) { DEBUG ("No input history, next entry is NULL"); return NULL; } @@ -499,15 +501,15 @@ chat_input_history_get_last (EmpathyChat *chat) priv = GET_PRIV (chat); - if (!priv->input_history) { + if (priv->input_history == NULL) { DEBUG ("No input history, last entry is NULL"); return NULL; } - + if (priv->input_history_index > 0) { - priv->input_history_index--; + priv->input_history_index--; } - + DEBUG ("Returning last entry index:%d", priv->input_history_index); entry = g_slist_nth_data (priv->input_history, priv->input_history_index); @@ -522,9 +524,9 @@ chat_input_history_update (EmpathyChat *chat, GtkTextIter start, end; gchar *text; InputHistoryEntry *entry; - + priv = GET_PRIV (chat); - + gtk_text_buffer_get_bounds (buffer, &start, &end); text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE); @@ -539,12 +541,11 @@ chat_input_history_update (EmpathyChat *chat, /* Save the changes in the history */ entry = g_slist_nth_data (priv->input_history, priv->input_history_index); - if (strcmp (chat_input_history_entry_get_text (entry), text)) { + if (tp_strdiff (chat_input_history_entry_get_text (entry), text)) { chat_input_history_entry_update_text (entry, text); } - + g_free (text); - } static void -- cgit v1.2.3 From ede64d4975a1fca4a562e4635dc43856610788ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jerzy=20Mansarli=C5=84ski?= Date: Sat, 31 Oct 2009 17:08:00 +0100 Subject: empathy-chat.c: input history - Using GList pointer instead of gint index. --- libempathy-gtk/empathy-chat.c | 192 ++++++++++++++++++++++++------------------ 1 file changed, 109 insertions(+), 83 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index a9f4c499e..b6356f834 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -73,8 +73,8 @@ typedef struct { EmpathyLogManager *log_manager; EmpathyAccountManager *account_manager; - GSList *input_history; - gint input_history_index; + GList *input_history; + GList *input_history_current; GList *compositors; GCompletion *completion; guint composing_stop_timeout_id; @@ -367,13 +367,23 @@ chat_input_history_entry_get_text (InputHistoryEntry *entry) return entry->text; } +static GList * +chat_input_history_remove_item (GList *list, + GList *item) +{ + list = g_list_remove_link (list, item); + chat_input_history_entry_free (item->data); + g_list_free_1 (item); + return list; +} + static void chat_input_history_revert (EmpathyChat *chat) { - EmpathyChatPriv *priv; - GSList *list; - GSList *item1; - GSList *item2; + EmpathyChatPriv *priv; + GList *list; + GList *item1; + GList *item2; InputHistoryEntry *entry; priv = GET_PRIV (chat); @@ -385,92 +395,98 @@ chat_input_history_revert (EmpathyChat *chat) } /* Delete temporary entry */ - if (priv->input_history_index != -1) { + if (priv->input_history_current != NULL) { item1 = list; - list = g_slist_remove_link (list, item1); - chat_input_history_entry_free (item1->data); - g_slist_free_1 (item1); - priv->input_history_index--; + list = chat_input_history_remove_item (list, item1); + if (priv->input_history_current == item1) { + /* Removed temporary entry was current entry */ + priv->input_history = list; + priv->input_history_current = NULL; + return; + } + } + else { + /* There is no entry to revert */ + return; } - /* Restore the current history message to original value */ - if (priv->input_history_index >= 0) { - item1 = g_slist_nth (list, priv->input_history_index); - entry = item1->data; - chat_input_history_entry_revert (entry); + /* Restore the current history entry to original value */ + item1 = priv->input_history_current; + entry = item1->data; + chat_input_history_entry_revert (entry); - /* Remove restored entry if there is other occurance before this entry */ - item2 = g_slist_find_custom (list, chat_input_history_entry_get_text (entry), + /* Remove restored entry if there is other occurance before this entry */ + item2 = g_list_find_custom (list, chat_input_history_entry_get_text (entry), + (GCompareFunc) chat_input_history_entry_cmp); + if (item2 != item1) { + list = chat_input_history_remove_item (list, item1); + } + else { + /* Remove other occurance of the restored entry */ + item2 = g_list_find_custom (item1->next, + chat_input_history_entry_get_text (entry), (GCompareFunc) chat_input_history_entry_cmp); - if (item2 != item1) { - list = g_slist_remove_link (list, item1); - chat_input_history_entry_free (item1->data); - g_slist_free1 (item1); + if (item2 != NULL) { + list = chat_input_history_remove_item (list, item2); } - else { - /* Remove other occurance of the restored entry */ - item2 = g_slist_find_custom (item1->next, - chat_input_history_entry_get_text (entry), - (GCompareFunc) chat_input_history_entry_cmp); - if (item2 != NULL) { - list = g_slist_remove_link (list, item2); - chat_input_history_entry_free (item2->data); - g_slist_free1 (item2); - } - } - } - priv->input_history_index = -1; + priv->input_history_current = NULL; priv->input_history = list; - } static void chat_input_history_add (EmpathyChat *chat, - const gchar *str) + const gchar *str, + gboolean temporary) { - EmpathyChatPriv *priv; - GSList *list; - GSList *item; + EmpathyChatPriv *priv; + GList *list; + GList *item; InputHistoryEntry *entry; priv = GET_PRIV (chat); list = priv->input_history; - /* Remove any other occurances of this entry */ - while ((item = g_slist_find_custom (list, str, (GCompareFunc) chat_input_history_entry_cmp)) != NULL) { - list = g_slist_remove_link (list, item); - chat_input_history_entry_free (item->data); - g_slist_free1 (item); - } + /* Remove any other occurances of this entry, if not temporary */ + if (!temporary) { + while ((item = g_list_find_custom (list, str, + (GCompareFunc) chat_input_history_entry_cmp)) != NULL) { + list = chat_input_history_remove_item (list, item); + } - /* Trim the list to the last 10 items */ - while (g_slist_length (list) > 10) { - item = g_slist_last (list); - if (item != NULL) { - list = g_slist_remove_link (list, item); - chat_input_history_entry_free (item->data); - g_slist_free1 (item); + /* Trim the list to the last 10 items */ + while (g_list_length (list) > 10) { + item = g_list_last (list); + if (item != NULL) { + list = chat_input_history_remove_item (list, item); + } } } + + /* Add new entry */ entry = chat_input_history_entry_new_with_text (str); - list = g_slist_prepend (list, entry); + list = g_list_prepend (list, entry); - /* Set list and reset the index */ + /* Set the list and the current item pointer */ priv->input_history = list; - priv->input_history_index = -1; + if (temporary) { + priv->input_history_current = list; + } + else { + priv->input_history_current = NULL; + } } static const gchar * chat_input_history_get_next (EmpathyChat *chat) { EmpathyChatPriv *priv; - gint max; - InputHistoryEntry *entry; + GList *item; + const gchar *msg; priv = GET_PRIV (chat); @@ -478,42 +494,54 @@ chat_input_history_get_next (EmpathyChat *chat) DEBUG ("No input history, next entry is NULL"); return NULL; } + g_assert (priv->input_history_current != NULL); - max = g_slist_length (priv->input_history) - 1; - - if (priv->input_history_index < max) { - priv->input_history_index++; + if ((item = g_list_next (priv->input_history_current)) == NULL) + { + item = priv->input_history_current; } - DEBUG ("Returning next entry index:%d", priv->input_history_index); + msg = chat_input_history_entry_get_text (item->data); + + DEBUG ("Returning next entry: '%s'", msg); - entry = g_slist_nth_data (priv->input_history, priv->input_history_index); - return chat_input_history_entry_get_text (entry); + priv->input_history_current = item; + + return msg; } static const gchar * -chat_input_history_get_last (EmpathyChat *chat) +chat_input_history_get_prev (EmpathyChat *chat) { EmpathyChatPriv *priv; - InputHistoryEntry *entry; + GList *item; + const gchar *msg; g_return_val_if_fail (EMPATHY_IS_CHAT (chat), NULL); priv = GET_PRIV (chat); if (priv->input_history == NULL) { - DEBUG ("No input history, last entry is NULL"); + DEBUG ("No input history, previous entry is NULL"); return NULL; } - if (priv->input_history_index > 0) { - priv->input_history_index--; + if (priv->input_history_current == NULL) + { + return NULL; + } + else if ((item = g_list_previous (priv->input_history_current)) == NULL) + { + item = priv->input_history_current; } - DEBUG ("Returning last entry index:%d", priv->input_history_index); + msg = chat_input_history_entry_get_text (item->data); - entry = g_slist_nth_data (priv->input_history, priv->input_history_index); - return chat_input_history_entry_get_text (entry); + DEBUG ("Returning previous entry: '%s'", msg); + + priv->input_history_current = item; + + return msg; } static void @@ -530,17 +558,15 @@ chat_input_history_update (EmpathyChat *chat, gtk_text_buffer_get_bounds (buffer, &start, &end); text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE); - if (priv->input_history_index == -1) { + if (priv->input_history_current == NULL) { /* Add the current text temporarily to the history */ - chat_input_history_add (chat, text); - priv->input_history_index++; - + chat_input_history_add (chat, text, TRUE); g_free (text); return; } /* Save the changes in the history */ - entry = g_slist_nth_data (priv->input_history, priv->input_history_index); + entry = priv->input_history_current->data; if (tp_strdiff (chat_input_history_entry_get_text (entry), text)) { chat_input_history_entry_update_text (entry, text); } @@ -561,7 +587,7 @@ chat_send (EmpathyChat *chat, priv = GET_PRIV (chat); - chat_input_history_add (chat, msg); + chat_input_history_add (chat, msg, FALSE); if (strcmp (msg, "/clear") == 0) { empathy_chat_view_clear (chat->view); @@ -874,7 +900,7 @@ chat_input_key_press_event_cb (GtkWidget *widget, if (event->keyval == GDK_Up) { str = chat_input_history_get_next (chat); } else { - str = chat_input_history_get_last (chat); + str = chat_input_history_get_prev (chat); } g_signal_handlers_block_by_func (buffer, @@ -1707,8 +1733,8 @@ chat_finalize (GObject *object) DEBUG ("Finalized: %p", object); - g_slist_foreach (priv->input_history, (GFunc) chat_input_history_entry_free, NULL); - g_slist_free (priv->input_history); + g_list_foreach (priv->input_history, (GFunc) chat_input_history_entry_free, NULL); + g_list_free (priv->input_history); g_list_foreach (priv->compositors, (GFunc) g_object_unref, NULL); g_list_free (priv->compositors); @@ -1883,7 +1909,7 @@ empathy_chat_init (EmpathyChat *chat) priv->log_manager = empathy_log_manager_dup_singleton (); priv->contacts_width = -1; priv->input_history = NULL; - priv->input_history_index = -1; + priv->input_history_current = NULL; priv->account_manager = empathy_account_manager_dup_singleton (); g_signal_connect (priv->account_manager, -- cgit v1.2.3