diff options
author | Benjamin Otte <otte@redhat.com> | 2012-01-15 05:29:02 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-02-02 03:14:00 +0100 |
commit | 82c2dad178b918699372a1d2942753af25908438 (patch) | |
tree | e39308c69f07ab78670763030173c10193523d6c | |
parent | 762ea4793fa7891a7973287fad25af8bb69c8de4 (diff) | |
download | gtk+-82c2dad178b918699372a1d2942753af25908438.tar.gz |
themingengine: Add a private function to query lengths
-rw-r--r-- | gtk/gtkstylecontext.c | 16 | ||||
-rw-r--r-- | gtk/gtkstylecontextprivate.h | 3 | ||||
-rw-r--r-- | gtk/gtkthemingengine.c | 11 | ||||
-rw-r--r-- | gtk/gtkthemingengineprivate.h | 3 |
4 files changed, 33 insertions, 0 deletions
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 370c782055..c4669eb586 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -2372,6 +2372,22 @@ _gtk_style_context_peek_property (GtkStyleContext *context, return _gtk_css_computed_values_get_value_by_name (data->store, property_name); } +double +_gtk_style_context_get_number (GtkStyleContext *context, + const char *property_name, + double one_hundred_percent) +{ + const GValue *value; + const GtkCssNumber *number; + + value = _gtk_style_context_peek_property (context, property_name); + number = g_value_get_boxed (value); + if (number->unit == GTK_CSS_PERCENT) + return number->value * one_hundred_percent * 0.01; + else + return number->value; +} + const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, GType widget_type, diff --git a/gtk/gtkstylecontextprivate.h b/gtk/gtkstylecontextprivate.h index ffde8db52e..59a8a698ca 100644 --- a/gtk/gtkstylecontextprivate.h +++ b/gtk/gtkstylecontextprivate.h @@ -27,6 +27,9 @@ G_BEGIN_DECLS const GValue * _gtk_style_context_peek_property (GtkStyleContext *context, const char *property_name); +double _gtk_style_context_get_number (GtkStyleContext *context, + const char *property_name, + double one_hundred_percent); const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, GType widget_type, GtkStateFlags state, diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index bac1f72301..ce90769ed6 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -340,6 +340,17 @@ _gtk_theming_engine_peek_property (GtkThemingEngine *engine, return _gtk_style_context_peek_property (engine->priv->context, property_name); } +double +_gtk_theming_engine_get_number (GtkThemingEngine *engine, + const char *property_name, + double one_hundred_percent) +{ + g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0.0); + g_return_val_if_fail (property_name != NULL, 0.0); + + return _gtk_style_context_get_number (engine->priv->context, property_name, one_hundred_percent); +} + /** * gtk_theming_engine_get_property: * @engine: a #GtkThemingEngine diff --git a/gtk/gtkthemingengineprivate.h b/gtk/gtkthemingengineprivate.h index 3cb20d82c3..10db6f7470 100644 --- a/gtk/gtkthemingengineprivate.h +++ b/gtk/gtkthemingengineprivate.h @@ -30,5 +30,8 @@ void _gtk_theming_engine_paint_spinner (cairo_t *cr, const GValue *_gtk_theming_engine_peek_property (GtkThemingEngine *engine, const char *property_name); +double _gtk_theming_engine_get_number (GtkThemingEngine *engine, + const char *property_name, + double one_hundred_percent); #endif /* __GTK_THEMING_ENGINE_PRIVATE_H__ */ |