modalDialog: Fix setting the initial key focus after the 1st time

Checking if _buttonLayout contains _initialKeyFocus always fails since we
destroy all children before. Instead, use a signal handler id when explicitly
setting the initial key focus which is zeroed if/when the actor is destroyed.

https://bugzilla.gnome.org/show_bug.cgi?id=663437
This commit is contained in:
Rui Matos 2012-02-12 19:55:59 +01:00
parent a197ce6f53
commit b58425d7d7

View File

@ -98,6 +98,7 @@ const ModalDialog = new Lang.Class({
global.focus_manager.add_group(this._dialogLayout);
this._initialKeyFocus = this._dialogLayout;
this._initialKeyFocusDestroyId = 0;
this._savedKeyFocus = null;
},
@ -134,8 +135,7 @@ const ModalDialog = new Lang.Class({
else
x_alignment = St.Align.MIDDLE;
if (this._initialKeyFocus == this._dialogLayout ||
this._buttonLayout.contains(this._initialKeyFocus))
if (!this._initialKeyFocusDestroyId)
this._initialKeyFocus = buttonInfo.button;
this._buttonLayout.add(buttonInfo.button,
{ expand: true,
@ -205,7 +205,15 @@ const ModalDialog = new Lang.Class({
},
setInitialKeyFocus: function(actor) {
if (this._initialKeyFocusDestroyId)
this._initialKeyFocus.disconnect(this._initialKeyFocusDestroyId);
this._initialKeyFocus = actor;
this._initialKeyFocusDestroyId = actor.connect('destroy', Lang.bind(this, function() {
this._initialKeyFocus = this._dialogLayout;
this._initialKeyFocusDestroyId = 0;
}));
},
open: function(timestamp) {