diff options
author | Benjamin Otte <otte@redhat.com> | 2016-02-12 04:40:35 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2016-02-13 04:49:07 +0100 |
commit | e2d966eda52ed8833ebdafdc7d6d43284a503453 (patch) | |
tree | 4aa0b17ebc0bb016d20f7273898a33e3c46c2ec2 /gtk/gtkcsstypes.c | |
parent | 7b301fcece6a9f2a18afc2e5e2169da9b6545bbf (diff) | |
download | gtk+-e2d966eda52ed8833ebdafdc7d6d43284a503453.tar.gz |
cssnumbervalue: Remove gtk_css_number_value_get_unit()
This is in preparation for calc(), as calc(50% - 5px) is valid CSS
but has 2 units. Instead, add a function to query a value's dimension
(so we can differentiate lengths from numbers) and add a function to
query if the value contains percentages.
Diffstat (limited to 'gtk/gtkcsstypes.c')
-rw-r--r-- | gtk/gtkcsstypes.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gtk/gtkcsstypes.c b/gtk/gtkcsstypes.c index 2e93cbca56..45e6caf8ee 100644 --- a/gtk/gtkcsstypes.c +++ b/gtk/gtkcsstypes.c @@ -138,6 +138,44 @@ gtk_css_change_print (GtkCssChange change, } } +GtkCssDimension +gtk_css_unit_get_dimension (GtkCssUnit unit) +{ + switch (unit) + { + case GTK_CSS_NUMBER: + return GTK_CSS_DIMENSION_NUMBER; + + case GTK_CSS_PERCENT: + return GTK_CSS_DIMENSION_PERCENTAGE; + + case GTK_CSS_PX: + case GTK_CSS_PT: + case GTK_CSS_EM: + case GTK_CSS_EX: + case GTK_CSS_REM: + case GTK_CSS_PC: + case GTK_CSS_IN: + case GTK_CSS_CM: + case GTK_CSS_MM: + return GTK_CSS_DIMENSION_LENGTH; + + case GTK_CSS_RAD: + case GTK_CSS_DEG: + case GTK_CSS_GRAD: + case GTK_CSS_TURN: + return GTK_CSS_DIMENSION_ANGLE; + + case GTK_CSS_S: + case GTK_CSS_MS: + return GTK_CSS_DIMENSION_TIME; + + default: + g_assert_not_reached (); + return GTK_CSS_DIMENSION_PERCENTAGE; + } +} + char * gtk_css_change_to_string (GtkCssChange change) { |