]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkcssstylefuncs.c
Updated Kazakh translation
[~andy/gtk] / gtk / gtkcssstylefuncs.c
index dcdd25d56991c5578982c583f3c65658315d650e..9db3510dd39fec90e00bad98719f2081caa0daf5 100644 (file)
 
 #include "gtkcssimagegradientprivate.h"
 #include "gtkcssprovider.h"
-#include "gtkcssrgbavalueprivate.h"
+#include "gtkcsstypedvalueprivate.h"
 #include "gtkcsstypesprivate.h"
 #include "gtkgradient.h"
 #include "gtkprivatetypebuiltins.h"
-#include "gtkcssshadowvalueprivate.h"
 #include "gtkstylecontextprivate.h"
 #include "gtksymboliccolorprivate.h"
 #include "gtkthemingengine.h"
@@ -50,7 +49,6 @@ static GHashTable *print_funcs = NULL;
 static GHashTable *compute_funcs = NULL;
 
 typedef gboolean         (* GtkStyleParseFunc)             (GtkCssParser           *parser,
-                                                            GFile                  *base,
                                                             GValue                 *value);
 typedef void             (* GtkStylePrintFunc)             (const GValue           *value,
                                                             GString                *string);
@@ -163,7 +161,6 @@ enum_print (int         value,
 
 static gboolean
 rgba_value_parse (GtkCssParser *parser,
-                  GFile        *base,
                   GValue       *value)
 {
   GtkSymbolicColor *symbolic;
@@ -209,16 +206,22 @@ rgba_value_compute (GtkStyleContext *context,
                     GtkCssValue     *specified)
 {
   GdkRGBA white = { 1, 1, 1, 1 };
+  const GValue *value;
+
+  value = _gtk_css_typed_value_get (specified);
   
-  if (_gtk_css_value_holds (specified, GTK_TYPE_SYMBOLIC_COLOR))
+  if (G_VALUE_HOLDS (value, GTK_TYPE_SYMBOLIC_COLOR))
     {
-      GtkSymbolicColor *symbolic = _gtk_css_value_get_boxed (specified);
+      GtkSymbolicColor *symbolic = g_value_get_boxed (value);
+      GValue new_value = G_VALUE_INIT;
       GdkRGBA rgba;
 
       if (!_gtk_style_context_resolve_color (context, symbolic, &rgba))
         rgba = white;
 
-      return _gtk_css_value_new_from_boxed (GDK_TYPE_RGBA, &rgba);
+      g_value_init (&new_value, GDK_TYPE_RGBA);
+      g_value_set_boxed (&new_value, &rgba);
+      return _gtk_css_typed_value_new_take (&new_value);
     }
   else
     return _gtk_css_value_ref (specified);
@@ -226,7 +229,6 @@ rgba_value_compute (GtkStyleContext *context,
 
 static gboolean 
 color_value_parse (GtkCssParser *parser,
-                   GFile        *base,
                    GValue       *value)
 {
   GtkSymbolicColor *symbolic;
@@ -278,11 +280,16 @@ color_value_compute (GtkStyleContext *context,
 {
   GdkRGBA rgba;
   GdkColor color = { 0, 65535, 65535, 65535 };
+  const GValue *value;
 
-  if (_gtk_css_value_holds (specified, GTK_TYPE_SYMBOLIC_COLOR))
+  value = _gtk_css_typed_value_get (specified);
+  
+  if (G_VALUE_HOLDS (value, GTK_TYPE_SYMBOLIC_COLOR))
     {
+      GValue new_value = G_VALUE_INIT;
+
       if (_gtk_style_context_resolve_color (context,
-                                            _gtk_css_value_get_boxed (specified),
+                                            g_value_get_boxed (value),
                                             &rgba))
         {
           color.red = rgba.red * 65535. + 0.5;
@@ -290,7 +297,9 @@ color_value_compute (GtkStyleContext *context,
           color.blue = rgba.blue * 65535. + 0.5;
         }
       
-      return _gtk_css_value_new_from_color (&color);
+      g_value_init (&new_value, GDK_TYPE_COLOR);
+      g_value_set_boxed (&new_value, &color);
+      return _gtk_css_typed_value_new_take (&new_value);
     }
   else
     return _gtk_css_value_ref (specified);
@@ -298,7 +307,6 @@ color_value_compute (GtkStyleContext *context,
 
 static gboolean
 symbolic_color_value_parse (GtkCssParser *parser,
-                            GFile        *base,
                             GValue       *value)
 {
   GtkSymbolicColor *symbolic;
@@ -329,7 +337,6 @@ symbolic_color_value_print (const GValue *value,
 
 static gboolean 
 font_description_value_parse (GtkCssParser *parser,
-                              GFile        *base,
                               GValue       *value)
 {
   PangoFontDescription *font_desc;
@@ -371,7 +378,6 @@ font_description_value_print (const GValue *value,
 
 static gboolean 
 boolean_value_parse (GtkCssParser *parser,
-                     GFile        *base,
                      GValue       *value)
 {
   if (_gtk_css_parser_try (parser, "true", TRUE) ||
@@ -405,14 +411,13 @@ boolean_value_print (const GValue *value,
 
 static gboolean 
 int_value_parse (GtkCssParser *parser,
-                 GFile        *base,
                  GValue       *value)
 {
   gint i;
 
   if (_gtk_css_parser_begins_with (parser, '-'))
     {
-      int res = _gtk_win32_theme_int_parse (parser, base, &i);
+      int res = _gtk_win32_theme_int_parse (parser, &i);
       if (res >= 0)
        {
          g_value_set_int (value, i);
@@ -440,7 +445,6 @@ int_value_print (const GValue *value,
 
 static gboolean 
 uint_value_parse (GtkCssParser *parser,
-                  GFile        *base,
                   GValue       *value)
 {
   guint u;
@@ -464,7 +468,6 @@ uint_value_print (const GValue *value,
 
 static gboolean 
 double_value_parse (GtkCssParser *parser,
-                    GFile        *base,
                     GValue       *value)
 {
   gdouble d;
@@ -488,7 +491,6 @@ double_value_print (const GValue *value,
 
 static gboolean 
 float_value_parse (GtkCssParser *parser,
-                   GFile        *base,
                    GValue       *value)
 {
   gdouble d;
@@ -512,7 +514,6 @@ float_value_print (const GValue *value,
 
 static gboolean 
 string_value_parse (GtkCssParser *parser,
-                    GFile        *base,
                     GValue       *value)
 {
   char *str = _gtk_css_parser_read_string (parser);
@@ -533,7 +534,6 @@ string_value_print (const GValue *value,
 
 static gboolean 
 theming_engine_value_parse (GtkCssParser *parser,
-                            GFile        *base,
                             GValue       *value)
 {
   GtkThemingEngine *engine;
@@ -587,7 +587,6 @@ theming_engine_value_print (const GValue *value,
 
 static gboolean 
 border_value_parse (GtkCssParser *parser,
-                    GFile        *base,
                     GValue       *value)
 {
   GtkBorder border = { 0, };
@@ -600,7 +599,7 @@ border_value_parse (GtkCssParser *parser,
        {
          /* These are strictly speaking signed, but we want to be able to use them
             for unsigned types too, as the actual ranges of values make this safe */
-         int res = _gtk_win32_theme_int_parse (parser, base, &numbers[i]);
+         int res = _gtk_win32_theme_int_parse (parser, &numbers[i]);
 
          if (res == 0) /* Parse error, report */
            return FALSE;
@@ -658,7 +657,6 @@ border_value_print (const GValue *value, GString *string)
 
 static gboolean 
 gradient_value_parse (GtkCssParser *parser,
-                      GFile        *base,
                       GValue       *value)
 {
   GtkGradient *gradient;
@@ -689,7 +687,6 @@ gradient_value_print (const GValue *value,
 
 static gboolean 
 pattern_value_parse (GtkCssParser *parser,
-                     GFile        *base,
                      GValue       *value)
 {
   if (_gtk_css_parser_try (parser, "none", TRUE))
@@ -700,7 +697,7 @@ pattern_value_parse (GtkCssParser *parser,
     {
       g_value_unset (value);
       g_value_init (value, GTK_TYPE_GRADIENT);
-      return gradient_value_parse (parser, base, value);
+      return gradient_value_parse (parser, value);
     }
   else
     {
@@ -713,7 +710,7 @@ pattern_value_parse (GtkCssParser *parser,
       cairo_t *cr;
       cairo_matrix_t matrix;
 
-      file = _gtk_css_parser_read_url (parser, base);
+      file = _gtk_css_parser_read_url (parser);
       if (file == NULL)
         return FALSE;
 
@@ -821,13 +818,18 @@ static GtkCssValue *
 pattern_value_compute (GtkStyleContext *context,
                        GtkCssValue     *specified)
 {
-  if (_gtk_css_value_holds (specified, GTK_TYPE_GRADIENT))
+  const GValue *value = _gtk_css_typed_value_get (specified);
+
+  if (G_VALUE_HOLDS (value, GTK_TYPE_GRADIENT))
     {
+      GValue new_value = G_VALUE_INIT;
       cairo_pattern_t *gradient;
       
-      gradient = gtk_gradient_resolve_for_context (_gtk_css_value_get_gradient (specified), context);
+      gradient = gtk_gradient_resolve_for_context (g_value_get_boxed (value), context);
 
-      return _gtk_css_value_new_take_pattern (gradient);
+      g_value_init (&new_value, CAIRO_GOBJECT_TYPE_PATTERN);
+      g_value_take_boxed (&new_value, gradient);
+      return _gtk_css_typed_value_new_take (&new_value);
     }
   else
     return _gtk_css_value_ref (specified);
@@ -835,7 +837,6 @@ pattern_value_compute (GtkStyleContext *context,
 
 static gboolean 
 enum_value_parse (GtkCssParser *parser,
-                  GFile        *base,
                   GValue       *value)
 {
   int v;
@@ -858,7 +859,6 @@ enum_value_print (const GValue *value,
 
 static gboolean 
 flags_value_parse (GtkCssParser *parser,
-                   GFile        *base,
                    GValue       *value)
 {
   GFlagsClass *flags_class;
@@ -1010,7 +1010,6 @@ gtk_css_style_funcs_init (void)
  * _gtk_css_style_parse_value:
  * @value: the value to parse into. Must be a valid initialized #GValue
  * @parser: the parser to parse from
- * @base: the base URL for @parser
  *
  * This is the generic parsing function used for CSS values. If the
  * function fails to parse a value, it will emit an error on @parser,
@@ -1020,8 +1019,7 @@ gtk_css_style_funcs_init (void)
  **/
 gboolean
 _gtk_css_style_parse_value (GValue       *value,
-                            GtkCssParser *parser,
-                            GFile        *base)
+                            GtkCssParser *parser)
 {
   GtkStyleParseFunc func;
 
@@ -1044,7 +1042,7 @@ _gtk_css_style_parse_value (GValue       *value,
       return FALSE;
     }
 
-  return (*func) (parser, base, value);
+  return (*func) (parser, value);
 }
 
 /**