[vte] widget: Store background saturation as double



commit 85d04d873dd3531ac289c858f640f0ee157dcd7a
Author: Christian Persch <chpe gnome org>
Date:   Tue May 3 00:15:19 2011 +0200

    widget: Store background saturation as double
    
    Conflicts:
        src/vte-private.h

 src/vte-private.h |    3 +--
 src/vte.c         |   20 +++++++++-----------
 2 files changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index 03b6735..81bd194 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -85,7 +85,6 @@ G_BEGIN_DECLS
 /* More color defines in vterowdata.h */
 
 #define VTE_SCROLLBACK_INIT            512
-#define VTE_SATURATION_MAX             10000
 #define VTE_DEFAULT_CURSOR             GDK_XTERM
 #define VTE_MOUSING_CURSOR             GDK_LEFT_PTR
 #define VTE_TAB_MAX                    999
@@ -407,7 +406,7 @@ struct _VteTerminalPrivate {
        GdkPixbuf *bg_pixbuf;
        char *bg_file;
         GdkRGBA bg_tint_color;
-       guint16 bg_saturation;  /* out of VTE_SATURATION_MAX */
+       double bg_saturation; /* 0.0 .. 1.0 */
 
        /* Key modifiers. */
        GdkModifierType modifiers;
diff --git a/src/vte.c b/src/vte.c
index 9fcd82b..0bdc983 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -8099,7 +8099,7 @@ vte_terminal_init(VteTerminal *terminal)
        pvt->bg_tint_color.green = 0.;
        pvt->bg_tint_color.blue = 0.;
         pvt->bg_tint_color.alpha = 1.;
-       pvt->bg_saturation = 0.4 * VTE_SATURATION_MAX;
+       pvt->bg_saturation = 0.4;
        pvt->selection_block_mode = FALSE;
        pvt->has_fonts = FALSE;
        pvt->root_pixmap_changed_tag = 0;
@@ -10717,7 +10717,7 @@ vte_terminal_get_property (GObject *object,
                         g_value_set_object (value, pvt->bg_pixbuf);
                         break;
                 case PROP_BACKGROUND_SATURATION:
-                        g_value_set_double (value, (double) pvt->bg_saturation / (double) 
VTE_SATURATION_MAX);
+                        g_value_set_double (value, pvt->bg_saturation);
                         break;
                 case PROP_BACKGROUND_TINT_COLOR:
                         g_value_set_boxed (value, &pvt->bg_tint_color);
@@ -12406,7 +12406,7 @@ vte_terminal_im_append_menuitems(VteTerminal *terminal, GtkMenuShell *menushell)
 static gboolean
 vte_terminal_background_update(VteTerminal *terminal)
 {
-       double saturation;
+        double saturation;
        const PangoColor *entry;
        GdkRGBA color;
 
@@ -12437,8 +12437,7 @@ vte_terminal_background_update(VteTerminal *terminal)
 
        /* If we're transparent, and either have no root image or are being
         * told to update it, get a new copy of the root window. */
-       saturation = (double) terminal->pvt->bg_saturation;
-       saturation /= VTE_SATURATION_MAX;
+       saturation = terminal->pvt->bg_saturation;
        if (terminal->pvt->bg_transparent) {
                if (terminal->pvt->root_pixmap_changed_tag == 0) {
                        VteBg *bg;
@@ -12524,21 +12523,20 @@ void
 vte_terminal_set_background_saturation(VteTerminal *terminal, double saturation)
 {
         VteTerminalPrivate *pvt;
-       guint v;
 
        g_return_if_fail(VTE_IS_TERMINAL(terminal));
+        g_return_if_fail(saturation >= 0.0 && saturation <= 1.0);
 
         pvt = terminal->pvt;
 
-       v = CLAMP(saturation * VTE_SATURATION_MAX, 0, VTE_SATURATION_MAX);
-        if (v == pvt->bg_saturation)
+        if (saturation == pvt->bg_saturation)
                 return;
 
        _vte_debug_print(VTE_DEBUG_MISC,
-                       "Setting background saturation to %d/%d.\n",
-                       v, VTE_SATURATION_MAX);
+                       "Setting background saturation to %.3f\n",
+                       saturation);
 
-        pvt->bg_saturation = v;
+        pvt->bg_saturation = saturation;
         g_object_notify(G_OBJECT (terminal), "background-saturation");
 
         vte_terminal_queue_background_update(terminal);


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