From 8be3c5ed21643369f963e4638a578e32271ce749 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Tue, 7 Aug 2012 16:20:43 +0200 Subject: [PATCH] St: fix parsing of transition-duration values According to css3-transition, transition-duration is expressed as a time, that is, in seconds or milliseconds. Fix that by recognizing numbers with units and implicitly converting to milliseconds after parsing. https://bugzilla.gnome.org/show_bug.cgi?id=681376 --- data/theme/gnome-shell.css | 23 +++++++------ src/st/st-theme-node.c | 68 +++++++++++++++++++++++++++++++++++++- src/st/st-theme-node.h | 4 +++ 3 files changed, 83 insertions(+), 12 deletions(-) diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css index 634d4cff4..977efa829 100644 --- a/data/theme/gnome-shell.css +++ b/data/theme/gnome-shell.css @@ -359,7 +359,7 @@ StScrollBar StButton#vhandle:active { background-gradient-start: rgba(5,5,6,0.1); background-gradient-end: rgba(254,254,254,0.1); background-gradient-direction: vertical; - transition-duration: 300; + transition-duration: 300ms; box-shadow: inset 0px 2px 4px rgba(0,0,0,0.6); } @@ -394,7 +394,7 @@ StScrollBar StButton#vhandle:active { color: rgb(64, 64, 64); caret-color: rgb(64, 64, 64); font-weight: bold; - transition-duration: 0; + transition-duration: 0ms; } .notification StEntry, @@ -425,7 +425,7 @@ StScrollBar StButton#vhandle:active { background-color: black; font-weight: bold; height: 1.86em; - transition-duration: 250; + transition-duration: 250ms; } #panel.lock-screen { @@ -508,7 +508,7 @@ StScrollBar StButton#vhandle:active { -minimum-hpadding: 6px; font-weight: bold; color: #ccc; - transition-duration: 100; + transition-duration: 100ms; } #panel.unlock-screen .panel-button, @@ -922,7 +922,7 @@ StScrollBar StButton#vhandle:active { border-radius: 4px; padding: 3px; border: 1px rgba(0,0,0,0); - transition-duration: 100; + transition-duration: 100ms; text-align: center; } @@ -939,7 +939,7 @@ StScrollBar StButton#vhandle:active { .grid-search-result:hover .overview-icon { background-color: rgba(255,255,255,0.1); text-shadow: black 0px 2px 2px; - transition-duration: 100; + transition-duration: 100ms; color:white; } @@ -961,13 +961,13 @@ StScrollBar StButton#vhandle:active { background-gradient-direction: vertical; border-radius: 4px; box-shadow: inset 0px 1px 2px 0px rgba(0, 0, 0, 1); - transition-duration: 100; + transition-duration: 100ms; } .show-apps:checked .show-apps-icon, .show-apps:focus .show-apps-icon { color: white; - transition-duration: 100; + transition-duration: 100ms; } .app-well-app:focus > .overview-icon, @@ -1006,7 +1006,7 @@ StScrollBar StButton#vhandle:active { -minimum-hpadding: 6px; font-weight: bold; color: #ccc; - transition-duration: 100; + transition-duration: 100ms; padding-left: .3em; padding-right: .3em; } @@ -1309,7 +1309,8 @@ StScrollBar StButton#vhandle:active { #message-tray { background: #2e3436 url(message-tray-background.png); background-repeat: repeat; - transition-duration: 250; + transition-duration: 250ms; + height: 72px; } #message-tray:keyboard { @@ -1579,7 +1580,7 @@ StScrollBar StButton#vhandle:active { .summary-source { border-radius: 4px; padding: 0 6px 0 6px; - transition-duration: 100; + transition-duration: 100ms; } .summary-source-counter { diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c index 694c49678..dc3fcc25e 100644 --- a/src/st/st-theme-node.c +++ b/src/st/st-theme-node.c @@ -770,6 +770,72 @@ st_theme_node_lookup_double (StThemeNode *node, return result; } +/** + * st_theme_node_lookup_time: + * @node: a #StThemeNode + * @property_name: The name of the time property + * @inherit: if %TRUE, if a value is not found for the property on the + * node, then it will be looked up on the parent node, and then on the + * parent's parent, and so forth. Note that if the property has a + * value of 'inherit' it will be inherited even if %FALSE is passed + * in for @inherit; this only affects the default behavior for inheritance. + * @value: (out): location to store the value that was determined. + * If the property is not found, the value in this location + * will not be changed. + * + * Generically looks up a property containing a single time value, + * which is converted to milliseconds. + * + * Return value: %TRUE if the property was found in the properties for this + * theme node (or in the properties of parent nodes when inheriting.) + */ +gboolean +st_theme_node_lookup_time (StThemeNode *node, + const char *property_name, + gboolean inherit, + double *value) +{ + gboolean result = FALSE; + int i; + + ensure_properties (node); + + for (i = node->n_properties - 1; i >= 0; i--) + { + CRDeclaration *decl = node->properties[i]; + + if (strcmp (decl->property->stryng->str, property_name) == 0) + { + CRTerm *term = decl->value; + + if (term->type != TERM_NUMBER) + continue; + + switch (term->content.num->type) + { + case NUM_TIME_S: + *value = 1000 * term->content.num->val; + result = TRUE; + break; + case NUM_TIME_MS: + *value = term->content.num->val; + result = TRUE; + break; + default: + ; + } + + if (result) + break; + } + } + + if (!result && inherit && node->parent_node) + result = st_theme_node_lookup_time (node->parent_node, property_name, inherit, value); + + return result; +} + /** * st_theme_node_get_double: * @node: a #StThemeNode @@ -2063,7 +2129,7 @@ st_theme_node_get_transition_duration (StThemeNode *node) if (node->transition_duration > -1) return st_slow_down_factor * node->transition_duration; - st_theme_node_lookup_double (node, "transition-duration", FALSE, &value); + st_theme_node_lookup_time (node, "transition-duration", FALSE, &value); node->transition_duration = (int)value; diff --git a/src/st/st-theme-node.h b/src/st/st-theme-node.h index 120cef898..98da358ba 100644 --- a/src/st/st-theme-node.h +++ b/src/st/st-theme-node.h @@ -134,6 +134,10 @@ gboolean st_theme_node_lookup_length (StThemeNode *node, const char *property_name, gboolean inherit, gdouble *length); +gboolean st_theme_node_lookup_time (StThemeNode *node, + const char *property_name, + gboolean inherit, + gdouble *value); gboolean st_theme_node_lookup_shadow (StThemeNode *node, const char *property_name, gboolean inherit,