Commit 94d20875 authored by Bastien Nocera's avatar Bastien Nocera

Add film strip in nautilus rather than in thumbnailer

This allows front-ends such as Totem to use the generated thumbnails
without the film strip.

https://bugzilla.gnome.org/show_bug.cgi?id=723907
parent d8a8ab3b
......@@ -172,6 +172,7 @@ libnautilus_private_la_SOURCES = \
nautilus-tree-view-drag-dest.h \
nautilus-ui-utilities.c \
nautilus-ui-utilities.h \
nautilus-video-mime-types.h \
nautilus-vfs-directory.c \
nautilus-vfs-directory.h \
nautilus-vfs-file.c \
......
......@@ -42,6 +42,7 @@
#include "nautilus-search-directory-file.h"
#include "nautilus-thumbnails.h"
#include "nautilus-ui-utilities.h"
#include "nautilus-video-mime-types.h"
#include "nautilus-vfs-file.h"
#include "nautilus-file-undo-operations.h"
#include "nautilus-file-undo-manager.h"
......@@ -4064,6 +4065,24 @@ nautilus_file_should_show_thumbnail (NautilusFile *file)
return FALSE;
}
static gboolean
nautilus_is_video_file (NautilusFile *file)
{
const char *mime_type;
guint i;
mime_type = eel_ref_str_peek (file->details->mime_type);
if (mime_type == NULL)
return FALSE;
for (i = 0; video_mime_types[i] != NULL; i++) {
if (g_content_type_equals (video_mime_types[i], mime_type))
return TRUE;
}
return FALSE;
}
static void
prepend_icon_name (const char *name,
GThemedIcon *icon)
......@@ -4294,7 +4313,10 @@ nautilus_file_get_icon (NautilusFile *file,
/* We don't want frames around small icons */
if (!gdk_pixbuf_get_has_alpha (raw_pixbuf) || s >= 128 * scale) {
nautilus_ui_frame_image (&scaled_pixbuf);
if (nautilus_is_video_file (file))
nautilus_ui_frame_video (&scaled_pixbuf);
else
nautilus_ui_frame_image (&scaled_pixbuf);
}
g_object_unref (raw_pixbuf);
......
......@@ -176,12 +176,7 @@ nautilus_get_thumbnail_frame (void)
static GdkPixbuf *thumbnail_frame = NULL;
if (thumbnail_frame == NULL) {
GInputStream *stream = g_resources_open_stream
("/org/gnome/nautilus/icons/thumbnail_frame.png", 0, NULL);
if (stream != NULL) {
thumbnail_frame = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
g_object_unref (stream);
}
thumbnail_frame = gdk_pixbuf_new_from_resource ("/org/gnome/nautilus/icons/thumbnail_frame.png", NULL);
}
return thumbnail_frame;
......@@ -215,3 +210,52 @@ nautilus_ui_frame_image (GdkPixbuf **pixbuf)
*pixbuf = pixbuf_with_frame;
}
static GdkPixbuf *filmholes_left = NULL;
static GdkPixbuf *filmholes_right = NULL;
static gboolean
ensure_filmholes (void)
{
if (filmholes_left == NULL) {
filmholes_left = gdk_pixbuf_new_from_resource ("/org/gnome/nautilus/icons/filmholes.png", NULL);
}
if (filmholes_right == NULL &&
filmholes_left != NULL) {
filmholes_right = gdk_pixbuf_flip (filmholes_left, FALSE);
}
return (filmholes_left && filmholes_right);
}
void
nautilus_ui_frame_video (GdkPixbuf **pixbuf)
{
int width, height;
int holes_width, holes_height;
int i;
if (!ensure_filmholes ())
return;
width = gdk_pixbuf_get_width (*pixbuf);
height = gdk_pixbuf_get_height (*pixbuf);
holes_width = gdk_pixbuf_get_width (filmholes_left);
holes_height = gdk_pixbuf_get_height (filmholes_left);
for (i = 0; i < height; i += holes_height) {
gdk_pixbuf_composite (filmholes_left, *pixbuf, 0, i,
MIN (width, holes_width),
MIN (height - i, holes_height),
0, i, 1, 1, GDK_INTERP_NEAREST, 255);
}
for (i = 0; i < height; i += holes_height) {
gdk_pixbuf_composite (filmholes_right, *pixbuf,
width - holes_width, i,
MIN (width, holes_width),
MIN (height - i, holes_height),
width - holes_width, i,
1, 1, GDK_INTERP_NEAREST, 255);
}
}
......@@ -42,5 +42,6 @@ GdkPixbuf * nautilus_ui_get_menu_icon (const char *icon_name
char * nautilus_escape_action_name (const char *action_name,
const char *prefix);
void nautilus_ui_frame_image (GdkPixbuf **pixbuf);
void nautilus_ui_frame_video (GdkPixbuf **pixbuf);
#endif /* NAUTILUS_UI_UTILITIES_H */
/* generated with mime-type-include.sh in the totem module, don't edit or
commit in the nautilus module without filing a bug against totem */
static const char *video_mime_types[] = {
"application/mxf",
"application/ogg",
"application/ram",
"application/sdp",
"application/vnd.apple.mpegurl",
"application/vnd.ms-wpl",
"application/vnd.rn-realmedia",
"application/x-extension-m4a",
"application/x-extension-mp4",
"application/x-flash-video",
"application/x-matroska",
"application/x-netshow-channel",
"application/x-ogg",
"application/x-quicktimeplayer",
"application/x-shorten",
"image/vnd.rn-realpix",
"image/x-pict",
"misc/ultravox",
"text/x-google-video-pointer",
"video/3gp",
"video/3gpp",
"video/dv",
"video/divx",
"video/fli",
"video/flv",
"video/mp2t",
"video/mp4",
"video/mp4v-es",
"video/mpeg",
"video/msvideo",
"video/ogg",
"video/quicktime",
"video/vivo",
"video/vnd.divx",
"video/vnd.mpegurl",
"video/vnd.rn-realvideo",
"video/vnd.vivo",
"video/webm",
"video/x-anim",
"video/x-avi",
"video/x-flc",
"video/x-fli",
"video/x-flic",
"video/x-flv",
"video/x-m4v",
"video/x-matroska",
"video/x-mpeg",
"video/x-mpeg2",
"video/x-ms-asf",
"video/x-ms-asx",
"video/x-msvideo",
"video/x-ms-wm",
"video/x-ms-wmv",
"video/x-ms-wmx",
"video/x-ms-wvx",
"video/x-nsv",
"video/x-ogm+ogg",
"video/x-theora+ogg",
"video/x-totem-stream",
"audio/x-pn-realaudio",
NULL
};
......@@ -10,6 +10,7 @@
<file>nautilus-shell-ui.xml</file>
<file>nautilus-app-menu.ui</file>
<file alias="icons/thumbnail_frame.png">../icons/thumbnail_frame.png</file>
<file alias="icons/filmholes.png">../icons/filmholes.png</file>
<file alias="icons/knob.png">../icons/knob.png</file>
</gresource>
</gresources>
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