]> Pileus Git - ~andy/gtk/blob - gtk/gtkcssinitialvalue.c
css: Introduce dependencies for value computations
[~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                                GtkStyleContext    *context,
39                                GtkCssDependencies *dependencies)
40 {
41   return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
42                                  property_id,
43                                  context,
44                                  dependencies);
45 }
46
47 static gboolean
48 gtk_css_value_initial_equal (const GtkCssValue *value1,
49                              const GtkCssValue *value2)
50 {
51   return TRUE;
52 }
53
54 static GtkCssValue *
55 gtk_css_value_initial_transition (GtkCssValue *start,
56                                   GtkCssValue *end,
57                                   double       progress)
58 {
59   return NULL;
60 }
61
62 static void
63 gtk_css_value_initial_print (const GtkCssValue *value,
64                              GString           *string)
65 {
66   g_string_append (string, "initial");
67 }
68
69 static const GtkCssValueClass GTK_CSS_VALUE_INITIAL = {
70   gtk_css_value_initial_free,
71   gtk_css_value_initial_compute,
72   gtk_css_value_initial_equal,
73   gtk_css_value_initial_transition,
74   gtk_css_value_initial_print
75 };
76
77 static GtkCssValue initial = { &GTK_CSS_VALUE_INITIAL, 1 };
78
79 GtkCssValue *
80 _gtk_css_initial_value_new (void)
81 {
82   return _gtk_css_value_ref (&initial);
83 }