]> git.0d.be Git - empathy.git/commitdiff
Add a gconf key to define the char to be added for tab completion. Fixes
authorXavier Claessens <xclaesse@gmail.com>
Fri, 30 Nov 2007 13:22:16 +0000 (13:22 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Fri, 30 Nov 2007 13:22:16 +0000 (13:22 +0000)
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

ChangeLog
data/empathy.schemas.in
libempathy-gtk/empathy-group-chat.c
libempathy-gtk/empathy-preferences.h

index e923af9e64f5e4b599c1cc2a7ce315a958f33e04..da0603094ee0d6ba8d8302ad4e4f91e4e94df88f 100644 (file)
--- 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
index 29a8bc9945d29c95248531a0d50caf4d058888a9..72ee4405ed1516986afc385656ce831c28404b02 100644 (file)
       </locale>
     </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>
index 88555339c34d31fde96f98220e282c29169bea84..442db950f2075e7bad44de17ef69c305274474a5 100644 (file)
@@ -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);
index c787c814d6c18009b8688d4658b0a7696a12c95f..39c2994c1404569e503d91e1ae44648bf409a092 100644 (file)
@@ -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"