buttonBox: Drop Shell.GenericContainer usage
Another easy port. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/153
This commit is contained in:
parent
dd4709bb27
commit
fc342fe8c5
@ -86,6 +86,7 @@ function _unpremultiply(color) {
|
|||||||
var AppMenuButton = new Lang.Class({
|
var AppMenuButton = new Lang.Class({
|
||||||
Name: 'AppMenuButton',
|
Name: 'AppMenuButton',
|
||||||
Extends: PanelMenu.Button,
|
Extends: PanelMenu.Button,
|
||||||
|
Signals: {'changed': {}},
|
||||||
|
|
||||||
_init(panel) {
|
_init(panel) {
|
||||||
this.parent(0.0, null, true);
|
this.parent(0.0, null, true);
|
||||||
@ -127,7 +128,7 @@ var AppMenuButton = new Lang.Class({
|
|||||||
this._visible = this._gtkSettings.gtk_shell_shows_app_menu &&
|
this._visible = this._gtkSettings.gtk_shell_shows_app_menu &&
|
||||||
!Main.overview.visible;
|
!Main.overview.visible;
|
||||||
if (!this._visible)
|
if (!this._visible)
|
||||||
this.actor.hide();
|
this.hide();
|
||||||
this._overviewHidingId = Main.overview.connect('hiding', this._sync.bind(this));
|
this._overviewHidingId = Main.overview.connect('hiding', this._sync.bind(this));
|
||||||
this._overviewShowingId = Main.overview.connect('showing', this._sync.bind(this));
|
this._overviewShowingId = Main.overview.connect('showing', this._sync.bind(this));
|
||||||
this._showsAppMenuId = this._gtkSettings.connect('notify::gtk-shell-shows-app-menu',
|
this._showsAppMenuId = this._gtkSettings.connect('notify::gtk-shell-shows-app-menu',
|
||||||
@ -155,7 +156,7 @@ var AppMenuButton = new Lang.Class({
|
|||||||
|
|
||||||
this._visible = true;
|
this._visible = true;
|
||||||
this.actor.reactive = true;
|
this.actor.reactive = true;
|
||||||
this.actor.show();
|
this.show();
|
||||||
Tweener.removeTweens(this.actor);
|
Tweener.removeTweens(this.actor);
|
||||||
Tweener.addTween(this.actor,
|
Tweener.addTween(this.actor,
|
||||||
{ opacity: 255,
|
{ opacity: 255,
|
||||||
@ -175,7 +176,7 @@ var AppMenuButton = new Lang.Class({
|
|||||||
time: Overview.ANIMATION_TIME,
|
time: Overview.ANIMATION_TIME,
|
||||||
transition: 'easeOutQuad',
|
transition: 'easeOutQuad',
|
||||||
onComplete() {
|
onComplete() {
|
||||||
this.actor.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
onCompleteScope: this });
|
onCompleteScope: this });
|
||||||
},
|
},
|
||||||
@ -366,7 +367,7 @@ var AppMenuButton = new Lang.Class({
|
|||||||
this._menuManager.addMenu(menu);
|
this._menuManager.addMenu(menu);
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy() {
|
_onDestroy() {
|
||||||
if (this._appStateChangedSignalId > 0) {
|
if (this._appStateChangedSignalId > 0) {
|
||||||
let appSys = Shell.AppSystem.get_default();
|
let appSys = Shell.AppSystem.get_default();
|
||||||
appSys.disconnect(this._appStateChangedSignalId);
|
appSys.disconnect(this._appStateChangedSignalId);
|
||||||
@ -398,8 +399,6 @@ var AppMenuButton = new Lang.Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Signals.addSignalMethods(AppMenuButton.prototype);
|
|
||||||
|
|
||||||
var ActivitiesButton = new Lang.Class({
|
var ActivitiesButton = new Lang.Class({
|
||||||
Name: 'ActivitiesButton',
|
Name: 'ActivitiesButton',
|
||||||
Extends: PanelMenu.Button,
|
Extends: PanelMenu.Button,
|
||||||
|
@ -15,21 +15,21 @@ const PopupMenu = imports.ui.popupMenu;
|
|||||||
|
|
||||||
var ButtonBox = new Lang.Class({
|
var ButtonBox = new Lang.Class({
|
||||||
Name: 'ButtonBox',
|
Name: 'ButtonBox',
|
||||||
|
Extends: St.Widget,
|
||||||
|
|
||||||
_init(params) {
|
_init(params) {
|
||||||
params = Params.parse(params, { style_class: 'panel-button' }, true);
|
params = Params.parse(params, { style_class: 'panel-button' }, true);
|
||||||
this.actor = new Shell.GenericContainer(params);
|
|
||||||
this.actor._delegate = this;
|
this.parent(params);
|
||||||
|
|
||||||
|
this.actor = this;
|
||||||
|
this._delegate = this;
|
||||||
|
|
||||||
this.container = new St.Bin({ y_fill: true,
|
this.container = new St.Bin({ y_fill: true,
|
||||||
x_fill: true,
|
x_fill: true,
|
||||||
child: this.actor });
|
child: this.actor });
|
||||||
|
|
||||||
this.actor.connect('get-preferred-width', this._getPreferredWidth.bind(this));
|
this.connect('style-changed', this._onStyleChanged.bind(this));
|
||||||
this.actor.connect('get-preferred-height', this._getPreferredHeight.bind(this));
|
|
||||||
this.actor.connect('allocate', this._allocate.bind(this));
|
|
||||||
|
|
||||||
this.actor.connect('style-changed', this._onStyleChanged.bind(this));
|
|
||||||
this._minHPadding = this._natHPadding = 0.0;
|
this._minHPadding = this._natHPadding = 0.0;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -40,31 +40,34 @@ var ButtonBox = new Lang.Class({
|
|||||||
this._natHPadding = themeNode.get_length('-natural-hpadding');
|
this._natHPadding = themeNode.get_length('-natural-hpadding');
|
||||||
},
|
},
|
||||||
|
|
||||||
_getPreferredWidth(actor, forHeight, alloc) {
|
vfunc_get_preferred_width(forHeight) {
|
||||||
let child = actor.get_first_child();
|
let child = this.get_first_child();
|
||||||
|
let minimumSize, naturalSize;
|
||||||
|
|
||||||
if (child) {
|
if (child)
|
||||||
[alloc.min_size, alloc.natural_size] = child.get_preferred_width(-1);
|
[minimumSize, naturalSize] = child.get_preferred_width(-1);
|
||||||
} else {
|
else
|
||||||
alloc.min_size = alloc.natural_size = 0;
|
minimumSize = naturalSize = 0;
|
||||||
}
|
|
||||||
|
|
||||||
alloc.min_size += 2 * this._minHPadding;
|
minimumSize += 2 * this._minHPadding;
|
||||||
alloc.natural_size += 2 * this._natHPadding;
|
naturalSize += 2 * this._natHPadding;
|
||||||
|
|
||||||
|
return [minimumSize, naturalSize];
|
||||||
},
|
},
|
||||||
|
|
||||||
_getPreferredHeight(actor, forWidth, alloc) {
|
vfunc_get_preferred_height(forWidth) {
|
||||||
let child = actor.get_first_child();
|
let child = this.get_first_child();
|
||||||
|
|
||||||
if (child) {
|
if (child)
|
||||||
[alloc.min_size, alloc.natural_size] = child.get_preferred_height(-1);
|
return child.get_preferred_height(-1);
|
||||||
} else {
|
|
||||||
alloc.min_size = alloc.natural_size = 0;
|
return [0, 0];
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_allocate(actor, box, flags) {
|
vfunc_allocate(box, flags) {
|
||||||
let child = actor.get_first_child();
|
this.set_allocation(box, flags);
|
||||||
|
|
||||||
|
let child = this.get_first_child();
|
||||||
if (!child)
|
if (!child)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -92,6 +95,7 @@ var ButtonBox = new Lang.Class({
|
|||||||
var Button = new Lang.Class({
|
var Button = new Lang.Class({
|
||||||
Name: 'PanelMenuButton',
|
Name: 'PanelMenuButton',
|
||||||
Extends: ButtonBox,
|
Extends: ButtonBox,
|
||||||
|
Signals: {'menu-set': {} },
|
||||||
|
|
||||||
_init(menuAlignment, nameText, dontCreateMenu) {
|
_init(menuAlignment, nameText, dontCreateMenu) {
|
||||||
this.parent({ reactive: true,
|
this.parent({ reactive: true,
|
||||||
@ -100,8 +104,9 @@ var Button = new Lang.Class({
|
|||||||
accessible_name: nameText ? nameText : "",
|
accessible_name: nameText ? nameText : "",
|
||||||
accessible_role: Atk.Role.MENU });
|
accessible_role: Atk.Role.MENU });
|
||||||
|
|
||||||
this.actor.connect('event', this._onEvent.bind(this));
|
this.connect('event', this._onEvent.bind(this));
|
||||||
this.actor.connect('notify::visible', this._onVisibilityChanged.bind(this));
|
this.connect('notify::visible', this._onVisibilityChanged.bind(this));
|
||||||
|
this.connect('destroy', this._onDestroy.bind(this));
|
||||||
|
|
||||||
if (dontCreateMenu)
|
if (dontCreateMenu)
|
||||||
this.menu = new PopupMenu.PopupDummyMenu(this.actor);
|
this.menu = new PopupMenu.PopupDummyMenu(this.actor);
|
||||||
@ -110,9 +115,9 @@ var Button = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setSensitive(sensitive) {
|
setSensitive(sensitive) {
|
||||||
this.actor.reactive = sensitive;
|
this.reactive = sensitive;
|
||||||
this.actor.can_focus = sensitive;
|
this.can_focus = sensitive;
|
||||||
this.actor.track_hover = sensitive;
|
this.track_hover = sensitive;
|
||||||
},
|
},
|
||||||
|
|
||||||
setMenu(menu) {
|
setMenu(menu) {
|
||||||
@ -184,17 +189,11 @@ var Button = new Lang.Class({
|
|||||||
this.menu.actor.style = ('max-height: %spx;').format(maxHeight);
|
this.menu.actor.style = ('max-height: %spx;').format(maxHeight);
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy() {
|
_onDestroy() {
|
||||||
this.actor._delegate = null;
|
|
||||||
|
|
||||||
if (this.menu)
|
if (this.menu)
|
||||||
this.menu.destroy();
|
this.menu.destroy();
|
||||||
this.actor.destroy();
|
|
||||||
|
|
||||||
this.emit('destroy');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Signals.addSignalMethods(Button.prototype);
|
|
||||||
|
|
||||||
/* SystemIndicator:
|
/* SystemIndicator:
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user