version 3, add changed signal for settings and change opacity
This commit is contained in:
parent
2d04d3fdba
commit
3b8e8a16d7
8 changed files with 26 additions and 18 deletions
5
Makefile
Normal file
5
Makefile
Normal file
|
@ -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
|
|
@ -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/
|
||||
```
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
./schemas/gschemas.compiled: ./schemas/org.gnome.shell.extensions.activate_gnome.gschema.xml
|
||||
glib-compile-schemas ./schemas/
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ const Gtk = imports.gi.Gtk
|
|||
const ExtensionUtils = imports.misc.extensionUtils
|
||||
const Me = ExtensionUtils.getCurrentExtension()
|
||||
|
||||
|
||||
function init() {
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<summary>Vertical position of line 2</summary>
|
||||
</key>
|
||||
<key name="l2-horizontal" type="d">
|
||||
<default>0.9</default>
|
||||
<default>0.92</default>
|
||||
<summary>Horizontal position of line 2</summary>
|
||||
</key>
|
||||
</schema>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue