changeset 10928:80a4e8e40057

[gaim-migrate @ 12705] "destroy-event" doesn't get this far when the window is closed, so the trans. data isn't cleaned up when the conv. window is closed. This causes crashes when we do try to clean up. So, we use the "deleting-conversation" signal and detect that the last conversation in the window is being deleted. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Wed, 18 May 2005 22:06:32 +0000
parents 4d87f2dccb6d
children 0e274aad49c8
files plugins/win32/transparency/win2ktrans.c
diffstat 1 files changed, 19 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/win32/transparency/win2ktrans.c	Wed May 18 04:48:51 2005 +0000
+++ b/plugins/win32/transparency/win2ktrans.c	Wed May 18 22:06:32 2005 +0000
@@ -163,16 +163,21 @@
 	return NULL;
 }
 
-static gboolean win_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data) {
-	slider_win *slidwin=NULL;
-	/* Remove window from the window list */
-	gaim_debug_info(WINTRANS_PLUGIN_ID, "Conv window destoyed.. removing from list\n");
+static void gaim_conversation_delete(GaimConversation *conv) {
+	GaimConvWindow *win = gaim_conversation_get_window(conv);
+	//If it is the last conversation in the window, get rid of the sliders
+	if (gaim_conv_window_get_conversation_count(win) == 1) {
+		GtkWidget *widget = GAIM_GTK_WINDOW(win)->window;
+		slider_win *slidwin = NULL;
 
-	if((slidwin=find_slidwin(widget))) {
-		window_list = g_list_remove(window_list, (gpointer)slidwin);
-		g_free(slidwin);
+		/* Remove window from the window list */
+		gaim_debug_info(WINTRANS_PLUGIN_ID, "Conv window destoyed.. removing from list\n");
+
+		if ((slidwin=find_slidwin(widget))) {
+			window_list = g_list_remove(window_list, (gpointer)slidwin);
+			g_free(slidwin);
+		}
 	}
-	return FALSE;
 }
 
 static void set_trans_option(GtkWidget *w, const char *pref) {
@@ -225,8 +230,6 @@
 		slidwin->win = win;
 		slidwin->slider = slider_box;
 		window_list = g_list_append(window_list, (gpointer)slidwin);
-		/* Set callback to remove window from the list, if the window is destroyed */
-		g_signal_connect(GTK_OBJECT(win), "destroy_event", G_CALLBACK(win_destroy_cb), NULL);
 	}
 }
 
@@ -345,6 +348,12 @@
 						plugin,
 						GAIM_CALLBACK(gaim_new_conversation),
 						NULL);
+	/* Set callback to remove window from the list, if the window is destroyed */
+	gaim_signal_connect(gaim_conversations_get_handle(),
+						"deleting-conversation",
+						plugin,
+						GAIM_CALLBACK(gaim_conversation_delete),
+						NULL);
 	gaim_signal_connect((void*)gaim_connections_get_handle(), "signed-on", plugin, GAIM_CALLBACK(blist_created), NULL);
 	MySetLayeredWindowAttributes = (void*)wgaim_find_and_loadproc("user32.dll", "SetLayeredWindowAttributes" );