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



commit 480f38b8e46ea570c50fee4a5e6d90a88e5e721c
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]