From 99d49c1800dcdf224d6028db9b4a697a808e1992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 19 Nov 2024 14:03:09 +0100 Subject: [PATCH] places-menu: Inherit from PopupImageMenuItem PopupImageMenuItems used to position the icon after the label, so we ended up with our own icon+label items. However the icon position was changed years ago in the shell, so inherit from PopupImageMenuItem instead. This does not only simplify the code a bit, but also pulls in features we are currently missing, like a11y labelling. Closes: https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/issues/542 (cherry picked from commit 568826e489779ddd9c2f4708180fd27f79210bdd) --- extensions/places-menu/extension.js | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/extensions/places-menu/extension.js b/extensions/places-menu/extension.js index bf68c029..8c1793cd 100644 --- a/extensions/places-menu/extension.js +++ b/extensions/places-menu/extension.js @@ -19,32 +19,17 @@ import {PlacesManager} from './placeDisplay.js'; const N_ = x => x; -const PLACE_ICON_SIZE = 16; - -class PlaceMenuItem extends PopupMenu.PopupBaseMenuItem { +class PlaceMenuItem extends PopupMenu.PopupImageMenuItem { static { GObject.registerClass(this); } constructor(info) { - super({ + super(info.name, info.icon, { style_class: 'place-menu-item', }); this._info = info; - this._icon = new St.Icon({ - gicon: info.icon, - icon_size: PLACE_ICON_SIZE, - }); - this.add_child(this._icon); - - this._label = new St.Label({ - text: info.name, - x_expand: true, - y_align: Clutter.ActorAlign.CENTER, - }); - this.add_child(this._label); - if (info.isRemovable()) { this._ejectIcon = new St.Icon({ icon_name: 'media-eject-symbolic', @@ -69,8 +54,8 @@ class PlaceMenuItem extends PopupMenu.PopupBaseMenuItem { } _propertiesChanged(info) { - this._icon.gicon = info.icon; - this._label.text = info.name; + this.setIcon(info.icon); + this.label.text = info.name; } }