aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-group-chat.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2007-11-30 21:22:16 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2007-11-30 21:22:16 +0800
commit33d57b9ae44d175a1c95f9005793bc2e0465342f (patch)
tree9146976f5dbf7c672a9988ce8aeb0a65be1b3017 /libempathy-gtk/empathy-group-chat.c
parentc289dc18ce15e60e94e82d9df9fec9dfce8ef7d4 (diff)
downloadgsoc2013-empathy-33d57b9ae44d175a1c95f9005793bc2e0465342f.tar
gsoc2013-empathy-33d57b9ae44d175a1c95f9005793bc2e0465342f.tar.gz
gsoc2013-empathy-33d57b9ae44d175a1c95f9005793bc2e0465342f.tar.bz2
gsoc2013-empathy-33d57b9ae44d175a1c95f9005793bc2e0465342f.tar.lz
gsoc2013-empathy-33d57b9ae44d175a1c95f9005793bc2e0465342f.tar.xz
gsoc2013-empathy-33d57b9ae44d175a1c95f9005793bc2e0465342f.tar.zst
gsoc2013-empathy-33d57b9ae44d175a1c95f9005793bc2e0465342f.zip
Add a gconf key to define the char to be added for tab completion. Fixes
2007-11-30 Xavier Claessens <xclaesse@gmail.com> * 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
Diffstat (limited to 'libempathy-gtk/empathy-group-chat.c')
-rw-r--r--libempathy-gtk/empathy-group-chat.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/libempathy-gtk/empathy-group-chat.c b/libempathy-gtk/empathy-group-chat.c
index 88555339c..442db950f 100644
--- a/libempathy-gtk/empathy-group-chat.c
+++ b/libempathy-gtk/empathy-group-chat.c
@@ -38,6 +38,7 @@
#include <libempathy/empathy-contact.h>
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-debug.h>
+#include <libempathy/empathy-conf.h>
#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, &current, 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, &current, 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, &current, 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, &current);
@@ -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);