[gtk/wip/baedert/for-master: 28/35] css: Make GtkStyleAnimation and subclasses non-objects
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master: 28/35] css: Make GtkStyleAnimation and subclasses non-objects
- Date: Sun, 10 May 2020 06:45:51 +0000 (UTC)
commit 1b10020b6e0853f92f75c7b9bae9d08acff2b5f6
Author: Timm Bäder <mail baedert org>
Date: Wed May 6 19:17:11 2020 +0200
css: Make GtkStyleAnimation and subclasses non-objects
Making them GObjects is unnecessary. This enables further optimizations
down the road. The only place we use them in is gtkcssanimatedstyle.c
after all.
gtk/gtkcssanimatedstyle.c | 25 ++++++++----
gtk/gtkcssanimation.c | 69 ++++++++++++++------------------
gtk/gtkcssanimationprivate.h | 8 +---
gtk/gtkcssdynamic.c | 40 ++++++++++---------
gtk/gtkcssdynamicprivate.h | 20 ----------
gtk/gtkcsstransition.c | 90 +++++++++++++++++++++++------------------
gtk/gtkcsstransitionprivate.h | 21 +---------
gtk/gtkstyleanimation.c | 91 ++++++++++++------------------------------
gtk/gtkstyleanimationprivate.h | 17 ++++----
9 files changed, 156 insertions(+), 225 deletions(-)
---
diff --git a/gtk/gtkcssanimatedstyle.c b/gtk/gtkcssanimatedstyle.c
index c04f040b0b..bef4a9028c 100644
--- a/gtk/gtkcssanimatedstyle.c
+++ b/gtk/gtkcssanimatedstyle.c
@@ -81,7 +81,7 @@ gtk_css_animated_style_dispose (GObject *object)
guint i;
for (i = 0; i < style->n_animations; i ++)
- g_object_unref (style->animations[i]);
+ gtk_style_animation_unref (style->animations[i]);
style->n_animations = 0;
g_free (style->animations);
@@ -646,7 +646,7 @@ gtk_css_animated_style_find_transition (GtkCssAnimatedStyle *style,
{
GtkStyleAnimation *animation = style->animations[i];
- if (!GTK_IS_CSS_TRANSITION (animation))
+ if (!_gtk_css_transition_is_transition (animation))
continue;
if (_gtk_css_transition_get_property ((GtkCssTransition *)animation) == property_id)
@@ -745,7 +745,7 @@ gtk_css_animated_style_find_animation (GtkStyleAnimation **animations,
{
GtkStyleAnimation *animation = animations[i];
- if (!GTK_IS_CSS_ANIMATION (animation))
+ if (!_gtk_css_animation_is_animation (animation))
continue;
if (g_str_equal (_gtk_css_animation_get_name ((GtkCssAnimation *)animation), name))
@@ -765,9 +765,19 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
{
GtkCssValue *durations, *delays, *timing_functions, *animation_names;
GtkCssValue *iteration_counts, *directions, *play_states, *fill_modes;
+ gboolean source_is_animated;
guint i;
animation_names = base_style->animation->animation_name;
+
+ if (_gtk_css_array_value_get_n_values (animation_names) == 1)
+ {
+ const char *name = _gtk_css_ident_value_get (_gtk_css_array_value_get_nth (animation_names, 0));
+
+ if (g_ascii_strcasecmp (name, "none") == 0)
+ return animations;
+ }
+
durations = base_style->animation->animation_duration;
delays = base_style->animation->animation_delay;
timing_functions = base_style->animation->animation_timing_function;
@@ -775,6 +785,7 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
directions = base_style->animation->animation_direction;
play_states = base_style->animation->animation_play_state;
fill_modes = base_style->animation->animation_fill_mode;
+ source_is_animated = GTK_IS_CSS_ANIMATED_STYLE (source);
for (i = 0; i < _gtk_css_array_value_get_n_values (animation_names); i++)
{
@@ -792,14 +803,14 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
if (animation)
continue;
- if (GTK_IS_CSS_ANIMATED_STYLE (source))
+ if (source_is_animated)
animation = gtk_css_animated_style_find_animation ((GtkStyleAnimation **)GTK_CSS_ANIMATED_STYLE
(source)->animations,
GTK_CSS_ANIMATED_STYLE (source)->n_animations,
name);
if (animation)
{
- animation = _gtk_css_animation_advance_with_play_state (GTK_CSS_ANIMATION (animation),
+ animation = _gtk_css_animation_advance_with_play_state ((GtkCssAnimation *)animation,
timestamp,
_gtk_css_play_state_value_get
(_gtk_css_array_value_get_nth (play_states, i)));
}
@@ -825,7 +836,7 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
}
if (!animations)
- animations = g_ptr_array_new ();
+ animations = g_ptr_array_sized_new (16);
g_ptr_array_add (animations, animation);
}
@@ -928,7 +939,7 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
continue;
if (!animations)
- animations = g_ptr_array_new ();
+ animations = g_ptr_array_sized_new (16);
animation = _gtk_style_animation_advance (animation, timestamp);
g_ptr_array_add (animations, animation);
diff --git a/gtk/gtkcssanimation.c b/gtk/gtkcssanimation.c
index 445b58d24d..076abd950a 100644
--- a/gtk/gtkcssanimation.c
+++ b/gtk/gtkcssanimation.c
@@ -26,8 +26,6 @@
#include <math.h>
-G_DEFINE_TYPE (GtkCssAnimation, _gtk_css_animation, GTK_TYPE_STYLE_ANIMATION)
-
static gboolean
gtk_css_animation_is_executing (GtkCssAnimation *animation)
{
@@ -80,7 +78,7 @@ static GtkStyleAnimation *
gtk_css_animation_advance (GtkStyleAnimation *style_animation,
gint64 timestamp)
{
- GtkCssAnimation *animation = GTK_CSS_ANIMATION (style_animation);
+ GtkCssAnimation *animation = (GtkCssAnimation *)style_animation;
return _gtk_css_animation_advance_with_play_state (animation,
timestamp,
@@ -91,7 +89,7 @@ static void
gtk_css_animation_apply_values (GtkStyleAnimation *style_animation,
GtkCssAnimatedStyle *style)
{
- GtkCssAnimation *animation = GTK_CSS_ANIMATION (style_animation);
+ GtkCssAnimation *animation = (GtkCssAnimation *)style_animation;
double progress;
guint i;
@@ -125,7 +123,7 @@ gtk_css_animation_is_finished (GtkStyleAnimation *style_animation)
static gboolean
gtk_css_animation_is_static (GtkStyleAnimation *style_animation)
{
- GtkCssAnimation *animation = GTK_CSS_ANIMATION (style_animation);
+ GtkCssAnimation *animation = (GtkCssAnimation *)style_animation;
if (animation->play_state == GTK_CSS_PLAY_STATE_PAUSED)
return TRUE;
@@ -134,35 +132,26 @@ gtk_css_animation_is_static (GtkStyleAnimation *style_animation)
}
static void
-gtk_css_animation_finalize (GObject *object)
+gtk_css_animation_free (GtkStyleAnimation *animation)
{
- GtkCssAnimation *animation = GTK_CSS_ANIMATION (object);
+ GtkCssAnimation *self = (GtkCssAnimation *)animation;
- g_free (animation->name);
- _gtk_css_keyframes_unref (animation->keyframes);
- _gtk_css_value_unref (animation->ease);
+ g_free (self->name);
+ _gtk_css_keyframes_unref (self->keyframes);
+ _gtk_css_value_unref (self->ease);
- G_OBJECT_CLASS (_gtk_css_animation_parent_class)->finalize (object);
+ g_slice_free (GtkCssAnimation, self);
}
-static void
-_gtk_css_animation_class_init (GtkCssAnimationClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkStyleAnimationClass *animation_class = GTK_STYLE_ANIMATION_CLASS (klass);
-
- object_class->finalize = gtk_css_animation_finalize;
+static const GtkStyleAnimationClass GTK_CSS_ANIMATION_CLASS = {
+ "GtkCssAnimation",
+ gtk_css_animation_free,
+ gtk_css_animation_is_finished,
+ gtk_css_animation_is_static,
+ gtk_css_animation_apply_values,
+ gtk_css_animation_advance,
+};
- animation_class->advance = gtk_css_animation_advance;
- animation_class->apply_values = gtk_css_animation_apply_values;
- animation_class->is_finished = gtk_css_animation_is_finished;
- animation_class->is_static = gtk_css_animation_is_static;
-}
-
-static void
-_gtk_css_animation_init (GtkCssAnimation *animation)
-{
-}
GtkStyleAnimation *
_gtk_css_animation_new (const char *name,
@@ -183,7 +172,9 @@ _gtk_css_animation_new (const char *name,
g_return_val_if_fail (ease != NULL, NULL);
g_return_val_if_fail (iteration_count >= 0, NULL);
- animation = g_object_new (GTK_TYPE_CSS_ANIMATION, NULL);
+ animation = g_slice_alloc (sizeof (GtkCssAnimation));
+ animation->parent.class = >K_CSS_ANIMATION_CLASS;
+ animation->parent.ref_count = 1;
animation->name = g_strdup (name);
animation->keyframes = _gtk_css_keyframes_ref (keyframes);
@@ -198,14 +189,12 @@ _gtk_css_animation_new (const char *name,
else
gtk_progress_tracker_advance_frame (&animation->tracker, timestamp);
- return GTK_STYLE_ANIMATION (animation);
+ return (GtkStyleAnimation *)animation;
}
const char *
_gtk_css_animation_get_name (GtkCssAnimation *animation)
{
- g_return_val_if_fail (GTK_IS_CSS_ANIMATION (animation), NULL);
-
return animation->name;
}
@@ -214,11 +203,9 @@ _gtk_css_animation_advance_with_play_state (GtkCssAnimation *source,
gint64 timestamp,
GtkCssPlayState play_state)
{
- GtkCssAnimation *animation;
-
- g_return_val_if_fail (GTK_IS_CSS_ANIMATION (source), NULL);
-
- animation = g_object_new (GTK_TYPE_CSS_ANIMATION, NULL);
+ GtkCssAnimation *animation = g_slice_alloc (sizeof (GtkCssAnimation));
+ animation->parent.class = >K_CSS_ANIMATION_CLASS;
+ animation->parent.ref_count = 1;
animation->name = g_strdup (source->name);
animation->keyframes = _gtk_css_keyframes_ref (source->keyframes);
@@ -233,5 +220,11 @@ _gtk_css_animation_advance_with_play_state (GtkCssAnimation *source,
else
gtk_progress_tracker_advance_frame (&animation->tracker, timestamp);
- return GTK_STYLE_ANIMATION (animation);
+ return (GtkStyleAnimation *)animation;
+}
+
+gboolean
+_gtk_css_animation_is_animation (GtkStyleAnimation *animation)
+{
+ return animation->class == >K_CSS_ANIMATION_CLASS;
}
diff --git a/gtk/gtkcssanimationprivate.h b/gtk/gtkcssanimationprivate.h
index 811cddfcce..ab47be8c9c 100644
--- a/gtk/gtkcssanimationprivate.h
+++ b/gtk/gtkcssanimationprivate.h
@@ -27,13 +27,6 @@
G_BEGIN_DECLS
-#define GTK_TYPE_CSS_ANIMATION (_gtk_css_animation_get_type ())
-#define GTK_CSS_ANIMATION(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_ANIMATION,
GtkCssAnimation))
-#define GTK_CSS_ANIMATION_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_ANIMATION,
GtkCssAnimationClass))
-#define GTK_IS_CSS_ANIMATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_ANIMATION))
-#define GTK_IS_CSS_ANIMATION_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_ANIMATION))
-#define GTK_CSS_ANIMATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_ANIMATION,
GtkCssAnimationClass))
-
typedef struct _GtkCssAnimation GtkCssAnimation;
typedef struct _GtkCssAnimationClass GtkCssAnimationClass;
@@ -73,6 +66,7 @@ GtkStyleAnimation * _gtk_css_animation_advance_with_play_state (GtkCssAnimat
GtkCssPlayState play_state);
const char * _gtk_css_animation_get_name (GtkCssAnimation *animation);
+gboolean _gtk_css_animation_is_animation (GtkStyleAnimation *animation);
G_END_DECLS
diff --git a/gtk/gtkcssdynamic.c b/gtk/gtkcssdynamic.c
index 89243b701c..5dc65101ab 100644
--- a/gtk/gtkcssdynamic.c
+++ b/gtk/gtkcssdynamic.c
@@ -20,10 +20,13 @@
#include "config.h"
#include "gtkcssdynamicprivate.h"
-
#include "gtkprogresstrackerprivate.h"
-G_DEFINE_TYPE (GtkCssDynamic, gtk_css_dynamic, GTK_TYPE_STYLE_ANIMATION)
+struct _GtkCssDynamic
+{
+ GtkStyleAnimation parent;
+ gint64 timestamp;
+};
static GtkStyleAnimation *
gtk_css_dynamic_advance (GtkStyleAnimation *style_animation,
@@ -36,13 +39,13 @@ static void
gtk_css_dynamic_apply_values (GtkStyleAnimation *style_animation,
GtkCssAnimatedStyle *style)
{
- GtkCssDynamic *dynamic = GTK_CSS_DYNAMIC (style_animation);
+ GtkCssDynamic *dynamic = (GtkCssDynamic *)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)
@@ -65,30 +68,29 @@ gtk_css_dynamic_is_static (GtkStyleAnimation *style_animation)
}
static void
-gtk_css_dynamic_class_init (GtkCssDynamicClass *klass)
+gtk_css_dynamic_free (GtkStyleAnimation *animation)
{
- 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;
+ g_slice_free (GtkCssDynamic, (GtkCssDynamic *)animation);
}
-static void
-gtk_css_dynamic_init (GtkCssDynamic *dynamic)
-{
-}
+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,
+};
GtkStyleAnimation *
gtk_css_dynamic_new (gint64 timestamp)
{
- GtkCssDynamic *dynamic;
-
- dynamic = g_object_new (GTK_TYPE_CSS_DYNAMIC, NULL);
+ GtkCssDynamic *dynamic = g_slice_alloc (sizeof (GtkCssDynamic));
+ dynamic->parent.class = >K_CSS_DYNAMIC_CLASS;
+ dynamic->parent.ref_count = 1;
dynamic->timestamp = timestamp;
- return GTK_STYLE_ANIMATION (dynamic);
+ return (GtkStyleAnimation *)dynamic;
}
diff --git a/gtk/gtkcssdynamicprivate.h b/gtk/gtkcssdynamicprivate.h
index 5b91baa32c..8f356c265a 100644
--- a/gtk/gtkcssdynamicprivate.h
+++ b/gtk/gtkcssdynamicprivate.h
@@ -26,27 +26,7 @@
G_BEGIN_DECLS
-#define GTK_TYPE_CSS_DYNAMIC (gtk_css_dynamic_get_type ())
-#define GTK_CSS_DYNAMIC(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_DYNAMIC,
GtkCssDynamic))
-#define GTK_CSS_DYNAMIC_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_DYNAMIC,
GtkCssDynamicClass))
-#define GTK_IS_CSS_DYNAMIC(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_DYNAMIC))
-#define GTK_IS_CSS_DYNAMIC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_DYNAMIC))
-#define GTK_CSS_DYNAMIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_DYNAMIC,
GtkCssDynamicClass))
-
typedef struct _GtkCssDynamic GtkCssDynamic;
-typedef struct _GtkCssDynamicClass GtkCssDynamicClass;
-
-struct _GtkCssDynamic
-{
- GtkStyleAnimation parent;
-
- gint64 timestamp;
-};
-
-struct _GtkCssDynamicClass
-{
- GtkStyleAnimationClass parent_class;
-};
GType gtk_css_dynamic_get_type (void) G_GNUC_CONST;
diff --git a/gtk/gtkcsstransition.c b/gtk/gtkcsstransition.c
index bb872a0b17..fee6d66d71 100644
--- a/gtk/gtkcsstransition.c
+++ b/gtk/gtkcsstransition.c
@@ -24,27 +24,22 @@
#include "gtkcsseasevalueprivate.h"
#include "gtkprogresstrackerprivate.h"
-G_DEFINE_TYPE (GtkCssTransition, _gtk_css_transition, GTK_TYPE_STYLE_ANIMATION)
-
-static GtkStyleAnimation *
-gtk_css_transition_advance (GtkStyleAnimation *style_animation,
- gint64 timestamp)
+struct _GtkCssTransition
{
- GtkCssTransition *source = (GtkCssTransition *)style_animation;
- GtkCssTransition *transition;
+ GtkStyleAnimation parent;
- transition = g_object_new (GTK_TYPE_CSS_TRANSITION, NULL);
+ guint property;
+ GtkCssValue *start;
+ GtkCssValue *ease;
+ GtkProgressTracker tracker;
+ guint finished;
+};
- transition->property = source->property;
- transition->start = _gtk_css_value_ref (source->start);
- transition->ease = _gtk_css_value_ref (source->ease);
- gtk_progress_tracker_init_copy (&source->tracker, &transition->tracker);
- gtk_progress_tracker_advance_frame (&transition->tracker, timestamp);
- transition->finished = gtk_progress_tracker_get_state (&transition->tracker) == GTK_PROGRESS_STATE_AFTER;
+static GtkStyleAnimation * gtk_css_transition_advance (GtkStyleAnimation *style_animation,
+ gint64 timestamp);
+
- return (GtkStyleAnimation *)transition;
-}
static void
gtk_css_transition_apply_values (GtkStyleAnimation *style_animation,
@@ -99,35 +94,46 @@ gtk_css_transition_is_static (GtkStyleAnimation *animation)
}
static void
-gtk_css_transition_finalize (GObject *object)
+gtk_css_transition_free (GtkStyleAnimation *animation)
{
- GtkCssTransition *transition = GTK_CSS_TRANSITION (object);
+ GtkCssTransition *self = (GtkCssTransition *)animation;
- _gtk_css_value_unref (transition->start);
- _gtk_css_value_unref (transition->ease);
+ gtk_css_value_unref (self->start);
+ gtk_css_value_unref (self->ease);
- G_OBJECT_CLASS (_gtk_css_transition_parent_class)->finalize (object);
+ g_slice_free (GtkCssTransition, self);
}
-static void
-_gtk_css_transition_class_init (GtkCssTransitionClass *klass)
+static const GtkStyleAnimationClass GTK_CSS_TRANSITION_CLASS = {
+ "GtkCssTransition",
+ gtk_css_transition_free,
+ gtk_css_transition_is_finished,
+ gtk_css_transition_is_static,
+ gtk_css_transition_apply_values,
+ gtk_css_transition_advance,
+};
+
+static GtkStyleAnimation *
+gtk_css_transition_advance (GtkStyleAnimation *style_animation,
+ gint64 timestamp)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkStyleAnimationClass *animation_class = GTK_STYLE_ANIMATION_CLASS (klass);
+ GtkCssTransition *source = (GtkCssTransition *)style_animation;
+ GtkCssTransition *transition;
- object_class->finalize = gtk_css_transition_finalize;
+ transition = g_slice_alloc (sizeof (GtkCssTransition));
+ transition->parent.class = >K_CSS_TRANSITION_CLASS;
+ transition->parent.ref_count = 1;
- animation_class->advance = gtk_css_transition_advance;
- animation_class->apply_values = gtk_css_transition_apply_values;
- animation_class->is_finished = gtk_css_transition_is_finished;
- animation_class->is_static = gtk_css_transition_is_static;
-}
+ transition->property = source->property;
+ transition->start = _gtk_css_value_ref (source->start);
+ transition->ease = _gtk_css_value_ref (source->ease);
-static void
-_gtk_css_transition_init (GtkCssTransition *transition)
-{
-}
+ gtk_progress_tracker_init_copy (&source->tracker, &transition->tracker);
+ gtk_progress_tracker_advance_frame (&transition->tracker, timestamp);
+ transition->finished = gtk_progress_tracker_get_state (&transition->tracker) == GTK_PROGRESS_STATE_AFTER;
+ return (GtkStyleAnimation *)transition;
+}
GtkStyleAnimation *
_gtk_css_transition_new (guint property,
GtkCssValue *start,
@@ -141,7 +147,9 @@ _gtk_css_transition_new (guint property,
g_return_val_if_fail (start != NULL, NULL);
g_return_val_if_fail (ease != NULL, NULL);
- transition = g_object_new (GTK_TYPE_CSS_TRANSITION, NULL);
+ transition = g_slice_alloc (sizeof (GtkCssTransition));
+ transition->parent.class = >K_CSS_TRANSITION_CLASS;
+ transition->parent.ref_count = 1;
transition->property = property;
transition->start = _gtk_css_value_ref (start);
@@ -150,13 +158,17 @@ _gtk_css_transition_new (guint property,
gtk_progress_tracker_advance_frame (&transition->tracker, timestamp);
transition->finished = gtk_progress_tracker_get_state (&transition->tracker) == GTK_PROGRESS_STATE_AFTER;
- return GTK_STYLE_ANIMATION (transition);
+ return (GtkStyleAnimation*)transition;
}
guint
_gtk_css_transition_get_property (GtkCssTransition *transition)
{
- g_return_val_if_fail (GTK_IS_CSS_TRANSITION (transition), 0);
-
return transition->property;
}
+
+gboolean
+_gtk_css_transition_is_transition (GtkStyleAnimation *animation)
+{
+ return animation->class == >K_CSS_TRANSITION_CLASS;
+}
diff --git a/gtk/gtkcsstransitionprivate.h b/gtk/gtkcsstransitionprivate.h
index 6f722023a1..f50f070c7e 100644
--- a/gtk/gtkcsstransitionprivate.h
+++ b/gtk/gtkcsstransitionprivate.h
@@ -25,26 +25,8 @@
G_BEGIN_DECLS
-#define GTK_TYPE_CSS_TRANSITION (_gtk_css_transition_get_type ())
-#define GTK_CSS_TRANSITION(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_CSS_TRANSITION,
GtkCssTransition))
-#define GTK_CSS_TRANSITION_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_CSS_TRANSITION,
GtkCssTransitionClass))
-#define GTK_IS_CSS_TRANSITION(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_CSS_TRANSITION))
-#define GTK_IS_CSS_TRANSITION_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_CSS_TRANSITION))
-#define GTK_CSS_TRANSITION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CSS_TRANSITION,
GtkCssTransitionClass))
-
-typedef struct _GtkCssTransition GtkCssTransition;
typedef struct _GtkCssTransitionClass GtkCssTransitionClass;
-
-struct _GtkCssTransition
-{
- GtkStyleAnimation parent;
-
- guint property;
- GtkCssValue *start;
- GtkCssValue *ease;
- GtkProgressTracker tracker;
- guint finished;
-};
+typedef struct _GtkCssTransition GtkCssTransition;
struct _GtkCssTransitionClass
{
@@ -61,6 +43,7 @@ GtkStyleAnimation * _gtk_css_transition_new (guint
gint64 delay_us);
guint _gtk_css_transition_get_property (GtkCssTransition *transition);
+gboolean _gtk_css_transition_is_transition (GtkStyleAnimation *animation);
G_END_DECLS
diff --git a/gtk/gtkstyleanimation.c b/gtk/gtkstyleanimation.c
index 754f09b0c0..0ad4667b7f 100644
--- a/gtk/gtkstyleanimation.c
+++ b/gtk/gtkstyleanimation.c
@@ -21,84 +21,47 @@
#include "gtkstyleanimationprivate.h"
-G_DEFINE_ABSTRACT_TYPE (GtkStyleAnimation, _gtk_style_animation, G_TYPE_OBJECT)
-
-static GtkStyleAnimation *
-gtk_style_animation_real_advance (GtkStyleAnimation *animation,
- gint64 timestamp)
-{
- return NULL;
-}
-
-static void
-gtk_style_animation_real_apply_values (GtkStyleAnimation *animation,
- GtkCssAnimatedStyle *style)
-{
-}
-
-static gboolean
-gtk_style_animation_real_is_finished (GtkStyleAnimation *animation)
-{
- return TRUE;
-}
-
-static gboolean
-gtk_style_animation_real_is_static (GtkStyleAnimation *animation)
-{
- return FALSE;
-}
-
-static void
-_gtk_style_animation_class_init (GtkStyleAnimationClass *klass)
-{
- klass->advance = gtk_style_animation_real_advance;
- klass->apply_values = gtk_style_animation_real_apply_values;
- klass->is_finished = gtk_style_animation_real_is_finished;
- klass->is_static = gtk_style_animation_real_is_static;
-}
-
-static void
-_gtk_style_animation_init (GtkStyleAnimation *animation)
-{
-}
-
GtkStyleAnimation *
-_gtk_style_animation_advance (GtkStyleAnimation *animation,
- gint64 timestamp)
+_gtk_style_animation_advance (GtkStyleAnimation *animation,
+ gint64 timestamp)
{
- GtkStyleAnimationClass *klass;
-
- g_return_val_if_fail (GTK_IS_STYLE_ANIMATION (animation), NULL);
+ g_assert (animation != NULL);
- klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
-
- return klass->advance (animation, timestamp);
+ return animation->class->advance (animation, timestamp);
}
void
_gtk_style_animation_apply_values (GtkStyleAnimation *animation,
GtkCssAnimatedStyle *style)
{
- GtkStyleAnimationClass *klass;
-
- g_return_if_fail (GTK_IS_STYLE_ANIMATION (animation));
- g_return_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style));
-
- klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
-
- klass->apply_values (animation, style);
+ animation->class->apply_values (animation, style);
}
gboolean
_gtk_style_animation_is_finished (GtkStyleAnimation *animation)
{
- GtkStyleAnimationClass *klass;
+ return animation->class->is_finished (animation);
+}
- g_return_val_if_fail (GTK_IS_STYLE_ANIMATION (animation), TRUE);
- klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
+GtkStyleAnimation *
+gtk_style_animation_ref (GtkStyleAnimation *animation)
+{
+ animation->ref_count++;
+ return animation;
+}
- return klass->is_finished (animation);
+GtkStyleAnimation *
+gtk_style_animation_unref (GtkStyleAnimation *animation)
+{
+ animation->ref_count--;
+
+ if (animation->ref_count == 0)
+ {
+ animation->class->free (animation);
+ return NULL;
+ }
+ return animation;
}
/**
@@ -115,9 +78,5 @@ _gtk_style_animation_is_finished (GtkStyleAnimation *animation)
gboolean
_gtk_style_animation_is_static (GtkStyleAnimation *animation)
{
- GtkStyleAnimationClass *klass;
-
- klass = GTK_STYLE_ANIMATION_GET_CLASS (animation);
-
- return klass->is_static (animation);
+ return animation->class->is_static (animation);
}
diff --git a/gtk/gtkstyleanimationprivate.h b/gtk/gtkstyleanimationprivate.h
index dacb159e60..dbf8dbce40 100644
--- a/gtk/gtkstyleanimationprivate.h
+++ b/gtk/gtkstyleanimationprivate.h
@@ -24,25 +24,19 @@
G_BEGIN_DECLS
-#define GTK_TYPE_STYLE_ANIMATION (_gtk_style_animation_get_type ())
-#define GTK_STYLE_ANIMATION(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_STYLE_ANIMATION,
GtkStyleAnimation))
-#define GTK_STYLE_ANIMATION_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_STYLE_ANIMATION,
GtkStyleAnimationClass))
-#define GTK_IS_STYLE_ANIMATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_STYLE_ANIMATION))
-#define GTK_IS_STYLE_ANIMATION_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_STYLE_ANIMATION))
-#define GTK_STYLE_ANIMATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_STYLE_ANIMATION,
GtkStyleAnimationClass))
-
typedef struct _GtkStyleAnimation GtkStyleAnimation;
typedef struct _GtkStyleAnimationClass GtkStyleAnimationClass;
struct _GtkStyleAnimation
{
- GObject parent;
+ const GtkStyleAnimationClass *class;
+ guint ref_count;
};
struct _GtkStyleAnimationClass
{
- GObjectClass parent_class;
-
+ const char *type_name;
+ void (* free) (GtkStyleAnimation *animation);
gboolean (* is_finished) (GtkStyleAnimation *animation);
gboolean (* is_static) (GtkStyleAnimation *animation);
void (* apply_values) (GtkStyleAnimation *animation,
@@ -60,6 +54,9 @@ void _gtk_style_animation_apply_values (GtkStyleAnimation
gboolean _gtk_style_animation_is_finished (GtkStyleAnimation *animation);
gboolean _gtk_style_animation_is_static (GtkStyleAnimation *animation);
+GtkStyleAnimation * gtk_style_animation_ref (GtkStyleAnimation *animation);
+GtkStyleAnimation * gtk_style_animation_unref (GtkStyleAnimation *animation);
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]