summaryrefslogtreecommitdiff
path: root/gtk/gtkcssdynamic.c
blob: 1d06c1c1fcbc80cf36ed7d6ae9f1d3e09bee8bcc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * Copyright © 2018 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.1 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/>.
 *
 * Authors: Benjamin Otte <otte@gnome.org>
 */

#include "config.h"

#include "gtkcssdynamicprivate.h"

#include "gtkprogresstrackerprivate.h"

G_DEFINE_TYPE (GtkCssDynamic, gtk_css_dynamic, GTK_TYPE_STYLE_ANIMATION)

static GtkStyleAnimation *
gtk_css_dynamic_advance (GtkStyleAnimation    *style_animation,
                         gint64                timestamp)
{
  return gtk_css_dynamic_new (timestamp);
}

static void
gtk_css_dynamic_apply_values (GtkStyleAnimation    *style_animation,
                              GtkCssAnimatedStyle  *style)
{
  GtkCssDynamic *dynamic = GTK_CSS_DYNAMIC (style_animation);
  guint i;

  for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
    {
      GtkCssValue *value, *dynamic_value;
      
      value = gtk_css_style_get_value (GTK_CSS_STYLE (style), i);
      dynamic_value = gtk_css_value_get_dynamic_value (value, dynamic->timestamp);
      if (value != dynamic_value)
        gtk_css_animated_style_set_animated_value (style, i, dynamic_value);
      gtk_css_value_unref (dynamic_value);
    }
}

static gboolean
gtk_css_dynamic_is_finished (GtkStyleAnimation *style_animation)
{
  return FALSE;
}

static gboolean
gtk_css_dynamic_is_static (GtkStyleAnimation *style_animation)
{
  return FALSE;
}

static void
gtk_css_dynamic_class_init (GtkCssDynamicClass *klass)
{
  GtkStyleAnimationClass *animation_class = GTK_STYLE_ANIMATION_CLASS (klass);

  animation_class->advance = gtk_css_dynamic_advance;
  animation_class->apply_values = gtk_css_dynamic_apply_values;
  animation_class->is_finished = gtk_css_dynamic_is_finished;
  animation_class->is_static = gtk_css_dynamic_is_static;
}

static void
gtk_css_dynamic_init (GtkCssDynamic *dynamic)
{
}

GtkStyleAnimation *
gtk_css_dynamic_new (gint64 timestamp)
{
  GtkCssDynamic *dynamic;

  dynamic = g_object_new (GTK_TYPE_CSS_DYNAMIC, NULL);

  dynamic->timestamp = timestamp;

  return GTK_STYLE_ANIMATION (dynamic);
}