remove dirty hack
This commit is contained in:
parent
d2626b4c8c
commit
7a6e6d9b53
2 changed files with 25 additions and 21 deletions
|
@ -25,10 +25,8 @@ const Me = ExtensionUtils.getCurrentExtension()
|
||||||
class Extension {
|
class Extension {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.labels = []
|
this.labels = []
|
||||||
this.loaded = 0
|
|
||||||
this.settings = null
|
this.settings = null
|
||||||
this.settings_handler_id = null
|
this.handlers = []
|
||||||
this.monitors_handler_id = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
|
@ -51,19 +49,8 @@ class Extension {
|
||||||
let w = Math.max(0, Math.floor(monitor.width * hl2 - label_2.width))
|
let w = Math.max(0, Math.floor(monitor.width * hl2 - label_2.width))
|
||||||
label_2.set_position(monitor.x + w, monitor.y + h)
|
label_2.set_position(monitor.x + w, monitor.y + h)
|
||||||
label_1.set_position(Math.min(monitor.x + w, monitor.x + monitor.width - label_1.width), monitor.y + h - label_1.height)
|
label_1.set_position(Math.min(monitor.x + w, monitor.x + monitor.width - label_1.width), monitor.y + h - label_1.height)
|
||||||
if (this.loaded < 4) {
|
|
||||||
this.loaded++
|
|
||||||
Mainloop.timeout_add(1000, () => this.update())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
enable() {
|
|
||||||
this.settings = ExtensionUtils.getSettings(Me.metadata['settings-schema'])
|
|
||||||
this.settings_handler_id = this.settings.connect('changed', () => this.update())
|
|
||||||
this.monitors_handler_id = Main.layoutManager.connect('monitors-changed', () => this.update())
|
|
||||||
this.update()
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
for (let label of this.labels) {
|
for (let label of this.labels) {
|
||||||
|
@ -73,13 +60,30 @@ class Extension {
|
||||||
this.labels = []
|
this.labels = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enable() {
|
||||||
|
this.settings = ExtensionUtils.getSettings(Me.metadata['settings-schema'])
|
||||||
|
this.handlers.push({
|
||||||
|
owner: this.settings,
|
||||||
|
id: this.settings.connect('changed', () => this.update())
|
||||||
|
})
|
||||||
|
this.handlers.push({
|
||||||
|
owner: Main.layoutManager,
|
||||||
|
id: Main.layoutManager.connect('monitors-changed', () => this.update())
|
||||||
|
})
|
||||||
|
this.handlers.push({
|
||||||
|
owner: Main.layoutManager,
|
||||||
|
id: Main.layoutManager.connect('startup-complete', () => this.update())
|
||||||
|
})
|
||||||
|
this.update()
|
||||||
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
this.cleanup()
|
this.cleanup()
|
||||||
this.settings.disconnect(this.settings_handler_id)
|
for (let handler of this.handlers) {
|
||||||
Main.layoutManager.disconnect(this.monitors_handler_id)
|
handler.owner.disconnect(handler.id)
|
||||||
|
}
|
||||||
|
this.handlers = []
|
||||||
this.settings = null
|
this.settings = null
|
||||||
this.settings_handler_id = null
|
|
||||||
this.monitors_handler_id = null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,6 @@
|
||||||
"41",
|
"41",
|
||||||
"42"
|
"42"
|
||||||
],
|
],
|
||||||
"version": 4,
|
"version": 5,
|
||||||
"url": "https://github.com/isjerryxiao/gnome-shell-extension-activate-gnome"
|
"url": "https://github.com/isjerryxiao/gnome-shell-extension-activate-gnome"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue