2018-02-13 07:22:34 +00:00
|
|
|
/*
|
|
|
|
* 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"
|
|
|
|
|
2020-05-06 17:17:11 +00:00
|
|
|
struct _GtkCssDynamic
|
|
|
|
{
|
|
|
|
GtkStyleAnimation parent;
|
|
|
|
gint64 timestamp;
|
|
|
|
};
|
2018-02-13 07:22:34 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2020-05-06 17:17:11 +00:00
|
|
|
GtkCssDynamic *dynamic = (GtkCssDynamic *)style_animation;
|
2018-02-13 07:22:34 +00:00
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < GTK_CSS_PROPERTY_N_PROPERTIES; i++)
|
|
|
|
{
|
|
|
|
GtkCssValue *value, *dynamic_value;
|
2020-05-06 17:17:11 +00:00
|
|
|
|
2018-02-13 07:22:34 +00:00
|
|
|
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);
|
2019-08-19 09:06:04 +00:00
|
|
|
else
|
|
|
|
gtk_css_value_unref (dynamic_value);
|
2018-02-13 07:22:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2020-05-06 17:17:11 +00:00
|
|
|
gtk_css_dynamic_free (GtkStyleAnimation *animation)
|
2018-02-13 07:22:34 +00:00
|
|
|
{
|
2020-05-06 17:17:11 +00:00
|
|
|
g_slice_free (GtkCssDynamic, (GtkCssDynamic *)animation);
|
2018-02-13 07:22:34 +00:00
|
|
|
}
|
|
|
|
|
2020-05-06 17:17:11 +00:00
|
|
|
static const GtkStyleAnimationClass GTK_CSS_DYNAMIC_CLASS = {
|
|
|
|
"GtkCssDynamic",
|
|
|
|
gtk_css_dynamic_free,
|
|
|
|
gtk_css_dynamic_is_finished,
|
|
|
|
gtk_css_dynamic_is_static,
|
|
|
|
gtk_css_dynamic_apply_values,
|
|
|
|
gtk_css_dynamic_advance,
|
|
|
|
};
|
2018-02-13 07:22:34 +00:00
|
|
|
|
|
|
|
GtkStyleAnimation *
|
|
|
|
gtk_css_dynamic_new (gint64 timestamp)
|
|
|
|
{
|
2020-05-06 17:17:11 +00:00
|
|
|
GtkCssDynamic *dynamic = g_slice_alloc (sizeof (GtkCssDynamic));
|
2018-02-13 07:22:34 +00:00
|
|
|
|
2020-05-06 17:17:11 +00:00
|
|
|
dynamic->parent.class = >K_CSS_DYNAMIC_CLASS;
|
|
|
|
dynamic->parent.ref_count = 1;
|
2018-02-13 07:22:34 +00:00
|
|
|
dynamic->timestamp = timestamp;
|
|
|
|
|
2020-05-06 17:17:11 +00:00
|
|
|
return (GtkStyleAnimation *)dynamic;
|
2018-02-13 07:22:34 +00:00
|
|
|
}
|
|
|
|
|