Fix positioning and blank spaces
This commit is contained in:
parent
5458908603
commit
8c709d38d5
32
extension.js
32
extension.js
|
@ -22,6 +22,7 @@
|
||||||
// https://gjs-docs.gnome.org/st10~1.0_api/st.widget
|
// https://gjs-docs.gnome.org/st10~1.0_api/st.widget
|
||||||
// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/panelMenu.js
|
// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/panelMenu.js
|
||||||
// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/popupMenu.js
|
// https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/popupMenu.js
|
||||||
|
//https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/panel.js
|
||||||
const St = imports.gi.St;
|
const St = imports.gi.St;
|
||||||
const Gio = imports.gi.Gio;
|
const Gio = imports.gi.Gio;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
|
@ -66,11 +67,13 @@ var MonitorWidget = GObject.registerClass({
|
||||||
},
|
},
|
||||||
class MonitorWidget extends PanelMenu.Button {
|
class MonitorWidget extends PanelMenu.Button {
|
||||||
|
|
||||||
_init(item, group, lastWidget) {
|
|
||||||
|
_init(item, group, position) {
|
||||||
super._init(0.0);
|
super._init(0.0);
|
||||||
|
|
||||||
this.name = item['name'];
|
this.name = item['name'];
|
||||||
this.group = group;
|
this.group = group;
|
||||||
|
this.fullname = this.name + '@' + this.group;
|
||||||
|
|
||||||
if (item.hasOwnProperty('icon'))
|
if (item.hasOwnProperty('icon'))
|
||||||
{
|
{
|
||||||
|
@ -105,8 +108,15 @@ class MonitorWidget extends PanelMenu.Button {
|
||||||
|
|
||||||
this.connect('enter-event', this._onEnter.bind(this));
|
this.connect('enter-event', this._onEnter.bind(this));
|
||||||
this.connect('leave-event', this._onLeave.bind(this));
|
this.connect('leave-event', this._onLeave.bind(this));
|
||||||
|
this.connect('style-changed', this._onStyleChanged.bind(this));
|
||||||
|
|
||||||
Main.panel.addToStatusArea(group, this, (lastWidget>0)?lastWidget:-1, box);
|
Main.panel.addToStatusArea(this.fullname, this, position, box);
|
||||||
|
}
|
||||||
|
|
||||||
|
_onStyleChanged(actor) {
|
||||||
|
// Force these values to avoid big spaces between each widgets
|
||||||
|
this._minHPadding = 1;
|
||||||
|
this._natHPadding = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_onEnter() {
|
_onEnter() {
|
||||||
|
@ -473,8 +483,22 @@ class GenericMonitorDBUS {
|
||||||
|
|
||||||
// New widget
|
// New widget
|
||||||
if (monitorWidget === null) {
|
if (monitorWidget === null) {
|
||||||
let lastWidget = group.length - 1;
|
let position = group.length - 1;
|
||||||
monitorWidget = new MonitorWidget(item, groupName, lastWidget);
|
// Find real position
|
||||||
|
if (position != -1) {
|
||||||
|
let lastWidget = group[position].container;
|
||||||
|
let childrens = lastWidget.get_parent().get_children();
|
||||||
|
for(;position < childrens.length; position++)
|
||||||
|
{
|
||||||
|
if (childrens[position] == lastWidget) {
|
||||||
|
position++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (position >= childrens.length)
|
||||||
|
position = -1;
|
||||||
|
}
|
||||||
|
monitorWidget = new MonitorWidget(item, groupName, position);
|
||||||
group.push(monitorWidget);
|
group.push(monitorWidget);
|
||||||
// Connect signals
|
// Connect signals
|
||||||
// if (onClick !== '') {
|
// if (onClick !== '') {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user