summaryrefslogtreecommitdiff
path: root/thunarx
diff options
context:
space:
mode:
authorBenedikt Meurer <benny@xfce.org>2005-09-03 22:47:13 +0000
committerBenedikt Meurer <benny@xfce.org>2005-09-03 22:47:13 +0000
commit4da80447c228fd89767747788e751f9daa5b04ca (patch)
tree5b371e55cd84882930363f30fd1e5bb7f729d715 /thunarx
parent2e712c264ad0d8bdb2d1d95088de195fbf2fbf92 (diff)
downloadthunar-4da80447c228fd89767747788e751f9daa5b04ca.tar.gz
2005-09-03 Benedikt Meurer <benny@xfce.org>
* thunar-vfs/thunar-vfs.symbols, thunar-vfs/thunar-vfs-mime-info.{c,h}, thunar-vfs/thunar-vfs-mime-database.c: Determine media and subtype of a ThunarVfsMimeInfo on-demand. * thunar-vfs/thunar-vfs-info.c(thunar_vfs_info_new_for_uri): Move the .desktop file handling to the regular file case. * thunar-vfs/thunar-vfs-thumb.{c,h}, thunar-vfs/thunar-vfs.symbols, thunar-vfs/Makefile.am, thunar-vfs/thunar-vfs.h: Import the ThunarVfsThumbFactory class, which implements the freedesktop thumbnail management specification. * thunarx/thunarx-gdk-pixbuf-extensions.{c,h}: Add new helper function thunarx_gdk_pixbuf_frame(), which is used to embed an arbitrary image into a frame (e.g. for thumbnails). * thunar/thunar-favourites-model.c, thunar/thunar-file.c, thunar/thunar-icon-factory.{c,h}, thunar/thunar-icon-renderer.c, thunar/thunar-list-model.c, thunar/thunar-location-buttons.c, thunar/thunar-window.c: Make sure we don't leak the default icon factory instance on exit. * thunar/Makefile.am, thunar/thunar-thumbnail-frame.{h,png}: Import the thumbnail frame image used by Nautilus. * thunar/thunar-icon-factory.{c,h}: Add thumbnail loading support to the icon factory and reorganize the internals a bit. * thunar/thunar-file.c: Load thumbnails for regular if possible. (Old svn revision: 17328)
Diffstat (limited to 'thunarx')
-rw-r--r--thunarx/thunarx-gdk-pixbuf-extensions.c124
-rw-r--r--thunarx/thunarx-gdk-pixbuf-extensions.h8
2 files changed, 132 insertions, 0 deletions
diff --git a/thunarx/thunarx-gdk-pixbuf-extensions.c b/thunarx/thunarx-gdk-pixbuf-extensions.c
index 1be649da..69752c52 100644
--- a/thunarx/thunarx-gdk-pixbuf-extensions.c
+++ b/thunarx/thunarx-gdk-pixbuf-extensions.c
@@ -149,6 +149,130 @@ thunarx_gdk_pixbuf_colorize (const GdkPixbuf *src,
+static void
+draw_frame_row (GdkPixbuf *frame_image,
+ gint target_width,
+ gint source_width,
+ gint source_v_position,
+ gint dest_v_position,
+ GdkPixbuf *result_pixbuf,
+ gint left_offset,
+ gint height)
+{
+ gint remaining_width;
+ gint slab_width;
+ gint h_offset;
+
+ for (h_offset = 0, remaining_width = target_width; remaining_width > 0; h_offset += slab_width, remaining_width -= slab_width)
+ {
+ slab_width = remaining_width > source_width ? source_width : remaining_width;
+ gdk_pixbuf_copy_area (frame_image, left_offset, source_v_position, slab_width, height, result_pixbuf, left_offset + h_offset, dest_v_position);
+ }
+}
+
+
+
+static void
+draw_frame_column (GdkPixbuf *frame_image,
+ gint target_height,
+ gint source_height,
+ gint source_h_position,
+ gint dest_h_position,
+ GdkPixbuf *result_pixbuf,
+ gint top_offset,
+ gint width)
+{
+ gint remaining_height;
+ gint slab_height;
+ gint v_offset;
+
+ for (v_offset = 0, remaining_height = target_height; remaining_height > 0; v_offset += slab_height, remaining_height -= slab_height)
+ {
+ slab_height = remaining_height > source_height ? source_height : remaining_height;
+ gdk_pixbuf_copy_area (frame_image, source_h_position, top_offset, width, slab_height, result_pixbuf, dest_h_position, top_offset + v_offset);
+ }
+}
+
+
+
+/**
+ * thunarx_gdk_pixbuf_frame:
+ * @src : the source #GdkPixbuf.
+ * @frame : the frame #GdkPixbuf.
+ * @left_offset : the left frame offset.
+ * @top_offset : the top frame offset.
+ * @right_offset : the right frame offset.
+ * @bottom_offset : the bottom frame offset.
+ *
+ * Embeds @src in @frame and returns the result as
+ * new #GdkPixbuf.
+ *
+ * The caller is responsible to free the returned
+ * #GdkPixbuf using g_object_unref().
+ *
+ * Return value: the framed version of @src.
+ **/
+GdkPixbuf*
+thunarx_gdk_pixbuf_frame (GdkPixbuf *src,
+ GdkPixbuf *frame,
+ gint left_offset,
+ gint top_offset,
+ gint right_offset,
+ gint bottom_offset)
+{
+ GdkPixbuf *dst;
+ gint dst_width;
+ gint dst_height;
+ gint frame_width;
+ gint frame_height;
+ gint src_width;
+ gint src_height;
+
+ g_return_val_if_fail (GDK_IS_PIXBUF (src), NULL);
+ g_return_val_if_fail (GDK_IS_PIXBUF (frame), NULL);
+
+ src_width = gdk_pixbuf_get_width (src);
+ src_height = gdk_pixbuf_get_height (src);
+
+ frame_width = gdk_pixbuf_get_width (frame);
+ frame_height = gdk_pixbuf_get_height (frame);
+
+ dst_width = src_width + left_offset + right_offset;
+ dst_height = src_height + top_offset + bottom_offset;
+
+ dst = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, dst_width, dst_height);
+
+ /* fill the destination if the source has an alpha channel */
+ if (G_UNLIKELY (gdk_pixbuf_get_has_alpha (src)))
+ gdk_pixbuf_fill (dst, 0xffffffff);
+
+ /* draw the left top cornder and top row */
+ gdk_pixbuf_copy_area (frame, 0, 0, left_offset, top_offset, dst, 0, 0);
+ draw_frame_row (frame, src_width, frame_width - left_offset - right_offset, 0, 0, dst, left_offset, top_offset);
+
+ /* draw the right top corner and left column */
+ gdk_pixbuf_copy_area (frame, frame_width - right_offset, 0, right_offset, top_offset, dst, dst_width - right_offset, 0);
+ draw_frame_column (frame, src_height, frame_height - top_offset - bottom_offset, 0, 0, dst, top_offset, left_offset);
+
+ /* draw the bottom right corner and bottom row */
+ gdk_pixbuf_copy_area (frame, frame_width - right_offset, frame_height - bottom_offset, right_offset,
+ bottom_offset, dst, dst_width - right_offset, dst_height - bottom_offset);
+ draw_frame_row (frame, src_width, frame_width - left_offset - right_offset, frame_height - bottom_offset,
+ dst_height - bottom_offset, dst, left_offset, bottom_offset);
+
+ /* draw the bottom left corner and the right column */
+ gdk_pixbuf_copy_area (frame, 0, frame_height - bottom_offset, left_offset, bottom_offset, dst, 0, dst_height - bottom_offset);
+ draw_frame_column (frame, src_height, frame_height - top_offset - bottom_offset, frame_width - right_offset,
+ dst_width - right_offset, dst, top_offset, right_offset);
+
+ /* copy the source pixbuf into the framed area */
+ gdk_pixbuf_copy_area (src, 0, 0, src_width, src_height, dst, left_offset, top_offset);
+
+ return dst;
+}
+
+
+
static guchar
lighten_channel (guchar cur_value)
{
diff --git a/thunarx/thunarx-gdk-pixbuf-extensions.h b/thunarx/thunarx-gdk-pixbuf-extensions.h
index 2287fc2e..ded8a694 100644
--- a/thunarx/thunarx-gdk-pixbuf-extensions.h
+++ b/thunarx/thunarx-gdk-pixbuf-extensions.h
@@ -26,6 +26,14 @@ G_BEGIN_DECLS;
GdkPixbuf *thunarx_gdk_pixbuf_colorize (const GdkPixbuf *src,
const GdkColor *color);
+
+GdkPixbuf *thunarx_gdk_pixbuf_frame (GdkPixbuf *src,
+ GdkPixbuf *frame,
+ gint left_offset,
+ gint top_offset,
+ gint right_offset,
+ gint bottom_offset);
+
GdkPixbuf *thunarx_gdk_pixbuf_spotlight (const GdkPixbuf *src);
G_END_DECLS;