Re: patch: new themable render modes for icons
- From: JackTheDipper <gnome-color-chooser punk-ass-bitch org>
- To: nautilus-list gnome org
- Subject: Re: patch: new themable render modes for icons
- Date: Wed, 01 Nov 2006 18:25:43 +0100
*grrr* wow, I'm so dumb. sorry for this mass flooding!
there was an ugly bug in the code (brackets can be so evil! *g*), here
is at last the correct patch and yes, it should be the last one for
today *be ashamed*
again, sorry, guys!
Jack ;o)
--- nautilus-2.14.3/libnautilus-private/nautilus-icon-container.c 2006-04-18 18:54:31.000000000 +0200
+++ nautilus-2.14.3_patched/libnautilus-private/nautilus-icon-container.c 2006-11-01 14:29:04.000000000 +0100
@@ -118,6 +118,9 @@
#define DEFAULT_LIGHT_INFO_COLOR 0xAAAAFD
#define DEFAULT_DARK_INFO_COLOR 0x33337F
+#define DEFAULT_NORMAL_RENDER_TYPE 0
+#define DEFAULT_PRELIGHT_RENDER_TYPE 1
+
#define MINIMUM_EMBEDDED_TEXT_RECT_WIDTH 20
#define MINIMUM_EMBEDDED_TEXT_RECT_HEIGHT 20
@@ -4811,6 +4814,33 @@
GDK_TYPE_COLOR,
G_PARAM_READABLE));
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_uint ("normal_render_type",
+ "Normal Icon Render Type",
+ "Type of normal icons being rendered (0=normal, 1=spotlight, 2=colorize, 3=black/white)",
+ 0, 3,
+ DEFAULT_NORMAL_RENDER_TYPE,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_uint ("prelight_render_type",
+ "Prelight Icon Render Type",
+ "Type of prelight icons being rendered (0=normal, 1=spotlight, 2=colorize, 3=black/white)",
+ 0, 3,
+ DEFAULT_PRELIGHT_RENDER_TYPE,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_boxed ("normal_color",
+ "Icon Normal Color",
+ "Color used for colorizing icons in normal state (default base[NORMAL])",
+ GDK_TYPE_COLOR,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_boxed ("prelight_color",
+ "Icon Prelight Color",
+ "Color used for colorizing prelighted icons (default base[PRELIGHT]",
+ GDK_TYPE_COLOR,
+ G_PARAM_READABLE));
+
binding_set = gtk_binding_set_by_class (class);
gtk_binding_entry_add_signal (binding_set, GDK_f, GDK_CONTROL_MASK, "start_interactive_search", 0);
@@ -7155,6 +7185,7 @@
{
NautilusIconContainer *container;
GtkStyle *style;
+ GdkColor *prelight_color, *normal_color;
guchar highlight_alpha, normal_alpha;
container = NAUTILUS_ICON_CONTAINER (user_data);
@@ -7183,18 +7214,49 @@
style->base[GTK_STATE_ACTIVE].green >> 8,
style->base[GTK_STATE_ACTIVE].blue >> 8,
highlight_alpha);
-
+
+ /* load the prelight color */
+ gtk_widget_style_get (GTK_WIDGET (container),
+ "prelight_color", &prelight_color,
+ NULL);
+
+ if (prelight_color) {
+ container->details->prelight_color_rgba =
+ EEL_RGBA_COLOR_PACK (prelight_color->red >> 8,
+ prelight_color->green >> 8,
+ prelight_color->blue >> 8,
+ 255);
+ } else { /* if not defined by rc, set to default value */
+ container->details->prelight_color_rgba =
+ EEL_RGBA_COLOR_PACK ( style->base[GTK_STATE_PRELIGHT].red >> 8,
+ style->base[GTK_STATE_PRELIGHT].green >> 8,
+ style->base[GTK_STATE_PRELIGHT].blue >> 8,
+ 255);
+ }
+
+
/* load the normal color */
gtk_widget_style_get (GTK_WIDGET (container),
+ "normal_color", &normal_color,
+ NULL);
+ gtk_widget_style_get (GTK_WIDGET (container),
"normal_alpha", &normal_alpha,
NULL);
-
- container->details->normal_color_rgba =
- EEL_RGBA_COLOR_PACK (style->base[GTK_STATE_NORMAL].red >> 8,
- style->base[GTK_STATE_NORMAL].green >> 8,
- style->base[GTK_STATE_NORMAL].blue >> 8,
- normal_alpha);
+ if (normal_color) {
+ container->details->normal_color_rgba =
+ EEL_RGBA_COLOR_PACK (normal_color->red >> 8,
+ normal_color->green >> 8,
+ normal_color->blue >> 8,
+ normal_alpha);
+ } else { /* if not defined by rc, set to default value */
+ container->details->normal_color_rgba =
+ EEL_RGBA_COLOR_PACK (style->base[GTK_STATE_NORMAL].red >> 8,
+ style->base[GTK_STATE_NORMAL].green >> 8,
+ style->base[GTK_STATE_NORMAL].blue >> 8,
+ normal_alpha);
+ }
+
setup_label_gcs (container);
}
--- nautilus-2.14.3/libnautilus-private/nautilus-icon-canvas-item.c 2006-04-26 17:00:23.000000000 +0200
+++ nautilus-2.14.3_patched/libnautilus-private/nautilus-icon-canvas-item.c 2006-11-01 18:09:21.000000000 +0100
@@ -1439,24 +1439,75 @@
128);
}
+static GdkPixbuf *
+render_icon (GdkPixbuf *pixbuf, guint render_type, guint color)
+{
+ GdkPixbuf *temp_pixbuf;
+
+ if (render_type == 2) {
+ /* colorize icon */
+ temp_pixbuf = eel_create_colorized_pixbuf (pixbuf,
+ EEL_RGBA_COLOR_GET_R (color),
+ EEL_RGBA_COLOR_GET_G (color),
+ EEL_RGBA_COLOR_GET_B (color));
+ } else if (render_type == 3) {
+ /* gray out icon (black/white) */
+
+ /* broken convert to ntsc color space and set hue and saturation to zero */
+ temp_pixbuf = eel_create_colorized_pixbuf (pixbuf, 76, 150, 29);
+ temp_pixbuf = eel_create_colorized_pixbuf (temp_pixbuf, 152, -70, -82);
+ temp_pixbuf = eel_create_colorized_pixbuf (temp_pixbuf, 54, -134, 80);
+ temp_pixbuf = eel_create_colorized_pixbuf (temp_pixbuf, 255, 0, 0);
+ /* convert back to rgb colorspace */
+ temp_pixbuf = eel_create_colorized_pixbuf (temp_pixbuf, 256, 244, 158);
+ temp_pixbuf = eel_create_colorized_pixbuf (temp_pixbuf, 256, -69, -165);
+ temp_pixbuf = eel_create_colorized_pixbuf (temp_pixbuf, 256, -283, 436);
+ /* lighten up */
+ temp_pixbuf = eel_create_spotlight_pixbuf (temp_pixbuf);
+ temp_pixbuf = eel_create_spotlight_pixbuf (temp_pixbuf);
+ temp_pixbuf = eel_create_spotlight_pixbuf (temp_pixbuf);
+ temp_pixbuf = eel_create_spotlight_pixbuf (temp_pixbuf);
+ temp_pixbuf = eel_create_spotlight_pixbuf (temp_pixbuf);
+ /* now the picture is gray and additionally most details have gone away */
+ } else {
+ /* lighten up icon (default colorize behavior) */
+ temp_pixbuf = eel_create_spotlight_pixbuf (pixbuf);
+ }
+
+ return temp_pixbuf;
+}
+
/* shared code to highlight or dim the passed-in pixbuf */
static GdkPixbuf *
real_map_pixbuf (NautilusIconCanvasItem *icon_item)
{
EelCanvas *canvas;
char *audio_filename;
+ NautilusIconContainer *container;
GdkPixbuf *temp_pixbuf, *old_pixbuf, *audio_pixbuf;
double zoom;
+ guint render_type;
temp_pixbuf = icon_item->details->pixbuf;
canvas = EEL_CANVAS_ITEM(icon_item)->canvas;
+ container = NAUTILUS_ICON_CONTAINER (canvas);
g_object_ref (temp_pixbuf);
if (icon_item->details->is_prelit) {
old_pixbuf = temp_pixbuf;
- temp_pixbuf = eel_create_spotlight_pixbuf (temp_pixbuf);
- g_object_unref (old_pixbuf);
+
+ gtk_widget_style_get (GTK_WIDGET (container),
+ "prelight_render_type", &render_type,
+ NULL);
+ if (render_type > 0) {
+ temp_pixbuf = render_icon (temp_pixbuf,
+ render_type,
+ container->details->prelight_color_rgba);
+ g_object_unref (old_pixbuf);
+ }
+
+
/* FIXME bugzilla.gnome.org 42471: This hard-wired image is inappropriate to
* this level of code, which shouldn't know that the
@@ -1514,6 +1565,30 @@
g_object_unref (old_pixbuf);
}
+ if (!icon_item->details->is_active
+ && !icon_item->details->is_prelit
+ && !icon_item->details->is_highlighted_for_selection
+ && !icon_item->details->is_highlighted_for_drop) {
+
+ old_pixbuf = temp_pixbuf;
+
+ gtk_widget_style_get (GTK_WIDGET (container),
+ "normal_render_type", &render_type,
+ NULL);
+ if (render_type > 0) {
+ /* if theme requests colorization */
+ temp_pixbuf = render_icon (temp_pixbuf,
+ render_type,
+ container->details->normal_color_rgba);
+ g_object_unref (old_pixbuf);
+ }
+
+
+
+ }
+
+
+
return temp_pixbuf;
}
@@ -1616,6 +1691,7 @@
icon_rect = icon_item->details->canvas_rect;
/* if the pre-lit or selection flag is set, make a pre-lit or darkened pixbuf and draw that instead */
+ /* and colorize normal pixbuf if rc wants that */
temp_pixbuf = map_pixbuf (icon_item);
pixbuf_rect.x = icon_rect.x0;
pixbuf_rect.y = icon_rect.y0;
--- nautilus-2.14.3/libnautilus-private/nautilus-icon-private.h 2006-04-18 18:54:31.000000000 +0200
+++ nautilus-2.14.3_patched/libnautilus-private/nautilus-icon-private.h 2006-10-31 18:07:04.000000000 +0100
@@ -196,6 +196,7 @@
guint32 highlight_color_rgba;
guint32 active_color_rgba;
guint32 normal_color_rgba;
+ guint32 prelight_color_rgba;
/* colors for text labels */
GdkGC *label_gcs [LAST_LABEL_COLOR];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]