diff options
author | Stefano Karapetsas <[email protected]> | 2012-10-10 19:35:21 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2012-10-10 19:35:21 +0200 |
commit | 2bad19e7888648507079d10340a01a4aa6b24e12 (patch) | |
tree | 22453cdf20872ce3e3eb3db54d1dbe3642205d3c /libcaja-private/caja-ui-utilities.c | |
parent | 2fbc016ecf597878e7a650db8f80ed91a49176b8 (diff) | |
download | caja-2bad19e7888648507079d10340a01a4aa6b24e12.tar.bz2 caja-2bad19e7888648507079d10340a01a4aa6b24e12.tar.xz |
refactor thumbnails codemate-file-manager-1.5.0
Diffstat (limited to 'libcaja-private/caja-ui-utilities.c')
-rw-r--r-- | libcaja-private/caja-ui-utilities.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/libcaja-private/caja-ui-utilities.c b/libcaja-private/caja-ui-utilities.c index 71ef9b31..9634c41c 100644 --- a/libcaja-private/caja-ui-utilities.c +++ b/libcaja-private/caja-ui-utilities.c @@ -254,3 +254,60 @@ caja_toolbar_action_from_menu_item (CajaMenuItem *item) return action; } + +static GdkPixbuf * +caja_get_thumbnail_frame (void) +{ + char *image_path; + static GdkPixbuf *thumbnail_frame = NULL; + + if (thumbnail_frame == NULL) + { + image_path = caja_pixmap_file ("thumbnail_frame.png"); + if (image_path != NULL) + { + thumbnail_frame = gdk_pixbuf_new_from_file (image_path, NULL); + } + g_free (image_path); + } + + return thumbnail_frame; +} + +#define CAJA_THUMBNAIL_FRAME_LEFT 3 +#define CAJA_THUMBNAIL_FRAME_TOP 3 +#define CAJA_THUMBNAIL_FRAME_RIGHT 3 +#define CAJA_THUMBNAIL_FRAME_BOTTOM 3 + +void +caja_ui_frame_image (GdkPixbuf **pixbuf) +{ + GdkPixbuf *pixbuf_with_frame, *frame; + int left_offset, top_offset, right_offset, bottom_offset; + int size; + + frame = caja_get_thumbnail_frame (); + if (frame == NULL) { + return; + } + + size = MAX (gdk_pixbuf_get_width (*pixbuf), + gdk_pixbuf_get_height (*pixbuf)); + + /* We don't want frames around small icons */ + if (size < 128 && gdk_pixbuf_get_has_alpha (*pixbuf)) { + return; + } + + left_offset = CAJA_THUMBNAIL_FRAME_LEFT; + top_offset = CAJA_THUMBNAIL_FRAME_TOP; + right_offset = CAJA_THUMBNAIL_FRAME_RIGHT; + bottom_offset = CAJA_THUMBNAIL_FRAME_BOTTOM; + + pixbuf_with_frame = eel_embed_image_in_frame + (*pixbuf, frame, + left_offset, top_offset, right_offset, bottom_offset); + g_object_unref (*pixbuf); + + *pixbuf = pixbuf_with_frame; +} |