aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2009-04-11 01:31:39 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-04-11 01:31:39 +0800
commit0a7bfb1f2dc560ab367327628a71fb24b6249993 (patch)
tree52220f6755f5cbfa9dcca42146a3f7619ec7b7f6 /libempathy-gtk
parent05ec8e2615766849326543337c1a58cd7b63b0f5 (diff)
downloadgsoc2013-empathy-0a7bfb1f2dc560ab367327628a71fb24b6249993.tar
gsoc2013-empathy-0a7bfb1f2dc560ab367327628a71fb24b6249993.tar.gz
gsoc2013-empathy-0a7bfb1f2dc560ab367327628a71fb24b6249993.tar.bz2
gsoc2013-empathy-0a7bfb1f2dc560ab367327628a71fb24b6249993.tar.lz
gsoc2013-empathy-0a7bfb1f2dc560ab367327628a71fb24b6249993.tar.xz
gsoc2013-empathy-0a7bfb1f2dc560ab367327628a71fb24b6249993.tar.zst
gsoc2013-empathy-0a7bfb1f2dc560ab367327628a71fb24b6249993.zip
Fix support for /me and /say commands.
From: Xavier Claessens <xclaesse@gmail.com> svn path=/trunk/; revision=2809
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-chat.c52
1 files changed, 16 insertions, 36 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index d11f33161..5f54c12eb 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -349,6 +349,7 @@ chat_send (EmpathyChat *chat,
const gchar *msg)
{
EmpathyChatPriv *priv;
+ EmpathyMessage *message;
if (EMP_STR_EMPTY (msg)) {
return;
@@ -358,24 +359,25 @@ chat_send (EmpathyChat *chat,
chat_sent_message_add (chat, msg);
- /* If this is not a command, send the message */
- if (msg[0] != '/') {
- EmpathyMessage *message;
-
- message = empathy_message_new (msg);
- empathy_tp_chat_send (priv->tp_chat, message);
- g_object_unref (message);
+ if (g_str_has_prefix (msg, "/clear")) {
+ empathy_chat_view_clear (chat->view);
return;
}
- /* Check for all supported commands */
- if (g_str_has_prefix (msg, "/clear")) {
- empathy_chat_view_clear (chat->view);
+ /* Blacklist messages begining by '/', except for "/me" and "/say"
+ * because they are handled in EmpathyMessage */
+ if (msg[0] == '/' &&
+ !g_str_has_prefix (msg, "/me") &&
+ !g_str_has_prefix (msg, "/say")) {
+ empathy_chat_view_append_event (chat->view,
+ _("Unsupported command"));
return;
}
- /* This is an unknown command, display a message to the user */
- empathy_chat_view_append_event (chat->view, _("Unsupported command"));
+ /* We can send the message */
+ message = empathy_message_new (msg);
+ empathy_tp_chat_send (priv->tp_chat, message);
+ g_object_unref (message);
}
static void
@@ -567,28 +569,6 @@ chat_property_changed_cb (EmpathyTpChat *tp_chat,
}
}
-static gboolean
-chat_get_is_command (const gchar *str)
-{
- g_return_val_if_fail (str != NULL, FALSE);
-
- if (str[0] != '/') {
- return FALSE;
- }
-
- if (g_str_has_prefix (str, "/me")) {
- return TRUE;
- }
- else if (g_str_has_prefix (str, "/nick")) {
- return TRUE;
- }
- else if (g_str_has_prefix (str, "/topic")) {
- return TRUE;
- }
-
- return FALSE;
-}
-
static void
chat_input_text_buffer_changed_cb (GtkTextBuffer *buffer,
EmpathyChat *chat)
@@ -648,8 +628,8 @@ chat_input_text_buffer_changed_cb (GtkTextBuffer *buffer,
str = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
- /* spell check string */
- if (!chat_get_is_command (str)) {
+ /* spell check string if not a command */
+ if (str[0] != '/') {
correct = empathy_spell_check (str);
} else {
correct = TRUE;