aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
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
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')
-rw-r--r--libempathy-gtk/empathy-group-chat.c41
-rw-r--r--libempathy-gtk/empathy-preferences.h1
2 files changed, 23 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);
diff --git a/libempathy-gtk/empathy-preferences.h b/libempathy-gtk/empathy-preferences.h
index c787c814d..39c2994c1 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"