totem r5838 - in trunk: . po src



Author: hadess
Date: Wed Dec 10 13:28:21 2008
New Revision: 5838
URL: http://svn.gnome.org/viewvc/totem?rev=5838&view=rev

Log:
2008-12-10  Bastien Nocera  <hadess hadess net>

	* src/Makefile.am:
	* src/totem-dnd-menu.[ch]:
	* src/totem-playlist.c (drop_cb):
	* src/totem.c (drop_video_cb), (drag_motion_video_cb):
	Patch from Maxim Ermilov <zaspire rambler ru> to allow
	"ask" drag'n'drop on the treeview and the video widget
	(Closes: #563252)

2008-12-10  Bastien Nocera  <hadess hadess net>

	* POTFILES.in: Add new file



Added:
   trunk/src/totem-dnd-menu.c
   trunk/src/totem-dnd-menu.h
Modified:
   trunk/ChangeLog
   trunk/po/ChangeLog
   trunk/po/POTFILES.in
   trunk/src/Makefile.am
   trunk/src/totem-playlist.c
   trunk/src/totem.c

Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in	(original)
+++ trunk/po/POTFILES.in	Wed Dec 10 13:28:21 2008
@@ -12,6 +12,7 @@
 [type: gettext/glade]data/uri.ui
 lib/totem-scrsaver.c
 src/totem-cell-renderer-video.c
+src/totem-dnd-menu.c
 src/totem-fullscreen.c
 src/totem-interface.c
 src/totem-menu.c

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Wed Dec 10 13:28:21 2008
@@ -100,6 +100,7 @@
 	$(TOTEMMARSHALFILES)				\
 	totem-private.h					\
 	totem-preferences.c totem-preferences.h		\
+	totem-dnd-menu.c totem-dnd-menu.h 		\
 	totem-options.c totem-options.h	\
 	totem-playlist.c totem-playlist.h \
 	totem-screenshot.c		\

Added: trunk/src/totem-dnd-menu.c
==============================================================================
--- (empty file)
+++ trunk/src/totem-dnd-menu.c	Wed Dec 10 13:28:21 2008
@@ -0,0 +1,121 @@
+/* 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ * The Totem project hereby grant permission for non-gpl compatible GStreamer
+ * plugins to be used and distributed together with GStreamer and Totem. This
+ * permission are above and beyond the permissions granted by the GPL license
+ * Totem is covered by.
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <glib.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "totem-dnd-menu.h"
+
+typedef struct
+{
+	GMainLoop *loop;
+	GdkDragAction ch;
+} DragData;
+
+static void
+drag_menu_deactivate_callback (GtkWidget *menu,
+			       DragData *dt)
+{
+	dt->ch = 0;
+	if (g_main_loop_is_running (dt->loop))
+		g_main_loop_quit (dt->loop);
+}
+
+static void
+drag_drop_action_activated_callback (GtkWidget  *menu_item,
+				     DragData       *dt)
+{
+	dt->ch = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "action"));
+	if (g_main_loop_is_running (dt->loop))
+		g_main_loop_quit (dt->loop);
+}
+
+static void
+drag_append_drop_action_menu_item (GtkWidget          *menu,
+				   const char    *text,
+				   const char    *icon,
+				   GdkDragAction action,
+				   DragData       *dt)
+{
+	GtkWidget *menu_item;
+
+	menu_item = gtk_image_menu_item_new_with_mnemonic (text);
+	gtk_widget_set_sensitive (menu_item, TRUE);
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+
+	if (icon != NULL) {
+		GtkWidget *image;
+
+		image = gtk_image_new_from_stock (icon, GTK_ICON_SIZE_MENU);
+		gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
+	}
+
+	g_object_set_data (G_OBJECT (menu_item), "action", GINT_TO_POINTER (action));
+
+	g_signal_connect (menu_item, "activate",
+			  G_CALLBACK (drag_drop_action_activated_callback), dt);
+
+	gtk_widget_show (menu_item);
+}
+
+GdkDragAction
+totem_drag_ask (gboolean show_add_to)
+{
+	GtkWidget *menu;
+	GtkWidget *menu_item;
+	DragData dt;
+
+	dt.ch = 0;
+
+	menu = gtk_menu_new ();
+
+	drag_append_drop_action_menu_item (menu, _("_Play Now"), "gtk-media-play", GDK_ACTION_MOVE, &dt);
+
+	if (show_add_to != FALSE)
+		drag_append_drop_action_menu_item (menu, _("_Add to Playlist"), "gtk-add", GDK_ACTION_COPY, &dt);
+
+	menu_item = gtk_separator_menu_item_new ();
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+	gtk_widget_show (menu_item);
+
+	drag_append_drop_action_menu_item (menu, _("Cancel"), NULL, 0, &dt);
+
+	g_signal_connect (menu, "deactivate",
+			  G_CALLBACK (drag_menu_deactivate_callback), &dt);
+
+	gtk_grab_add (menu);
+
+	gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
+			3, gtk_get_current_event_time ());
+
+	dt.loop = g_main_loop_new (NULL, FALSE);
+	g_main_loop_run (dt.loop);
+	gtk_grab_remove (menu);
+	g_main_loop_unref (dt.loop);
+
+	gtk_widget_destroy (menu);
+
+	return dt.ch;
+}

Added: trunk/src/totem-dnd-menu.h
==============================================================================
--- (empty file)
+++ trunk/src/totem-dnd-menu.h	Wed Dec 10 13:28:21 2008
@@ -0,0 +1,29 @@
+/* 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ * The Totem project hereby grant permission for non-gpl compatible GStreamer
+ * plugins to be used and distributed together with GStreamer and Totem. This
+ * permission are above and beyond the permissions granted by the GPL license
+ * Totem is covered by.
+ */
+
+#ifndef __TOTEM_DND_MENU_H__
+#define __TOTEM_DND_MENU_H__
+
+#include <gdk/gdkkeysyms.h>
+
+GdkDragAction totem_drag_ask (gboolean show_add_to);
+
+#endif

Modified: trunk/src/totem-playlist.c
==============================================================================
--- trunk/src/totem-playlist.c	(original)
+++ trunk/src/totem-playlist.c	Wed Dec 10 13:28:21 2008
@@ -32,6 +32,7 @@
 #include <gio/gio.h>
 #include <string.h>
 
+#include "totem-dnd-menu.h"
 #include "totem-uri.h"
 #include "totem-interface.h"
 #include "video-utils.h"
@@ -392,10 +393,17 @@
 	GList *p, *file_list;
 	guint i;
 
-	if (context->action == GDK_ACTION_MOVE) {
-		totem_playlist_clear (playlist);
+	if (context->suggested_action == GDK_ACTION_ASK) {
+		context->action = totem_drag_ask (PL_LEN != 0);
+		if (context->action == 0) {
+			gtk_drag_finish (context, FALSE, FALSE, time);
+			return;
+		}
 	}
 
+	if (context->action == GDK_ACTION_MOVE)
+		totem_playlist_clear (playlist);
+
 	list = g_uri_list_extract_uris ((char *)data->data);
 	file_list = NULL;
 
@@ -551,7 +559,7 @@
 playlist_show_popup_menu (TotemPlaylist *playlist, GdkEventButton *event)
 {
 	guint button = 0;
-       	guint32 time;
+	guint32 time;
 	GtkTreePath *path;
 	gint count;
 	GtkWidget *menu;

Modified: trunk/src/totem.c
==============================================================================
--- trunk/src/totem.c	(original)
+++ trunk/src/totem.c	Wed Dec 10 13:28:21 2008
@@ -59,6 +59,7 @@
 #include "totem-uri.h"
 #include "totem-interface.h"
 #include "video-utils.h"
+#include "totem-dnd-menu.h"
 
 #include "totem.h"
 #include "totem-private.h"
@@ -1586,12 +1587,18 @@
 	 guint               time,
 	 Totem              *totem)
 {
-	gboolean retval;
+	gboolean retval = FALSE;
 	gboolean empty_pl;
 
-	empty_pl = (context->action == GDK_ACTION_MOVE);
+	if (context->suggested_action == GDK_ACTION_ASK)
+		context->action = totem_drag_ask (TRUE); //FIXME should be playlist != empty
 
-	retval = totem_action_drop_files (totem, data, info, empty_pl);
+	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);
+		return;
+	}
 	gtk_drag_finish (context, retval, FALSE, time);
 }
 
@@ -1608,6 +1615,8 @@
 	gdk_window_get_pointer (widget->window, NULL, NULL, &mask);
 	if (mask & GDK_CONTROL_MASK) {
 		gdk_drag_status (context, GDK_ACTION_COPY, time);
+	} else if (mask & GDK_MOD1_MASK || context->suggested_action == GDK_ACTION_ASK) {
+		gdk_drag_status (context, GDK_ACTION_ASK, time);
 	} else {
 		gdk_drag_status (context, GDK_ACTION_MOVE, time);
 	}



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