Commit c997bbe8 authored by Cosimo Cecchi's avatar Cosimo Cecchi

all: remove the built-in hover audio previewer

This is not really useful anymore now that we have Sushi, which is way
more powerful.
parent 065cecec
......@@ -3,7 +3,6 @@ NULL=
icondir = $(datadir)/pixmaps/nautilus
icon_DATA =\
audio.svg \
knob.png \
thumbnail_frame.png \
$(NULL)
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="28" height="28" id="svg2" version="1.1" inkscape:version="0.47 r22583" sodipodi:docname="New document 1">
<defs id="defs4">
<linearGradient inkscape:collect="always" id="linearGradient3793">
<stop style="stop-color: rgb(85, 87, 83); stop-opacity: 1;" offset="0" id="stop3795"/>
<stop style="stop-color: rgb(0, 0, 0); stop-opacity: 1;" offset="1" id="stop3797"/>
</linearGradient>
<inkscape:perspective sodipodi:type="inkscape:persp3d" inkscape:vp_x="0 : 526.18109 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_z="744.09448 : 526.18109 : 1" inkscape:persp3d-origin="372.04724 : 350.78739 : 1" id="perspective10"/>
<inkscape:perspective id="perspective2824" inkscape:persp3d-origin="0.5 : 0.33333333 : 1" inkscape:vp_z="1 : 0.5 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_x="0 : 0.5 : 1" sodipodi:type="inkscape:persp3d"/>
<inkscape:perspective id="perspective2838" inkscape:persp3d-origin="0.5 : 0.33333333 : 1" inkscape:vp_z="1 : 0.5 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_x="0 : 0.5 : 1" sodipodi:type="inkscape:persp3d"/>
<inkscape:perspective id="perspective2852" inkscape:persp3d-origin="0.5 : 0.33333333 : 1" inkscape:vp_z="1 : 0.5 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_x="0 : 0.5 : 1" sodipodi:type="inkscape:persp3d"/>
<inkscape:perspective id="perspective2866" inkscape:persp3d-origin="0.5 : 0.33333333 : 1" inkscape:vp_z="1 : 0.5 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_x="0 : 0.5 : 1" sodipodi:type="inkscape:persp3d"/>
<inkscape:perspective id="perspective2880" inkscape:persp3d-origin="0.5 : 0.33333333 : 1" inkscape:vp_z="1 : 0.5 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_x="0 : 0.5 : 1" sodipodi:type="inkscape:persp3d"/>
<inkscape:perspective id="perspective2894" inkscape:persp3d-origin="0.5 : 0.33333333 : 1" inkscape:vp_z="1 : 0.5 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_x="0 : 0.5 : 1" sodipodi:type="inkscape:persp3d"/>
<inkscape:perspective id="perspective2908" inkscape:persp3d-origin="0.5 : 0.33333333 : 1" inkscape:vp_z="1 : 0.5 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_x="0 : 0.5 : 1" sodipodi:type="inkscape:persp3d"/>
<inkscape:perspective id="perspective2922" inkscape:persp3d-origin="0.5 : 0.33333333 : 1" inkscape:vp_z="1 : 0.5 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_x="0 : 0.5 : 1" sodipodi:type="inkscape:persp3d"/>
<inkscape:perspective id="perspective2936" inkscape:persp3d-origin="0.5 : 0.33333333 : 1" inkscape:vp_z="1 : 0.5 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_x="0 : 0.5 : 1" sodipodi:type="inkscape:persp3d"/>
<inkscape:perspective id="perspective2950" inkscape:persp3d-origin="14 : 8.6666667 : 1" inkscape:vp_z="28 : 13 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_x="0 : 13 : 1" sodipodi:type="inkscape:persp3d"/>
<inkscape:perspective id="perspective3856" inkscape:persp3d-origin="14 : 8.6666667 : 1" inkscape:vp_z="28 : 13 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_x="0 : 13 : 1" sodipodi:type="inkscape:persp3d"/>
<radialGradient inkscape:collect="always" xlink:href="#linearGradient3793" id="radialGradient3871" gradientUnits="userSpaceOnUse" gradientTransform="matrix(2.0512, 0, 0, 2.0512, -473.079, -629.301)" cx="488.83804" cy="543.78619" fx="488.83804" fy="543.78619" r="8.875"/>
<radialGradient inkscape:collect="always" xlink:href="#linearGradient3793" id="radialGradient3894" gradientUnits="userSpaceOnUse" gradientTransform="matrix(2.0512, 0, 0, 2.0512, -473.079, -629.301)" cx="488.83804" cy="543.78619" fx="488.83804" fy="543.78619" r="8.875"/>
</defs>
<sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1" inkscape:cx="25.110625" inkscape:cy="8.8072819" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" inkscape:snap-nodes="true" inkscape:snap-bbox="false" inkscape:snap-global="false" inkscape:window-width="1280" inkscape:window-height="742" inkscape:window-x="0" inkscape:window-y="26" inkscape:window-maximized="1">
<inkscape:grid type="xygrid" id="grid2942" empspacing="5" visible="true" enabled="true" snapvisiblegridlinesonly="true"/>
</sodipodi:namedview>
<metadata id="metadata7">
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<dc:title/>
</cc:Work>
</rdf:RDF>
</metadata>
<g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1" transform="translate(0, -1024.36)">
<g transform="matrix(1, 0, 0, 0.997177, -518.988, 548.313)" id="g3863">
<path id="path3865" d="m 532,480.375 c -6.07513,0 -11,4.92487 -11,11 0,6.07513 4.92487,11 11,11 2.25341,0 4.34949,-0.71247 6.09375,-1.875 0,0 2.08361,1.9375 6.90625,1.9375 0,0 0,0 0,0 0,0 0,0 0,0 -4.5,-3.25 -3.90625,-4.875 -3.90625,-4.875 1.2099,-1.7668 1.90625,-3.88444 1.90625,-6.1875 0,-6.07513 -4.92487,-11 -11,-11 z" style="color: rgb(0, 0, 0); fill: url(&quot;#radialGradient3894&quot;) rgb(0, 0, 0); fill-opacity: 1; fill-rule: nonzero; stroke: rgb(255, 255, 255); stroke-width: 4.00566; stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 4; stroke-opacity: 1; stroke-dasharray: none; marker: none; visibility: visible; display: inline; overflow: visible;" sodipodi:nodetypes="cssccsscsc"/>
<path sodipodi:nodetypes="csscccsc" style="color: rgb(0, 0, 0); fill: rgb(16, 16, 16); fill-opacity: 1; fill-rule: nonzero; stroke: none; stroke-width: 1; marker: none; visibility: visible; display: inline; overflow: visible;" d="m 532,480.375 c -6.07513,0 -11,4.92487 -11,11 0,6.07513 4.92487,11 11,11 2.25341,0 4.34949,-0.71247 6.09375,-1.875 0,0 2.08361,1.9375 6.90625,1.9375 -4.5,-3.25 -3.90625,-4.875 -3.90625,-4.875 1.2099,-1.7668 1.90625,-3.88444 1.90625,-6.1875 0,-6.07513 -4.92487,-11 -11,-11 z" id="path3867"/>
<path style="color: rgb(0, 0, 0); fill: rgb(255, 255, 255); fill-opacity: 1; fill-rule: nonzero; stroke: none; stroke-width: 1; marker: none; visibility: visible; display: inline; overflow: visible;" d="m 530.28181,487.375 c -0.29406,10e-4 -0.28174,0.28275 -0.28174,0.28275 l 0,8.45479 c 0,0 -0.004,0.24964 0.25,0.24964 l 0.23437,0 4.51556,-4.50919 -4.47058,-4.47894 c 0,0 -0.24761,9.5e-4 -0.24761,9.5e-4 z" id="path3869" sodipodi:nodetypes="cccccccs" inkscape:export-filename="/home/hbons/Dropbox/Public/play.png" inkscape:export-xdpi="90" inkscape:export-ydpi="90"/>
</g>
</g>
</svg>
\ No newline at end of file
......@@ -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);
......
......@@ -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)
{
......
......@@ -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);
......
......@@ -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 \
......
/* 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 const char *audio_mime_types[] = {
"audio/3gpp",
"audio/ac3",
"audio/AMR",
"audio/AMR-WB",
"audio/basic",
"audio/midi",
"audio/mp4",
"audio/mpeg",
"audio/ogg",
"audio/prs.sid",
"audio/vnd.rn-realaudio",
"audio/x-aiff",
"audio/x-ape",
"audio/x-flac",
"audio/x-gsm",
"audio/x-it",
"audio/x-m4a",
"audio/x-matroska",
"audio/x-mod",
"audio/x-mp3",
"audio/x-mpeg",
"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-speex",
"audio/x-tta",
"audio/x-wav",
"audio/x-wavpack",
"audio/x-vorbis",
"audio/x-vorbis+ogg",
"audio/x-xm",
"application/x-flac",
};
......@@ -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",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment