Skip to content

Commit

Permalink
refactor thumbnails code
Browse files Browse the repository at this point in the history
  • Loading branch information
stefano-k committed Oct 10, 2012
1 parent 2fbc016 commit 2bad19e
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 533 deletions.
2 changes: 1 addition & 1 deletion libcaja-private/caja-directory-async.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4307,7 +4307,7 @@ get_pixbuf_for_content (goffset file_len,
while (res && file_len > 0) while (res && file_len > 0)
{ {
chunk_len = file_len; chunk_len = file_len;
res = gdk_pixbuf_loader_write (loader, file_contents, chunk_len, NULL); res = gdk_pixbuf_loader_write (loader, (guchar *) file_contents, chunk_len, NULL);
file_contents += chunk_len; file_contents += chunk_len;
file_len -= chunk_len; file_len -= chunk_len;
} }
Expand Down
23 changes: 17 additions & 6 deletions libcaja-private/caja-file.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "caja-search-directory.h" #include "caja-search-directory.h"
#include "caja-search-directory-file.h" #include "caja-search-directory-file.h"
#include "caja-thumbnails.h" #include "caja-thumbnails.h"
#include "caja-ui-utilities.h"
#include "caja-users-groups-cache.h" #include "caja-users-groups-cache.h"
#include "caja-vfs-file.h" #include "caja-vfs-file.h"
#include "caja-saved-search-file.h" #include "caja-saved-search-file.h"
Expand Down Expand Up @@ -2791,7 +2792,7 @@ compare_files_by_size (CajaFile *file_1, CajaFile *file_2)
*/ */


Knowledge size_known_1, size_known_2; Knowledge size_known_1, size_known_2;
goffset size_1, size_2; goffset size_1 = 0, size_2 = 0;


size_known_1 = get_size (file_1, &size_1); size_known_1 = get_size (file_1, &size_1);
size_known_2 = get_size (file_2, &size_2); size_known_2 = get_size (file_2, &size_2);
Expand Down Expand Up @@ -4267,8 +4268,20 @@ caja_file_get_icon (CajaFile *file,


gicon = get_custom_icon (file); gicon = get_custom_icon (file);
if (gicon) { if (gicon) {
GdkPixbuf *pixbuf;

icon = caja_icon_info_lookup (gicon, size); icon = caja_icon_info_lookup (gicon, size);
g_object_unref (gicon); g_object_unref (gicon);

pixbuf = caja_icon_info_get_pixbuf (icon);
if (pixbuf != NULL) {
caja_ui_frame_image (&pixbuf);
g_object_unref (icon);

icon = caja_icon_info_new_for_pixbuf (pixbuf);
g_object_unref (pixbuf);
}

return icon; return icon;
} }


Expand Down Expand Up @@ -4302,13 +4315,11 @@ caja_file_get_icon (CajaFile *file,
} }


scaled_pixbuf = gdk_pixbuf_scale_simple (raw_pixbuf, scaled_pixbuf = gdk_pixbuf_scale_simple (raw_pixbuf,
w * scale, h * scale, MAX (w * scale, 1),
MAX (h * scale, 1),
GDK_INTERP_BILINEAR); GDK_INTERP_BILINEAR);


/* We don't want frames around small icons */ caja_ui_frame_image (&scaled_pixbuf);
if (!gdk_pixbuf_get_has_alpha(raw_pixbuf) || s >= 128) {
caja_thumbnail_frame_image (&scaled_pixbuf);
}
g_object_unref (raw_pixbuf); g_object_unref (raw_pixbuf);


/* Don't scale up if more than 25%, then read the original /* Don't scale up if more than 25%, then read the original
Expand Down
Loading

0 comments on commit 2bad19e

Please sign in to comment.