[gtk+/gtk-style-context: 286/347] GtkCssProvider: Parse alpha() symbolic colors.



commit db8e0a3cab233f264e854a81d50505e19d8db085
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Oct 25 20:44:15 2010 +0200

    GtkCssProvider: Parse alpha() symbolic colors.
    
    The "alpha" symbolic color modifies a passed color's alpha by a factor,
    the syntax would accept things like:
    
    background-color: alpha (@bg_color, 0.8);
    foreground-color: alpha (shade (@fg_color, 0.8), 0.5);

 gtk/gtkcssprovider.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index 782433c..69d3527 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -1583,12 +1583,19 @@ symbolic_color_parse_str (const gchar  *string,
 
       *end_ptr = (gchar *) end;
     }
-  else if (g_str_has_prefix (str, "shade"))
+  else if (g_str_has_prefix (str, "shade") ||
+           g_str_has_prefix (str, "alpha"))
     {
       GtkSymbolicColor *param_color;
+      gboolean is_shade = FALSE;
       gdouble factor;
 
-      str += strlen ("shade");
+      is_shade = g_str_has_prefix (str, "shade");
+
+      if (is_shade)
+        str += strlen ("shade");
+      else
+        str += strlen ("alpha");
 
       SKIP_SPACES (str);
 
@@ -1629,7 +1636,11 @@ symbolic_color_parse_str (const gchar  *string,
           return NULL;
         }
 
-      symbolic_color = gtk_symbolic_color_new_shade (param_color, factor);
+      if (is_shade)
+        symbolic_color = gtk_symbolic_color_new_shade (param_color, factor);
+      else
+        symbolic_color = gtk_symbolic_color_new_alpha (param_color, factor);
+
       gtk_symbolic_color_unref (param_color);
       (*end_ptr)++;
     }



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