changeset 21281:d7d3f31d52fb

I feel good when I am able to send messages, instead of just typing them.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 06 Nov 2007 21:19:19 +0000
parents cfbff4a9b2b6
children a14c663152cc
files finch/gntconv.c
diffstat 1 files changed, 67 insertions(+), 73 deletions(-) [+]
line wrap: on
line diff
--- a/finch/gntconv.c	Mon Nov 05 19:20:30 2007 +0000
+++ b/finch/gntconv.c	Tue Nov 06 21:19:19 2007 +0000
@@ -114,87 +114,81 @@
 	}
 }
 
-static gboolean
-entry_key_pressed(GntWidget *w, const char *key, FinchConv *ggconv)
+static void
+entry_key_pressed(GntWidget *w, FinchConv *ggconv)
 {
-	if (key[0] == '\r' && key[1] == 0)
+	const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry));
+	if (*text == '/')
 	{
-		const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry));
-		if (*text == '/')
-		{
-			PurpleConversation *conv = ggconv->active_conv;
-			PurpleCmdStatus status;
-			const char *cmdline = text + 1;
-			char *error = NULL, *escape;
+		PurpleConversation *conv = ggconv->active_conv;
+		PurpleCmdStatus status;
+		const char *cmdline = text + 1;
+		char *error = NULL, *escape;
+
+		escape = g_markup_escape_text(cmdline, -1);
+		status = purple_cmd_do_command(conv, cmdline, escape, &error);
+		g_free(escape);
 
-			escape = g_markup_escape_text(cmdline, -1);
-			status = purple_cmd_do_command(conv, cmdline, escape, &error);
-			g_free(escape);
-
-			switch (status)
-			{
-				case PURPLE_CMD_STATUS_OK:
-					break;
-				case PURPLE_CMD_STATUS_NOT_FOUND:
-					purple_conversation_write(conv, "", _("No such command."),
-							PURPLE_MESSAGE_NO_LOG, time(NULL));
-					break;
-				case PURPLE_CMD_STATUS_WRONG_ARGS:
-					purple_conversation_write(conv, "", _("Syntax Error:  You typed the wrong number of arguments "
-										"to that command."),
-							PURPLE_MESSAGE_NO_LOG, time(NULL));
-					break;
-				case PURPLE_CMD_STATUS_FAILED:
-					purple_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."),
+		switch (status)
+		{
+			case PURPLE_CMD_STATUS_OK:
+				break;
+			case PURPLE_CMD_STATUS_NOT_FOUND:
+				purple_conversation_write(conv, "", _("No such command."),
+						PURPLE_MESSAGE_NO_LOG, time(NULL));
+				break;
+			case PURPLE_CMD_STATUS_WRONG_ARGS:
+				purple_conversation_write(conv, "", _("Syntax Error:  You typed the wrong number of arguments "
+							"to that command."),
+						PURPLE_MESSAGE_NO_LOG, time(NULL));
+				break;
+			case PURPLE_CMD_STATUS_FAILED:
+				purple_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."),
+						PURPLE_MESSAGE_NO_LOG, time(NULL));
+				break;
+			case PURPLE_CMD_STATUS_WRONG_TYPE:
+				if(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
+					purple_conversation_write(conv, "", _("That command only works in chats, not IMs."),
 							PURPLE_MESSAGE_NO_LOG, time(NULL));
-					break;
-				case PURPLE_CMD_STATUS_WRONG_TYPE:
-					if(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
-						purple_conversation_write(conv, "", _("That command only works in chats, not IMs."),
-								PURPLE_MESSAGE_NO_LOG, time(NULL));
-					else
-						purple_conversation_write(conv, "", _("That command only works in IMs, not chats."),
-								PURPLE_MESSAGE_NO_LOG, time(NULL));
-					break;
-				case PURPLE_CMD_STATUS_WRONG_PRPL:
-					purple_conversation_write(conv, "", _("That command doesn't work on this protocol."),
+				else
+					purple_conversation_write(conv, "", _("That command only works in IMs, not chats."),
 							PURPLE_MESSAGE_NO_LOG, time(NULL));
-					break;
-			}
-			g_free(error);
+				break;
+			case PURPLE_CMD_STATUS_WRONG_PRPL:
+				purple_conversation_write(conv, "", _("That command doesn't work on this protocol."),
+						PURPLE_MESSAGE_NO_LOG, time(NULL));
+				break;
 		}
-		else if (!purple_account_is_connected(ggconv->active_conv->account))
-		{
-			purple_conversation_write(ggconv->active_conv, "", _("Message was not sent, because you are not signed on."),
-					PURPLE_MESSAGE_ERROR | PURPLE_MESSAGE_NO_LOG, time(NULL));
-		}
-		else
+		g_free(error);
+	}
+	else if (!purple_account_is_connected(ggconv->active_conv->account))
+	{
+		purple_conversation_write(ggconv->active_conv, "", _("Message was not sent, because you are not signed on."),
+				PURPLE_MESSAGE_ERROR | PURPLE_MESSAGE_NO_LOG, time(NULL));
+	}
+	else
+	{
+		char *escape = g_markup_escape_text(text, -1);
+		char *apos = purple_strreplace(escape, "&apos;", "'");
+		g_free(escape);
+		escape = apos;
+		switch (purple_conversation_get_type(ggconv->active_conv))
 		{
-			char *escape = g_markup_escape_text(text, -1);
-			char *apos = purple_strreplace(escape, "&apos;", "'");
-			g_free(escape);
-			escape = apos;
-			switch (purple_conversation_get_type(ggconv->active_conv))
-			{
-				case PURPLE_CONV_TYPE_IM:
-					purple_conv_im_send_with_flags(PURPLE_CONV_IM(ggconv->active_conv), escape, PURPLE_MESSAGE_SEND);
-					break;
-				case PURPLE_CONV_TYPE_CHAT:
-					purple_conv_chat_send(PURPLE_CONV_CHAT(ggconv->active_conv), escape);
-					break;
-				default:
-					g_free(escape);
-					g_return_val_if_reached(FALSE);
-			}
-			g_free(escape);
-			purple_idle_touch();
+			case PURPLE_CONV_TYPE_IM:
+				purple_conv_im_send_with_flags(PURPLE_CONV_IM(ggconv->active_conv), escape, PURPLE_MESSAGE_SEND);
+				break;
+			case PURPLE_CONV_TYPE_CHAT:
+				purple_conv_chat_send(PURPLE_CONV_CHAT(ggconv->active_conv), escape);
+				break;
+			default:
+				g_free(escape);
+				g_return_if_reached();
 		}
-		gnt_entry_add_to_history(GNT_ENTRY(ggconv->entry), text);
-		gnt_entry_clear(GNT_ENTRY(ggconv->entry));
-		return TRUE;
+		g_free(escape);
+		purple_idle_touch();
 	}
-
-	return FALSE;
+	gnt_entry_add_to_history(GNT_ENTRY(ggconv->entry), text);
+	gnt_entry_clear(GNT_ENTRY(ggconv->entry));
 }
 
 static void
@@ -689,7 +683,7 @@
 	gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(ggc->tv), ggc->entry);
 	gnt_text_view_attach_pager_widget(GNT_TEXT_VIEW(ggc->tv), ggc->entry);
 
-	g_signal_connect_after(G_OBJECT(ggc->entry), "key_pressed", G_CALLBACK(entry_key_pressed), ggc);
+	g_signal_connect_after(G_OBJECT(ggc->entry), "activate", G_CALLBACK(entry_key_pressed), ggc);
 	g_signal_connect(G_OBJECT(ggc->entry), "completion", G_CALLBACK(completion_cb), NULL);
 	g_signal_connect(G_OBJECT(ggc->window), "destroy", G_CALLBACK(closing_window), ggc);