]> Pileus Git - ~andy/gtk/blob - gtk/gtkcssinitialvalue.c
css: Huge refactoring to avoid computing wrong values
[~andy/gtk] / gtk / gtkcssinitialvalue.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2011 Red Hat, Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include "config.h"
19
20 #include "gtkcssinitialvalueprivate.h"
21
22 #include "gtkcssstylepropertyprivate.h"
23
24 struct _GtkCssValue {
25   GTK_CSS_VALUE_BASE
26 };
27
28 static void
29 gtk_css_value_initial_free (GtkCssValue *value)
30 {
31   /* Can only happen if the unique value gets unreffed too often */
32   g_assert_not_reached ();
33 }
34
35 static GtkCssValue *
36 gtk_css_value_initial_compute (GtkCssValue             *value,
37                                guint                    property_id,
38                                GtkStyleProviderPrivate *provider,
39                                GtkCssComputedValues    *values,
40                                GtkCssComputedValues    *parent_values,
41                                GtkCssDependencies      *dependencies)
42 {
43   return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
44                                  property_id,
45                                  provider,
46                                  values,
47                                  parent_values,
48                                  dependencies);
49 }
50
51 static gboolean
52 gtk_css_value_initial_equal (const GtkCssValue *value1,
53                              const GtkCssValue *value2)
54 {
55   return TRUE;
56 }
57
58 static GtkCssValue *
59 gtk_css_value_initial_transition (GtkCssValue *start,
60                                   GtkCssValue *end,
61                                   guint        property_id,
62                                   double       progress)
63 {
64   return NULL;
65 }
66
67 static void
68 gtk_css_value_initial_print (const GtkCssValue *value,
69                              GString           *string)
70 {
71   g_string_append (string, "initial");
72 }
73
74 static const GtkCssValueClass GTK_CSS_VALUE_INITIAL = {
75   gtk_css_value_initial_free,
76   gtk_css_value_initial_compute,
77   gtk_css_value_initial_equal,
78   gtk_css_value_initial_transition,
79   gtk_css_value_initial_print
80 };
81
82 static GtkCssValue initial = { &GTK_CSS_VALUE_INITIAL, 1 };
83
84 GtkCssValue *
85 _gtk_css_initial_value_new (void)
86 {
87   return _gtk_css_value_ref (&initial);
88 }