/pidgin/main: c0334bd2d848: Send 'typing' status when typing in ...

Ankit Vani a at nevitus.org
Mon Dec 30 14:00:56 EST 2013


Changeset: c0334bd2d848bb730636fe0829b7bc3d8dc91ae8
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-12-31 00:30 +0530
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/c0334bd2d848

Description:

Send 'typing' status when typing in an IM

diffstat:

 pidgin/gtkconv.c |  71 +++++++++++++++++++++++++------------------------------
 1 files changed, 32 insertions(+), 39 deletions(-)

diffs (136 lines):

diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -199,15 +199,14 @@ static void generate_send_to_items(Pidgi
 /* Prototypes. <-- because Paco-Paco hates this comment. */
 static void load_conv_theme(PidginConversation *gtkconv);
 static gboolean infopane_entry_activate(PidginConversation *gtkconv);
-#if 0
 static void got_typing_keypress(PidginConversation *gtkconv, gboolean first);
-#endif
 static void gray_stuff_out(PidginConversation *gtkconv);
 static void add_chat_user_common(PurpleChatConversation *chat, PurpleChatUser *cb, const char *old_name);
 static gboolean tab_complete(PurpleConversation *conv);
 static void pidgin_conv_updated(PurpleConversation *conv, PurpleConversationUpdateType type);
 static void conv_set_unseen(PurpleConversation *gtkconv, PidginUnseenState state);
 static void gtkconv_set_unseen(PidginConversation *gtkconv, PidginUnseenState state);
+static void update_typing_state(PidginConversation *gtkconv, gboolean deleting);
 static void update_typing_icon(PidginConversation *gtkconv);
 static void update_typing_message(PidginConversation *gtkconv, const char *message);
 gboolean pidgin_conv_has_focus(PurpleConversation *conv);
@@ -2199,6 +2198,20 @@ entry_key_press_cb(GtkWidget *entry, Gdk
 
 		}
 	}
+
+	if (PURPLE_IS_IM_CONVERSATION(conv)) {
+		gboolean deleting = FALSE;
+
+		switch (event->keyval) {
+		case GDK_KEY_BackSpace:
+		case GDK_KEY_Delete:
+		case GDK_KEY_KP_Delete:
+			deleting = TRUE;
+		}
+
+		update_typing_state(gtkconv, deleting);
+	}
+
 	return FALSE;
 }
 
@@ -2410,54 +2423,34 @@ menu_conv_sel_send_cb(GObject *m, gpoint
 	pidgin_conv_switch_active_conversation(PURPLE_CONVERSATION(im));
 }
 
-#if 0
-static void
-insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position,
-			   gchar *new_text, gint new_text_length, gpointer user_data)
-{
-	PidginConversation *gtkconv = (PidginConversation *)user_data;
+static void
+update_typing_state(PidginConversation *gtkconv, gboolean deleting)
+{
+	PurpleIMConversation *im;
+	gchar *text;
 
 	g_return_if_fail(gtkconv != NULL);
 
 	if (!purple_prefs_get_bool("/purple/conversations/im/send_typing"))
 		return;
 
-	got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) &&
-	                    gtk_text_iter_is_end(position)));
-}
-
-static void
-delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos,
-			   GtkTextIter *end_pos, gpointer user_data)
-{
-	PidginConversation *gtkconv = (PidginConversation *)user_data;
-	PurpleConversation *conv;
-	PurpleIMConversation *im;
-
-	g_return_if_fail(gtkconv != NULL);
-
-	conv = gtkconv->active_conv;
-
-	if (!purple_prefs_get_bool("/purple/conversations/im/send_typing"))
-		return;
-
-	im = PURPLE_CONV_IM(conv);
-
-	if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) {
+	im = PURPLE_IM_CONVERSATION(gtkconv->active_conv);
+
+	text = gtk_webview_get_body_text(GTK_WEBVIEW(gtkconv->entry));
+
+	if (!*text) {
 
 		/* We deleted all the text, so turn off typing. */
 		purple_im_conversation_stop_send_typed_timeout(im);
 
-		serv_send_typing(purple_conversation_get_connection(conv),
-						 purple_conversation_get_name(conv),
+		serv_send_typing(purple_conversation_get_connection(gtkconv->active_conv),
+						 purple_conversation_get_name(gtkconv->active_conv),
 						 PURPLE_IM_NOT_TYPING);
 	}
 	else {
-		/* We're deleting, but not all of it, so it counts as typing. */
-		got_typing_keypress(gtkconv, FALSE);
-	}
-}
-#endif
+		got_typing_keypress(gtkconv, !deleting && text[1] == '\0');
+	}
+}
 
 /**************************************************************************
  * A bunch of buddy icon functions
@@ -3722,7 +3715,6 @@ setup_menubar(PidginWindow *win)
  * Utility functions
  **************************************************************************/
 
-#if 0
 static void
 got_typing_keypress(PidginConversation *gtkconv, gboolean first)
 {
@@ -3734,7 +3726,7 @@ got_typing_keypress(PidginConversation *
 	 * send PURPLE_IM_TYPED any time soon.
 	 */
 
-	im = PURPLE_CONV_IM(conv);
+	im = PURPLE_IM_CONVERSATION(conv);
 
 	purple_im_conversation_stop_send_typed_timeout(im);
 	purple_im_conversation_start_send_typed_timeout(im);
@@ -3751,6 +3743,7 @@ got_typing_keypress(PidginConversation *
 	}
 }
 
+#if 0
 static gboolean
 typing_animation(gpointer data) {
 	PidginConversation *gtkconv = data;



More information about the Commits mailing list