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



commit 87b9a4fbe5b7f2ee4f51b21f1011dcb22916eb9b
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 a4c7732..d61a564 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]