StThemeNode: use (out caller-allocates) on ClutterColor-returning methods

Properly annotate the themenode methods that return ClutterColors, and
update their JS callers to take advantage of that.

https://bugzilla.gnome.org/show_bug.cgi?id=642295
This commit is contained in:
Dan Winship 2011-02-14 09:20:22 -05:00
parent 688b9697c8
commit 1224e959b6
5 changed files with 45 additions and 25 deletions

View File

@ -189,10 +189,8 @@ BoxPointer.prototype = {
let halfBorder = borderWidth / 2;
let halfBase = Math.floor(base/2);
let borderColor = new Clutter.Color();
themeNode.get_color('-arrow-border-color', borderColor);
let backgroundColor = new Clutter.Color();
themeNode.get_color('-arrow-background-color', backgroundColor);
let borderColor = themeNode.get_color('-arrow-border-color');
let backgroundColor = themeNode.get_color('-arrow-background-color');
let [width, height] = area.get_surface_size();
let [boxWidth, boxHeight] = [width, height];

View File

@ -29,10 +29,9 @@ function _onVertSepRepaint (area)
let cr = area.get_context();
let themeNode = area.get_theme_node();
let [width, height] = area.get_surface_size();
let stippleColor = new Clutter.Color();
let stippleColor = themeNode.get_color('-stipple-color');
let stippleWidth = themeNode.get_length('-stipple-width');
let x = Math.floor(width/2) + 0.5;
themeNode.lookup_color('-stipple-color', false, stippleColor);
cr.moveTo(x, 0);
cr.lineTo(x, height);
Clutter.cairo_set_source_color(cr, stippleColor);

View File

@ -89,8 +89,7 @@ URLHighlighter.prototype = {
this.actor = new St.Label({ reactive: true, style_class: 'url-highlighter' });
this._linkColor = '#ccccff';
this.actor.connect('style-changed', Lang.bind(this, function() {
let color = new Clutter.Color();
let hasColor = this.actor.get_theme_node().get_color('link-color', color);
let [hasColor, color] = this.actor.get_theme_node().lookup_color('link-color', false);
if (hasColor) {
let linkColor = color.to_string().substr(0, 7);
if (linkColor != this._linkColor) {

View File

@ -151,8 +151,7 @@ PopupBaseMenuItem.prototype = {
_onRepaintDot: function(area) {
let cr = area.get_context();
let [width, height] = area.get_surface_size();
let color = new Clutter.Color();
area.get_theme_node().get_foreground_color(color);
let color = area.get_theme_node().get_foreground_color();
cr.setSourceRGBA (
color.red / 255,
@ -309,10 +308,8 @@ PopupSeparatorMenuItem.prototype = {
let [width, height] = area.get_surface_size();
let margin = themeNode.get_length('-margin-horizontal');
let gradientHeight = themeNode.get_length('-gradient-height');
let startColor = new Clutter.Color();
themeNode.get_color('-gradient-start', startColor);
let endColor = new Clutter.Color();
themeNode.get_color('-gradient-end', endColor);
let startColor = themeNode.get_color('-gradient-start');
let endColor = themeNode.get_color('-gradient-end');
let gradientWidth = (width - margin * 2);
let gradientOffset = (height - gradientHeight) / 2;
@ -373,10 +370,8 @@ PopupSliderMenuItem.prototype = {
let sliderBorderWidth = themeNode.get_length('-slider-border-width');
let sliderBorderColor = new Clutter.Color();
themeNode.get_color('-slider-border-color', sliderBorderColor);
let sliderColor = new Clutter.Color();
themeNode.get_color('-slider-background-color', sliderColor);
let sliderBorderColor = themeNode.get_color('-slider-border-color');
let sliderColor = themeNode.get_color('-slider-background-color');
cr.setSourceRGBA (
sliderColor.red / 255,
@ -396,8 +391,7 @@ PopupSliderMenuItem.prototype = {
let handleY = height / 2;
let handleX = handleRadius + (width - 2 * handleRadius) * this._value;
let color = new Clutter.Color();
themeNode.get_foreground_color(color);
let color = themeNode.get_foreground_color();
cr.setSourceRGBA (
color.red / 255,
color.green / 255,

View File

@ -529,8 +529,8 @@ get_color_from_term (StThemeNode *node,
* 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.
* @color: location to store the color that was determined.
* If the property is not found, the value in this location
* @color: (out caller-allocates): location to store the color 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 color value. When
@ -585,7 +585,8 @@ st_theme_node_lookup_color (StThemeNode *node,
* st_theme_node_get_color:
* @node: a #StThemeNode
* @property_name: The name of the color property
* @color: location to store the color that was determined.
* @color: (out caller-allocates): location to store the color that
* was determined.
*
* Generically looks up a property containing a single color value. When
* specific getters (like st_theme_node_get_background_color()) exist, they
@ -1479,6 +1480,13 @@ st_theme_node_get_outline_width (StThemeNode *node)
return node->outline_width;
}
/**
* st_theme_node_get_outline_color:
* @node: a #StThemeNode
* @color: (out caller-allocates): location to store the color
*
* Returns the color of @node's outline.
*/
void
st_theme_node_get_outline_color (StThemeNode *node,
ClutterColor *color)
@ -1741,6 +1749,13 @@ _st_theme_node_ensure_background (StThemeNode *node)
}
}
/**
* st_theme_node_get_background_color:
* @node: a #StThemeNode
* @color: (out caller-allocates): location to store the color
*
* Returns @node's background color.
*/
void
st_theme_node_get_background_color (StThemeNode *node,
ClutterColor *color)
@ -1762,6 +1777,13 @@ st_theme_node_get_background_image (StThemeNode *node)
return node->background_image;
}
/**
* st_theme_node_get_foreground_color:
* @node: a #StThemeNode
* @color: (out caller-allocates): location to store the color
*
* Returns @node's foreground color.
*/
void
st_theme_node_get_foreground_color (StThemeNode *node,
ClutterColor *color)
@ -1805,8 +1827,8 @@ st_theme_node_get_foreground_color (StThemeNode *node,
* st_theme_node_get_background_gradient:
* @node: A #StThemeNode
* @type: (out): Type of gradient
* @start: Color at start of gradient
* @end: Color at end of gradient
* @start: (out caller-allocates): Color at start of gradient
* @end: (out caller-allocates): Color at end of gradient
*
* The @start and @end arguments will only be set if @type is not #ST_GRADIENT_NONE.
*/
@ -1828,6 +1850,14 @@ st_theme_node_get_background_gradient (StThemeNode *node,
}
}
/**
* st_theme_node_get_border_color:
* @node: a #StThemeNode
* @side: a #StSide
* @color: (out caller-allocates): location to store the color
*
* Returns the color of @node's border on @side
*/
void
st_theme_node_get_border_color (StThemeNode *node,
StSide side,