diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3ee62eb
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+activate_gnome@isjerryxiao/schemas/gschemas.compiled
diff --git a/README.md b/README.md
index 46660ba..043a00e 100644
--- a/README.md
+++ b/README.md
@@ -3,5 +3,12 @@
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
+ln -s $(realpath activate_gnome/activate_gnome@isjerryxiao) ~/.local/share/gnome-shell/extensions/
+```
+
## Contributing
* Copyright © 2021 JerryXiao
diff --git a/activate_gnome@isjerryxiao/Makefile b/activate_gnome@isjerryxiao/Makefile
new file mode 100644
index 0000000..0afaeb6
--- /dev/null
+++ b/activate_gnome@isjerryxiao/Makefile
@@ -0,0 +1,2 @@
+./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 68e09eb..73e6b1e 100644
--- a/activate_gnome@isjerryxiao/extension.js
+++ b/activate_gnome@isjerryxiao/extension.js
@@ -2,7 +2,7 @@
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
+ * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@@ -11,14 +11,14 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
+ * along with this program. If not, see .
*
- * SPDX-License-Identifier: GPL-2.0-or-later
- */
-
+ * 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 ExtensionUtils = imports.misc.extensionUtils
const Me = ExtensionUtils.getCurrentExtension()
@@ -26,20 +26,33 @@ class Extension {
constructor() {
this.label_1 = null
this.label_2 = null
+ this.loaded = 0
+ this.settings = null
}
+ update() {
+ if (this.label_1 && this.label_2) {
+ let [text1, text2, vl2, hl2] = this.settings
+ 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)
+ 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())
+ }
+ }
enable() {
- let text1 = "Activate Gnome";
- let text2 = "Go to Settings to activate Gnome."
- this.label_1 = new St.Label({ style_class: 'label-1', text: text1 })
+ 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')
+ this.settings = [text1, text2, vl2, hl2]
this.label_2 = new St.Label({ style_class: 'label-2', text: text2 })
- let monitor = Main.layoutManager.primaryMonitor
+ this.label_1 = new St.Label({ style_class: 'label-1', text: text1 })
Main.layoutManager.addTopChrome(this.label_2, {"trackFullscreen": false})
- let h = Math.floor(monitor.height / 18 * 17 - this.label_2.height)
- let w = Math.floor(monitor.width / 10 * 9 - this.label_2.width)
- this.label_2.set_position(w, h)
Main.layoutManager.addTopChrome(this.label_1, {"trackFullscreen": false})
- this.label_1.set_position(w, h - this.label_1.height)
+ this.update()
}
disable() {
@@ -49,9 +62,11 @@ class Extension {
this.label_2.destroy()
this.label_1 = null
this.label_2 = null
+ this.settings = null
}
}
function init() {
+ log(`initializing ${Me.metadata.name}`);
return new Extension()
}
diff --git a/activate_gnome@isjerryxiao/metadata.json b/activate_gnome@isjerryxiao/metadata.json
index 73693ab..7f6f91a 100644
--- a/activate_gnome@isjerryxiao/metadata.json
+++ b/activate_gnome@isjerryxiao/metadata.json
@@ -1,11 +1,12 @@
{
- "name": "activate_gnome",
- "description": "Shows Activate Gnome watermark on your screen.",
- "uuid": "activate_gnome@isjerryxiao",
- "shell-version": [
- "40",
- "41"
- ],
- "version": 1,
- "url": "https://github.com/isjerryxiao/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",
+ "shell-version": [
+ "40",
+ "41"
+ ],
+ "version": 1,
+ "url": "https://github.com/isjerryxiao/activate_gnome"
}
diff --git a/activate_gnome@isjerryxiao/prefs.js b/activate_gnome@isjerryxiao/prefs.js
new file mode 100644
index 0000000..e76a136
--- /dev/null
+++ b/activate_gnome@isjerryxiao/prefs.js
@@ -0,0 +1,106 @@
+const Gio = imports.gi.Gio
+const Gtk = imports.gi.Gtk
+
+const ExtensionUtils = imports.misc.extensionUtils
+const Me = ExtensionUtils.getCurrentExtension()
+
+
+function init() {
+}
+
+function buildPrefsWidget() {
+ this.settings = ExtensionUtils.getSettings(Me.metadata['settings-schema'])
+
+ let prefsWidget = new Gtk.Box({
+ orientation: Gtk.Orientation.VERTICAL,
+ halign: Gtk.Align.CENTER,
+ spacing: 6,
+ margin_top: 12,
+ margin_bottom: 12,
+ margin_start: 6,
+ margin_end: 6,
+ })
+
+ // line 1
+ let l1label = new Gtk.Label({
+ label: 'Line 1',
+ margin_top: 6,
+ use_markup: true,
+ })
+ prefsWidget.append(l1label)
+
+ let l1entry = new Gtk.Entry({
+ margin_top: 6,
+ hexpand: true,
+ })
+ l1entry.set_width_chars(30)
+ prefsWidget.append(l1entry)
+
+ // line 2
+ let l2label = new Gtk.Label({
+ label: 'Line 2',
+ margin_top: 6,
+ use_markup: true,
+ })
+ prefsWidget.append(l2label)
+
+ let l2entry = new Gtk.Entry({
+ margin_top: 6,
+ hexpand: true,
+ })
+ l2entry.set_width_chars(30)
+ prefsWidget.append(l2entry)
+
+ // l2-vertical
+ let vlabel = new Gtk.Label({
+ label: 'Vertical Position',
+ margin_top: 12,
+ use_markup: true,
+ })
+ prefsWidget.append(vlabel)
+
+ let ventry = new Gtk.SpinButton({
+ margin_top: 6,
+ numeric: true,
+ digits: 4,
+ })
+ ventry.set_range(0.0, 1.0)
+ ventry.set_increments(0.01, 0.1)
+ prefsWidget.append(ventry)
+
+ // l2-horizontal
+ let hlabel = new Gtk.Label({
+ label: 'Horizontal Position',
+ margin_top: 6,
+ use_markup: true,
+ })
+ prefsWidget.append(hlabel)
+
+ let hentry = new Gtk.SpinButton({
+ margin_top: 6,
+ numeric: true,
+ digits: 4,
+ })
+ hentry.set_range(0.0, 1.0)
+ hentry.set_increments(0.01, 0.1)
+ prefsWidget.append(hentry)
+
+ let resetbtn = new Gtk.Button({
+ label: 'reset',
+ margin_top: 12,
+ })
+ resetbtn.connect('clicked', () => {
+ this.settings.reset('text-l1')
+ this.settings.reset('text-l2')
+ this.settings.reset('l2-vertical')
+ this.settings.reset('l2-horizontal')
+ })
+ prefsWidget.append(resetbtn)
+
+ this.settings.bind('text-l1', l1entry, 'text', Gio.SettingsBindFlags.DEFAULT)
+ this.settings.bind('text-l2', l2entry, 'text', Gio.SettingsBindFlags.DEFAULT)
+ this.settings.bind('l2-vertical', ventry, 'value', Gio.SettingsBindFlags.DEFAULT)
+ this.settings.bind('l2-horizontal', hentry, 'value', Gio.SettingsBindFlags.DEFAULT)
+
+ return prefsWidget
+}
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
new file mode 100644
index 0000000..b1e6dbc
--- /dev/null
+++ b/activate_gnome@isjerryxiao/schemas/org.gnome.shell.extensions.activate_gnome.gschema.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+ 'Activate Gnome'
+ Text to display on line 1
+
+
+ 'Go to Settings to activate Gnome.'
+ Text to display on line 2
+
+
+ 0.9444444444444444
+ Vertical position of line 2
+
+
+ 0.9
+ Horizontal position of line 2
+
+
+