# HG changeset patch
# Node ID cabaab494d95
# Parent  3a52d37dd34e
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -160,7 +160,6 @@
 
 static void pidgin_conv_set_position_size(PidginConvWindow *win, int x, int y,
 		int width, int height);
-static gboolean pidgin_conv_xy_to_right_infopane(PidginConvWindow *win, int x, int y);
 
 static PurpleBlistNode *
 get_conversation_blist_node(PurpleConversation *conv)
@@ -4017,21 +4016,6 @@
 		gray_stuff_out(PIDGIN_CONVERSATION(conv));
 }
 
-static gboolean
-pidgin_conv_xy_to_right_infopane(PidginConvWindow *win, int x, int y)
-{
-	gint pane_x, pane_y, x_rel;
-	PidginConversation *gtkconv;
-	GtkAllocation allocation;
-
-	gdk_window_get_origin(gtk_widget_get_window(win->notebook),
-	                      &pane_x, &pane_y);
-	x_rel = x - pane_x;
-	gtkconv = pidgin_conv_window_get_active_gtkconv(win);
-	gtk_widget_get_allocation(gtkconv->infopane, &allocation);
-	return (x_rel > allocation.x + allocation.width / 2);
-}
-
 int
 pidgin_conv_get_tab_at_xy(PidginConvWindow *win, int x, int y, gboolean *to_right)
 {
@@ -4964,346 +4948,6 @@
 }
 
 static void
-notebook_init_grab(PidginConvWindow *gtkwin, GtkWidget *widget, GdkEvent *event)
-{
-	static GdkCursor *cursor = NULL;
-	GdkDevice *device;
-
-	gtkwin->in_drag = TRUE;
-
-	if (gtkwin->drag_leave_signal) {
-		g_signal_handler_disconnect(G_OBJECT(widget),
-		                            gtkwin->drag_leave_signal);
-		gtkwin->drag_leave_signal = 0;
-	}
-
-	if (cursor == NULL) {
-		GdkDisplay *display = gtk_widget_get_display(gtkwin->notebook);
-		cursor = gdk_cursor_new_for_display(display, GDK_FLEUR);
-	}
-
-	/* Grab the pointer */
-	gtk_grab_add(gtkwin->notebook);
-	device = gdk_event_get_device(event);
-	if (!gdk_display_device_is_grabbed(gdk_device_get_display(device),
-	                                   device)) {
-		gdk_seat_grab(gdk_event_get_seat(event),
-		              gtk_widget_get_window(gtkwin->notebook),
-		              GDK_SEAT_CAPABILITY_ALL_POINTING, FALSE, cursor, event,
-		              NULL, NULL);
-	}
-}
-
-static gboolean
-notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, PidginConvWindow *win)
-{
-
-	/*
-	* Make sure the user moved the mouse far enough for the
-	* drag to be initiated.
-	*/
-	if (win->in_predrag) {
-		if (e->x_root <  win->drag_min_x ||
-		    e->x_root >= win->drag_max_x ||
-		    e->y_root <  win->drag_min_y ||
-		    e->y_root >= win->drag_max_y) {
-
-			    win->in_predrag = FALSE;
-			    notebook_init_grab(win, widget, (GdkEvent *)e);
-		    }
-	}
-	else { /* Otherwise, draw the arrows. */
-		PidginConvWindow *dest_win;
-		GtkNotebook *dest_notebook;
-		GtkWidget *tab;
-		gint page_num;
-		gboolean horiz_tabs = FALSE;
-		gboolean to_right = FALSE;
-
-		/* Get the window that the cursor is over. */
-		dest_win = pidgin_conv_window_get_at_event((GdkEvent *)e);
-
-		if (dest_win == NULL) {
-			pidgin_dnd_hints_hide_all();
-
-			return TRUE;
-		}
-
-		dest_notebook = GTK_NOTEBOOK(dest_win->notebook);
-
-		if (gtk_notebook_get_show_tabs(dest_notebook)) {
-			page_num = pidgin_conv_get_tab_at_xy(dest_win,
-			                                      e->x_root, e->y_root, &to_right);
-			to_right = to_right && (win != dest_win);
-			tab = pidgin_conv_window_get_gtkconv_at_index(dest_win, page_num)->tabby;
-		} else {
-			page_num = 0;
-			to_right = pidgin_conv_xy_to_right_infopane(dest_win, e->x_root, e->y_root);
-			tab = pidgin_conv_window_get_gtkconv_at_index(dest_win, page_num)->infopane;
-		}
-
-		if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP ||
-				gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) {
-			horiz_tabs = TRUE;
-		}
-
-		if (gtk_notebook_get_show_tabs(dest_notebook) == FALSE && win == dest_win)
-		{
-			/* dragging a tab from a single-tabbed window over its own window */
-			pidgin_dnd_hints_hide_all();
-			return TRUE;
-		} else if (horiz_tabs) {
-			if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) {
-				pidgin_dnd_hints_show_relative(HINT_ARROW_DOWN, tab, HINT_POSITION_RIGHT, HINT_POSITION_TOP);
-				pidgin_dnd_hints_show_relative(HINT_ARROW_UP, tab, HINT_POSITION_RIGHT, HINT_POSITION_BOTTOM);
-			} else {
-				pidgin_dnd_hints_show_relative(HINT_ARROW_DOWN, tab, HINT_POSITION_LEFT, HINT_POSITION_TOP);
-				pidgin_dnd_hints_show_relative(HINT_ARROW_UP, tab, HINT_POSITION_LEFT, HINT_POSITION_BOTTOM);
-			}
-		} else {
-			if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) {
-				pidgin_dnd_hints_show_relative(HINT_ARROW_RIGHT, tab, HINT_POSITION_LEFT, HINT_POSITION_BOTTOM);
-				pidgin_dnd_hints_show_relative(HINT_ARROW_LEFT, tab, HINT_POSITION_RIGHT, HINT_POSITION_BOTTOM);
-			} else {
-				pidgin_dnd_hints_show_relative(HINT_ARROW_RIGHT, tab, HINT_POSITION_LEFT, HINT_POSITION_TOP);
-				pidgin_dnd_hints_show_relative(HINT_ARROW_LEFT, tab, HINT_POSITION_RIGHT, HINT_POSITION_TOP);
-			}
-		}
-	}
-
-	return TRUE;
-}
-
-static gboolean
-notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, PidginConvWindow *win)
-{
-	if (win->in_drag)
-		return FALSE;
-
-	if (e->x_root <  win->drag_min_x ||
-	    e->x_root >= win->drag_max_x ||
-	    e->y_root <  win->drag_min_y ||
-	    e->y_root >= win->drag_max_y) {
-
-		win->in_predrag = FALSE;
-		notebook_init_grab(win, widget, (GdkEvent *)e);
-	}
-
-	return TRUE;
-}
-
-static gboolean
-notebook_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConvWindow *win)
-{
-	gint nb_x, nb_y;
-	int tab_clicked;
-	GtkWidget *page;
-	GtkWidget *tab;
-	GtkAllocation allocation;
-
-	if (e->button == GDK_BUTTON_MIDDLE && e->type == GDK_BUTTON_PRESS) {
-		PidginConversation *gtkconv;
-		tab_clicked = pidgin_conv_get_tab_at_xy(win, e->x_root, e->y_root, NULL);
-
-		if (tab_clicked == -1)
-			return FALSE;
-
-		gtkconv = pidgin_conv_window_get_gtkconv_at_index(win, tab_clicked);
-		close_conv_cb(NULL, gtkconv);
-		return TRUE;
-	}
-
-
-	if (e->button != GDK_BUTTON_PRIMARY || e->type != GDK_BUTTON_PRESS)
-		return FALSE;
-
-
-	if (win->in_drag) {
-		purple_debug_warning("gtkconv",
-		                     "Already in the middle of a window drag at tab_press_cb");
-		return TRUE;
-	}
-
-	/*
-	* Make sure a tab was actually clicked. The arrow buttons
-	* mess things up.
-	*/
-	tab_clicked = pidgin_conv_get_tab_at_xy(win, e->x_root, e->y_root, NULL);
-
-	if (tab_clicked == -1)
-		return FALSE;
-
-	/*
-	* Get the relative position of the press event, with regards to
-	* the position of the notebook.
-	*/
-	gdk_window_get_origin(gtk_widget_get_window(win->notebook), &nb_x, &nb_y);
-
-	/* Reset the min/max x/y */
-	win->drag_min_x = 0;
-	win->drag_min_y = 0;
-	win->drag_max_x = 0;
-	win->drag_max_y = 0;
-
-	/* Find out which tab was dragged. */
-	page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked);
-	tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page);
-
-	gtk_widget_get_allocation(tab, &allocation);
-
-	win->drag_min_x = allocation.x      + nb_x;
-	win->drag_min_y = allocation.y      + nb_y;
-	win->drag_max_x = allocation.width  + win->drag_min_x;
-	win->drag_max_y = allocation.height + win->drag_min_y;
-
-	/* Make sure the click occurred in the tab. */
-	if (e->x_root <  win->drag_min_x ||
-	    e->x_root >= win->drag_max_x ||
-	    e->y_root <  win->drag_min_y ||
-	    e->y_root >= win->drag_max_y) {
-
-		return FALSE;
-	}
-
-	win->in_predrag = TRUE;
-	win->drag_tab = tab_clicked;
-
-	/* Connect the new motion signals. */
-	win->drag_motion_signal =
-		g_signal_connect(G_OBJECT(widget), "motion_notify_event",
-		                 G_CALLBACK(notebook_motion_cb), win);
-
-	win->drag_leave_signal =
-		g_signal_connect(G_OBJECT(widget), "leave_notify_event",
-		                 G_CALLBACK(notebook_leave_cb), win);
-
-	return FALSE;
-}
-
-static gboolean
-notebook_release_cb(GtkWidget *widget, GdkEventButton *e, PidginConvWindow *win)
-{
-	PidginConvWindow *dest_win;
-	GtkNotebook *dest_notebook;
-	PidginConversation *active_gtkconv;
-	PidginConversation *gtkconv;
-	gint dest_page_num = 0;
-	gboolean new_window = FALSE;
-	gboolean to_right = FALSE;
-	GdkDevice *device;
-
-	/*
-	* Don't check to make sure that the event's window matches the
-	* widget's, because we may be getting an event passed on from the
-	* close button.
-	*/
-	if (e->button != GDK_BUTTON_PRIMARY && e->type != GDK_BUTTON_RELEASE)
-		return FALSE;
-
-	device = gdk_event_get_device((GdkEvent *)e);
-	if (gdk_display_device_is_grabbed(gdk_device_get_display(device), device)) {
-		gdk_seat_ungrab(gdk_event_get_seat((GdkEvent *)e));
-		gtk_grab_remove(widget);
-	}
-
-	if (!win->in_predrag && !win->in_drag)
-		return FALSE;
-
-	/* Disconnect the motion signal. */
-	if (win->drag_motion_signal) {
-		g_signal_handler_disconnect(G_OBJECT(widget),
-		                            win->drag_motion_signal);
-
-		win->drag_motion_signal = 0;
-	}
-
-	/*
-	* If we're in a pre-drag, we'll also need to disconnect the leave
-	* signal.
-	*/
-	if (win->in_predrag) {
-		win->in_predrag = FALSE;
-
-		if (win->drag_leave_signal) {
-			g_signal_handler_disconnect(G_OBJECT(widget),
-			                            win->drag_leave_signal);
-
-			win->drag_leave_signal = 0;
-		}
-	}
-
-	/* If we're not in drag...        */
-	/* We're perfectly normal people! */
-	if (!win->in_drag)
-		return FALSE;
-
-	win->in_drag = FALSE;
-
-	pidgin_dnd_hints_hide_all();
-
-	dest_win = pidgin_conv_window_get_at_event((GdkEvent *)e);
-
-	active_gtkconv = pidgin_conv_window_get_active_gtkconv(win);
-
-	if (dest_win == NULL) {
-		/* If the current window doesn't have any other conversations,
-		* there isn't much point transferring the conv to a new window. */
-		if (pidgin_conv_window_get_gtkconv_count(win) > 1) {
-			/* Make a new window to stick this to. */
-			dest_win = pidgin_conv_window_new();
-			new_window = TRUE;
-		}
-	}
-
-	if (dest_win == NULL)
-		return FALSE;
-
-	purple_signal_emit(pidgin_conversations_get_handle(),
-	                 "conversation-dragging", win, dest_win);
-
-	/* Get the destination page number. */
-	if (!new_window) {
-		dest_notebook = GTK_NOTEBOOK(dest_win->notebook);
-		if (gtk_notebook_get_show_tabs(dest_notebook)) {
-			dest_page_num = pidgin_conv_get_tab_at_xy(dest_win,
-			                                           e->x_root, e->y_root, &to_right);
-		} else {
-			dest_page_num = 0;
-			to_right = pidgin_conv_xy_to_right_infopane(dest_win, e->x_root, e->y_root);
-		}
-	}
-
-	gtkconv = pidgin_conv_window_get_gtkconv_at_index(win, win->drag_tab);
-
-	if (win == dest_win) {
-		gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num);
-	} else {
-		pidgin_conv_window_remove_gtkconv(win, gtkconv);
-		pidgin_conv_window_add_gtkconv(dest_win, gtkconv);
-		gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right);
-		pidgin_conv_window_switch_gtkconv(dest_win, gtkconv);
-		if (new_window) {
-			gint win_width, win_height;
-
-			gtk_window_get_size(GTK_WINDOW(dest_win->window),
-			                    &win_width, &win_height);
-#ifdef _WIN32  /* only override window manager placement on Windows */
-			gtk_window_move(GTK_WINDOW(dest_win->window),
-			                e->x_root - (win_width  / 2),
-			                e->y_root - (win_height / 2));
-#endif
-
-			pidgin_conv_window_show(dest_win);
-		}
-	}
-
-	gtk_widget_grab_focus(active_gtkconv->editor);
-
-	return TRUE;
-}
-
-
-static void
 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num,
                       gpointer user_data)
 {
@@ -5546,14 +5190,6 @@
 	g_signal_connect_after(G_OBJECT(win->notebook), "switch_page",
 	                       G_CALLBACK(switch_conv_cb), win);
 
-	/* Setup the tab drag and drop signals. */
-	gtk_widget_add_events(win->notebook,
-	                      GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK);
-	g_signal_connect(G_OBJECT(win->notebook), "button_press_event",
-	                 G_CALLBACK(notebook_press_cb), win);
-	g_signal_connect(G_OBJECT(win->notebook), "button_release_event",
-	                 G_CALLBACK(notebook_release_cb), win);
-
 	testidea = pidgin_conversation_window_get_vbox(PIDGIN_CONVERSATION_WINDOW(win->window));
 
 	/* Setup the menubar. */
