# HG changeset patch
# Node ID 42633f155e08
# Parent  63639da06cbd
diff --git a/ChangeLog.API b/ChangeLog.API
--- a/ChangeLog.API
+++ b/ChangeLog.API
@@ -1063,6 +1063,8 @@
 		* pidgin_clear_cursor
 		* pidgin_connection_get_handle
 		* PidginConversation.sg
+		* PidginConversation signals: chat-nick-autocomplete,
+		  chat-nick-clicked, conversation-window-created.
 		* PidginConvPlacementFunc
 		* pidgin_conv_get_tab_at_xy
 		* pidgin_conv_get_tab_icon, use PidginPresenceIcon instead.
@@ -1076,6 +1078,7 @@
 		* pidgin_conv_placement_set_current_func
 		* pidgin_conv_placement_get_current_func
 		* pidgin_conv_present_conversation
+		* pidgin_conv_switch_active_conversation
 		* PidginConvWindow
 		* pidgin_conv_window_add_gtkconv
 		* pidgin_conv_window_destroy
diff --git a/doc/reference/pidgin/signals_gtkconv.md b/doc/reference/pidgin/signals_gtkconv.md
--- a/doc/reference/pidgin/signals_gtkconv.md
+++ b/doc/reference/pidgin/signals_gtkconv.md
@@ -156,21 +156,6 @@
 **user_data**
 : User data set when the signal handler was connected.
 
-### conversation-switched
-
-```c
-void user_function(PurpleConversation *conv, gpointer user_data);
-```
-
-Emitted when a window switched from one conversation to another.
-
-**Parameters:**
-
-**new_conv**
-: The now active conversation.
-
-**user_data**
-: User data set when the signal handler was connected.
 
 ### conversation-displayed
 
diff --git a/pidgin/gtkconv.h b/pidgin/gtkconv.h
--- a/pidgin/gtkconv.h
+++ b/pidgin/gtkconv.h
@@ -80,14 +80,6 @@
 PurpleConversationUiOps *pidgin_conversations_get_conv_ui_ops(void);
 
 /**
- * pidgin_conv_switch_active_conversation:
- * @conv: The conversation
- *
- * Sets the active conversation within a GTK-conversation.
- */
-void pidgin_conv_switch_active_conversation(PurpleConversation *conv);
-
-/**
  * pidgin_conv_attach_to_conversation:
  * @conv:  The conversation.
  *
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -25,7 +25,6 @@
 #endif
 
 #include <glib/gi18n-lib.h>
-#include <glib/gstdio.h>
 
 #include <gplugin.h>
 
@@ -35,49 +34,14 @@
 
 #include <purple.h>
 
-#include <math.h>
-
-#include "gtkblist.h"
 #include "gtkconv.h"
-#include "gtkdialogs.h"
-#include "gtkutils.h"
-#include "pidginavatar.h"
-#include "pidgincolor.h"
 #include "pidgincore.h"
 #include "pidgindisplaywindow.h"
 #include "pidgininfopane.h"
-#include "pidgininvitedialog.h"
 #include "pidginmessage.h"
-#include "pidginpresenceicon.h"
-
-enum {
-	CHAT_USERS_ICON_COLUMN,
-	CHAT_USERS_ALIAS_COLUMN,
-	CHAT_USERS_ALIAS_KEY_COLUMN,
-	CHAT_USERS_NAME_COLUMN,
-	CHAT_USERS_FLAGS_COLUMN,
-	CHAT_USERS_COLOR_COLUMN,
-	CHAT_USERS_WEIGHT_COLUMN,
-	CHAT_USERS_ICON_NAME_COLUMN,
-	CHAT_USERS_COLUMNS
-};
-
-typedef enum
-{
-	PIDGIN_CONV_SET_TITLE			= 1 << 0,
-	PIDGIN_CONV_BUDDY_ICON			= 1 << 1,
-	PIDGIN_CONV_MENU			= 1 << 2,
-	PIDGIN_CONV_TAB_ICON			= 1 << 3,
-	PIDGIN_CONV_TOPIC			= 1 << 4,
-	PIDGIN_CONV_COLORIZE_TITLE		= 1 << 6,
-}PidginConvFields;
-
-#define	PIDGIN_CONV_ALL	((1 << 7) - 1)
 
 /* Prototypes. <-- because Paco-Paco hates this comment. */
-static void pidgin_conv_updated(PurpleConversation *conv, PurpleConversationUpdateType type);
 gboolean pidgin_conv_has_focus(PurpleConversation *conv);
-static void pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields);
 
 static void pidgin_conv_placement_place(PidginConversation *conv);
 
@@ -265,175 +229,6 @@
 	talkatu_buffer_clear(TALKATU_BUFFER(buffer));
 }
 
-static gboolean
-gtkconv_cycle_focus(PidginConversation *gtkconv, GtkDirectionType dir)
-{
-	GtkWidget *next = NULL;
-	struct {
-		GtkWidget *from;
-		GtkWidget *to;
-	} transitions[] = {
-		{gtkconv->entry, gtkconv->history},
-		{gtkconv->history, gtkconv->entry},
-		{NULL, NULL}
-	}, *ptr;
-
-	for (ptr = transitions; !next && ptr->from; ptr++) {
-		GtkWidget *from, *to;
-		if (dir == GTK_DIR_TAB_FORWARD) {
-			from = ptr->from;
-			to = ptr->to;
-		} else {
-			from = ptr->to;
-			to = ptr->from;
-		}
-		if (gtk_widget_is_focus(from))
-			next = to;
-	}
-
-	if (next)
-		gtk_widget_grab_focus(next);
-	return !!next;
-}
-
-static gboolean
-conv_keypress_common(PidginConversation *gtkconv, guint keyval,
-                     GdkModifierType state)
-{
-	/* If CTRL was held down... */
-	if (state & GDK_CONTROL_MASK) {
-		switch (keyval) {
-			case GDK_KEY_F6:
-				if (gtkconv_cycle_focus(gtkconv,
-				                        state & GDK_SHIFT_MASK ?
-				                        GTK_DIR_TAB_BACKWARD :
-				                        GTK_DIR_TAB_FORWARD))
-				{
-					return TRUE;
-				}
-				break;
-		} /* End of switch */
-
-	/* If ALT (or whatever) was held down... */
-	} else if (state & GDK_ALT_MASK) {
-
-	/* If neither CTRL nor ALT were held down... */
-	} else {
-		switch (keyval) {
-		case GDK_KEY_F6:
-			if (gtkconv_cycle_focus(gtkconv,
-			                        state & GDK_SHIFT_MASK ?
-			                        GTK_DIR_TAB_BACKWARD :
-			                        GTK_DIR_TAB_FORWARD))
-			{
-				return TRUE;
-			}
-			break;
-		case GDK_KEY_Page_Up:
-		case GDK_KEY_KP_Page_Up:
-			talkatu_auto_scroller_decrement(TALKATU_AUTO_SCROLLER(gtkconv->vadjustment));
-			return TRUE;
-			break;
-		case GDK_KEY_Page_Down:
-		case GDK_KEY_KP_Page_Down:
-			talkatu_auto_scroller_increment(TALKATU_AUTO_SCROLLER(gtkconv->vadjustment));
-			return TRUE;
-			break;
-		}
-	}
-	return FALSE;
-}
-
-static gboolean
-is_valid_conversation_key(guint keyval, GdkModifierType state)
-{
-	if (state & GDK_CONTROL_MASK) {
-		return TRUE;
-	}
-
-	switch (keyval) {
-		case GDK_KEY_F6:
-		case GDK_KEY_F10:
-		case GDK_KEY_Menu:
-		case GDK_KEY_Shift_L:
-		case GDK_KEY_Shift_R:
-		case GDK_KEY_Control_L:
-		case GDK_KEY_Control_R:
-		case GDK_KEY_Escape:
-		case GDK_KEY_Up:
-		case GDK_KEY_Down:
-		case GDK_KEY_Left:
-		case GDK_KEY_Right:
-		case GDK_KEY_Page_Up:
-		case GDK_KEY_KP_Page_Up:
-		case GDK_KEY_Page_Down:
-		case GDK_KEY_KP_Page_Down:
-		case GDK_KEY_Home:
-		case GDK_KEY_End:
-		case GDK_KEY_Tab:
-		case GDK_KEY_KP_Tab:
-		case GDK_KEY_ISO_Left_Tab:
-			return TRUE;
-		default:
-			return FALSE;
-	}
-}
-
-/*
- * If someone tries to type into the conversation backlog of a
- * conversation window then we yank focus from the conversation backlog
- * and give it to the text entry box so that people can type
- * all the live long day and it will get entered into the entry box.
- */
-static gboolean
-refocus_entry_cb(GtkEventControllerKey *controller, guint keyval,
-                 G_GNUC_UNUSED guint keycode, GdkModifierType state,
-                 gpointer data)
-{
-	PidginConversation *gtkconv = data;
-	GtkWidget *input = NULL;
-	GdkEvent *event = NULL;
-
-	/* If we have a valid key for the conversation display, then exit */
-	event = gtk_event_controller_get_current_event(GTK_EVENT_CONTROLLER(controller));
-	if (is_valid_conversation_key(keyval, state)) {
-		if (gdk_event_get_event_type(event) == GDK_KEY_PRESS) {
-			return conv_keypress_common(gtkconv, keyval, state);
-		}
-		return FALSE;
-	}
-
-	input = talkatu_editor_get_input(TALKATU_EDITOR(gtkconv->editor));
-	gtk_widget_grab_focus(input);
-	gtk_event_controller_key_forward(controller, input);
-
-	return TRUE;
-}
-
-void
-pidgin_conv_switch_active_conversation(PurpleConversation *conv)
-{
-	PidginConversation *gtkconv;
-	PurpleConversation *old_conv;
-
-	g_return_if_fail(conv != NULL);
-
-	gtkconv = PIDGIN_CONVERSATION(conv);
-	old_conv = gtkconv->active_conv;
-
-	purple_debug_info("gtkconv", "setting active conversation on toolbar %p\n",
-		conv);
-
-	if (old_conv == conv)
-		return;
-
-	gtkconv->active_conv = conv;
-
-	purple_signal_emit(pidgin_conversations_get_handle(), "conversation-switched", conv);
-
-	g_object_set_data(G_OBJECT(gtkconv->entry), "transient_buddy", NULL);
-}
-
 /**************************************************************************
  * Utility functions
  **************************************************************************/
@@ -443,7 +238,6 @@
 	GSimpleActionGroup *ag = NULL;
 	GtkTextBuffer *buffer = NULL;
 	GtkWidget *vbox, *input, *hpaned, *sw;
-	GtkEventController *key = NULL;
 	PurpleConversation *conv = gtkconv->active_conv;
 
 	/* Setup the top part of the pane */
@@ -475,13 +269,6 @@
 
 	g_object_set_data(G_OBJECT(gtkconv->history), "gtkconv", gtkconv);
 
-	key = gtk_event_controller_key_new();
-	g_signal_connect(key, "key-pressed", G_CALLBACK(refocus_entry_cb),
-	                 gtkconv);
-	g_signal_connect(key, "key-released", G_CALLBACK(refocus_entry_cb),
-	                 gtkconv);
-	gtk_widget_add_controller(gtkconv->history, key);
-
 	/* Setup the entry widget and all signals */
 	gtkconv->editor = talkatu_editor_new();
 	ag = talkatu_action_group_new(TALKATU_FORMAT_HTML);
@@ -568,7 +355,6 @@
 		g_object_set_data(G_OBJECT(conv), "pidgin", gtkconv);
 		if (!g_list_find(gtkconv->convs, conv))
 			gtkconv->convs = g_list_prepend(gtkconv->convs, conv);
-		pidgin_conv_switch_active_conversation(conv);
 		return;
 	}
 
@@ -760,99 +546,6 @@
 	return FALSE;
 }
 
-static void
-pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields)
-{
-	PidginConversation *gtkconv;
-	PidginDisplayWindow *displaywin;
-	GtkRoot *win;
-
-	gtkconv = PIDGIN_CONVERSATION(conv);
-	if (!gtkconv)
-		return;
-
-	win = gtk_widget_get_root(gtkconv->tab_cont);
-	displaywin = PIDGIN_DISPLAY_WINDOW(win);
-
-	if (fields & PIDGIN_CONV_SET_TITLE)
-	{
-		purple_conversation_autoset_title(conv);
-	}
-
-	if ((fields & PIDGIN_CONV_COLORIZE_TITLE) ||
-			(fields & PIDGIN_CONV_SET_TITLE) ||
-			(fields & PIDGIN_CONV_TOPIC))
-	{
-		char *title;
-		PurpleAccount *account = purple_conversation_get_account(conv);
-
-		if ((account == NULL) ||
-			!purple_account_is_connected(account) ||
-			(PURPLE_IS_CHAT_CONVERSATION(conv)
-				&& purple_chat_conversation_has_left(PURPLE_CHAT_CONVERSATION(conv))))
-			title = g_strdup_printf("(%s)", purple_conversation_get_title(conv));
-		else
-			title = g_strdup(purple_conversation_get_title(conv));
-
-		if (pidgin_display_window_conversation_is_selected(displaywin, conv)) {
-			const char* current_title = gtk_window_get_title(GTK_WINDOW(win));
-			if (current_title == NULL || !purple_strequal(current_title, title)) {
-				gtk_window_set_title(GTK_WINDOW(win), title);
-			}
-		}
-
-		g_free(title);
-	}
-}
-
-static void
-pidgin_conv_updated(PurpleConversation *conv, PurpleConversationUpdateType type)
-{
-	PidginConvFields flags = 0;
-
-	g_return_if_fail(conv != NULL);
-
-	if (type == PURPLE_CONVERSATION_UPDATE_ACCOUNT)
-	{
-		flags = PIDGIN_CONV_ALL;
-	}
-	else if (type == PURPLE_CONVERSATION_UPDATE_TYPING ||
-	         type == PURPLE_CONVERSATION_UPDATE_UNSEEN ||
-	         type == PURPLE_CONVERSATION_UPDATE_TITLE)
-	{
-		flags = PIDGIN_CONV_COLORIZE_TITLE;
-	}
-	else if (type == PURPLE_CONVERSATION_UPDATE_TOPIC)
-	{
-		flags = PIDGIN_CONV_TOPIC;
-	}
-	else if (type == PURPLE_CONVERSATION_ACCOUNT_ONLINE ||
-	         type == PURPLE_CONVERSATION_ACCOUNT_OFFLINE)
-	{
-		flags = PIDGIN_CONV_MENU | PIDGIN_CONV_TAB_ICON | PIDGIN_CONV_SET_TITLE;
-	}
-	else if (type == PURPLE_CONVERSATION_UPDATE_AWAY)
-	{
-		flags = PIDGIN_CONV_TAB_ICON;
-	}
-	else if (type == PURPLE_CONVERSATION_UPDATE_ADD ||
-	         type == PURPLE_CONVERSATION_UPDATE_REMOVE ||
-	         type == PURPLE_CONVERSATION_UPDATE_CHATLEFT)
-	{
-		flags = PIDGIN_CONV_SET_TITLE | PIDGIN_CONV_MENU;
-	}
-	else if (type == PURPLE_CONVERSATION_UPDATE_ICON)
-	{
-		flags = PIDGIN_CONV_BUDDY_ICON;
-	}
-	else if (type == PURPLE_CONVERSATION_UPDATE_FEATURES)
-	{
-		flags = PIDGIN_CONV_MENU;
-	}
-
-	pidgin_conv_update_fields(conv, flags);
-}
-
 static PurpleConversationUiOps conversation_ui_ops =
 {
 	.create_conversation = pidgin_conv_new,
@@ -901,232 +594,6 @@
 	}
 }
 
-static PidginConversation *
-get_gtkconv_with_contact(PurpleMetaContact *contact)
-{
-	PurpleBlistNode *node;
-
-	node = ((PurpleBlistNode*)contact)->child;
-
-	for (; node; node = node->next)
-	{
-		PurpleBuddy *buddy = (PurpleBuddy*)node;
-		PurpleConversation *im;
-		PurpleConversationManager *manager;
-
-		manager = purple_conversation_manager_get_default();
-		im = purple_conversation_manager_find_im(manager,
-		                                         purple_buddy_get_account(buddy),
-		                                         purple_buddy_get_name(buddy));
-		if(PURPLE_IS_IM_CONVERSATION(im)) {
-			return PIDGIN_CONVERSATION(im);
-		}
-	}
-	return NULL;
-}
-
-static void
-account_signed_off_cb(PurpleConnection *gc, G_GNUC_UNUSED gpointer event)
-{
-	PurpleConversationManager *manager;
-	GList *list;
-
-	manager = purple_conversation_manager_get_default();
-	list = purple_conversation_manager_get_all(manager);
-
-	while(list != NULL) {
-		PurpleConversation *conv = PURPLE_CONVERSATION(list->data);
-
-		/* This seems fine in theory, but we also need to cover the
-		 * case of this account matching one of the other buddies in
-		 * one of the contacts containing the buddy corresponding to
-		 * a conversation.  It's easier to just update them all. */
-		/* if (purple_conversation_get_account(conv) == account) */
-			pidgin_conv_update_fields(conv, PIDGIN_CONV_TAB_ICON |
-							PIDGIN_CONV_MENU | PIDGIN_CONV_COLORIZE_TITLE);
-
-		if (PURPLE_CONNECTION_IS_CONNECTED(gc) &&
-				PURPLE_IS_CHAT_CONVERSATION(conv) &&
-				purple_conversation_get_account(conv) == purple_connection_get_account(gc) &&
-				g_object_get_data(G_OBJECT(conv), "want-to-rejoin")) {
-			GHashTable *comps = NULL;
-			PurpleChat *chat = purple_blist_find_chat(purple_conversation_get_account(conv), purple_conversation_get_name(conv));
-			if (chat == NULL) {
-				PurpleProtocol *protocol = purple_connection_get_protocol(gc);
-				comps = purple_protocol_chat_info_defaults(PURPLE_PROTOCOL_CHAT(protocol), gc, purple_conversation_get_name(conv));
-			} else {
-				comps = purple_chat_get_components(chat);
-			}
-			purple_serv_join_chat(gc, comps);
-			if (chat == NULL && comps != NULL)
-				g_hash_table_destroy(comps);
-		}
-
-		list = g_list_delete_link(list, list);
-	}
-}
-
-static void
-account_signing_off(PurpleConnection *gc)
-{
-	PurpleConversationManager *manager;
-	GList *list;
-	PurpleAccount *account = purple_connection_get_account(gc);
-
-	manager = purple_conversation_manager_get_default();
-	list = purple_conversation_manager_get_all(manager);
-
-	/* We are about to sign off. See which chats we are currently in, and mark
-	 * them for rejoin on reconnect. */
-	while(list != NULL) {
-		if(PURPLE_IS_CHAT_CONVERSATION(list->data)) {
-			PurpleConversation *conv;
-			PurpleChatConversation *chat;
-			gboolean left;
-
-			conv = PURPLE_CONVERSATION(list->data);
-			chat = PURPLE_CHAT_CONVERSATION(conv);
-			left = purple_chat_conversation_has_left(chat);
-
-			if(!left && purple_conversation_get_account(conv) == account) {
-				g_object_set_data(G_OBJECT(conv), "want-to-rejoin",
-				                  GINT_TO_POINTER(TRUE));
-
-				purple_conversation_write_system_message(
-					conv,
-					_("The account has disconnected and you are no longer in "
-					  "this chat. You will automatically rejoin the chat when "
-					  "the account reconnects."),
-					PURPLE_MESSAGE_NO_LOG);
-			}
-		}
-
-		list = g_list_delete_link(list, list);
-	}
-}
-
-static void
-update_buddy_status_changed(PurpleBuddy *buddy, PurpleStatus *old, PurpleStatus *newstatus)
-{
-	PidginConversation *gtkconv;
-	PurpleConversation *conv;
-
-	gtkconv = get_gtkconv_with_contact(purple_buddy_get_contact(buddy));
-	if (gtkconv)
-	{
-		conv = gtkconv->active_conv;
-		pidgin_conv_update_fields(conv, PIDGIN_CONV_TAB_ICON
-		                              | PIDGIN_CONV_COLORIZE_TITLE
-		                              | PIDGIN_CONV_BUDDY_ICON);
-		if ((purple_status_is_online(old) ^ purple_status_is_online(newstatus)) != 0)
-			pidgin_conv_update_fields(conv, PIDGIN_CONV_MENU);
-	}
-}
-
-static void
-update_buddy_privacy_changed(PurpleBuddy *buddy)
-{
-	PidginConversation *gtkconv;
-	PurpleConversation *conv;
-
-	gtkconv = get_gtkconv_with_contact(purple_buddy_get_contact(buddy));
-	if (gtkconv) {
-		conv = gtkconv->active_conv;
-		pidgin_conv_update_fields(conv, PIDGIN_CONV_TAB_ICON | PIDGIN_CONV_MENU);
-	}
-}
-
-static void
-update_buddy_idle_changed(PurpleBuddy *buddy, G_GNUC_UNUSED gboolean old,
-                          G_GNUC_UNUSED gboolean newidle)
-{
-	PurpleConversation *im;
-	PurpleConversationManager *manager;
-
-	manager = purple_conversation_manager_get_default();
-	im = purple_conversation_manager_find_im(manager,
-	                                         purple_buddy_get_account(buddy),
-	                                         purple_buddy_get_name(buddy));
-	if(PURPLE_IS_IM_CONVERSATION(im)) {
-		pidgin_conv_update_fields(im, PIDGIN_CONV_TAB_ICON);
-	}
-}
-
-static void
-update_buddy_icon(PurpleBuddy *buddy)
-{
-	PurpleConversation *im;
-	PurpleConversationManager *manager;
-
-	manager = purple_conversation_manager_get_default();
-	im = purple_conversation_manager_find_im(manager,
-	                                         purple_buddy_get_account(buddy),
-	                                         purple_buddy_get_name(buddy));
-
-	if(PURPLE_IS_IM_CONVERSATION(im)) {
-		pidgin_conv_update_fields(im, PIDGIN_CONV_BUDDY_ICON);
-	}
-}
-
-static void
-update_buddy_sign(PurpleBuddy *buddy, const char *which)
-{
-	PurplePresence *presence;
-	PurpleStatus *on, *off;
-
-	presence = purple_buddy_get_presence(buddy);
-	if (!presence)
-		return;
-	off = purple_presence_get_status(presence, "offline");
-	on = purple_presence_get_status(presence, "available");
-
-	if (*(which+1) == 'f')
-		update_buddy_status_changed(buddy, on, off);
-	else
-		update_buddy_status_changed(buddy, off, on);
-}
-
-static void
-update_conversation_switched(PurpleConversation *conv)
-{
-	pidgin_conv_update_fields(conv, PIDGIN_CONV_TAB_ICON |
-		PIDGIN_CONV_SET_TITLE | PIDGIN_CONV_MENU |
-		PIDGIN_CONV_BUDDY_ICON);
-}
-
-static void
-update_buddy_typing(PurpleAccount *account, const char *who)
-{
-	PurpleConversation *conv;
-	PurpleConversationManager *manager;
-	PidginConversation *gtkconv;
-
-	manager = purple_conversation_manager_get_default();
-	conv = purple_conversation_manager_find_im(manager, account, who);
-	if(!PURPLE_IS_CONVERSATION(conv)) {
-		return;
-	}
-
-	gtkconv = PIDGIN_CONVERSATION(conv);
-	if(gtkconv && gtkconv->active_conv == conv) {
-		pidgin_conv_update_fields(conv, PIDGIN_CONV_COLORIZE_TITLE);
-	}
-}
-
-static void
-update_chat(PurpleChatConversation *chat)
-{
-	pidgin_conv_update_fields(PURPLE_CONVERSATION(chat), PIDGIN_CONV_TOPIC |
-					PIDGIN_CONV_MENU | PIDGIN_CONV_SET_TITLE);
-}
-
-static void
-update_chat_topic(PurpleChatConversation *chat, G_GNUC_UNUSED const char *old,
-                  G_GNUC_UNUSED const char *new)
-{
-	pidgin_conv_update_fields(PURPLE_CONVERSATION(chat), PIDGIN_CONV_TOPIC);
-}
-
 static void
 pidgin_conv_attach(PurpleConversation *conv)
 {
@@ -1166,7 +633,6 @@
 pidgin_conversations_init(void)
 {
 	void *handle = pidgin_conversations_get_handle();
-	void *blist_handle = purple_blist_get_handle();
 
 	/* Conversations */
 	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations");
@@ -1175,8 +641,6 @@
 
 	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar", TRUE);
 
-	purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/scrollback_lines", 4000);
-
 	/* Conversations -> Chat */
 	purple_prefs_remove(PIDGIN_PREFS_ROOT "/conversations/chat");
 
@@ -1206,41 +670,13 @@
 		purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2,
 		PURPLE_TYPE_CONVERSATION, PURPLE_TYPE_MESSAGE);
 
-	purple_signal_register(handle, "conversation-switched",
-						 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
-						 PURPLE_TYPE_CONVERSATION);
-
 	purple_signal_register(handle, "conversation-displayed",
 						 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
 						 G_TYPE_POINTER); /* (PidginConversation *) */
 
-	purple_signal_register(handle, "chat-nick-autocomplete",
-						 purple_marshal_BOOLEAN__POINTER_BOOLEAN,
-						 G_TYPE_BOOLEAN, 1, PURPLE_TYPE_CONVERSATION);
-
-	purple_signal_register(handle, "chat-nick-clicked",
-						 purple_marshal_BOOLEAN__POINTER_POINTER_UINT,
-						 G_TYPE_BOOLEAN, 3, PURPLE_TYPE_CONVERSATION,
-						 G_TYPE_STRING, G_TYPE_UINT);
-
-	purple_signal_register(handle, "conversation-window-created",
-		purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
-		G_TYPE_POINTER); /* (PidginConvWindow *) */
-
-
 	/**********************************************************************
 	 * UI operations
 	 **********************************************************************/
-
-	purple_signal_connect(purple_connections_get_handle(), "signed-on", handle,
-						G_CALLBACK(account_signed_off_cb),
-						GINT_TO_POINTER(PURPLE_CONVERSATION_ACCOUNT_ONLINE));
-	purple_signal_connect(purple_connections_get_handle(), "signed-off", handle,
-						G_CALLBACK(account_signed_off_cb),
-						GINT_TO_POINTER(PURPLE_CONVERSATION_ACCOUNT_OFFLINE));
-	purple_signal_connect(purple_connections_get_handle(), "signing-off", handle,
-						G_CALLBACK(account_signing_off), NULL);
-
 	purple_signal_connect(purple_conversations_get_handle(), "writing-im-msg",
 		handle, G_CALLBACK(writing_msg), NULL);
 	purple_signal_connect(purple_conversations_get_handle(), "writing-chat-msg",
@@ -1249,35 +685,6 @@
 						handle, G_CALLBACK(received_im_msg_cb), NULL);
 
 	purple_conversations_set_ui_ops(&conversation_ui_ops);
-
-	/* Callbacks to update a conversation */
-	purple_signal_connect(blist_handle, "buddy-signed-on",
-						handle, G_CALLBACK(update_buddy_sign), "on");
-	purple_signal_connect(blist_handle, "buddy-signed-off",
-						handle, G_CALLBACK(update_buddy_sign), "off");
-	purple_signal_connect(blist_handle, "buddy-status-changed",
-						handle, G_CALLBACK(update_buddy_status_changed), NULL);
-	purple_signal_connect(blist_handle, "buddy-privacy-changed",
-						handle, G_CALLBACK(update_buddy_privacy_changed), NULL);
-	purple_signal_connect(blist_handle, "buddy-idle-changed",
-						handle, G_CALLBACK(update_buddy_idle_changed), NULL);
-	purple_signal_connect(blist_handle, "buddy-icon-changed",
-						handle, G_CALLBACK(update_buddy_icon), NULL);
-	purple_signal_connect(purple_conversations_get_handle(), "buddy-typing",
-						handle, G_CALLBACK(update_buddy_typing), NULL);
-	purple_signal_connect(purple_conversations_get_handle(), "buddy-typing-stopped",
-						handle, G_CALLBACK(update_buddy_typing), NULL);
-	purple_signal_connect(pidgin_conversations_get_handle(), "conversation-switched",
-						handle, G_CALLBACK(update_conversation_switched), NULL);
-	purple_signal_connect(purple_conversations_get_handle(), "chat-left", handle,
-						G_CALLBACK(update_chat), NULL);
-	purple_signal_connect(purple_conversations_get_handle(), "chat-joined", handle,
-						G_CALLBACK(update_chat), NULL);
-	purple_signal_connect(purple_conversations_get_handle(), "chat-topic-changed", handle,
-						G_CALLBACK(update_chat_topic), NULL);
-	purple_signal_connect_priority(purple_conversations_get_handle(), "conversation-updated", handle,
-						G_CALLBACK(pidgin_conv_updated), NULL,
-						PURPLE_SIGNAL_PRIORITY_LOWEST);
 }
 
 void
diff --git a/pidgin/pidgindisplaywindow.c b/pidgin/pidgindisplaywindow.c
--- a/pidgin/pidgindisplaywindow.c
+++ b/pidgin/pidgindisplaywindow.c
@@ -432,7 +432,7 @@
 
 	/* Add a key controller. */
 	key = gtk_event_controller_key_new();
-	gtk_event_controller_set_propagation_phase(key, GTK_PHASE_CAPTURE);
+	gtk_event_controller_set_propagation_phase(key, GTK_PHASE_BUBBLE);
 	g_signal_connect(G_OBJECT(key), "key-pressed",
 	                 G_CALLBACK(pidgin_display_window_key_pressed_cb),
 	                 window);
