[gtk+] cssstyle: Add gtk_css_style_is_static()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] cssstyle: Add gtk_css_style_is_static()
- Date: Wed, 18 Mar 2015 15:10:40 +0000 (UTC)
commit 759d8dafd99d47466aaffc355906955a0c658005
Author: Benjamin Otte <otte redhat com>
Date: Fri Feb 27 18:41:13 2015 +0100
cssstyle: Add gtk_css_style_is_static()
Gets rid of the need to do
if (ANIMATED_STYLE() &&
animated_style_is_static(ANIMATED_STYLE(style))
gtk/gtkcssanimatedstyle.c | 32 ++++++++++++++++----------------
gtk/gtkcssanimatedstyleprivate.h | 2 --
gtk/gtkcssnode.c | 6 ++----
gtk/gtkcssstyle.c | 16 ++++++++++++++++
gtk/gtkcssstyleprivate.h | 3 +++
5 files changed, 37 insertions(+), 22 deletions(-)
---
diff --git a/gtk/gtkcssanimatedstyle.c b/gtk/gtkcssanimatedstyle.c
index 6e845f6..d13403a 100644
--- a/gtk/gtkcssanimatedstyle.c
+++ b/gtk/gtkcssanimatedstyle.c
@@ -63,6 +63,21 @@ gtk_css_animated_style_get_section (GtkCssStyle *style,
return gtk_css_style_get_section (animated->style, id);
}
+static gboolean
+gtk_css_animated_style_is_static (GtkCssStyle *style)
+{
+ GtkCssAnimatedStyle *animated = GTK_CSS_ANIMATED_STYLE (style);
+ GSList *list;
+
+ for (list = animated->animations; list; list = list->next)
+ {
+ if (!_gtk_style_animation_is_static (list->data, animated->current_time))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static void
gtk_css_animated_style_dispose (GObject *object)
{
@@ -101,6 +116,7 @@ gtk_css_animated_style_class_init (GtkCssAnimatedStyleClass *klass)
style_class->get_value = gtk_css_animated_style_get_value;
style_class->get_section = gtk_css_animated_style_get_section;
+ style_class->is_static = gtk_css_animated_style_is_static;
}
static void
@@ -472,19 +488,3 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
return GTK_CSS_STYLE (result);
}
-
-gboolean
-gtk_css_animated_style_is_static (GtkCssAnimatedStyle *style)
-{
- GSList *list;
-
- gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), TRUE);
-
- for (list = style->animations; list; list = list->next)
- {
- if (!_gtk_style_animation_is_static (list->data, style->current_time))
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/gtk/gtkcssanimatedstyleprivate.h b/gtk/gtkcssanimatedstyleprivate.h
index 4a6d2b9..7ae8887 100644
--- a/gtk/gtkcssanimatedstyleprivate.h
+++ b/gtk/gtkcssanimatedstyleprivate.h
@@ -68,8 +68,6 @@ void gtk_css_animated_style_set_animated_value(GtkCssAnimated
GtkCssValue * gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
guint id);
-gboolean gtk_css_animated_style_is_static (GtkCssAnimatedStyle *style);
-
G_END_DECLS
#endif /* __GTK_CSS_ANIMATED_STYLE_PRIVATE_H__ */
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index 11200d8..297068b 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -271,8 +271,7 @@ gtk_css_node_real_update_style (GtkCssNode *cssnode,
new_style = g_object_ref (style);
}
- if (GTK_IS_CSS_ANIMATED_STYLE (new_style) &&
- !gtk_css_animated_style_is_static (GTK_CSS_ANIMATED_STYLE (new_style)))
+ if (!gtk_css_style_is_static (new_style))
gtk_css_node_set_invalid (cssnode, TRUE);
g_object_unref (new_static_style);
@@ -901,8 +900,7 @@ gtk_css_node_validate_internal (GtkCssNode *cssnode,
/* need to set to FALSE then to TRUE here to make it chain up */
gtk_css_node_set_invalid (cssnode, FALSE);
- if (GTK_IS_CSS_ANIMATED_STYLE (cssnode->style) &&
- !gtk_css_animated_style_is_static (GTK_CSS_ANIMATED_STYLE (cssnode->style)))
+ if (!gtk_css_style_is_static (cssnode->style))
gtk_css_node_set_invalid (cssnode, TRUE);
GTK_CSS_NODE_GET_CLASS (cssnode)->validate (cssnode);
diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c
index 0849191..c4afe13 100644
--- a/gtk/gtkcssstyle.c
+++ b/gtk/gtkcssstyle.c
@@ -46,10 +46,17 @@ gtk_css_style_real_get_section (GtkCssStyle *style,
return NULL;
}
+static gboolean
+gtk_css_style_real_is_static (GtkCssStyle *style)
+{
+ return TRUE;
+}
+
static void
gtk_css_style_class_init (GtkCssStyleClass *klass)
{
klass->get_section = gtk_css_style_real_get_section;
+ klass->is_static = gtk_css_style_real_is_static;
}
static void
@@ -97,6 +104,15 @@ gtk_css_style_get_difference (GtkCssStyle *style,
return result;
}
+gboolean
+gtk_css_style_is_static (GtkCssStyle *style)
+{
+ gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), TRUE);
+
+ return GTK_CSS_STYLE_GET_CLASS (style)->is_static (style);
+}
+
+
void
gtk_css_style_print (GtkCssStyle *style,
GString *string)
diff --git a/gtk/gtkcssstyleprivate.h b/gtk/gtkcssstyleprivate.h
index ad5b596..d3226a6 100644
--- a/gtk/gtkcssstyleprivate.h
+++ b/gtk/gtkcssstyleprivate.h
@@ -54,6 +54,8 @@ struct _GtkCssStyleClass
* Optional: default impl will just return NULL */
GtkCssSection * (* get_section) (GtkCssStyle *style,
guint id);
+ /* TRUE if this style will require changes based on timestamp */
+ gboolean (* is_static) (GtkCssStyle *style);
};
GType gtk_css_style_get_type (void) G_GNUC_CONST;
@@ -64,6 +66,7 @@ GtkCssSection * gtk_css_style_get_section (GtkCssStyle
guint id);
GtkBitmask * gtk_css_style_get_difference (GtkCssStyle *style,
GtkCssStyle *other);
+gboolean gtk_css_style_is_static (GtkCssStyle *style);
char * gtk_css_style_to_string (GtkCssStyle *style);
void gtk_css_style_print (GtkCssStyle *style,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]