[totem] Bug 578249 – Don't restart video when drag and dropping on itself



commit ee3a03d2bf34d27ed79d0e9ef8ee9235ed22e63d
Author: Robin Stocker <robin nibor org>
Date:   Thu Jul 16 09:49:31 2009 +0200

    Bug 578249 â?? Don't restart video when drag and dropping on itself
    
    2009-07-16  Robin Stocker  <robin nibor org>
    
    	* src/totem-object.c (drop_video_cb, drag_video_cb):
    	* src/totem-private.h (TotemObject): When dragging the video and
    	then accidentally dropping it again on itself, ignore it instead
    	of restarting the video. (Closes: #578249)

 ChangeLog           |    7 +++++++
 src/totem-object.c  |   25 +++++++++++++++++++------
 src/totem-private.h |    4 ++++
 3 files changed, 30 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3b33c5b..004ea8f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-07-16  Robin Stocker  <robin nibor org>
+
+	* src/totem-object.c (drop_video_cb, drag_video_cb):
+	* src/totem-private.h (TotemObject): When dragging the video and
+	then accidentally dropping it again on itself, ignore it instead
+	of restarting the video. (Closes: #578249)
+
 2009-07-14  Jan Schmidt  <thaytan noraisin net>
 
 	* src/backend/bacon-video-widget-gst-0.10.c (setup_vis):
diff --git a/src/totem-object.c b/src/totem-object.c
index 3f0a26c..87f0517 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -2208,16 +2208,27 @@ drop_video_cb (GtkWidget     *widget,
 {
 	gboolean empty_pl;
 
-	if (context->suggested_action == GDK_ACTION_ASK)
+	if (context->suggested_action == GDK_ACTION_ASK) {
 		context->action = totem_drag_ask (totem_get_playlist_length (totem) > 0);
+	}
 
-	if (context->action != GDK_ACTION_DEFAULT) {
-		empty_pl = (context->action == GDK_ACTION_MOVE);
-		totem_action_drop_files (totem, data, info, empty_pl);
-		gtk_drag_finish (context, TRUE, FALSE, time);
+	/* User selected cancel */
+	if (context->action == GDK_ACTION_DEFAULT) {
+		gtk_drag_finish (context, FALSE, FALSE, time);
 		return;
 	}
-	gtk_drag_finish (context, FALSE, FALSE, time);
+
+	/* Drop of video on itself */
+	if (context->source_window == totem->video_drag_source_window &&
+	    context->action == GDK_ACTION_MOVE) {
+		gtk_drag_finish (context, FALSE, FALSE, time);
+		return;
+	}
+
+	empty_pl = (context->action == GDK_ACTION_MOVE);
+	totem_action_drop_files (totem, data, info, empty_pl);
+	gtk_drag_finish (context, TRUE, FALSE, time);
+	return;
 }
 
 static void
@@ -2312,6 +2323,8 @@ drag_video_cb (GtkWidget *widget,
 	gtk_selection_data_set (selection_data, selection_data->target,
 				8, (guchar *) text, len);
 
+	totem->video_drag_source_window = context->source_window;
+
 	g_free (text);
 }
 
diff --git a/src/totem-private.h b/src/totem-private.h
index 3143cc9..f9eeea1 100644
--- a/src/totem-private.h
+++ b/src/totem-private.h
@@ -160,6 +160,10 @@ struct TotemObject {
 	UniqueApp *app;
 	TotemStates state;
 	TotemOpenLocation *open_location;
+
+	/* Stored source_window of GdkDragContext from a video drag,
+	 * used to detect when the video is dropped on itself. */
+	GdkWindow *video_drag_source_window;
 };
 
 GtkWidget *totem_volume_create (void);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]