version 2

This commit is contained in:
JerryXiao 2021-10-31 21:40:24 +08:00
parent 3e811e562c
commit 2d04d3fdba
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5
2 changed files with 14 additions and 11 deletions

View file

@ -16,9 +16,9 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
* / * /
/* exported init */ /* exported init */
const St = imports.gi.St; const St = imports.gi.St
const Main = imports.ui.main; const Main = imports.ui.main
const Mainloop = imports.mainloop; const Mainloop = imports.mainloop
const ExtensionUtils = imports.misc.extensionUtils const ExtensionUtils = imports.misc.extensionUtils
const Me = ExtensionUtils.getCurrentExtension() const Me = ExtensionUtils.getCurrentExtension()
@ -38,15 +38,18 @@ class Extension {
let w = Math.floor(monitor.width * hl2 - this.label_2.width) let w = Math.floor(monitor.width * hl2 - this.label_2.width)
this.label_2.set_position(w, h) this.label_2.set_position(w, h)
this.label_1.set_position(w, h - this.label_1.height) this.label_1.set_position(w, h - this.label_1.height)
if (this.loaded++ < 4) Mainloop.timeout_add(1000, () => this.update()) if (this.loaded < 4) {
this.loaded++
Mainloop.timeout_add(1000, () => this.update())
}
} }
} }
enable() { enable() {
let settings = ExtensionUtils.getSettings(Me.metadata['settings-schema']) let settings = ExtensionUtils.getSettings(Me.metadata['settings-schema'])
let text1 = settings.get_string('text-l1') || settings.get_default().get_string('text-l1') let text1 = settings.get_string('text-l1') || settings.get_default_value('text-l1').get_string()
let text2 = settings.get_string('text-l2') || settings.get_default().get_string('text-l2') let text2 = settings.get_string('text-l2') || settings.get_default_value('text-l2').get_string()
let vl2 = settings.get_double('l2-vertical') || settings.get_default().get_double('l2-vertical') let vl2 = settings.get_double('l2-vertical') || settings.get_default_value('l2-vertical').get_double()
let hl2 = settings.get_double('l2-horizontal') || settings.get_default().get_double('l2-horizontal') let hl2 = settings.get_double('l2-horizontal') || settings.get_default_value('l2-horizontal').get_double()
this.settings = [text1, text2, vl2, hl2] this.settings = [text1, text2, vl2, hl2]
this.label_2 = new St.Label({ style_class: 'label-2', text: text2 }) this.label_2 = new St.Label({ style_class: 'label-2', text: text2 })
this.label_1 = new St.Label({ style_class: 'label-1', text: text1 }) this.label_1 = new St.Label({ style_class: 'label-1', text: text1 })
@ -67,6 +70,6 @@ class Extension {
} }
function init() { function init() {
log(`initializing ${Me.metadata.name}`); log(`initializing ${Me.metadata.name}`)
return new Extension() return new Extension()
} }

View file

@ -7,6 +7,6 @@
"40", "40",
"41" "41"
], ],
"version": 1, "version": 2,
"url": "https://github.com/isjerryxiao/activate_gnome" "url": "https://github.com/isjerryxiao/gnome-shell-extension-activate-gnome"
} }