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 halfBorder = borderWidth / 2;
let halfBase = Math.floor(base/2); let halfBase = Math.floor(base/2);
let borderColor = new Clutter.Color(); let borderColor = themeNode.get_color('-arrow-border-color');
themeNode.get_color('-arrow-border-color', borderColor); let backgroundColor = themeNode.get_color('-arrow-background-color');
let backgroundColor = new Clutter.Color();
themeNode.get_color('-arrow-background-color', backgroundColor);
let [width, height] = area.get_surface_size(); let [width, height] = area.get_surface_size();
let [boxWidth, boxHeight] = [width, height]; let [boxWidth, boxHeight] = [width, height];

View File

@ -29,10 +29,9 @@ function _onVertSepRepaint (area)
let cr = area.get_context(); let cr = area.get_context();
let themeNode = area.get_theme_node(); let themeNode = area.get_theme_node();
let [width, height] = area.get_surface_size(); 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 stippleWidth = themeNode.get_length('-stipple-width');
let x = Math.floor(width/2) + 0.5; let x = Math.floor(width/2) + 0.5;
themeNode.lookup_color('-stipple-color', false, stippleColor);
cr.moveTo(x, 0); cr.moveTo(x, 0);
cr.lineTo(x, height); cr.lineTo(x, height);
Clutter.cairo_set_source_color(cr, stippleColor); 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.actor = new St.Label({ reactive: true, style_class: 'url-highlighter' });
this._linkColor = '#ccccff'; this._linkColor = '#ccccff';
this.actor.connect('style-changed', Lang.bind(this, function() { this.actor.connect('style-changed', Lang.bind(this, function() {
let color = new Clutter.Color(); let [hasColor, color] = this.actor.get_theme_node().lookup_color('link-color', false);
let hasColor = this.actor.get_theme_node().get_color('link-color', color);
if (hasColor) { if (hasColor) {
let linkColor = color.to_string().substr(0, 7); let linkColor = color.to_string().substr(0, 7);
if (linkColor != this._linkColor) { if (linkColor != this._linkColor) {

View File

@ -151,8 +151,7 @@ PopupBaseMenuItem.prototype = {
_onRepaintDot: function(area) { _onRepaintDot: function(area) {
let cr = area.get_context(); let cr = area.get_context();
let [width, height] = area.get_surface_size(); let [width, height] = area.get_surface_size();
let color = new Clutter.Color(); let color = area.get_theme_node().get_foreground_color();
area.get_theme_node().get_foreground_color(color);
cr.setSourceRGBA ( cr.setSourceRGBA (
color.red / 255, color.red / 255,
@ -309,10 +308,8 @@ PopupSeparatorMenuItem.prototype = {
let [width, height] = area.get_surface_size(); let [width, height] = area.get_surface_size();
let margin = themeNode.get_length('-margin-horizontal'); let margin = themeNode.get_length('-margin-horizontal');
let gradientHeight = themeNode.get_length('-gradient-height'); let gradientHeight = themeNode.get_length('-gradient-height');
let startColor = new Clutter.Color(); let startColor = themeNode.get_color('-gradient-start');
themeNode.get_color('-gradient-start', startColor); let endColor = themeNode.get_color('-gradient-end');
let endColor = new Clutter.Color();
themeNode.get_color('-gradient-end', endColor);
let gradientWidth = (width - margin * 2); let gradientWidth = (width - margin * 2);
let gradientOffset = (height - gradientHeight) / 2; let gradientOffset = (height - gradientHeight) / 2;
@ -373,10 +370,8 @@ PopupSliderMenuItem.prototype = {
let sliderBorderWidth = themeNode.get_length('-slider-border-width'); let sliderBorderWidth = themeNode.get_length('-slider-border-width');
let sliderBorderColor = new Clutter.Color(); let sliderBorderColor = themeNode.get_color('-slider-border-color');
themeNode.get_color('-slider-border-color', sliderBorderColor); let sliderColor = themeNode.get_color('-slider-background-color');
let sliderColor = new Clutter.Color();
themeNode.get_color('-slider-background-color', sliderColor);
cr.setSourceRGBA ( cr.setSourceRGBA (
sliderColor.red / 255, sliderColor.red / 255,
@ -396,8 +391,7 @@ PopupSliderMenuItem.prototype = {
let handleY = height / 2; let handleY = height / 2;
let handleX = handleRadius + (width - 2 * handleRadius) * this._value; let handleX = handleRadius + (width - 2 * handleRadius) * this._value;
let color = new Clutter.Color(); let color = themeNode.get_foreground_color();
themeNode.get_foreground_color(color);
cr.setSourceRGBA ( cr.setSourceRGBA (
color.red / 255, color.red / 255,
color.green / 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 * 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 * value of 'inherit' it will be inherited even if %FALSE is passed
* in for @inherit; this only affects the default behavior for inheritance. * in for @inherit; this only affects the default behavior for inheritance.
* @color: location to store the color that was determined. * @color: (out caller-allocates): location to store the color that was
* If the property is not found, the value in this location * determined. If the property is not found, the value in this location
* will not be changed. * will not be changed.
* *
* Generically looks up a property containing a single color value. When * 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: * st_theme_node_get_color:
* @node: a #StThemeNode * @node: a #StThemeNode
* @property_name: The name of the color property * @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 * Generically looks up a property containing a single color value. When
* specific getters (like st_theme_node_get_background_color()) exist, they * 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; 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 void
st_theme_node_get_outline_color (StThemeNode *node, st_theme_node_get_outline_color (StThemeNode *node,
ClutterColor *color) 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 void
st_theme_node_get_background_color (StThemeNode *node, st_theme_node_get_background_color (StThemeNode *node,
ClutterColor *color) ClutterColor *color)
@ -1762,6 +1777,13 @@ st_theme_node_get_background_image (StThemeNode *node)
return node->background_image; 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 void
st_theme_node_get_foreground_color (StThemeNode *node, st_theme_node_get_foreground_color (StThemeNode *node,
ClutterColor *color) ClutterColor *color)
@ -1805,8 +1827,8 @@ st_theme_node_get_foreground_color (StThemeNode *node,
* st_theme_node_get_background_gradient: * st_theme_node_get_background_gradient:
* @node: A #StThemeNode * @node: A #StThemeNode
* @type: (out): Type of gradient * @type: (out): Type of gradient
* @start: Color at start of gradient * @start: (out caller-allocates): Color at start of gradient
* @end: Color at end 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. * 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 void
st_theme_node_get_border_color (StThemeNode *node, st_theme_node_get_border_color (StThemeNode *node,
StSide side, StSide side,