changeset 11447:ef6e94bdda08

[gaim-migrate @ 13686] Renamed "conversation-drag-end" signal to "conversation-dragging" and emit before the conv. window swap happens. This prevents the old conv window from being freed before the signal emits. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 05 Sep 2005 05:38:10 +0000
parents 41134575a091
children 1d29b44038c7
files plugins/ChangeLog.API plugins/gtk-signals-test.c plugins/notify.c plugins/win32/transparency/win2ktrans.c src/gtkconv.c
diffstat 5 files changed, 56 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/ChangeLog.API	Mon Sep 05 05:15:45 2005 +0000
+++ b/plugins/ChangeLog.API	Mon Sep 05 05:38:10 2005 +0000
@@ -81,6 +81,11 @@
 	* Changed: gaim_buddy_icon_new(), leaves a reference which the caller
 	           owns. Use gaim_buddy_icon_unref() immediately if you don't
 	           want a reference (the old behavior).
+	* Changed: GAIM_CONV_UNKNOWN to GAIM_CONV_TYPE_UNKNOWN.
+	* Changed: GAIM_CONV_IM to GAIM_CONV_TYPE_IM.
+	* Changed: GAIM_CONV_CHAT to GAIM_CONV_TYPE_CHAT.
+	* Changed: GAIM_CONV_MISC to GAIM_CONV_TYPE_MISC.
+	* Changed: GAIM_CONV_ANY to GAIM_CONV_TYPE_ANY.
 
 	Signals:
 	* Changed: "received-im-msg" and "received-chat-msg" to match, both
@@ -100,11 +105,9 @@
 	           "file-recv-complete", "file-send-accept", "file-send-start",
 	           "file-send-cancel", and "file-send-complete" signals.  See
 	           the Doxygen documentation for the details.
-	* Changed: GAIM_CONV_UNKNOWN to GAIM_CONV_TYPE_UNKNOWN.
-	* Changed: GAIM_CONV_IM to GAIM_CONV_TYPE_IM.
-	* Changed: GAIM_CONV_CHAT to GAIM_CONV_TYPE_CHAT.
-	* Changed: GAIM_CONV_MISC to GAIM_CONV_TYPE_MISC.
-	* Changed: GAIM_CONV_ANY to GAIM_CONV_TYPE_ANY.
+	* Changed: Renamed "conversation-drag-end" to "conversation-dragging"
+	           and emit before the conv. window swap happens. This prevents
+	           the old conv window from being freed before the signal emits.
 
 version 1.0.0 (09/17/2004):
 	* Added: get_chat_name to the GaimPluginProtocolInfo struct
--- a/plugins/gtk-signals-test.c	Mon Sep 05 05:15:45 2005 +0000
+++ b/plugins/gtk-signals-test.c	Mon Sep 05 05:38:10 2005 +0000
@@ -56,8 +56,8 @@
  * Conversation subsystem signal callbacks
  **************************************************************************/
 static void
-conversation_drag_end_cb(GaimConvWindow *source, GaimConvWindow *destination) {
-	gaim_debug_info("gtk-signal-test", "conversation drag ended cb\n");
+conversation_dragging_cb(GaimConvWindow *source, GaimConvWindow *destination) {
+	gaim_debug_info("gtk-signal-test", "conversation dragging cb\n");
 }
 
 /**************************************************************************
@@ -81,8 +81,8 @@
 						plugin, GAIM_CALLBACK(blist_drawing_tooltip_cb), NULL);
 
 	/* Conversations subsystem signals */
-	gaim_signal_connect(conv_handle, "conversation-drag-ended",
-						plugin, GAIM_CALLBACK(conversation_drag_end_cb), NULL);
+	gaim_signal_connect(conv_handle, "conversation-dragging",
+						plugin, GAIM_CALLBACK(conversation_dragging_cb), NULL);
 
 	return TRUE;
 }
--- a/plugins/notify.c	Mon Sep 05 05:15:45 2005 +0000
+++ b/plugins/notify.c	Mon Sep 05 05:38:10 2005 +0000
@@ -427,7 +427,7 @@
 
 #if 0
 static void
-conversation_drag_ended(GaimConversation *active_conv,
+conversation_dragging(GaimConversation *active_conv,
                         GaimConvWindow *old_gaimwin,
                         GaimConvWindow *new_gaimwin)
 {
@@ -792,8 +792,8 @@
 	gaim_signal_connect(conv_handle, "conversation-switched", plugin,
 	                    GAIM_CALLBACK(conv_switched), NULL);
 #if 0
-	gaim_signal_connect(gtk_conv_handle, "conversation-drag-ended", plugin,
-	                    GAIM_CALLBACK(conversation_drag_ended), NULL);
+	gaim_signal_connect(gtk_conv_handle, "conversation-dragging", plugin,
+	                    GAIM_CALLBACK(conversation_dragging), NULL);
 #endif
 
 	while (convs) {
--- a/plugins/win32/transparency/win2ktrans.c	Mon Sep 05 05:15:45 2005 +0000
+++ b/plugins/win32/transparency/win2ktrans.c	Mon Sep 05 05:38:10 2005 +0000
@@ -357,7 +357,7 @@
 	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" );
 
-	gaim_signal_connect((void*)gaim_gtk_conversations_get_handle(), "conversation-drag-ended", plugin, GAIM_CALLBACK(set_window_trans), NULL);
+	gaim_signal_connect((void*)gaim_gtk_conversations_get_handle(), "conversation-dragging", plugin, GAIM_CALLBACK(set_window_trans), NULL);
 
 	update_convs_wintrans(NULL, NULL);
 
--- a/src/gtkconv.c	Mon Sep 05 05:15:45 2005 +0000
+++ b/src/gtkconv.c	Mon Sep 05 05:38:10 2005 +0000
@@ -2271,10 +2271,10 @@
 {
 	GaimConvWindow *dest_win;
 	GaimGtkWindow *gtkwin;
-	GaimGtkWindow *dest_gtkwin;
 	GaimConversation *conv;
-	GtkNotebook *dest_notebook;
-	gint dest_page_num;
+	GaimGtkConversation *gtkconv;
+	gint dest_page_num = 0;
+	gboolean new_window = FALSE;
 
 	/*
 	 * Don't check to make sure that the event's window matches the
@@ -2297,7 +2297,7 @@
 	/* Disconnect the motion signal. */
 	if (gtkwin->drag_motion_signal) {
 		g_signal_handler_disconnect(G_OBJECT(widget),
-									gtkwin->drag_motion_signal);
+			gtkwin->drag_motion_signal);
 
 		gtkwin->drag_motion_signal = 0;
 	}
@@ -2311,7 +2311,7 @@
 
 		if (gtkwin->drag_leave_signal) {
 			g_signal_handler_disconnect(G_OBJECT(widget),
-										gtkwin->drag_leave_signal);
+				gtkwin->drag_leave_signal);
 
 			gtkwin->drag_leave_signal = 0;
 		}
@@ -2331,61 +2331,52 @@
 	conv = gaim_conv_window_get_active_conversation(win);
 
 	if (dest_win == NULL) {
-		if (gaim_conv_window_get_conversation_count(win) < 2)
-			return FALSE;
-
+		/* If the current window doesn't have any other conversations,
+		 * there isn't much point transferring the conv to a new window. */
 		if (gaim_conv_window_get_conversation_count(win) > 1) {
 			/* Make a new window to stick this to. */
-			GaimGtkConversation *gtkconv;
+			dest_win = gaim_conv_window_new();
+			new_window = TRUE;
+		}
+	}
+
+	if (dest_win == NULL)
+		return FALSE;
+
+	gaim_signal_emit(gaim_gtk_conversations_get_handle(),
+		"conversation-dragging", win, dest_win);
+
+	/* Get the destination page number. */
+	if (!new_window)
+		dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win,
+			e->x_root, e->y_root);
+
+	gtkconv = GAIM_GTK_CONVERSATION(conv);
+
+	if (win == dest_win) {
+		gtk_notebook_reorder_child(GTK_NOTEBOOK(gtkwin->notebook), gtkconv->tab_cont, dest_page_num);
+	}
+	else {
+		gaim_conv_window_remove_conversation(win, conv);
+		gaim_conv_window_add_conversation(dest_win, conv);
+		gtk_notebook_reorder_child(GTK_NOTEBOOK(GAIM_GTK_WINDOW(dest_win)->notebook), gtkconv->tab_cont, dest_page_num);
+		gaim_conv_window_switch_conversation(dest_win, conv);
+		if (new_window) {
+			GaimGtkWindow *dest_gtkwin = GAIM_GTK_WINDOW(dest_win);
 			gint win_width, win_height;
 
-			gtkconv = GAIM_GTK_CONVERSATION(conv);
-
-			dest_win = gaim_conv_window_new();
-
-			gaim_conv_window_add_conversation(dest_win,
-			                                  gaim_conv_window_remove_conversation(win,
-			                                  conv));
-
-			dest_gtkwin = GAIM_GTK_WINDOW(dest_win);
-
 			gtk_window_get_size(GTK_WINDOW(dest_gtkwin->window),
-								&win_width, &win_height);
+				&win_width, &win_height);
 
 			gtk_window_move(GTK_WINDOW(dest_gtkwin->window),
-							e->x_root - (win_width  / 2),
-							e->y_root - (win_height / 2));
+				e->x_root - (win_width  / 2),
+				e->y_root - (win_height / 2));
 
 			gaim_conv_window_show(dest_win);
 		}
-	} else {
-		GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv);
-		dest_gtkwin = GAIM_GTK_WINDOW(dest_win);
-
-		/* Get the destination notebook. */
-		dest_notebook = GTK_NOTEBOOK(gtkwin->notebook);
-
-		/* Get the destination page number. */
-		dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win,
-								e->x_root, e->y_root);
-
-		if (win == dest_win) {
-			gtk_notebook_reorder_child(GTK_NOTEBOOK(gtkwin->notebook), gtkconv->tab_cont, dest_page_num);
-		}
-		else {
-			GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv);
-
-			gaim_conv_window_remove_conversation(win, conv);
-			gaim_conv_window_add_conversation(dest_win, conv);
-			gtk_notebook_reorder_child(GTK_NOTEBOOK(GAIM_GTK_WINDOW(dest_win)->notebook), gtkconv->tab_cont, dest_page_num);
-			gaim_conv_window_switch_conversation(dest_win, gtkconv->active_conv);
-		}
-
-		gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry);
 	}
 
-	gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-drag-ended",
-	                 win, dest_win);
+	gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry);
 
 	return TRUE;
 }
@@ -6171,7 +6162,7 @@
 	/**********************************************************************
 	 * Register signals
 	 **********************************************************************/
-	gaim_signal_register(handle, "conversation-drag-ended",
+	gaim_signal_register(handle, "conversation-dragging",
 	                     gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
 	                     gaim_value_new(GAIM_TYPE_SUBTYPE,
 	                                    GAIM_SUBTYPE_CONV_WINDOW),