StThemeNode: simplify use of get_color/get_double/get_length
Although within St itself there are situations where the semantics of these functions (return TRUE or FALSE and return the actual value in an out parameter) is useful, it's mostly just annoying at the application level, where you generally know that the CSS property is going to specified, and there is no especially sane fallback if it's not. So rename the current methods to lookup_color, lookup_double, and lookup_length, and add new get_color, get_double, and get_length methods that don't take an "inherit" parameter, and return their values directly. (Well, except for get_color, due to the lack of (out caller-allocates) in gjs.) And update the code to use either the old or new methods as appropriate. https://bugzilla.gnome.org/show_bug.cgi?id=632590
This commit is contained in:
@ -143,13 +143,12 @@ PopupSeparatorMenuItem.prototype = {
|
||||
let cr = area.get_context();
|
||||
let themeNode = area.get_theme_node();
|
||||
let [width, height] = area.get_surface_size();
|
||||
let found, margin, gradientHeight;
|
||||
[found, margin] = themeNode.get_length('-margin-horizontal', false);
|
||||
[found, gradientHeight] = themeNode.get_length('-gradient-height', false);
|
||||
let margin = themeNode.get_length('-margin-horizontal');
|
||||
let gradientHeight = themeNode.get_length('-gradient-height');
|
||||
let startColor = new Clutter.Color();
|
||||
themeNode.get_color('-gradient-start', false, startColor);
|
||||
themeNode.get_color('-gradient-start', startColor);
|
||||
let endColor = new Clutter.Color();
|
||||
themeNode.get_color('-gradient-end', false, endColor);
|
||||
themeNode.get_color('-gradient-end', endColor);
|
||||
|
||||
let gradientWidth = (width - margin * 2);
|
||||
let gradientOffset = (height - gradientHeight) / 2;
|
||||
@ -200,20 +199,17 @@ PopupSliderMenuItem.prototype = {
|
||||
let themeNode = area.get_theme_node();
|
||||
let [width, height] = area.get_surface_size();
|
||||
|
||||
let found, handleRadius;
|
||||
[found, handleRadius] = themeNode.get_length('-slider-handle-radius', false);
|
||||
let handleRadius = themeNode.get_length('-slider-handle-radius');
|
||||
|
||||
let sliderWidth = width - 2 * handleRadius;
|
||||
let sliderHeight;
|
||||
[found, sliderHeight] = themeNode.get_length('-slider-height', false);
|
||||
let sliderHeight = themeNode.get_length('-slider-height');
|
||||
|
||||
let sliderBorderWidth;
|
||||
[found, sliderBorderWidth] = themeNode.get_length('-slider-border-width', false);
|
||||
let sliderBorderWidth = themeNode.get_length('-slider-border-width');
|
||||
|
||||
let sliderBorderColor = new Clutter.Color();
|
||||
themeNode.get_color('-slider-border-color', false, sliderBorderColor);
|
||||
themeNode.get_color('-slider-border-color', sliderBorderColor);
|
||||
let sliderColor = new Clutter.Color();
|
||||
themeNode.get_color('-slider-background-color', false, sliderColor);
|
||||
themeNode.get_color('-slider-background-color', sliderColor);
|
||||
|
||||
cr.setSourceRGBA (
|
||||
sliderColor.red / 255,
|
||||
@ -288,8 +284,7 @@ PopupSliderMenuItem.prototype = {
|
||||
relY = absY - sliderY;
|
||||
|
||||
let width = this._slider.width;
|
||||
let found, handleRadius;
|
||||
[found, handleRadius] = this._slider.get_theme_node().get_length('-slider-handle-radius', false);
|
||||
let handleRadius = this._slider.get_theme_node().get_length('-slider-handle-radius');
|
||||
|
||||
let newvalue;
|
||||
if (relX < handleRadius)
|
||||
|
Reference in New Issue
Block a user