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 "gtkcssinheritvalueprivate.h"
21
22#include "gtkcssinitialvalueprivate.h"
23#include "gtkcssstyleprivate.h"
24
25struct _GtkCssValue {
26 GTK_CSS_VALUE_BASE
27};
28
29static void G_GNUC_NORETURN
30gtk_css_value_inherit_free (GtkCssValue *value)
31{
32 /* Can only happen if the unique value gets unreffed too often */
33 g_assert_not_reached ();
34}
35
36static GtkCssValue *
37gtk_css_value_inherit_compute (GtkCssValue *value,
38 guint property_id,
39 GtkStyleProvider *provider,
40 GtkCssStyle *style,
41 GtkCssStyle *parent_style)
42{
43 if (parent_style)
44 {
45 return _gtk_css_value_ref (value: gtk_css_style_get_value (style: parent_style, id: property_id));
46 }
47 else
48 {
49 return _gtk_css_value_compute (value: _gtk_css_initial_value_get (),
50 property_id,
51 provider,
52 style,
53 parent_style);
54 }
55}
56
57static gboolean
58gtk_css_value_inherit_equal (const GtkCssValue *value1,
59 const GtkCssValue *value2)
60{
61 return TRUE;
62}
63
64static GtkCssValue *
65gtk_css_value_inherit_transition (GtkCssValue *start,
66 GtkCssValue *end,
67 guint property_id,
68 double progress)
69{
70 return NULL;
71}
72
73static void
74gtk_css_value_inherit_print (const GtkCssValue *value,
75 GString *string)
76{
77 g_string_append (string, val: "inherit");
78}
79
80static const GtkCssValueClass GTK_CSS_VALUE_INHERIT = {
81 "GtkCssInheritValue",
82 gtk_css_value_inherit_free,
83 gtk_css_value_inherit_compute,
84 gtk_css_value_inherit_equal,
85 gtk_css_value_inherit_transition,
86 NULL,
87 NULL,
88 gtk_css_value_inherit_print
89};
90
91static GtkCssValue inherit = { &GTK_CSS_VALUE_INHERIT, 1 };
92
93GtkCssValue *
94_gtk_css_inherit_value_new (void)
95{
96 return _gtk_css_value_ref (value: &inherit);
97}
98
99GtkCssValue *
100_gtk_css_inherit_value_get (void)
101{
102 return &inherit;
103}
104

source code of gtk/gtk/gtkcssinheritvalue.c