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

source code of gtk/gtk/gtkcssunsetvalue.c