[gnome-shell/gbsneto/remove-generic-container: 24/39] buttonBox: Drop Shell.GenericContainer usage
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/remove-generic-container: 24/39] buttonBox: Drop Shell.GenericContainer usage
- Date: Fri, 5 Oct 2018 21:36:28 +0000 (UTC)
commit d63e746fa2e8cc615e08d8a0d4d53eba7d90c5e2
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Jul 6 10:48:15 2018 +0200
buttonBox: Drop Shell.GenericContainer usage
Another easy port.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/153
js/ui/panel.js | 11 ++++----
js/ui/panelMenu.js | 73 +++++++++++++++++++++++++++---------------------------
2 files changed, 41 insertions(+), 43 deletions(-)
---
diff --git a/js/ui/panel.js b/js/ui/panel.js
index b6e831069..e61557ab9 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -86,6 +86,7 @@ function _unpremultiply(color) {
var AppMenuButton = new Lang.Class({
Name: 'AppMenuButton',
Extends: PanelMenu.Button,
+ Signals: {'changed': {}},
_init(panel) {
this.parent(0.0, null, true);
@@ -127,7 +128,7 @@ var AppMenuButton = new Lang.Class({
this._visible = this._gtkSettings.gtk_shell_shows_app_menu &&
!Main.overview.visible;
if (!this._visible)
- this.actor.hide();
+ this.hide();
this._overviewHidingId = Main.overview.connect('hiding', 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',
@@ -155,7 +156,7 @@ var AppMenuButton = new Lang.Class({
this._visible = true;
this.actor.reactive = true;
- this.actor.show();
+ this.show();
Tweener.removeTweens(this.actor);
Tweener.addTween(this.actor,
{ opacity: 255,
@@ -175,7 +176,7 @@ var AppMenuButton = new Lang.Class({
time: Overview.ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete() {
- this.actor.hide();
+ this.hide();
},
onCompleteScope: this });
},
@@ -366,7 +367,7 @@ var AppMenuButton = new Lang.Class({
this._menuManager.addMenu(menu);
},
- destroy() {
+ _onDestroy() {
if (this._appStateChangedSignalId > 0) {
let appSys = Shell.AppSystem.get_default();
appSys.disconnect(this._appStateChangedSignalId);
@@ -398,8 +399,6 @@ var AppMenuButton = new Lang.Class({
}
});
-Signals.addSignalMethods(AppMenuButton.prototype);
-
var ActivitiesButton = new Lang.Class({
Name: 'ActivitiesButton',
Extends: PanelMenu.Button,
diff --git a/js/ui/panelMenu.js b/js/ui/panelMenu.js
index b23d8e49f..6f496db97 100644
--- a/js/ui/panelMenu.js
+++ b/js/ui/panelMenu.js
@@ -15,21 +15,21 @@ const PopupMenu = imports.ui.popupMenu;
var ButtonBox = new Lang.Class({
Name: 'ButtonBox',
+ Extends: St.Widget,
_init(params) {
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,
x_fill: true,
child: this.actor });
- this.actor.connect('get-preferred-width', this._getPreferredWidth.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.connect('style-changed', this._onStyleChanged.bind(this));
this._minHPadding = this._natHPadding = 0.0;
},
@@ -40,31 +40,34 @@ var ButtonBox = new Lang.Class({
this._natHPadding = themeNode.get_length('-natural-hpadding');
},
- _getPreferredWidth(actor, forHeight, alloc) {
- let child = actor.get_first_child();
+ vfunc_get_preferred_width(forHeight) {
+ let child = this.get_first_child();
+ let minimumSize, naturalSize;
- if (child) {
- [alloc.min_size, alloc.natural_size] = child.get_preferred_width(-1);
- } else {
- alloc.min_size = alloc.natural_size = 0;
- }
+ if (child)
+ [minimumSize, naturalSize] = child.get_preferred_width(-1);
+ else
+ minimumSize = naturalSize = 0;
+
+ minimumSize += 2 * this._minHPadding;
+ naturalSize += 2 * this._natHPadding;
- alloc.min_size += 2 * this._minHPadding;
- alloc.natural_size += 2 * this._natHPadding;
+ return [minimumSize, naturalSize];
},
- _getPreferredHeight(actor, forWidth, alloc) {
- let child = actor.get_first_child();
+ vfunc_get_preferred_height(forWidth) {
+ let child = this.get_first_child();
- if (child) {
- [alloc.min_size, alloc.natural_size] = child.get_preferred_height(-1);
- } else {
- alloc.min_size = alloc.natural_size = 0;
- }
+ if (child)
+ return child.get_preferred_height(-1);
+
+ return [0, 0];
},
- _allocate(actor, box, flags) {
- let child = actor.get_first_child();
+ vfunc_allocate(box, flags) {
+ this.set_allocation(box, flags);
+
+ let child = this.get_first_child();
if (!child)
return;
@@ -92,6 +95,7 @@ var ButtonBox = new Lang.Class({
var Button = new Lang.Class({
Name: 'PanelMenuButton',
Extends: ButtonBox,
+ Signals: {'menu-set': {} },
_init(menuAlignment, nameText, dontCreateMenu) {
this.parent({ reactive: true,
@@ -100,8 +104,9 @@ var Button = new Lang.Class({
accessible_name: nameText ? nameText : "",
accessible_role: Atk.Role.MENU });
- this.actor.connect('event', this._onEvent.bind(this));
- this.actor.connect('notify::visible', this._onVisibilityChanged.bind(this));
+ this.connect('event', this._onEvent.bind(this));
+ this.connect('notify::visible', this._onVisibilityChanged.bind(this));
+ this.connect('destroy', this._onDestroy.bind(this));
if (dontCreateMenu)
this.menu = new PopupMenu.PopupDummyMenu(this.actor);
@@ -110,9 +115,9 @@ var Button = new Lang.Class({
},
setSensitive(sensitive) {
- this.actor.reactive = sensitive;
- this.actor.can_focus = sensitive;
- this.actor.track_hover = sensitive;
+ this.reactive = sensitive;
+ this.can_focus = sensitive;
+ this.track_hover = sensitive;
},
setMenu(menu) {
@@ -184,17 +189,11 @@ var Button = new Lang.Class({
this.menu.actor.style = ('max-height: %spx;').format(maxHeight);
},
- destroy() {
- this.actor._delegate = null;
-
+ _onDestroy() {
if (this.menu)
this.menu.destroy();
- this.actor.destroy();
-
- this.emit('destroy');
}
});
-Signals.addSignalMethods(Button.prototype);
/* SystemIndicator:
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]