From 33d57b9ae44d175a1c95f9005793bc2e0465342f Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 30 Nov 2007 13:22:16 +0000 Subject: [PATCH] Add a gconf key to define the char to be added for tab completion. Fixes 2007-11-30 Xavier Claessens * data/empathy.schemas.in: * libempathy-gtk/empathy-group-chat.c: * libempathy-gtk/empathy-preferences.h: Add a gconf key to define the char to be added for tab completion. Fixes bug #453418 (Matej Cepl, Xavier Claessens). svn path=/trunk/; revision=451 --- ChangeLog | 8 ++++++ data/empathy.schemas.in | 16 +++++++++++ libempathy-gtk/empathy-group-chat.c | 41 +++++++++++++++------------- libempathy-gtk/empathy-preferences.h | 1 + 4 files changed, 47 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index e923af9e..da060309 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-11-30 Xavier Claessens + + * data/empathy.schemas.in: + * libempathy-gtk/empathy-group-chat.c: + * libempathy-gtk/empathy-preferences.h: Add a gconf key to define the + char to be added for tab completion. + Fixes bug #453418 (Matej Cepl, Xavier Claessens). + 2007-11-28 Xavier Claessens * libempathy-gtk/empathy-private-chat.c: Request new Text Channel if diff --git a/data/empathy.schemas.in b/data/empathy.schemas.in index 29a8bc99..72ee4405 100644 --- a/data/empathy.schemas.in +++ b/data/empathy.schemas.in @@ -230,6 +230,22 @@ + + /schemas/apps/empathy/conversation/nick_completion_char + /apps/empathy/conversation/nick_completion_char + empathy + string + : + + Nick completed character + + Character to add after nickname when using nick completion (tab) + in group chat. + + + + + /schemas/apps/empathy/hints/close_main_window /apps/empathy/hints/close_main_window diff --git a/libempathy-gtk/empathy-group-chat.c b/libempathy-gtk/empathy-group-chat.c index 88555339..442db950 100644 --- a/libempathy-gtk/empathy-group-chat.c +++ b/libempathy-gtk/empathy-group-chat.c @@ -38,6 +38,7 @@ #include #include #include +#include #include "empathy-group-chat.h" #include "empathy-chat.h" @@ -48,6 +49,7 @@ //#include "empathy-sound.h" #include "empathy-images.h" #include "empathy-ui-utils.h" +#include "empathy-preferences.h" #define DEBUG_DOMAIN "GroupChat" @@ -594,18 +596,16 @@ static gboolean group_chat_key_press_event (EmpathyChat *chat, GdkEventKey *event) { - EmpathyGroupChatPriv *priv; - GtkTextBuffer *buffer; - GtkTextIter start, current; - gchar *nick, *completed; - gint len; - GList *list, *completed_list; - gboolean is_start_of_buffer; - - priv = GET_PRIV (chat); + EmpathyGroupChatPriv *priv = GET_PRIV (chat); if (!(event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) && event->keyval == GDK_Tab) { + GtkTextBuffer *buffer; + GtkTextIter start, current; + gchar *nick, *completed; + GList *list, *completed_list; + gboolean is_start_of_buffer; + buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (EMPATHY_CHAT (chat)->input_text_view)); gtk_text_buffer_get_iter_at_mark (buffer, ¤t, gtk_text_buffer_get_insert (buffer)); @@ -614,14 +614,10 @@ group_chat_key_press_event (EmpathyChat *chat, gtk_text_iter_backward_word_start (&start); is_start_of_buffer = gtk_text_iter_is_start (&start); - nick = gtk_text_buffer_get_text (buffer, &start, ¤t, FALSE); - - len = strlen (nick); - list = empathy_contact_list_get_members (EMPATHY_CONTACT_LIST (priv->tp_chat)); - g_completion_add_items (priv->completion, list); + nick = gtk_text_buffer_get_text (buffer, &start, ¤t, FALSE); completed_list = g_completion_complete (priv->completion, nick, &completed); @@ -629,8 +625,9 @@ group_chat_key_press_event (EmpathyChat *chat, g_free (nick); if (completed) { - int len; + guint len; const gchar *text; + gchar *complete_char = NULL; gtk_text_buffer_delete (buffer, &start, ¤t); @@ -650,10 +647,16 @@ group_chat_key_press_event (EmpathyChat *chat, gtk_text_buffer_insert_at_cursor (buffer, text, strlen (text)); - if (len == 1) { - if (is_start_of_buffer) { - gtk_text_buffer_insert_at_cursor (buffer, ": ", 2); - } + if (len == 1 && is_start_of_buffer && + empathy_conf_get_string (empathy_conf_get (), + EMPATHY_PREFS_CHAT_NICK_COMPLETION_CHAR, + &complete_char) && + complete_char != NULL) { + gtk_text_buffer_insert_at_cursor (buffer, + complete_char, + strlen (complete_char)); + gtk_text_buffer_insert_at_cursor (buffer, " ", 1); + g_free (complete_char); } g_free (completed); diff --git a/libempathy-gtk/empathy-preferences.h b/libempathy-gtk/empathy-preferences.h index c787c814..39c2994c 100644 --- a/libempathy-gtk/empathy-preferences.h +++ b/libempathy-gtk/empathy-preferences.h @@ -40,6 +40,7 @@ G_BEGIN_DECLS #define EMPATHY_PREFS_CHAT_THEME_CHAT_ROOM EMPATHY_PREFS_PATH "/conversation/theme_chat_room" #define EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES EMPATHY_PREFS_PATH "/conversation/spell_checker_languages" #define EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED EMPATHY_PREFS_PATH "/conversation/spell_checker_enabled" +#define EMPATHY_PREFS_CHAT_NICK_COMPLETION_CHAR EMPATHY_PREFS_PATH "/conversation/nick_completion_char" #define EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS EMPATHY_PREFS_PATH "/ui/separate_chat_windows" #define EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN EMPATHY_PREFS_PATH "/ui/main_window_hidden" #define EMPATHY_PREFS_UI_AVATAR_DIRECTORY EMPATHY_PREFS_PATH "/ui/avatar_directory" -- 2.39.2