Simplify Button class by using ShellButtonBox

Make Button class purely about adding visuals, and use ShellButtonBox
for behavior. API equivalences:

  shell.button => shell.actor [for consistency]

  staysPressed parameter to constructor => replaced by manually setting
   the 'active' property of button.actor as appropriate

  pressIn/release => button.actor.active = true/false

  enter-event/leave-event signals => button.actor notify::hover

Along the way, this fixes a bug with the user status menu where it was
not getting set to active because the button was getting a leave
(triggered by the menu popping up and grabbing the pointer) before for
button release, which disabled the staysPressed behavior.

Reported by Michael Meeks
http://bugzilla.gnome.org/show_bug.cgi?id=593471
This commit is contained in:
Owen W. Taylor
2009-08-29 07:23:28 -04:00
parent 0fd6bc5172
commit 5803aa7e65
3 changed files with 66 additions and 114 deletions

View File

@ -460,24 +460,23 @@ SearchSectionHeader.prototype = {
this._showTooltip = true;
let button = new Button.Button(box, PRELIGHT_COLOR, BACKGROUND_COLOR,
TEXT_COLOR, false, null);
button.button.height = box.height;
button.button.padding_left = DEFAULT_PADDING;
button.button.padding_right = DEFAULT_PADDING;
TEXT_COLOR);
button.actor.height = box.height;
button.actor.padding_left = DEFAULT_PADDING;
button.actor.padding_right = DEFAULT_PADDING;
button.button.connect('button-release-event', onClick);
button.connect('enter-event', Lang.bind(this, this._onButtonEntered));
button.connect('leave-event', Lang.bind(this, this._onButtonLeft));
this.actor = button.button;
button.actor.connect('activate', onClick);
button.actor.connect('notify::hover', Lang.bind(this, this._updateTooltip));
this.actor = button.actor;
},
_onButtonEntered : function() {
if (this._showTooltip)
this.tooltip.show();
},
_onButtonLeft : function() {
this.tooltip.hide();
_updateTooltip : function(actor) {
if (actor.hover) {
if (this._showTooltip)
this.tooltip.show();
} else {
this.tooltip.hide();
}
},
setShowTooltip : function(showTooltip) {
@ -683,7 +682,6 @@ Dash.prototype = {
Lang.bind(this,
function () {
this._toggleOnlyAppSearchShown();
return true;
}));
this._searchResultsSection.content.append(this._appSearchHeader.actor, Big.BoxPackFlags.NONE);
this._appSearchResultArea = new ResultArea(AppDisplay.AppDisplay, false);
@ -695,7 +693,6 @@ Dash.prototype = {
Lang.bind(this,
function () {
this._toggleOnlyDocSearchShown();
return true;
}));
this._searchResultsSection.content.append(this._docSearchHeader.actor, Big.BoxPackFlags.NONE);
this._docSearchResultArea = new ResultArea(DocDisplay.DocDisplay, false);