From 3b8e8a16d78aff071ebcf8f01a154125a708f940 Mon Sep 17 00:00:00 2001 From: Jerry Date: Mon, 1 Nov 2021 14:36:10 +0800 Subject: [PATCH] version 3, add changed signal for settings and change opacity --- Makefile | 5 ++++ README.md | 2 +- activate_gnome@isjerryxiao/Makefile | 2 -- activate_gnome@isjerryxiao/extension.js | 24 ++++++++++++------- activate_gnome@isjerryxiao/metadata.json | 4 ++-- activate_gnome@isjerryxiao/prefs.js | 1 - ...hell.extensions.activate_gnome.gschema.xml | 2 +- activate_gnome@isjerryxiao/stylesheet.css | 4 ++-- 8 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 Makefile delete mode 100644 activate_gnome@isjerryxiao/Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7c29a4a --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +schemdir = ./activate_gnome@isjerryxiao/schemas +$(schemdir)/gschemas.compiled: $(schemdir)/org.gnome.shell.extensions.activate_gnome.gschema.xml + glib-compile-schemas $(schemdir)/ +clean: + rm $(schemdir)/gschemas.compiled diff --git a/README.md b/README.md index fdff7d8..d724240 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A gnome-shell extension to show 'Activate Gnome' watermark. ## Installation ``` git clone https://github.com/isjerryxiao/gnome-shell-extension-activate-gnome activate_gnome -make -C activate_gnome/activate_gnome@isjerryxiao +make -C activate_gnome ln -s $(realpath activate_gnome/activate_gnome@isjerryxiao) ~/.local/share/gnome-shell/extensions/ ``` diff --git a/activate_gnome@isjerryxiao/Makefile b/activate_gnome@isjerryxiao/Makefile deleted file mode 100644 index 0afaeb6..0000000 --- a/activate_gnome@isjerryxiao/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -./schemas/gschemas.compiled: ./schemas/org.gnome.shell.extensions.activate_gnome.gschema.xml - glib-compile-schemas ./schemas/ diff --git a/activate_gnome@isjerryxiao/extension.js b/activate_gnome@isjerryxiao/extension.js index 4b41a1a..721bd09 100644 --- a/activate_gnome@isjerryxiao/extension.js +++ b/activate_gnome@isjerryxiao/extension.js @@ -28,11 +28,18 @@ class Extension { this.label_2 = null this.loaded = 0 this.settings = null + this.handler_id = null } update() { if (this.label_1 && this.label_2) { - let [text1, text2, vl2, hl2] = this.settings + let settings = this.settings + 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.label_1.text = text1 + this.label_2.text = text2 let monitor = Main.layoutManager.primaryMonitor let h = Math.floor(monitor.height * vl2 - this.label_2.height) let w = Math.floor(monitor.width * hl2 - this.label_2.width) @@ -44,15 +51,12 @@ class Extension { } } } + enable() { - let settings = ExtensionUtils.getSettings(Me.metadata['settings-schema']) - 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 }) + this.settings = ExtensionUtils.getSettings(Me.metadata['settings-schema']) + this.handler_id = this.settings.connect('changed', () => this.update()) + this.label_2 = new St.Label({ style_class: 'label-2', text: '' }) + this.label_1 = new St.Label({ style_class: 'label-1', text: '' }) Main.layoutManager.addTopChrome(this.label_2, {"trackFullscreen": false}) Main.layoutManager.addTopChrome(this.label_1, {"trackFullscreen": false}) this.update() @@ -65,7 +69,9 @@ class Extension { this.label_2.destroy() this.label_1 = null this.label_2 = null + this.settings.disconnect(this.handler_id) this.settings = null + this.handler_id = null } } diff --git a/activate_gnome@isjerryxiao/metadata.json b/activate_gnome@isjerryxiao/metadata.json index ace37ef..1dabeb0 100644 --- a/activate_gnome@isjerryxiao/metadata.json +++ b/activate_gnome@isjerryxiao/metadata.json @@ -1,5 +1,5 @@ { - "name": "activate_gnome", + "name": "Activate Gnome", "description": "Shows Activate Gnome watermark on your screen.", "uuid": "activate_gnome@isjerryxiao", "settings-schema": "org.gnome.shell.extensions.activate_gnome", @@ -7,6 +7,6 @@ "40", "41" ], - "version": 2, + "version": 3, "url": "https://github.com/isjerryxiao/gnome-shell-extension-activate-gnome" } diff --git a/activate_gnome@isjerryxiao/prefs.js b/activate_gnome@isjerryxiao/prefs.js index e76a136..50d5ed5 100644 --- a/activate_gnome@isjerryxiao/prefs.js +++ b/activate_gnome@isjerryxiao/prefs.js @@ -4,7 +4,6 @@ const Gtk = imports.gi.Gtk const ExtensionUtils = imports.misc.extensionUtils const Me = ExtensionUtils.getCurrentExtension() - function init() { } diff --git a/activate_gnome@isjerryxiao/schemas/org.gnome.shell.extensions.activate_gnome.gschema.xml b/activate_gnome@isjerryxiao/schemas/org.gnome.shell.extensions.activate_gnome.gschema.xml index b1e6dbc..4585131 100644 --- a/activate_gnome@isjerryxiao/schemas/org.gnome.shell.extensions.activate_gnome.gschema.xml +++ b/activate_gnome@isjerryxiao/schemas/org.gnome.shell.extensions.activate_gnome.gschema.xml @@ -15,7 +15,7 @@ Vertical position of line 2 - 0.9 + 0.92 Horizontal position of line 2 diff --git a/activate_gnome@isjerryxiao/stylesheet.css b/activate_gnome@isjerryxiao/stylesheet.css index e96fbd5..4149348 100644 --- a/activate_gnome@isjerryxiao/stylesheet.css +++ b/activate_gnome@isjerryxiao/stylesheet.css @@ -2,14 +2,14 @@ .label-1 { font-size: 36px; font-weight: normal; - color: rgba(255, 255, 255, 0.3); + color: rgba(255, 255, 255, 0.4); background-color: rgba(10, 10, 10, 0); border-radius: 5px; } .label-2 { font-size: 26px; font-weight: normal; - color: rgba(255, 255, 255, 0.3); + color: rgba(255, 255, 255, 0.4); background-color: rgba(10, 10, 10, 0); border-radius: 5px; }