[vte/vte-next: 49/114] Remove vte_terminal_set_background_saturation



commit 4758afcd5a90f73d5ec1714f4d01733919a4e5ff
Author: Christian Persch <chpe gnome org>
Date:   Tue May 3 02:35:02 2011 +0200

    Remove vte_terminal_set_background_saturation
    
    Instead, use the alpha component from the background tint colour.

 doc/reference/vte-sections.txt |    1 -
 src/vte-private.h              |    1 -
 src/vte.c                      |   98 ++++++----------------------------------
 src/vte.h                      |    2 -
 src/vteapp.c                   |    2 +-
 src/vtebg.c                    |   25 +++--------
 src/vtebg.h                    |    1 -
 src/vtedraw.c                  |    5 +-
 src/vtedraw.h                  |    3 +-
 9 files changed, 24 insertions(+), 114 deletions(-)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index 2d47873..10a27d8 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -38,7 +38,6 @@ vte_terminal_set_colors_rgba
 vte_terminal_set_default_colors
 vte_terminal_set_background_image
 vte_terminal_set_background_image_file
-vte_terminal_set_background_saturation
 vte_terminal_set_background_tint_color_rgba
 vte_terminal_set_scroll_background
 vte_terminal_set_cursor_shape
diff --git a/src/vte-private.h b/src/vte-private.h
index d26aaaf..b3c4081 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -367,7 +367,6 @@ struct _VteTerminalPrivate {
 	GdkPixbuf *bg_pixbuf;
 	char *bg_file;
         GdkRGBA bg_tint_color;
-	double bg_saturation; /* 0.0 .. 1.0 */
 
 	/* Key modifiers. */
 	GdkModifierType modifiers;
diff --git a/src/vte.c b/src/vte.c
index 0ef2096..f0bb223 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -144,7 +144,6 @@ enum {
         PROP_AUDIBLE_BELL,
         PROP_BACKGROUND_IMAGE_FILE,
         PROP_BACKGROUND_IMAGE_PIXBUF,
-        PROP_BACKGROUND_SATURATION,
         PROP_BACKGROUND_TINT_COLOR,
         PROP_BACKSPACE_BINDING,
         PROP_CURSOR_BLINK_MODE,
@@ -7580,11 +7579,10 @@ vte_terminal_init(VteTerminal *terminal)
 	gtk_widget_ensure_style(&terminal->widget);
 
 	/* Set up background information. */
-	pvt->bg_tint_color.red = 0.;
-	pvt->bg_tint_color.green = 0.;
-	pvt->bg_tint_color.blue = 0.;
-        pvt->bg_tint_color.alpha = 1.;
-	pvt->bg_saturation = 0.4;
+        pvt->bg_tint_color.red = 1.;
+        pvt->bg_tint_color.green = 1.;
+        pvt->bg_tint_color.blue = 1.;
+        pvt->bg_tint_color.alpha = .6;
 	pvt->selection_block_mode = FALSE;
 	pvt->has_fonts = FALSE;
 
@@ -10513,9 +10511,6 @@ vte_terminal_get_property (GObject *object,
                 case PROP_BACKGROUND_IMAGE_PIXBUF:
                         g_value_set_object (value, pvt->bg_pixbuf);
                         break;
-                case PROP_BACKGROUND_SATURATION:
-                        g_value_set_double (value, pvt->bg_saturation);
-                        break;
                 case PROP_BACKGROUND_TINT_COLOR:
                         g_value_set_boxed (value, &pvt->bg_tint_color);
                         break;
@@ -10614,9 +10609,6 @@ vte_terminal_set_property (GObject *object,
                 case PROP_BACKGROUND_IMAGE_PIXBUF:
                         vte_terminal_set_background_image (terminal, g_value_get_object (value));
                         break;
-                case PROP_BACKGROUND_SATURATION:
-                        vte_terminal_set_background_saturation (terminal, g_value_get_double (value));
-                        break;
                 case PROP_BACKGROUND_TINT_COLOR:
                         vte_terminal_set_background_tint_color_rgba (terminal, g_value_get_boxed (value));
                         break;
@@ -11308,7 +11300,7 @@ vte_terminal_class_init(VteTerminalClass *klass)
          * VteTerminal:background-image-file: (type filename):
          *
          * Sets a background image file for the widget.  If specified by
-         * #VteTerminal:background-saturation:, the terminal will tint its
+         * #VteTerminal:background-tint-color:, the terminal will tint its
          * in-memory copy of the image before applying it to the terminal.
          * 
          * Since: 0.20
@@ -11327,7 +11319,7 @@ vte_terminal_class_init(VteTerminalClass *klass)
          * drawn using the default background color will instead be drawn over the
          * specified image.  If necessary, the image will be tiled to cover the
          * widget's entire visible area. If specified by
-         * #VteTerminal:background-saturation:, the terminal will tint its
+         * #VteTerminal:background-tint-color:, the terminal will tint its
          * in-memory copy of the image before applying it to the terminal.
          * 
          * Since: 0.20
@@ -11340,31 +11332,11 @@ vte_terminal_class_init(VteTerminalClass *klass)
                                       G_PARAM_READWRITE | STATIC_PARAMS));
 
         /**
-         * VteTerminal:background-saturation:
-         *
-         * If a background image has been set using #VteTerminal:background-image-file: or
-         * #VteTerminal:background-image-pixbuf:,
-         * and the saturation value is less
-         * than 1.0, the terminal will adjust the colors of the image before drawing
-         * the image.  To do so, the terminal will create a copy of the background
-         * image and modify its pixel values.
-         *
-         * Since: 0.20
-         */
-        g_object_class_install_property
-                (gobject_class,
-                 PROP_BACKGROUND_SATURATION,
-                 g_param_spec_double ("background-saturation", NULL, NULL,
-                                      0.0, 1.0,
-                                      0.4,
-                                      G_PARAM_READWRITE | STATIC_PARAMS));
-     
-        /**
          * VteTerminal:background-tint-color:
          *
          * If a background image has been set using #VteTerminal:background-image-file: or
          * #VteTerminal:background-image-pixbuf:, and
-         * and the value set by VteTerminal:background-saturation: is less than 1.0,
+         * and the alpha value set by VteTerminal:background-tint-color: is greater than 0.0,
          * the terminal
          * will adjust the color of the image before drawing the image.  To do so,
          * the terminal will create a copy of the background image
@@ -12002,7 +11974,6 @@ vte_terminal_im_append_menuitems(VteTerminal *terminal, GtkMenuShell *menushell)
 static gboolean
 vte_terminal_background_update(VteTerminal *terminal)
 {
-        double saturation;
 	const GdkRGBA *entry;
         GdkRGBA rgba;
         GdkColor color;
@@ -12036,29 +12007,25 @@ vte_terminal_background_update(VteTerminal *terminal)
         rgba.alpha *= terminal->pvt->bg_tint_color.alpha;
         _vte_draw_set_background_solid (terminal->pvt->draw, &rgba);
 
-	saturation = terminal->pvt->bg_saturation;
 	if (terminal->pvt->bg_file) {
 		_vte_draw_set_background_image(terminal->pvt->draw,
 					       VTE_BG_SOURCE_FILE,
 					       NULL,
 					       terminal->pvt->bg_file,
-					       &terminal->pvt->bg_tint_color,
-					       saturation);
+					       &terminal->pvt->bg_tint_color);
 	} else
 	if (GDK_IS_PIXBUF(terminal->pvt->bg_pixbuf)) {
 		_vte_draw_set_background_image(terminal->pvt->draw,
 					       VTE_BG_SOURCE_PIXBUF,
 					       terminal->pvt->bg_pixbuf,
 					       NULL,
-					       &terminal->pvt->bg_tint_color,
-					       saturation);
+					       &terminal->pvt->bg_tint_color);
 	} else {
 		_vte_draw_set_background_image(terminal->pvt->draw,
 					       VTE_BG_SOURCE_NONE,
 					       NULL,
 					       NULL,
-					       &terminal->pvt->bg_tint_color,
-					       saturation);
+					       &terminal->pvt->bg_tint_color);
 	}
 
 	/* Note that the update has finished. */
@@ -12085,52 +12052,15 @@ vte_terminal_queue_background_update(VteTerminal *terminal)
 }
 
 /**
- * vte_terminal_set_background_saturation:
- * @terminal: a #VteTerminal
- * @saturation: a floating point value between 0.0 and 1.0.
- *
- * If a background image has been set using
- * vte_terminal_set_background_image(),
- * vte_terminal_set_background_image_file(),
- * and the saturation value is less
- * than 1.0, the terminal will adjust the colors of the image before drawing
- * the image.  To do so, the terminal will create a copy of the background
- * image and modify its pixel values.
- */
-void
-vte_terminal_set_background_saturation(VteTerminal *terminal, double saturation)
-{
-        VteTerminalPrivate *pvt;
-
-	g_return_if_fail(VTE_IS_TERMINAL(terminal));
-        g_return_if_fail(saturation >= 0.0 && saturation <= 1.0);
-
-        pvt = terminal->pvt;
-
-        if (saturation == pvt->bg_saturation)
-                return;
-
-	_vte_debug_print(VTE_DEBUG_MISC,
-			"Setting background saturation to %.3f\n",
-			saturation);
-
-        pvt->bg_saturation = saturation;
-        g_object_notify(G_OBJECT (terminal), "background-saturation");
-
-        vte_terminal_queue_background_update(terminal);
-}
-
-/**
  * vte_terminal_set_background_tint_color_rgba:
  * @terminal: a #VteTerminal
- * @color: (allow-none): a color which the terminal background should be tinted to if its
- *   saturation is not 1.0.
+ * @rgba: (allow-none): a color which the terminal background should be tinted to if
  *
  * If a background image has been set using
  * vte_terminal_set_background_image(),
  * vte_terminal_set_background_image_file(),
  * and the value set by
- * vte_terminal_set_background_saturation() is less than one, the terminal
+ * alpha value in @rgba is greater than 0.0, the terminal
  * will adjust the color of the image before drawing the image.  To do so,
  * the terminal will create a copy of the background image
  * and modify its pixel values.  The initial tint color
@@ -12171,7 +12101,7 @@ vte_terminal_set_background_tint_color_rgba(VteTerminal *terminal,
  * drawn using the default background color will instead be drawn over the
  * specified image.  If necessary, the image will be tiled to cover the
  * widget's entire visible area. If specified by
- * vte_terminal_set_background_saturation(), the terminal will tint its
+ * vte_terminal_set_background_tint_color_rgba(), the terminal will tint its
  * in-memory copy of the image before applying it to the terminal.
  */
 void
@@ -12230,7 +12160,7 @@ vte_terminal_set_background_image(VteTerminal *terminal, GdkPixbuf *image)
  * @path: (type filename): path to an image file
  *
  * Sets a background image for the widget.  If specified by
- * vte_terminal_set_background_saturation(), the terminal will tint its
+ * vte_terminal_set_background_tint_color_rgba(), the terminal will tint its
  * in-memory copy of the image before applying it to the terminal.
  */
 void
diff --git a/src/vte.h b/src/vte.h
index 941508c..52ca560 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -255,8 +255,6 @@ void vte_terminal_set_background_image_file(VteTerminal *terminal,
 					    const char *path);
 void vte_terminal_set_background_tint_color_rgba(VteTerminal *terminal,
                                                  const GdkRGBA *rgba);
-void vte_terminal_set_background_saturation(VteTerminal *terminal,
-					    double saturation);
 
 /* Set whether or not the cursor blinks. */
 void vte_terminal_set_cursor_blink_mode(VteTerminal *terminal,
diff --git a/src/vteapp.c b/src/vteapp.c
index f58bf2a..1681565 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -776,7 +776,7 @@ main(int argc, char **argv)
 
 	highlight.red = highlight.green = highlight.blue = 0.75; highlight.alpha = 1.0;
 	cursor.red = 1.0; cursor.green = cursor.blue = 0.5; cursor.alpha = 1.0;
-        tint.red = tint.green = tint.blue = 0.; tint.alpha = .875;
+        tint.red = tint.green = tint.blue = 1.; tint.alpha = .875;
 
         if (tint_color_string) {
                 if (!gdk_rgba_parse (&tint, tint_color_string))
diff --git a/src/vtebg.c b/src/vtebg.c
index 49fb5ab..6bdde6f 100644
--- a/src/vtebg.c
+++ b/src/vtebg.c
@@ -38,7 +38,6 @@ typedef struct {
 	char *source_file;
 
 	GdkRGBA tint_color;
-	double saturation;
 	cairo_surface_t *surface;
 } VteBgCacheItem;
 
@@ -178,7 +177,6 @@ vte_bg_cache_add(VteBg *bg, VteBgCacheItem *item)
  * @source_pixbuf: a #GdkPixbuf, or %NULL
  * @source_file: path of an image file, or %NULL
  * @tint: a #GdkRGBA to use as tint color
- * @saturation: the saturation as a value between 0.0 and 1.0
  *
  * Returns: a reference to a #cairo_surface_t, or %NULL on if
  *   there is no matching item in the cache
@@ -188,8 +186,7 @@ vte_bg_cache_search(VteBg *bg,
 		    VteBgSourceType source_type,
 		    const GdkPixbuf *source_pixbuf,
 		    const char *source_file,
-		    const GdkRGBA *tint,
-		    double saturation)
+		    const GdkRGBA *tint)
 {
 	GList *i;
 
@@ -197,7 +194,6 @@ vte_bg_cache_search(VteBg *bg,
 	for (i = bg->pvt->cache; i != NULL; i = g_list_next(i)) {
 		VteBgCacheItem *item = i->data;
 		if (gdk_rgba_equal (&item->tint_color, tint) &&
-		    (saturation == item->saturation) &&
 		    (source_type == item->source_type)) {
 			switch (source_type) {
 			case VTE_BG_SOURCE_PIXBUF:
@@ -228,7 +224,6 @@ vte_bg_cache_search(VteBg *bg,
  * @source_pixbuf: (allow-none): a #GdkPixbuf, or %NULL
  * @source_file: (allow-none): path of an image file, or %NULL
  * @tint: a #GdkRGBA to use as tint color
- * @saturation: the saturation as a value between 0.0 and 1.0
  * @other: a #cairo_surface_t
  *
  * Returns: a reference to a #cairo_surface_t, or %NULL on failure
@@ -239,7 +234,6 @@ vte_bg_get_surface(VteBg *bg,
 		   GdkPixbuf *source_pixbuf,
 		   const char *source_file,
 		   const GdkRGBA *tint,
-		   double saturation,
 		   cairo_surface_t *other)
 {
         VteBgPrivate *pvt;
@@ -248,7 +242,6 @@ vte_bg_get_surface(VteBg *bg,
 	cairo_surface_t *cached;
 	cairo_t *cr;
 	int width, height;
-        double alpha;
 
         g_return_val_if_fail(VTE_IS_BG(bg), NULL);
         pvt = bg->pvt;
@@ -259,16 +252,16 @@ vte_bg_get_surface(VteBg *bg,
 
 	cached = vte_bg_cache_search(bg, source_type,
 				     source_pixbuf, source_file,
-				     tint, saturation);
+				     tint);
 	if (cached != NULL) {
 		return cached;
 	}
 
         /* FIXME: The above only returned a hit when the source *and*
-         * tint and saturation matched. This means that for VTE_BG_SOURCE_FILE,
+         * tint matched. This means that for VTE_BG_SOURCE_FILE,
          * we will create below *another* #GdkPixbuf for the same source file,
          * wasting memory. We should instead look up the source pixbuf regardless
-         * of tint and saturation, and just create a new #VteBgCacheItem
+         * of tint, and just create a new #VteBgCacheItem
          * with a new surface for it.
          */
 
@@ -277,7 +270,6 @@ vte_bg_get_surface(VteBg *bg,
 	item->source_pixbuf = NULL;
 	item->source_file = NULL;
 	item->tint_color = *tint;
-	item->saturation = saturation;
         item->surface = NULL;
 	pixbuf = NULL;
 
@@ -314,13 +306,8 @@ vte_bg_get_surface(VteBg *bg,
 		gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
 	cairo_paint (cr);
 
-        alpha = (1. - saturation) * tint->alpha;
-	if (alpha > 0.) {
-		cairo_set_source_rgba (cr, 
-				       tint->red,
-				       tint->green,
-				       tint->blue,
-				       alpha);
+	if (tint->alpha > 0.) {
+                gdk_cairo_set_source_rgba (cr, tint);
 		cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
 		cairo_paint (cr);
 	}
diff --git a/src/vtebg.h b/src/vtebg.h
index 5b4a9b9..5f8ca81 100644
--- a/src/vtebg.h
+++ b/src/vtebg.h
@@ -61,7 +61,6 @@ vte_bg_get_surface(VteBg *bg,
 		   GdkPixbuf *source_pixbuf,
 		   const char *source_file,
 		   const GdkRGBA *tint,
-		   double saturation,
 		   cairo_surface_t *other);
 
 G_END_DECLS
diff --git a/src/vtedraw.c b/src/vtedraw.c
index 75b2a2b..23de77a 100644
--- a/src/vtedraw.c
+++ b/src/vtedraw.c
@@ -819,8 +819,7 @@ _vte_draw_set_background_image (struct _vte_draw *draw,
 			        VteBgSourceType type,
 			        GdkPixbuf *pixbuf,
 			        const char *filename,
-			        const GdkRGBA *color,
-			        double saturation)
+			        const GdkRGBA *color)
 {
 	cairo_surface_t *surface;
 
@@ -829,7 +828,7 @@ _vte_draw_set_background_image (struct _vte_draw *draw,
 
 	surface = vte_bg_get_surface (vte_bg_get_for_screen (gtk_widget_get_screen (draw->widget)),
 				     type, pixbuf, filename,
-				     color, saturation,
+				     color,
 				     cairo_get_target(draw->cr));
 
 	_vte_draw_end (draw);
diff --git a/src/vtedraw.h b/src/vtedraw.h
index 751df6d..6a1ae90 100644
--- a/src/vtedraw.h
+++ b/src/vtedraw.h
@@ -73,8 +73,7 @@ void _vte_draw_set_background_image(struct _vte_draw *draw,
 				    VteBgSourceType type,
 				    GdkPixbuf *pixbuf,
 				    const char *file,
-				    const GdkRGBA *color,
-				    double saturation);
+				    const GdkRGBA *color);
 void _vte_draw_set_background_scroll(struct _vte_draw *draw,
 				     gint x, gint y);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]