mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-08-27 03:19:18 +00:00
file: Don’t frame videos or images
Video framing is no longer desirable from a design standpoint, and framing images does not align with what’s done in the flow box view.
This commit is contained in:
parent
d2ab245cd7
commit
4d489b24ab
Binary file not shown.
Before Width: | Height: | Size: 173 B |
|
@ -283,7 +283,6 @@ libnautilus_sources = [
|
|||
'nautilus-vfs-directory.h',
|
||||
'nautilus-vfs-file.c',
|
||||
'nautilus-vfs-file.h',
|
||||
'nautilus-video-mime-types.h',
|
||||
'nautilus-view-icon-controller.c',
|
||||
'nautilus-view-icon-controller.h',
|
||||
'nautilus-view-icon-item-ui.c',
|
||||
|
|
|
@ -71,7 +71,6 @@
|
|||
#include "nautilus-thumbnails.h"
|
||||
#include "nautilus-ui-utilities.h"
|
||||
#include "nautilus-vfs-file.h"
|
||||
#include "nautilus-video-mime-types.h"
|
||||
|
||||
#ifdef HAVE_SELINUX
|
||||
#include <selinux/selinux.h>
|
||||
|
@ -4773,29 +4772,6 @@ 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 GList *
|
||||
sort_keyword_list_and_remove_duplicates (GList *keywords)
|
||||
{
|
||||
|
@ -5184,28 +5160,6 @@ nautilus_file_get_thumbnail_icon (NautilusFile *file,
|
|||
MAX (h * thumb_scale, 1),
|
||||
GDK_INTERP_BILINEAR);
|
||||
|
||||
/* We don't want frames around small icons */
|
||||
if (!gdk_pixbuf_get_has_alpha (file->details->thumbnail) || s >= 128 * scale)
|
||||
{
|
||||
gboolean use_experimental_views;
|
||||
|
||||
use_experimental_views = g_settings_get_boolean (nautilus_preferences,
|
||||
NAUTILUS_PREFERENCES_USE_EXPERIMENTAL_VIEWS);
|
||||
if (!use_experimental_views)
|
||||
{
|
||||
#if 0
|
||||
if (nautilus_is_video_file (file))
|
||||
{
|
||||
nautilus_ui_frame_video (&pixbuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
nautilus_ui_frame_image (&pixbuf);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
g_clear_object (&file->details->scaled_thumbnail);
|
||||
file->details->scaled_thumbnail = pixbuf;
|
||||
file->details->thumbnail_scale = thumb_scale;
|
||||
|
|
|
@ -169,186 +169,6 @@ nautilus_gmenu_add_item_in_submodel (GMenu *menu,
|
|||
g_object_unref (submodel);
|
||||
}
|
||||
|
||||
#define NAUTILUS_THUMBNAIL_FRAME_LEFT 3
|
||||
#define NAUTILUS_THUMBNAIL_FRAME_TOP 3
|
||||
#define NAUTILUS_THUMBNAIL_FRAME_RIGHT 3
|
||||
#define NAUTILUS_THUMBNAIL_FRAME_BOTTOM 3
|
||||
|
||||
static cairo_surface_t *
|
||||
embed_surface_in_frame (cairo_surface_t *source_image,
|
||||
const gchar *frame_image_url,
|
||||
GtkBorder *slice_width,
|
||||
GtkBorder *border_width)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
gint source_width;
|
||||
gint source_height;
|
||||
g_autofree gchar *css_str = NULL;
|
||||
g_autoptr (GtkCssProvider) provider = NULL;
|
||||
g_autoptr (GtkStyleContext) context = NULL;
|
||||
g_autoptr (GError) error = NULL;
|
||||
g_autoptr (GtkWidgetPath) path = NULL;
|
||||
gdouble scale_x;
|
||||
gdouble scale_y;
|
||||
|
||||
cairo_surface_get_device_scale (source_image, &scale_x, &scale_y);
|
||||
|
||||
source_width = cairo_image_surface_get_width (source_image) / (gint) floor (scale_x);
|
||||
source_height = cairo_image_surface_get_height (source_image) / (gint) floor (scale_y);
|
||||
|
||||
css_str = g_strdup_printf (".embedded-image { border-image: url(\"%s\") %d %d %d %d / %dpx %dpx %dpx %dpx }",
|
||||
frame_image_url,
|
||||
slice_width->top, slice_width->right, slice_width->bottom, slice_width->left,
|
||||
border_width->top, border_width->right, border_width->bottom, border_width->left);
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css_str, -1, &error);
|
||||
|
||||
if (error != NULL)
|
||||
{
|
||||
g_warning ("Unable to create the thumbnail frame image: %s", error->message);
|
||||
|
||||
return g_object_ref (source_image);
|
||||
}
|
||||
|
||||
surface = cairo_surface_create_similar (source_image,
|
||||
CAIRO_CONTENT_COLOR_ALPHA,
|
||||
source_width, source_height);
|
||||
cr = cairo_create (surface);
|
||||
|
||||
context = gtk_style_context_new ();
|
||||
path = gtk_widget_path_new ();
|
||||
gtk_widget_path_append_type (path, GTK_TYPE_ICON_VIEW);
|
||||
|
||||
gtk_style_context_set_path (context, path);
|
||||
gtk_style_context_add_provider (context,
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
cairo_save (cr);
|
||||
cairo_rectangle (cr,
|
||||
border_width->left,
|
||||
border_width->top,
|
||||
source_width - border_width->left - border_width->right,
|
||||
source_height - border_width->top - border_width->bottom);
|
||||
cairo_clip (cr);
|
||||
gtk_render_icon_surface (context, cr, source_image, 0, 0);
|
||||
cairo_restore (cr);
|
||||
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_add_class (context, "embedded-image");
|
||||
|
||||
gtk_render_frame (context, cr, 0, 0, source_width, source_height);
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
cairo_destroy (cr);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
static GdkPixbuf *
|
||||
embed_image_in_frame (GdkPixbuf *source_image,
|
||||
const gchar *frame_image_url,
|
||||
GtkBorder *slice_width,
|
||||
GtkBorder *border_width)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_surface_t *embedded_surface;
|
||||
GdkPixbuf *retval;
|
||||
|
||||
surface = gdk_cairo_surface_create_from_pixbuf (source_image, 0, NULL);
|
||||
|
||||
/* Force the device scale to 1.0, since pixbufs are always in unscaled
|
||||
* dimensions.
|
||||
*/
|
||||
cairo_surface_set_device_scale (surface, 1.0, 1.0);
|
||||
embedded_surface = embed_surface_in_frame (surface, frame_image_url,
|
||||
slice_width, border_width);
|
||||
retval = gdk_pixbuf_get_from_surface (embedded_surface,
|
||||
0, 0,
|
||||
cairo_image_surface_get_width (embedded_surface),
|
||||
cairo_image_surface_get_height (embedded_surface));
|
||||
|
||||
cairo_surface_destroy (embedded_surface);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_ui_frame_image (GdkPixbuf **pixbuf)
|
||||
{
|
||||
GtkBorder border;
|
||||
GdkPixbuf *pixbuf_with_frame;
|
||||
|
||||
border.left = NAUTILUS_THUMBNAIL_FRAME_LEFT;
|
||||
border.top = NAUTILUS_THUMBNAIL_FRAME_TOP;
|
||||
border.right = NAUTILUS_THUMBNAIL_FRAME_RIGHT;
|
||||
border.bottom = NAUTILUS_THUMBNAIL_FRAME_BOTTOM;
|
||||
|
||||
pixbuf_with_frame = embed_image_in_frame (*pixbuf,
|
||||
"resource:///org/gnome/nautilus/icons/thumbnail_frame.png",
|
||||
&border, &border);
|
||||
g_object_unref (*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, TRUE);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
nautilus_file_date_in_between (guint64 unix_file_time,
|
||||
GDateTime *initial_date,
|
||||
|
|
|
@ -34,9 +34,6 @@ void nautilus_gmenu_merge (GMenu *original
|
|||
const gchar *submodel_name,
|
||||
gboolean prepend);
|
||||
|
||||
void nautilus_ui_frame_image (GdkPixbuf **pixbuf);
|
||||
void nautilus_ui_frame_video (GdkPixbuf **pixbuf);
|
||||
|
||||
gboolean nautilus_file_date_in_between (guint64 file_unix_time,
|
||||
GDateTime *initial_date,
|
||||
GDateTime *end_date);
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
/* 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
|
||||
};
|
|
@ -24,7 +24,6 @@
|
|||
<file alias="gtk/ui/nautilusgtkplacesviewrow.ui">../gtk/nautilusgtkplacesviewrow.ui</file>
|
||||
<file alias="gtk/ui/nautilusgtksidebarrow.ui">../gtk/nautilusgtksidebarrow.ui</file>
|
||||
<file alias="icons/thumbnail_frame.png">../../icons/thumbnail_frame.png</file>
|
||||
<file alias="icons/filmholes.png">../../icons/filmholes.png</file>
|
||||
<file>css/Adwaita.css</file>
|
||||
<file>css/nautilus.css</file>
|
||||
<file>text-x-preview.png</file>
|
||||
|
|
Loading…
Reference in a new issue