2007-10-16 14:48:41 +00:00
|
|
|
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 <config.h>
|
|
|
|
#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;
|
|
|
|
+
|
2007-10-30 14:09:18 +00:00
|
|
|
+ new_cmd = g_strdup_printf ("%s uridecodebin uri=fd://0 ! audioconvert ! audioresample ! autoaudiosink", command);
|
2007-10-16 14:48:41 +00:00
|
|
|
+ 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 = \
|