aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--ChangeLog8
-rw-r--r--data/empathy.schemas.in16
-rw-r--r--libempathy-gtk/empathy-group-chat.c41
-rw-r--r--libempathy-gtk/empathy-preferences.h1
4 files changed, 47 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index e923af9e6..da0603094 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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).
+
2007-11-28 Xavier Claessens <xclaesse@gmail.com>
* libempathy-gtk/empathy-private-chat.c: Request new Text Channel if
diff --git a/data/empathy.schemas.in b/data/empathy.schemas.in
index 29a8bc994..72ee4405e 100644
--- a/data/empathy.schemas.in
+++ b/data/empathy.schemas.in
@@ -231,6 +231,22 @@
</schema>
<schema>
+ <key>/schemas/apps/empathy/conversation/nick_completion_char</key>
+ <applyto>/apps/empathy/conversation/nick_completion_char</applyto>
+ <owner>empathy</owner>
+ <type>string</type>
+ <default>:</default>
+ <locale name="C">
+ <short>Nick completed character</short>
+ <long>
+ Character to add after nickname when using nick completion (tab)
+ in group chat.
+ </long>
+
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/empathy/hints/close_main_window</key>
<applyto>/apps/empathy/hints/close_main_window</applyto>
<owner>empathy</owner>
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"