1/*
2 * Copyright © 2018 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.1 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 * Authors: Benjamin Otte <otte@gnome.org>
18 */
19
20#include "config.h"
21
22#include "gtkcssdynamicprivate.h"
23#include "gtkprogresstrackerprivate.h"
24
25struct _GtkCssDynamic
26{
27 GtkStyleAnimation parent;
28 gint64 timestamp;
29};
30
31static GtkStyleAnimation *
32gtk_css_dynamic_advance (GtkStyleAnimation *style_animation,
33 gint64 timestamp)
34{
35 return gtk_css_dynamic_new (timestamp);
36}
37
38static void
39gtk_css_dynamic_apply_values (GtkStyleAnimation *style_animation,
40 GtkCssAnimatedStyle *style)
41{
42 GtkCssDynamic *dynamic = (GtkCssDynamic *)style_animation;
43 guint i;
44
45 for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
46 {
47 GtkCssValue *value, *dynamic_value;
48
49 value = gtk_css_style_get_value (GTK_CSS_STYLE (style), id: i);
50 dynamic_value = gtk_css_value_get_dynamic_value (value, monotonic_time: dynamic->timestamp);
51 if (value != dynamic_value)
52 gtk_css_animated_style_set_animated_value (style, id: i, value: dynamic_value);
53 else
54 gtk_css_value_unref (value: dynamic_value);
55 }
56}
57
58static gboolean
59gtk_css_dynamic_is_finished (GtkStyleAnimation *style_animation)
60{
61 return FALSE;
62}
63
64static gboolean
65gtk_css_dynamic_is_static (GtkStyleAnimation *style_animation)
66{
67 return FALSE;
68}
69
70static void
71gtk_css_dynamic_free (GtkStyleAnimation *animation)
72{
73 g_slice_free (GtkCssDynamic, (GtkCssDynamic *)animation);
74}
75
76static const GtkStyleAnimationClass GTK_CSS_DYNAMIC_CLASS = {
77 "GtkCssDynamic",
78 gtk_css_dynamic_free,
79 gtk_css_dynamic_is_finished,
80 gtk_css_dynamic_is_static,
81 gtk_css_dynamic_apply_values,
82 gtk_css_dynamic_advance,
83};
84
85GtkStyleAnimation *
86gtk_css_dynamic_new (gint64 timestamp)
87{
88 GtkCssDynamic *dynamic = g_slice_alloc (block_size: sizeof (GtkCssDynamic));
89
90 dynamic->parent.class = &GTK_CSS_DYNAMIC_CLASS;
91 dynamic->parent.ref_count = 1;
92 dynamic->timestamp = timestamp;
93
94 return (GtkStyleAnimation *)dynamic;
95}
96
97

source code of gtk/gtk/gtkcssdynamic.c