[nautilus] all: remove the built-in hover audio previewer



commit c997bbe8b8bfb423d03f3475088a983e59bd9168
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sun Jul 31 20:24:53 2011 +0200

    all: remove the built-in hover audio previewer
    
    This is not really useful anymore now that we have Sushi, which is way
    more powerful.

 icons/Makefile.am                               |    1 -
 icons/audio.svg                                 |   43 ----
 libnautilus-private/nautilus-icon-canvas-item.c |   77 +-------
 libnautilus-private/nautilus-icon-container.c   |   34 ---
 libnautilus-private/nautilus-icon-private.h     |    3 -
 src/Makefile.am                                 |    1 -
 src/nautilus-audio-mime-types.h                 |   45 ----
 src/nautilus-icon-view.c                        |  271 -----------------------
 8 files changed, 1 insertions(+), 474 deletions(-)
---
diff --git a/icons/Makefile.am b/icons/Makefile.am
index 95fec1d..b183e9c 100644
--- a/icons/Makefile.am
+++ b/icons/Makefile.am
@@ -3,7 +3,6 @@ NULL=
 icondir = $(datadir)/pixmaps/nautilus
 
 icon_DATA =\
-	audio.svg \
 	knob.png \
 	thumbnail_frame.png \
 	$(NULL)
diff --git a/libnautilus-private/nautilus-icon-canvas-item.c b/libnautilus-private/nautilus-icon-canvas-item.c
index c94bb0c..4bf1a03 100644
--- a/libnautilus-private/nautilus-icon-canvas-item.c
+++ b/libnautilus-private/nautilus-icon-canvas-item.c
@@ -101,9 +101,6 @@ struct NautilusIconCanvasItemDetails {
 	 * text_height_for_layout will always be equal to text_height.
 	 * Used for the last line of a line-wise icon layout. */
 	guint entire_text : 1;
-	
-	/* preview state */
-	guint is_active : 1;
 
     	/* Highlight state. */
    	guint is_highlighted_for_selection : 1;
@@ -113,7 +110,6 @@ struct NautilusIconCanvasItemDetails {
 	guint show_stretch_handles : 1;
 	guint is_prelit : 1;
 
-	guint rendered_is_active : 1;
 	guint rendered_is_highlighted_for_selection : 1;
 	guint rendered_is_highlighted_for_drop : 1;
 	guint rendered_is_highlighted_for_clipboard : 1;
@@ -1341,9 +1337,7 @@ static GdkPixbuf *
 real_map_pixbuf (NautilusIconCanvasItem *icon_item)
 {
 	EelCanvas *canvas;
-	char *audio_filename;
-	GdkPixbuf *temp_pixbuf, *old_pixbuf, *audio_pixbuf;
-	int emblem_size;
+	GdkPixbuf *temp_pixbuf, *old_pixbuf;
 	
 	temp_pixbuf = icon_item->details->pixbuf;
 	canvas = EEL_CANVAS_ITEM(icon_item)->canvas;
@@ -1356,45 +1350,6 @@ real_map_pixbuf (NautilusIconCanvasItem *icon_item)
 
 		temp_pixbuf = eel_create_spotlight_pixbuf (temp_pixbuf);
 		g_object_unref (old_pixbuf);
-
-		/* FIXME bugzilla.gnome.org 42471: This hard-wired image is inappropriate to
-		 * this level of code, which shouldn't know that the
-		 * preview is audio, nor should it have an icon
-		 * hard-wired in.
-		 */
-
-		/* if the icon is currently being previewed, superimpose an image to indicate that */
-		/* audio is the only kind of previewing right now, so this code isn't as general as it could be */
-		if (icon_item->details->is_active) {
-			emblem_size = nautilus_icon_get_emblem_size_for_icon_size (gdk_pixbuf_get_width (temp_pixbuf));
-			/* Load the audio symbol. */
-			audio_filename = nautilus_pixmap_file ("audio.svg");
-			if (audio_filename != NULL) {
-				audio_pixbuf = gdk_pixbuf_new_from_file_at_scale (audio_filename,
-										  emblem_size, emblem_size,
-										  TRUE,
-										  NULL);
-			} else {
-				audio_pixbuf = NULL;
-			}
-			
-			/* Composite it onto the icon. */
-			if (audio_pixbuf != NULL) {
-				gdk_pixbuf_composite
-					(audio_pixbuf,
-					 temp_pixbuf,
-					 0, 0,
-					 gdk_pixbuf_get_width (audio_pixbuf),
-					 gdk_pixbuf_get_height (audio_pixbuf),
-					 0, 0,
-					 1.0, 1.0,
-					 GDK_INTERP_BILINEAR, 0xFF);
-				
-				g_object_unref (audio_pixbuf);
-			}
-			
-			g_free (audio_filename);
-		}
 	}
 
 	if (icon_item->details->is_highlighted_for_selection
@@ -1419,7 +1374,6 @@ static GdkPixbuf *
 map_pixbuf (NautilusIconCanvasItem *icon_item)
 {
 	if (!(icon_item->details->rendered_pixbuf != NULL
-	      && icon_item->details->rendered_is_active == icon_item->details->is_active
 	      && icon_item->details->rendered_is_prelit == icon_item->details->is_prelit
 	      && icon_item->details->rendered_is_highlighted_for_selection == icon_item->details->is_highlighted_for_selection
 	      && icon_item->details->rendered_is_highlighted_for_drop == icon_item->details->is_highlighted_for_drop
@@ -1429,7 +1383,6 @@ map_pixbuf (NautilusIconCanvasItem *icon_item)
 			g_object_unref (icon_item->details->rendered_pixbuf);
 		}
 		icon_item->details->rendered_pixbuf = real_map_pixbuf (icon_item);
-		icon_item->details->rendered_is_active = icon_item->details->is_active;
 		icon_item->details->rendered_is_prelit = icon_item->details->is_prelit;
 		icon_item->details->rendered_is_highlighted_for_selection = icon_item->details->is_highlighted_for_selection;
 		icon_item->details->rendered_is_highlighted_for_drop = icon_item->details->is_highlighted_for_drop;
@@ -1697,20 +1650,6 @@ nautilus_icon_canvas_item_event (EelCanvasItem *item, GdkEvent *event)
 
 				icon_item->details->cursor_window = g_object_ref (cursor_window);
 			}
-
-			/* FIXME bugzilla.gnome.org 42473: 
-			 * We should emit our own signal here,
-			 * not one from the container; it could hook
-			 * up to that signal and emit one of its
-			 * own. Doing it this way hard-codes what
-			 * "user_data" is. Also, the two signals
-			 * should be separate. The "unpreview" signal
-			 * does not have a return value.
-			 */
-			icon_item->details->is_active = nautilus_icon_container_emit_preview_signal
-				(NAUTILUS_ICON_CONTAINER (item->canvas),
-				 NAUTILUS_ICON_CANVAS_ITEM (item)->user_data,
-				 TRUE);
 		}
 		return TRUE;
 		
@@ -1721,21 +1660,7 @@ nautilus_icon_canvas_item_event (EelCanvasItem *item, GdkEvent *event)
 			 * higlighted for drop. The latter gets turned on
 			 * by the drag&drop motion callback.
 			 */
-			/* FIXME bugzilla.gnome.org 42473: 
-			 * We should emit our own signal here,
-			 * not one from the containe; it could hook up
-			 * to that signal and emit one of its
-			 * ownr. Doing it this way hard-codes what
-			 * "user_data" is. Also, the two signals
-			 * should be separate. The "unpreview" signal
-			 * does not have a return value.
-			 */
-			nautilus_icon_container_emit_preview_signal
-				(NAUTILUS_ICON_CONTAINER (item->canvas),
-				 NAUTILUS_ICON_CANVAS_ITEM (item)->user_data,
-				 FALSE);			
 			icon_item->details->is_prelit = FALSE;
-			icon_item->details->is_active = 0;			
 			icon_item->details->is_highlighted_for_drop = FALSE;
 			nautilus_icon_canvas_item_invalidate_label_size (icon_item);
 			eel_canvas_item_request_update (item);
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index 3753d1e..8448eec 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -251,7 +251,6 @@ enum {
 	HANDLE_URI_LIST,
 	HANDLE_TEXT,
 	HANDLE_RAW,
-	PREVIEW,
 	SELECTION_CHANGED,
 	ICON_ADDED,
 	ICON_REMOVED,
@@ -5986,17 +5985,6 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class)
 		                NULL, NULL,
 		                g_cclosure_marshal_VOID__VOID,
 		                G_TYPE_NONE, 0);
-	signals[PREVIEW]
-		= g_signal_new ("preview",
-		                G_TYPE_FROM_CLASS (class),
-		                G_SIGNAL_RUN_LAST,
-		                G_STRUCT_OFFSET (NautilusIconContainerClass,
-						 preview),
-		                NULL, NULL,
-		                g_cclosure_marshal_generic,
-		                G_TYPE_INT, 2,
-				G_TYPE_POINTER,
-				G_TYPE_BOOLEAN);
 	signals[BAND_SELECT_STARTED]
 		= g_signal_new ("band_select_started",
 		                G_TYPE_FROM_CLASS (class),
@@ -8409,28 +8397,6 @@ end_renaming_mode (NautilusIconContainer *container, gboolean commit)
 
 }
 
-/* emit preview signal, called by the canvas item */
-gboolean
-nautilus_icon_container_emit_preview_signal (NautilusIconContainer *icon_container,
-					     NautilusIcon *icon,
-					     gboolean start_flag)
-{
-	gboolean result;
-	
-	g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (icon_container), FALSE);
-	g_return_val_if_fail (icon != NULL, FALSE);
-	g_return_val_if_fail (start_flag == FALSE || start_flag == TRUE, FALSE);
-	
-	result = FALSE;
-	g_signal_emit (icon_container,
-			 signals[PREVIEW], 0,
-			 icon->data,
-			 start_flag,
-			 &result);
-	
-	return result;
-}
-
 gboolean
 nautilus_icon_container_has_stored_icon_positions (NautilusIconContainer *container)
 {
diff --git a/libnautilus-private/nautilus-icon-private.h b/libnautilus-private/nautilus-icon-private.h
index 9b0a3d7..9298d10 100644
--- a/libnautilus-private/nautilus-icon-private.h
+++ b/libnautilus-private/nautilus-icon-private.h
@@ -310,9 +310,6 @@ char *        nautilus_icon_container_get_icon_drop_target_uri    (NautilusIconC
 void          nautilus_icon_container_update_icon                 (NautilusIconContainer *container,
 								   NautilusIcon          *icon);
 gboolean      nautilus_icon_container_has_stored_icon_positions   (NautilusIconContainer *container);
-gboolean      nautilus_icon_container_emit_preview_signal         (NautilusIconContainer *view,
-								   NautilusIcon          *icon,
-								   gboolean               start_flag);
 gboolean      nautilus_icon_container_scroll                      (NautilusIconContainer *container,
 								   int                    delta_x,
 								   int                    delta_y);
diff --git a/src/Makefile.am b/src/Makefile.am
index ac1c8f6..752bd97 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -47,7 +47,6 @@ nautilus_SOURCES = \
 	nautilus-actions.h			\
 	nautilus-application.c			\
 	nautilus-application.h			\
-	nautilus-audio-mime-types.h		\
 	nautilus-bookmark-list.c		\
 	nautilus-bookmark-list.h		\
 	nautilus-bookmarks-window.c		\
diff --git a/src/nautilus-icon-view.c b/src/nautilus-icon-view.c
index ff45911..0a42e14 100644
--- a/src/nautilus-icon-view.c
+++ b/src/nautilus-icon-view.c
@@ -69,8 +69,6 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
-#include "nautilus-audio-mime-types.h"
-
 #define POPUP_PATH_ICON_APPEARANCE		"/selection/Icon Appearance Items"
 
 enum 
@@ -112,11 +110,6 @@ struct NautilusIconViewDetails
 	GtkActionGroup *icon_action_group;
 	guint icon_merge_id;
 	
-	int audio_preview_timeout;
-	NautilusFile *audio_preview_file;
-	int audio_preview_child_watch;
-	GPid audio_preview_child_pid;
-
 	gboolean filter_by_screen;
 	int num_screens;
 
@@ -191,9 +184,6 @@ static gboolean             set_sort_reversed                         (NautilusI
 								       gboolean              new_value,
 								       gboolean              set_metadata);
 static void                 switch_to_manual_layout                   (NautilusIconView     *view);
-static void                 preview_audio                             (NautilusIconView     *icon_view,
-								       NautilusFile         *file,
-								       gboolean              start_flag);
 static void                 update_layout_menus                       (NautilusIconView     *view);
 static NautilusFileSortType get_default_sort_order                    (NautilusFile         *file,
 								       gboolean             *reversed);
@@ -221,9 +211,6 @@ nautilus_icon_view_destroy (GtkWidget *object)
 		icon_view->details->clipboard_handler_id = 0;
 	}
 
-	/* kill any sound preview process that is ongoing */
-	preview_audio (icon_view, NULL, FALSE);
-
 	if (icon_view->details->icons_not_positioned) {
 		nautilus_file_list_free (icon_view->details->icons_not_positioned);
 		icon_view->details->icons_not_positioned = NULL;
@@ -523,10 +510,6 @@ nautilus_icon_view_remove_file (NautilusView *view, NautilusFile *file, Nautilus
 
 	if (nautilus_icon_container_remove (get_icon_container (icon_view),
 					    NAUTILUS_ICON_CONTAINER_ICON_DATA (file))) {
-		if (file == icon_view->details->audio_preview_file) {
-			preview_audio (icon_view, NULL, FALSE);
-		}
-
 		nautilus_file_unref (file);
 	}
 }
@@ -1024,9 +1007,6 @@ nautilus_icon_view_begin_loading (NautilusView *view)
 
 	g_free (uri);
 
-	/* kill any sound preview process that is ongoing */
-	preview_audio (icon_view, NULL, FALSE);
-
 	/* Set up the zoom level from the metadata. */
 	if (nautilus_view_supports_zooming (NAUTILUS_VIEW (icon_view))) {
 		if (icon_view->details->compact) {
@@ -1792,255 +1772,6 @@ band_select_ended_callback (NautilusIconContainer *container,
 	nautilus_view_stop_batching_selection_changes (NAUTILUS_VIEW (icon_view));
 }
 
-/* handle the preview signal by inspecting the mime type.  For now, we only preview local sound files. */
-
-static char **
-get_preview_argv (char *uri)
-{
-	char *command;
-	char **argv;
-	int i;
-
-	command = g_find_program_in_path ("totem-audio-preview");
-	if (command) {
-		argv = g_new (char *, 3);
-		argv[0] = command;
-		argv[1] = g_strdup (uri);
-		argv[2] = NULL;
-
-		return argv;
-	}
-		
-	command = g_find_program_in_path ("gst-launch-0.10");
-	if (command) {
-		argv = g_new (char *, 10);
-		i = 0;
-		argv[i++] = command;
-		argv[i++] = g_strdup ("playbin");
-		argv[i++] = g_strconcat ("uri=", uri, NULL);
-		/* do not display videos */
-		argv[i++] = g_strdup ("current-video=-1");
-		argv[i++] = NULL;
-		return argv;
-	}
-
-	return NULL;
-}
-
-static void
-audio_child_died (GPid     pid,
-		  gint     status,
-		  gpointer data)
-{
-	NautilusIconView *icon_view;
-
-	icon_view = NAUTILUS_ICON_VIEW (data);
-
-	icon_view->details->audio_preview_child_watch = 0;
-	icon_view->details->audio_preview_child_pid = 0;
-}
-
-/* here's the timer task that actually plays the file using mpg123, ogg123 or play. */
-/* FIXME bugzilla.gnome.org 41258: we should get the application from our mime-type stuff */
-static gboolean
-play_file (gpointer callback_data)
-{
-	NautilusFile *file;
-	NautilusIconView *icon_view;
-	GPid child_pid;
-	char **argv;
-	GError *error;
-	char *uri;
-	GFile *gfile;
-	char *path;
-
-	icon_view = NAUTILUS_ICON_VIEW (callback_data);
-	
-	/* Stop timeout */
-	icon_view->details->audio_preview_timeout = 0;
-
-	file = icon_view->details->audio_preview_file;
-	gfile = nautilus_file_get_location (file);
-	path = g_file_get_path (gfile);
-
-	/* if we have a local path, use that instead of the native URI.
-	 * this can be useful for special GVfs mounts, such as cdda://
-	 */
-	if (path) {
-		uri = g_filename_to_uri (path, NULL, NULL);
-	} else {
-		uri = nautilus_file_get_uri (file);
-	}
-
-	g_object_unref (gfile);
-	g_free (path);
-
-	argv = get_preview_argv (uri);
-	g_free (uri);
-	if (argv == NULL) {
-		return FALSE;
-	}
-
-	error = NULL;
-	if (!g_spawn_async_with_pipes (NULL,
-				       argv,
-				       NULL, 
-				       G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
-				       NULL,
-				       NULL /* user_data */,
-				       &child_pid,
-				       NULL, NULL, NULL,
-				       &error)) {
-		g_strfreev (argv);
-		g_warning ("Error spawning sound preview: %s\n", error->message);
-		g_error_free (error);
-		return FALSE;
-	}
-	g_strfreev (argv);
-
-	icon_view->details->audio_preview_child_watch =
-		g_child_watch_add (child_pid,
-				   audio_child_died, NULL);
-	icon_view->details->audio_preview_child_pid = child_pid;
-	
-	return FALSE;
-}
-
-/* FIXME bugzilla.gnome.org 42530: Hardcoding this here sucks. We should be using components
- * for open ended things like this.
- */
-
-/* this routine is invoked from the preview signal handler to preview a sound file.  We
-   want to wait a suitable delay until we actually do it, so set up a timer task to actually
-   start playing.  If we move out before the task files, we remove it. */
-
-static void
-preview_audio (NautilusIconView *icon_view, NautilusFile *file, gboolean start_flag)
-{		
-	/* Stop current audio playback */
-	if (icon_view->details->audio_preview_child_pid != 0) {
-		kill (icon_view->details->audio_preview_child_pid, SIGTERM);
-		g_source_remove (icon_view->details->audio_preview_child_watch);
-		waitpid (icon_view->details->audio_preview_child_pid, NULL, 0);
-		icon_view->details->audio_preview_child_pid = 0;
-	}
-	
-	if (icon_view->details->audio_preview_timeout != 0) {
-		g_source_remove (icon_view->details->audio_preview_timeout);
-		icon_view->details->audio_preview_timeout = 0;
-	}
-			
-	if (start_flag) {
-		icon_view->details->audio_preview_file = file;
-		icon_view->details->audio_preview_timeout = g_timeout_add (1000, play_file, icon_view);
-	}
-}
-
-static gboolean
-sound_preview_type_supported (NautilusFile *file)
-{
-	char *mime_type;
-	guint i;
-	
-	mime_type = nautilus_file_get_mime_type (file);
-	if (mime_type == NULL) {
- 		return FALSE;
-	}
-	for (i = 0; i < G_N_ELEMENTS (audio_mime_types); i++) {
-		if (g_content_type_is_a (mime_type, audio_mime_types[i])) {
-			g_free (mime_type);
-			return TRUE;
-		}
-	}
-	
-	g_free (mime_type);
-	return FALSE;
-}
-
-
-static gboolean
-should_preview_sound (NautilusFile *file)
-{
-	GFile *location;
-	GFilesystemPreviewType use_preview;
-	int preview_sound_pref;
-
-	use_preview = nautilus_file_get_filesystem_use_preview (file);
-	preview_sound_pref = g_settings_get_enum (nautilus_preferences,
-						  NAUTILUS_PREFERENCES_PREVIEW_SOUND);
-
-	location = nautilus_file_get_location (file);
-	if (g_file_has_uri_scheme (location, "burn")) {
-		g_object_unref (location);
-		return FALSE;
-	}
-	g_object_unref (location);
-
-	/* Check user performance preference */	
-	if (preview_sound_pref == NAUTILUS_SPEED_TRADEOFF_NEVER) {
-		return FALSE;
-	}
-		
-	if (preview_sound_pref == NAUTILUS_SPEED_TRADEOFF_ALWAYS) {
-		if (use_preview == G_FILESYSTEM_PREVIEW_TYPE_NEVER) {
-			return FALSE;
-		} else {
-			return TRUE;
-		}
-	}
-	
-	if (use_preview == G_FILESYSTEM_PREVIEW_TYPE_NEVER) {
-		/* file system says to never preview anything */
-		return FALSE;
-	} else if (use_preview == G_FILESYSTEM_PREVIEW_TYPE_IF_LOCAL) {
-		/* file system says we should treat file as if it's local */
-		return TRUE;
-	} else {
-		/* only local files */
-		return nautilus_file_is_local (file);
-	}
-}
-
-static int
-icon_container_preview_callback (NautilusIconContainer *container,
-				 NautilusFile *file,
-				 gboolean start_flag,
-				 NautilusIconView *icon_view)
-{
-	int result;
-	char *file_name, *message;
-		
-	result = 0;
-	
-	/* preview files based on the mime_type. */
-	/* at first, we just handle sounds */
-	if (should_preview_sound (file)) {
-		if (sound_preview_type_supported (file)) {
-			result = 1;
-			preview_audio (icon_view, file, start_flag);
-		}
-	}
-
-	/* Display file name in status area at low zoom levels, since
-	 * the name is not displayed or hard to read in the icon view.
-	 */
-	if (nautilus_icon_view_get_zoom_level (NAUTILUS_VIEW (icon_view)) <= NAUTILUS_ZOOM_LEVEL_SMALLER) {
-		if (start_flag) {
-			file_name = nautilus_file_get_display_name (file);
-			message = g_strdup_printf (_("pointing at \"%s\""), file_name);
-			g_free (file_name);
-			nautilus_window_slot_set_status
-				(nautilus_view_get_nautilus_window_slot (NAUTILUS_VIEW (icon_view)),
-				 message, NULL);
-			g_free (message);
-		} else {
-			nautilus_view_display_selection_info (NAUTILUS_VIEW(icon_view));
-		}
-	}
-	
-	return result;
-}
-
 static void
 renaming_icon_callback (NautilusIconContainer *container,
 			GtkWidget *widget,
@@ -2601,8 +2332,6 @@ create_icon_container (NautilusIconView *icon_view)
 				 G_CALLBACK (get_stored_icon_position_callback), icon_view, 0);
 	g_signal_connect_object (icon_container, "layout_changed",
 				 G_CALLBACK (layout_changed_callback), icon_view, 0);
-	g_signal_connect_object (icon_container, "preview",
-				 G_CALLBACK (icon_container_preview_callback), icon_view, 0);
 	g_signal_connect_object (icon_container, "renaming_icon",
 				 G_CALLBACK (renaming_icon_callback), icon_view, 0);
 	g_signal_connect_object (icon_container, "icon_stretch_started",



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