From 2d04d3fdba27483f3bb5660263b5017e3c431d69 Mon Sep 17 00:00:00 2001 From: Jerry Date: Sun, 31 Oct 2021 21:40:24 +0800 Subject: [PATCH] version 2 --- activate_gnome@isjerryxiao/extension.js | 21 ++++++++++++--------- activate_gnome@isjerryxiao/metadata.json | 4 ++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/activate_gnome@isjerryxiao/extension.js b/activate_gnome@isjerryxiao/extension.js index 73e6b1e..4b41a1a 100644 --- a/activate_gnome@isjerryxiao/extension.js +++ b/activate_gnome@isjerryxiao/extension.js @@ -16,9 +16,9 @@ * SPDX-License-Identifier: GPL-3.0-or-later * / /* exported init */ -const St = imports.gi.St; -const Main = imports.ui.main; -const Mainloop = imports.mainloop; +const St = imports.gi.St +const Main = imports.ui.main +const Mainloop = imports.mainloop const ExtensionUtils = imports.misc.extensionUtils const Me = ExtensionUtils.getCurrentExtension() @@ -38,15 +38,18 @@ class Extension { let w = Math.floor(monitor.width * hl2 - this.label_2.width) this.label_2.set_position(w, h) 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() { let settings = ExtensionUtils.getSettings(Me.metadata['settings-schema']) - let text1 = settings.get_string('text-l1') || settings.get_default().get_string('text-l1') - let text2 = settings.get_string('text-l2') || settings.get_default().get_string('text-l2') - let vl2 = settings.get_double('l2-vertical') || settings.get_default().get_double('l2-vertical') - let hl2 = settings.get_double('l2-horizontal') || settings.get_default().get_double('l2-horizontal') + 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_value('text-l2').get_string() + 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_value('l2-horizontal').get_double() this.settings = [text1, text2, vl2, hl2] this.label_2 = new St.Label({ style_class: 'label-2', text: text2 }) this.label_1 = new St.Label({ style_class: 'label-1', text: text1 }) @@ -67,6 +70,6 @@ class Extension { } function init() { - log(`initializing ${Me.metadata.name}`); + log(`initializing ${Me.metadata.name}`) return new Extension() } diff --git a/activate_gnome@isjerryxiao/metadata.json b/activate_gnome@isjerryxiao/metadata.json index 7f6f91a..ace37ef 100644 --- a/activate_gnome@isjerryxiao/metadata.json +++ b/activate_gnome@isjerryxiao/metadata.json @@ -7,6 +7,6 @@ "40", "41" ], - "version": 1, - "url": "https://github.com/isjerryxiao/activate_gnome" + "version": 2, + "url": "https://github.com/isjerryxiao/gnome-shell-extension-activate-gnome" }