diff options
author | Timm Bäder <mail@baedert.org> | 2019-08-17 19:29:44 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2019-09-09 17:36:23 +0200 |
commit | 3a3a59c1882296aec8f37e21c78f71e82a127e30 (patch) | |
tree | b769ada6b2503437b017f233d595778b4e2ce410 /gtk/gtkcssdimensionvalue.c | |
parent | 6ed6cc46de8492786015615e1b1244f2888957f9 (diff) | |
download | gtk+-3a3a59c1882296aec8f37e21c78f71e82a127e30.tar.gz |
cssdimensionvalue: Create a few more common singletons
Diffstat (limited to 'gtk/gtkcssdimensionvalue.c')
-rw-r--r-- | gtk/gtkcssdimensionvalue.c | 59 |
1 files changed, 49 insertions, 10 deletions
diff --git a/gtk/gtkcssdimensionvalue.c b/gtk/gtkcssdimensionvalue.c index 4efdf13ef2..4108a248c8 100644 --- a/gtk/gtkcssdimensionvalue.c +++ b/gtk/gtkcssdimensionvalue.c @@ -296,6 +296,7 @@ gtk_css_dimension_value_new (double value, static GtkCssValue number_singletons[] = { { >K_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_NUMBER, 0 }, { >K_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_NUMBER, 1 }, + { >K_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_NUMBER, 96 }, /* DPI default */ }; static GtkCssValue px_singletons[] = { { >K_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_PX, 0 }, @@ -303,20 +304,58 @@ gtk_css_dimension_value_new (double value, { >K_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_PX, 2 }, { >K_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_PX, 3 }, { >K_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_PX, 4 }, + { >K_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_PX, 16 }, /* Icon size default */ + }; + static GtkCssValue percent_singletons[] = { + { >K_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_PERCENT, 0 }, + { >K_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_PERCENT, 100 }, + }; + static GtkCssValue second_singletons[] = { + { >K_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_S, 0 }, + { >K_CSS_VALUE_DIMENSION.value_class, 1, GTK_CSS_S, 1 }, }; GtkCssValue *result; - if (unit == GTK_CSS_NUMBER && (value == 0 || value == 1)) - return _gtk_css_value_ref (&number_singletons[(int) value]); - - if (unit == GTK_CSS_PX && - (value == 0 || - value == 1 || - value == 2 || - value == 3 || - value == 4)) + switch ((guint)unit) { - return _gtk_css_value_ref (&px_singletons[(int) value]); + case GTK_CSS_NUMBER: + if (value == 0 || value == 1) + return _gtk_css_value_ref (&number_singletons[(int) value]); + + if (value == 96) + return _gtk_css_value_ref (&number_singletons[2]); + + break; + + case GTK_CSS_PX: + if (value == 0 || + value == 1 || + value == 2 || + value == 3 || + value == 4) + return _gtk_css_value_ref (&px_singletons[(int) value]); + else if (value == 16) + return _gtk_css_value_ref (&px_singletons[5]); + + break; + + case GTK_CSS_PERCENT: + if (value == 0) + return _gtk_css_value_ref (&percent_singletons[0]); + + if (value == 100) + return _gtk_css_value_ref (&percent_singletons[1]); + + break; + + case GTK_CSS_S: + if (value == 0 || value == 1) + return _gtk_css_value_ref (&second_singletons[(int)value]); + + break; + + default: + ; } result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_DIMENSION.value_class); |