]> Pileus Git - ~andy/gtk/blob - gtk/gtkstyleanimation.c
GtkColorChooserWidget: deselect swatch before removing palettes
[~andy/gtk] / gtk / gtkstyleanimation.c
1 /*
2  * Copyright © 2012 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 "gtkstyleanimationprivate.h"
23
24 G_DEFINE_ABSTRACT_TYPE (GtkStyleAnimation, _gtk_style_animation, G_TYPE_OBJECT)
25
26 static void
27 gtk_style_animation_real_set_values (GtkStyleAnimation    *animation,
28                                      gint64                for_time_us,
29                                      GtkCssComputedValues *values)
30 {
31 }
32
33 static gboolean
34 gtk_style_animation_real_is_finished (GtkStyleAnimation *animation,
35                                       gint64             at_time_us)
36 {
37   return TRUE;
38 }
39
40 static gboolean
41 gtk_style_animation_real_is_static (GtkStyleAnimation *animation,
42                                     gint64             at_time_us)
43 {
44   return FALSE;
45 }
46
47 static void
48 _gtk_style_animation_class_init (GtkStyleAnimationClass *klass)
49 {
50   klass->set_values = gtk_style_animation_real_set_values;
51   klass->is_finished = gtk_style_animation_real_is_finished;
52   klass->is_static = gtk_style_animation_real_is_static;
53 }
54
55 static void
56 _gtk_style_animation_init (GtkStyleAnimation *animation)
57 {
58 }
59
60 void
61 _gtk_style_animation_set_values (GtkStyleAnimation    *animation,
62                                  gint64                for_time_us,
63                                  GtkCssComputedValues *values)
64 {
65   GtkStyleAnimationClass *klass;
66
67   g_return_if_fail (GTK_IS_STYLE_ANIMATION (animation));
68   g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
69
70   klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
71
72   return klass->set_values (animation, for_time_us, values);
73 }
74
75 gboolean
76 _gtk_style_animation_is_finished (GtkStyleAnimation *animation,
77                                   gint64             at_time_us)
78 {
79   GtkStyleAnimationClass *klass;
80
81   g_return_val_if_fail (GTK_IS_STYLE_ANIMATION (animation), TRUE);
82
83   klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
84
85   return klass->is_finished (animation, at_time_us);
86 }
87
88 /**
89  * _gtk_style_animation_is_static:
90  * @animation: The animation to query
91  * @at_time_us: The timestamp to query for
92  *
93  * Checks if @animation will not change its values anymore after
94  * @at_time_us. This happens for example when the animation has reached its
95  * final value or when it has been paused.
96  *
97  * Returns: %TRUE if @animation will not change anymore after @at_time_us
98  **/
99 gboolean
100 _gtk_style_animation_is_static (GtkStyleAnimation *animation,
101                                 gint64             at_time_us)
102 {
103   GtkStyleAnimationClass *klass;
104
105   g_return_val_if_fail (GTK_IS_STYLE_ANIMATION (animation), TRUE);
106
107   klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
108
109   return klass->is_static (animation, at_time_us);
110 }