summaryrefslogtreecommitdiff
path: root/thunarx
diff options
context:
space:
mode:
authorBenedikt Meurer <benny@xfce.org>2005-07-24 17:12:27 +0000
committerBenedikt Meurer <benny@xfce.org>2005-07-24 17:12:27 +0000
commite24ebc3dd35e1a5b1d16db4469b346722d683fb6 (patch)
treebaf5d45212c8491d203b3d38023ce72384e38789 /thunarx
parent5796662bbb68da6f37dccebc8c4e6301c6883526 (diff)
downloadthunar-e24ebc3dd35e1a5b1d16db4469b346722d683fb6.tar.gz
2005-07-24 Benedikt Meurer <benny@xfce.org>
* thunar/thunar-file.c(thunar_file_load_icon): Actually cache the result of an icon lookup. * thunarx/, thunarx/Makefile.am, configure.in.in: Add "thunarx" namespace, which contains extensions to existing frameworks and various helper functions that don't fit anywhere else. * thunarx/thunarx-gdk-pixbuf-extensions.{c,h}: Add a method to colorize a GdkPixbuf to a given GdkColor. * thunar/main.c, thunar/thunar-desktop-model.{c,h}, thunar/Makefile.am, thunar/thunar-desktop-window.{c,h}, thunar/thunar-desktop-view.{c,h}: Add proof-of-concept for the desktop support. (Old svn revision: 16409)
Diffstat (limited to 'thunarx')
-rw-r--r--thunarx/Makefile.am25
-rw-r--r--thunarx/thunarx-gdk-pixbuf-extensions.c90
-rw-r--r--thunarx/thunarx-gdk-pixbuf-extensions.h32
3 files changed, 147 insertions, 0 deletions
diff --git a/thunarx/Makefile.am b/thunarx/Makefile.am
new file mode 100644
index 00000000..4f639bd2
--- /dev/null
+++ b/thunarx/Makefile.am
@@ -0,0 +1,25 @@
+# $Id$
+
+INCLUDES = \
+ -I$(top_srcdir) \
+ -DEXO_API_SUBJECT_TO_CHANGE \
+ -DEXO_DISABLE_DEPRECATED \
+ -DG_LOG_DOMAIN=\"thunarx\"
+
+noinst_LTLIBRARIES = \
+ libthunarx.la
+
+libthunarx_la_SOURCES = \
+ thunarx-gdk-pixbuf-extensions.c \
+ thunarx-gdk-pixbuf-extensions.h
+
+libthunarx_la_CFLAGS = \
+ $(EXO_CFLAGS)
+
+libthunarx_la_LDFLAGS = \
+ -no-undefined
+
+libthunarx_la_LIBADD = \
+ $(EXO_LIBS)
+
+# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/thunarx/thunarx-gdk-pixbuf-extensions.c b/thunarx/thunarx-gdk-pixbuf-extensions.c
new file mode 100644
index 00000000..f5d51bfd
--- /dev/null
+++ b/thunarx/thunarx-gdk-pixbuf-extensions.c
@@ -0,0 +1,90 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <thunarx/thunarx-gdk-pixbuf-extensions.h>
+
+
+
+/**
+ * thunarx_gdk_pixbuf_colorize:
+ * @src : the source #GdkPixbuf.
+ * @color : the new color.
+ *
+ * Creates a new #GdkPixbuf based on @src, which is
+ * colorized to @color.
+ *
+ * Return value: the colorized #GdkPixbuf.
+ **/
+GdkPixbuf*
+thunarx_gdk_pixbuf_colorize (GdkPixbuf *src,
+ const GdkColor *color)
+{
+ gint i, j;
+ gint width, height, has_alpha, src_row_stride, dst_row_stride;
+ gint red_value, green_value, blue_value;
+ guchar *target_pixels;
+ guchar *original_pixels;
+ guchar *pixsrc;
+ guchar *pixdest;
+ GdkPixbuf *dest;
+
+ red_value = color->red / 255.0;
+ green_value = color->green / 255.0;
+ blue_value = color->blue / 255.0;
+
+ dest = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src),
+ gdk_pixbuf_get_has_alpha (src),
+ gdk_pixbuf_get_bits_per_sample (src),
+ gdk_pixbuf_get_width (src),
+ gdk_pixbuf_get_height (src));
+
+ has_alpha = gdk_pixbuf_get_has_alpha (src);
+ width = gdk_pixbuf_get_width (src);
+ height = gdk_pixbuf_get_height (src);
+ src_row_stride = gdk_pixbuf_get_rowstride (src);
+ dst_row_stride = gdk_pixbuf_get_rowstride (dest);
+ target_pixels = gdk_pixbuf_get_pixels (dest);
+ original_pixels = gdk_pixbuf_get_pixels (src);
+
+ for (i = 0; i < height; i++)
+ {
+ pixdest = target_pixels + i*dst_row_stride;
+ pixsrc = original_pixels + i*src_row_stride;
+
+ for (j = 0; j < width; j++)
+ {
+ *pixdest++ = (*pixsrc++ * red_value) >> 8;
+ *pixdest++ = (*pixsrc++ * green_value) >> 8;
+ *pixdest++ = (*pixsrc++ * blue_value) >> 8;
+
+ if (has_alpha)
+ *pixdest++ = *pixsrc++;
+ }
+ }
+
+ return dest;
+}
+
+
+
+
diff --git a/thunarx/thunarx-gdk-pixbuf-extensions.h b/thunarx/thunarx-gdk-pixbuf-extensions.h
new file mode 100644
index 00000000..6f685cda
--- /dev/null
+++ b/thunarx/thunarx-gdk-pixbuf-extensions.h
@@ -0,0 +1,32 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __THUNARX_GDK_PIXBUF_EXTENSIONS_H__
+#define __THUNARX_GDK_PIXBUF_EXTENSIONS_H__
+
+#include <gdk/gdk.h>
+
+G_BEGIN_DECLS;
+
+GdkPixbuf *thunarx_gdk_pixbuf_colorize (GdkPixbuf *src,
+ const GdkColor *color);
+
+G_END_DECLS;
+
+#endif /* !__THUNARX_GDK_PIXBUF_EXTENSIONS_H__ */