[StWidget] add list-like methods for style_class and pseudo_class

Since style_class and pseudo_class are space-separated lists of names,
add new methods to add and remove individual names rather than just
re-setting the entire name.

Update existing code to use the new pseudo-class methods where
appropriate. In some cases, this may result in actors having multiple
pseudoclasses where previously they only had one at a time, but there
don't seem to be any visible differences.

(There are some places that could usefully use the new style_class
methods as well, but this patch doesn't change them.)

Also, update test-theme.c to test the new methods.

https://bugzilla.gnome.org/show_bug.cgi?id=604943
This commit is contained in:
Dan Winship
2010-03-19 11:37:04 -04:00
parent 7c37e94eda
commit 909b5ec43c
14 changed files with 367 additions and 88 deletions

View File

@ -797,12 +797,12 @@ AppIconMenu.prototype = {
_updateHighlight: function (item) {
if (this._highlightedItem) {
this._highlightedItem.set_style_pseudo_class(null);
this._highlightedItem.remove_style_pseudo_class('hover');
this.emit('highlight-window', null);
}
this._highlightedItem = item;
if (this._highlightedItem) {
item.set_style_pseudo_class('hover');
item.add_style_pseudo_class('hover');
let window = this._highlightedItem._window;
if (window)
this.emit('highlight-window', window);

View File

@ -359,7 +359,10 @@ SearchResult.prototype = {
},
setSelected: function(selected) {
this._content.set_style_pseudo_class(selected ? 'selected' : null);
if (selected)
this._content.add_style_pseudo_class('selected');
else
this._content.remove_style_pseudo_class('selected');
},
activate: function() {
@ -630,10 +633,10 @@ MoreLink.prototype = {
setPane: function (pane) {
this._pane = pane;
this._pane.connect('open-state-changed', Lang.bind(this, function(pane, isOpen) {
if (!isOpen)
this._expander.style_class = 'more-link-expander';
if (isOpen)
this._expander.add_style_class_name('open');
else
this._expander.style_class = 'more-link-expander open';
this._expander.remove_style_class_name('open');
}));
}
};

View File

@ -105,7 +105,10 @@ GenericDisplayItem.prototype = {
// Highlights the item by setting a different background color than the default
// if isSelected is true, removes the highlighting otherwise.
markSelected: function(isSelected) {
this.actor.set_style_pseudo_class(isSelected ? "selected" : null);
if (iSelected)
this.actor.add_style_pseudo_class('selected');
else
this.actor.remove_style_pseudo_class('selected');
},
/*

View File

@ -84,7 +84,7 @@ Notebook.prototype = {
if (this._selectedIndex < 0)
return;
let tabData = this._tabs[this._selectedIndex];
tabData.labelBox.set_style_pseudo_class(null);
tabData.labelBox.remove_style_pseudo_class('selected');
tabData.scrollView.hide();
this._selectedIndex = -1;
},
@ -98,7 +98,7 @@ Notebook.prototype = {
return;
}
let tabData = this._tabs[index];
tabData.labelBox.set_style_pseudo_class('selected');
tabData.labelBox.add_style_pseudo_class('selected');
tabData.scrollView.show();
this._selectedIndex = index;
this.emit('selection', tabData.child);

View File

@ -484,7 +484,10 @@ NewWorkspaceArea.prototype = {
},
setStyle: function(isHover) {
this._child1.set_style_pseudo_class(isHover ? 'hover' : null);
if (isHover)
this._child1.add_style_pseudo_class('hover');
else
this._child1.remove_style_pseudo_class('hover');
}
};