gtkcssinheritvalue.c 2.79 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/* GTK - The GIMP Toolkit
 * Copyright (C) 2011 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

#include "config.h"

#include "gtkcssinheritvalueprivate.h"

22
#include "gtkcssinitialvalueprivate.h"
23 24
#include "gtkstylecontextprivate.h"

25 26 27 28 29 30 31 32 33 34 35
struct _GtkCssValue {
  GTK_CSS_VALUE_BASE
};

static void
gtk_css_value_inherit_free (GtkCssValue *value)
{
  /* Can only happen if the unique value gets unreffed too often */
  g_assert_not_reached ();
}

36
static GtkCssValue *
37 38 39
gtk_css_value_inherit_compute (GtkCssValue             *value,
                               guint                    property_id,
                               GtkStyleProviderPrivate *provider,
40
                               GtkCssStyle             *style,
41
                               GtkCssStyle             *parent_style)
42
{
43
  if (parent_style)
44
    {
45
      return _gtk_css_value_ref (gtk_css_style_get_value (parent_style, property_id));
46
    }
47
  else
48
    {
49
      return _gtk_css_value_compute (_gtk_css_initial_value_get (),
50
                                     property_id,
51
                                     provider,
52
                                     style,
53
                                     parent_style);
54
    }
55 56
}

57 58 59 60 61 62 63
static gboolean
gtk_css_value_inherit_equal (const GtkCssValue *value1,
                             const GtkCssValue *value2)
{
  return TRUE;
}

64 65 66
static GtkCssValue *
gtk_css_value_inherit_transition (GtkCssValue *start,
                                  GtkCssValue *end,
67
                                  guint        property_id,
68 69 70 71 72
                                  double       progress)
{
  return NULL;
}

73 74 75 76 77 78 79 80 81
static void
gtk_css_value_inherit_print (const GtkCssValue *value,
                             GString           *string)
{
  g_string_append (string, "inherit");
}

static const GtkCssValueClass GTK_CSS_VALUE_INHERIT = {
  gtk_css_value_inherit_free,
82
  gtk_css_value_inherit_compute,
83
  gtk_css_value_inherit_equal,
84
  gtk_css_value_inherit_transition,
85 86 87 88 89 90 91 92 93 94
  gtk_css_value_inherit_print
};

static GtkCssValue inherit = { &GTK_CSS_VALUE_INHERIT, 1 };

GtkCssValue *
_gtk_css_inherit_value_new (void)
{
  return _gtk_css_value_ref (&inherit);
}
Benjamin Otte's avatar
Benjamin Otte committed
95 96 97 98 99 100

GtkCssValue *
_gtk_css_inherit_value_get (void)
{
  return &inherit;
}