From 98cbfca06e01935c8a45d6cdcdf42ed38d5827b7 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Tue, 16 Oct 2007 14:48:41 +0000 Subject: [PATCH] - Add patch from upstream to get audio preview working again (#332251) --- nautilus-2.20-make-audio-preview-work.patch | 218 ++++++++++++++++++++ nautilus.spec | 10 +- 2 files changed, 227 insertions(+), 1 deletion(-) create mode 100644 nautilus-2.20-make-audio-preview-work.patch diff --git a/nautilus-2.20-make-audio-preview-work.patch b/nautilus-2.20-make-audio-preview-work.patch new file mode 100644 index 0000000..61c6bbb --- /dev/null +++ b/nautilus-2.20-make-audio-preview-work.patch @@ -0,0 +1,218 @@ +Index: src/file-manager/fm-icon-view.c +=================================================================== +--- src/file-manager/fm-icon-view.c (revision 13313) ++++ src/file-manager/fm-icon-view.c (working copy) +@@ -24,6 +24,7 @@ + + #include + #include "fm-icon-view.h" ++#include "nautilus-audio-mime-types.h" + + #include "fm-actions.h" + #include "fm-icon-container.h" +@@ -1747,6 +1748,28 @@ + + /* handle the preview signal by inspecting the mime type. For now, we only preview local sound files. */ + ++#if USE_OLD_AUDIO_PREVIEW ++static char * ++get_preview_command (void) ++{ ++ char *command; ++ ++ command = g_find_program_in_path ("totem-audio-preview"); ++ if (command) ++ return command; ++ command = g_find_program_in_path ("gst-launch-0.10"); ++ if (command) { ++ char *new_cmd; ++ ++ new_cmd = g_strdup_printf ("%s playbin uri=fd://0", command); ++ g_free (command); ++ return new_cmd; ++ } ++ ++ return NULL; ++} ++#endif /* USE_OLD_AUDIO_PREVIEW */ ++ + /* 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 +@@ -1757,50 +1780,27 @@ + FMIconView *icon_view; + FILE *sound_process; + char *file_uri; +- char *suffix; +- char *mime_type; +- const char *command_str; +- gboolean is_mp3; +- gboolean is_ogg; ++ char *command_str; + pid_t mp3_pid; + + GnomeVFSResult result; + GnomeVFSHandle *handle; + char *buffer; +- const char *audio_device = NULL; + GnomeVFSFileSize bytes_read; + +- audio_device = g_getenv ("AUDIODEV"); + icon_view = FM_ICON_VIEW (callback_data); ++ ++ command_str = get_preview_command (); ++ if (command_str == NULL) ++ return FALSE; + + file = icon_view->details->audio_preview_file; + file_uri = nautilus_file_get_uri (file); +- mime_type = nautilus_file_get_mime_type (file); +- is_mp3 = eel_strcasecmp (mime_type, "audio/mpeg") == 0; +- is_ogg = eel_strcasecmp (mime_type, "application/ogg") == 0 || +- eel_strcasecmp (mime_type, "application/x-ogg") == 0; + + mp3_pid = fork (); + if (mp3_pid == (pid_t) 0) { + /* Set the group (session) id to this process for future killing. */ + setsid(); +- if (is_mp3) { +- command_str = "mpg123 -y -q -"; +- } else if (is_ogg) { +- command_str = "ogg123 -q -"; +- } else { +- suffix = strrchr(file_uri, '.'); +- if (suffix == NULL) { +- suffix = "wav"; +- } else { +- suffix += 1; /* skip the period */ +- } +- if (audio_device) { +- command_str = g_strdup_printf("play -d %s -t %s -", audio_device, suffix); +- } else { +- command_str = g_strdup_printf("play -t %s -", suffix); +- } +- } + + /* read the file with gnome-vfs, feeding it to the sound player's standard input */ + /* First, open the file. */ +@@ -1851,7 +1851,7 @@ + } + + g_free (file_uri); +- g_free (mime_type); ++ g_free (command_str); + + icon_view->details->audio_preview_timeout = 0; + #else +@@ -1923,6 +1923,25 @@ + } + + 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 (strcmp (mime_type, audio_mime_types[i]) == 0) { ++ g_free (mime_type); ++ return TRUE; ++ } ++ } ++ ++ return FALSE; ++} ++ ++static gboolean + should_preview_sound (NautilusFile *file) + { + char *uri; +@@ -1981,25 +2000,17 @@ + FMIconView *icon_view) + { + int result; +- char *mime_type, *file_name, *message; ++ char *file_name, *message; + + result = 0; + + /* preview files based on the mime_type. */ + /* at first, we just handle sounds */ + if (should_preview_sound (file)) { +- mime_type = nautilus_file_get_mime_type (file); +- +- if ((eel_istr_has_prefix (mime_type, "audio/") +- || eel_istr_has_prefix (mime_type, "application/ogg") +- || eel_istr_has_prefix (mime_type, "application/x-ogg")) +- && eel_strcasecmp (mime_type, "audio/x-pn-realaudio") != 0 +- && eel_strcasecmp (mime_type, "audio/x-mpegurl") != 0 +- && can_play_sound ()) { ++ if (sound_preview_type_supported (file) && can_play_sound ()) { + result = 1; + preview_audio (icon_view, file, start_flag); + } +- g_free (mime_type); + } + + /* Display file name in status area at low zoom levels, since +Index: src/file-manager/nautilus-audio-mime-types.h +=================================================================== +--- src/file-manager/nautilus-audio-mime-types.h (revision 0) ++++ src/file-manager/nautilus-audio-mime-types.h (revision 0) +@@ -0,0 +1,41 @@ ++/* generated with mime-types-include.sh in the totem module, don't edit or ++ commit in the nautilus module without filing a bug against totem */ ++static char *audio_mime_types[] = { ++"audio/3gpp", ++"audio/ac3", ++"audio/AMR", ++"audio/AMR-WB", ++"audio/basic", ++"audio/mp4", ++"audio/mpeg", ++"audio/mpegurl", ++"audio/ogg", ++"audio/vnd.rn-realaudio", ++"audio/x-ape", ++"audio/x-flac", ++"audio/x-it", ++"audio/x-m4a", ++"audio/x-matroska", ++"audio/x-mod", ++"audio/x-mp3", ++"audio/x-mpeg", ++"audio/x-mpegurl", ++"audio/x-ms-asf", ++"audio/x-ms-asx", ++"audio/x-ms-wax", ++"audio/x-ms-wma", ++"audio/x-musepack", ++"audio/x-pn-aiff", ++"audio/x-pn-au", ++"audio/x-pn-wav", ++"audio/x-pn-windows-acm", ++"audio/x-realaudio", ++"audio/x-real-audio", ++"audio/x-sbc", ++"audio/x-scpls", ++"audio/x-tta", ++"audio/x-wav", ++"audio/x-wav", ++"audio/x-wavpack", ++"audio/x-vorbis", ++}; +Index: src/file-manager/Makefile.am +=================================================================== +--- src/file-manager/Makefile.am (revision 13313) ++++ src/file-manager/Makefile.am (working copy) +@@ -38,6 +38,7 @@ + fm-tree-model.h \ + fm-tree-view.c \ + fm-tree-view.h \ ++ nautilus-audio-mime-types.h \ + $(NULL) + + EMPTY_VIEW_SOURCES = \ diff --git a/nautilus.spec b/nautilus.spec index 1def9f4..963f8bf 100644 --- a/nautilus.spec +++ b/nautilus.spec @@ -18,7 +18,7 @@ Name: nautilus Summary: Nautilus is a file manager for GNOME Version: 2.20.0 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2+ Group: User Interface/Desktops Source: http://download.gnome.org/sources/%{name}/2.20/%{name}-%{version}.tar.bz2 @@ -84,6 +84,9 @@ Patch7: nautilus-2.20-async_thumbnail_fixes.patch # http://bugzilla.gnome.org/show_bug.cgi?id=454884 Patch8: nautilus-2.20.0-small-font-fix.patch +# http://bugzilla.gnome.org/show_bug.cgi?id=486827 +Patch9: nautilus-2.20-make-audio-preview-work.patch + %description Nautilus integrates access to files, applications, media, Internet-based resources and the Web. Nautilus delivers a dynamic and @@ -120,6 +123,7 @@ for writing nautilus extensions. %patch6 -p1 -b .dynamic-search %patch7 -p0 -b .async_thumbnail_fixes %patch8 -p1 -b .small-font-fix +%patch0 -p0 -b .audio-preview %build @@ -228,6 +232,10 @@ fi %{_libdir}/*.so %changelog +* Tue Oct 16 2007 - Bastien Nocera - 2.20.0-5 +- Add patch from upstream to get audio preview working again + (#332251) + * Wed Oct 3 2007 Matthias Clasen - 2.20.0-4 - Move /usr/lib/nautilus/extensions-1.0 to the extensions package