gnome 45, version 10
This commit is contained in:
parent
62f9ad1cd3
commit
7f394453c8
3 changed files with 171 additions and 176 deletions
|
@ -14,16 +14,15 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-3.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()
|
|
||||||
|
|
||||||
class Extension {
|
import St from 'gi://St'
|
||||||
constructor() {
|
import * as Main from 'resource:///org/gnome/shell/ui/main.js'
|
||||||
|
import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js'
|
||||||
|
|
||||||
|
export default class ActivateGnomeExtension extends Extension {
|
||||||
|
constructor(metadata) {
|
||||||
|
super(metadata)
|
||||||
this.labels = []
|
this.labels = []
|
||||||
this.settings = null
|
this.settings = null
|
||||||
this.handlers = []
|
this.handlers = []
|
||||||
|
@ -65,7 +64,7 @@ class Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
this.settings = ExtensionUtils.getSettings(Me.metadata['settings-schema'])
|
this.settings = this.getSettings()
|
||||||
this.handlers.push({
|
this.handlers.push({
|
||||||
owner: this.settings,
|
owner: this.settings,
|
||||||
id: this.settings.connect('changed', () => this.update())
|
id: this.settings.connect('changed', () => this.update())
|
||||||
|
@ -90,8 +89,3 @@ class Extension {
|
||||||
this.settings = null
|
this.settings = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
|
||||||
log(`initializing ${Me.metadata.name}`)
|
|
||||||
return new Extension()
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,12 +4,8 @@
|
||||||
"uuid": "activate_gnome@isjerryxiao",
|
"uuid": "activate_gnome@isjerryxiao",
|
||||||
"settings-schema": "org.gnome.shell.extensions.activate_gnome",
|
"settings-schema": "org.gnome.shell.extensions.activate_gnome",
|
||||||
"shell-version": [
|
"shell-version": [
|
||||||
"40",
|
"45"
|
||||||
"41",
|
|
||||||
"42",
|
|
||||||
"43",
|
|
||||||
"44"
|
|
||||||
],
|
],
|
||||||
"version": 9,
|
"version": 10,
|
||||||
"url": "https://github.com/isjerryxiao/gnome-shell-extension-activate-gnome"
|
"url": "https://github.com/isjerryxiao/gnome-shell-extension-activate-gnome"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,158 +1,163 @@
|
||||||
const Gio = imports.gi.Gio
|
import Gio from 'gi://Gio'
|
||||||
const Gtk = imports.gi.Gtk
|
import Gtk from 'gi://Gtk'
|
||||||
|
import Adw from 'gi://Adw'
|
||||||
|
|
||||||
const ExtensionUtils = imports.misc.extensionUtils
|
import { ExtensionPreferences } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'
|
||||||
const Me = ExtensionUtils.getCurrentExtension()
|
|
||||||
|
|
||||||
function init() {
|
export default class ActivateGnomeExtensionPreferences extends ExtensionPreferences {
|
||||||
}
|
fillPreferencesWindow(window) {
|
||||||
|
const page = new Adw.PreferencesPage()
|
||||||
function buildPrefsWidget() {
|
window.add(page)
|
||||||
this.settings = ExtensionUtils.getSettings(Me.metadata['settings-schema'])
|
|
||||||
|
const group = new Adw.PreferencesGroup()
|
||||||
let prefsWidget = new Gtk.Box({
|
page.add(group)
|
||||||
orientation: Gtk.Orientation.VERTICAL,
|
|
||||||
halign: Gtk.Align.CENTER,
|
this.settings = this.getSettings()
|
||||||
spacing: 6,
|
|
||||||
margin_top: 12,
|
let prefsWidget = new Gtk.Box({
|
||||||
margin_bottom: 12,
|
orientation: Gtk.Orientation.VERTICAL,
|
||||||
margin_start: 6,
|
halign: Gtk.Align.CENTER,
|
||||||
margin_end: 6,
|
spacing: 6,
|
||||||
})
|
margin_top: 12,
|
||||||
|
margin_bottom: 12,
|
||||||
// line 1
|
margin_start: 6,
|
||||||
let label_line_1 = new Gtk.Label({
|
margin_end: 6,
|
||||||
label: '<b>Line 1</b>',
|
})
|
||||||
margin_top: 6,
|
|
||||||
use_markup: true,
|
// line 1
|
||||||
})
|
let label_line_1 = new Gtk.Label({
|
||||||
prefsWidget.append(label_line_1)
|
label: '<b>Line 1</b>',
|
||||||
|
margin_top: 6,
|
||||||
let entry_line_1 = new Gtk.Entry({
|
use_markup: true,
|
||||||
margin_top: 6,
|
})
|
||||||
hexpand: true,
|
prefsWidget.append(label_line_1)
|
||||||
})
|
|
||||||
entry_line_1.set_width_chars(30)
|
let entry_line_1 = new Gtk.Entry({
|
||||||
prefsWidget.append(entry_line_1)
|
margin_top: 6,
|
||||||
|
hexpand: true,
|
||||||
// line 2
|
})
|
||||||
let label_line_2 = new Gtk.Label({
|
entry_line_1.set_width_chars(30)
|
||||||
label: '<b>Line 2</b>',
|
prefsWidget.append(entry_line_1)
|
||||||
margin_top: 6,
|
|
||||||
use_markup: true,
|
// line 2
|
||||||
})
|
let label_line_2 = new Gtk.Label({
|
||||||
prefsWidget.append(label_line_2)
|
label: '<b>Line 2</b>',
|
||||||
|
margin_top: 6,
|
||||||
let entry_line_2 = new Gtk.Entry({
|
use_markup: true,
|
||||||
margin_top: 6,
|
})
|
||||||
hexpand: true,
|
prefsWidget.append(label_line_2)
|
||||||
})
|
|
||||||
entry_line_2.set_width_chars(30)
|
let entry_line_2 = new Gtk.Entry({
|
||||||
prefsWidget.append(entry_line_2)
|
margin_top: 6,
|
||||||
|
hexpand: true,
|
||||||
// line 2 vertical position
|
})
|
||||||
let label_line_2_vertical_position = new Gtk.Label({
|
entry_line_2.set_width_chars(30)
|
||||||
label: '<b>Vertical Position</b>',
|
prefsWidget.append(entry_line_2)
|
||||||
margin_top: 12,
|
|
||||||
use_markup: true,
|
// line 2 vertical position
|
||||||
})
|
let label_line_2_vertical_position = new Gtk.Label({
|
||||||
prefsWidget.append(label_line_2_vertical_position)
|
label: '<b>Vertical Position</b>',
|
||||||
|
margin_top: 12,
|
||||||
let scale_line_2_vertical_position = new Gtk.Scale({
|
use_markup: true,
|
||||||
adjustment: new Gtk.Adjustment({lower: 0.01, upper: 1.0, step_increment: 0.01, page_increment: 0.1}),
|
})
|
||||||
margin_top: 6,
|
prefsWidget.append(label_line_2_vertical_position)
|
||||||
draw_value: false,
|
|
||||||
digits: 4,
|
let scale_line_2_vertical_position = new Gtk.Scale({
|
||||||
})
|
adjustment: new Gtk.Adjustment({lower: 0.01, upper: 1.0, step_increment: 0.01, page_increment: 0.1}),
|
||||||
prefsWidget.append(scale_line_2_vertical_position)
|
margin_top: 6,
|
||||||
|
draw_value: false,
|
||||||
// line 2 horizontal position
|
digits: 4,
|
||||||
let label_line_2_horizontal_position = new Gtk.Label({
|
})
|
||||||
label: '<b>Horizontal Position</b>',
|
prefsWidget.append(scale_line_2_vertical_position)
|
||||||
margin_top: 6,
|
|
||||||
use_markup: true,
|
// line 2 horizontal position
|
||||||
})
|
let label_line_2_horizontal_position = new Gtk.Label({
|
||||||
prefsWidget.append(label_line_2_horizontal_position)
|
label: '<b>Horizontal Position</b>',
|
||||||
|
margin_top: 6,
|
||||||
let scale_line_2_horizontal_position = new Gtk.Scale({
|
use_markup: true,
|
||||||
adjustment: new Gtk.Adjustment({lower: 0.01, upper: 1.0, step_increment: 0.01, page_increment: 0.1}),
|
})
|
||||||
margin_top: 6,
|
prefsWidget.append(label_line_2_horizontal_position)
|
||||||
draw_value: false,
|
|
||||||
digits: 4,
|
let scale_line_2_horizontal_position = new Gtk.Scale({
|
||||||
})
|
adjustment: new Gtk.Adjustment({lower: 0.01, upper: 1.0, step_increment: 0.01, page_increment: 0.1}),
|
||||||
prefsWidget.append(scale_line_2_horizontal_position)
|
margin_top: 6,
|
||||||
|
draw_value: false,
|
||||||
// line 1 text size
|
digits: 4,
|
||||||
let label_line_1_text_size = new Gtk.Label({
|
})
|
||||||
label: '<b>Line 1 Text Size</b>',
|
prefsWidget.append(scale_line_2_horizontal_position)
|
||||||
margin_top: 12,
|
|
||||||
use_markup: true,
|
// line 1 text size
|
||||||
})
|
let label_line_1_text_size = new Gtk.Label({
|
||||||
prefsWidget.append(label_line_1_text_size)
|
label: '<b>Line 1 Text Size</b>',
|
||||||
|
margin_top: 12,
|
||||||
let spinbutton_line_1_text_size = new Gtk.SpinButton({
|
use_markup: true,
|
||||||
adjustment: new Gtk.Adjustment({lower: 1.0, upper: 65535.0, step_increment: 1.0, page_increment: 10.0}),
|
})
|
||||||
margin_top: 6,
|
prefsWidget.append(label_line_1_text_size)
|
||||||
numeric: true,
|
|
||||||
digits: 1,
|
let spinbutton_line_1_text_size = new Gtk.SpinButton({
|
||||||
})
|
adjustment: new Gtk.Adjustment({lower: 1.0, upper: 65535.0, step_increment: 1.0, page_increment: 10.0}),
|
||||||
prefsWidget.append(spinbutton_line_1_text_size)
|
margin_top: 6,
|
||||||
|
numeric: true,
|
||||||
// line 2 text size
|
digits: 1,
|
||||||
let label_line_2_text_size = new Gtk.Label({
|
})
|
||||||
label: '<b>Line 2 Text Size</b>',
|
prefsWidget.append(spinbutton_line_1_text_size)
|
||||||
margin_top: 6,
|
|
||||||
use_markup: true,
|
// line 2 text size
|
||||||
})
|
let label_line_2_text_size = new Gtk.Label({
|
||||||
prefsWidget.append(label_line_2_text_size)
|
label: '<b>Line 2 Text Size</b>',
|
||||||
|
margin_top: 6,
|
||||||
let spinbutton_line_2_text_size = new Gtk.SpinButton({
|
use_markup: true,
|
||||||
adjustment: new Gtk.Adjustment({lower: 1.0, upper: 65535.0, step_increment: 1.0, page_increment: 10.0}),
|
})
|
||||||
margin_top: 6,
|
prefsWidget.append(label_line_2_text_size)
|
||||||
numeric: true,
|
|
||||||
digits: 1,
|
let spinbutton_line_2_text_size = new Gtk.SpinButton({
|
||||||
})
|
adjustment: new Gtk.Adjustment({lower: 1.0, upper: 65535.0, step_increment: 1.0, page_increment: 10.0}),
|
||||||
prefsWidget.append(spinbutton_line_2_text_size)
|
margin_top: 6,
|
||||||
|
numeric: true,
|
||||||
// opacity
|
digits: 1,
|
||||||
let label_opacity = new Gtk.Label({
|
})
|
||||||
label: '<b>Opacity</b>',
|
prefsWidget.append(spinbutton_line_2_text_size)
|
||||||
margin_top: 6,
|
|
||||||
use_markup: true,
|
// opacity
|
||||||
})
|
let label_opacity = new Gtk.Label({
|
||||||
prefsWidget.append(label_opacity)
|
label: '<b>Opacity</b>',
|
||||||
|
margin_top: 6,
|
||||||
let scale_opacity = new Gtk.Scale({
|
use_markup: true,
|
||||||
adjustment: new Gtk.Adjustment({lower: 0.1, upper: 255, step_increment: 0.1, page_increment: 1}),
|
})
|
||||||
margin_top: 6,
|
prefsWidget.append(label_opacity)
|
||||||
draw_value: false,
|
|
||||||
digits: 1,
|
let scale_opacity = new Gtk.Scale({
|
||||||
})
|
adjustment: new Gtk.Adjustment({lower: 0.1, upper: 255, step_increment: 0.1, page_increment: 1}),
|
||||||
prefsWidget.append(scale_opacity)
|
margin_top: 6,
|
||||||
|
draw_value: false,
|
||||||
let button_reset = new Gtk.Button({
|
digits: 1,
|
||||||
label: 'reset',
|
})
|
||||||
margin_top: 12,
|
prefsWidget.append(scale_opacity)
|
||||||
margin_bottom: 6,
|
|
||||||
})
|
let button_reset = new Gtk.Button({
|
||||||
button_reset.connect('clicked', () => {
|
label: 'reset',
|
||||||
this.settings.reset('text-l1')
|
margin_top: 12,
|
||||||
this.settings.reset('text-l2')
|
margin_bottom: 6,
|
||||||
this.settings.reset('l2-vertical')
|
})
|
||||||
this.settings.reset('l2-horizontal')
|
button_reset.connect('clicked', () => {
|
||||||
this.settings.reset('size-l1')
|
this.settings.reset('text-l1')
|
||||||
this.settings.reset('size-l2')
|
this.settings.reset('text-l2')
|
||||||
this.settings.reset('opacity')
|
this.settings.reset('l2-vertical')
|
||||||
})
|
this.settings.reset('l2-horizontal')
|
||||||
prefsWidget.append(button_reset)
|
this.settings.reset('size-l1')
|
||||||
|
this.settings.reset('size-l2')
|
||||||
this.settings.bind('text-l1', entry_line_1, 'text', Gio.SettingsBindFlags.DEFAULT)
|
this.settings.reset('opacity')
|
||||||
this.settings.bind('text-l2', entry_line_2, 'text', Gio.SettingsBindFlags.DEFAULT)
|
})
|
||||||
this.settings.bind('l2-vertical', scale_line_2_vertical_position.adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
prefsWidget.append(button_reset)
|
||||||
this.settings.bind('l2-horizontal', scale_line_2_horizontal_position.adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
|
||||||
this.settings.bind('size-l1', spinbutton_line_1_text_size.adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
this.settings.bind('text-l1', entry_line_1, 'text', Gio.SettingsBindFlags.DEFAULT)
|
||||||
this.settings.bind('size-l2', spinbutton_line_2_text_size.adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
this.settings.bind('text-l2', entry_line_2, 'text', Gio.SettingsBindFlags.DEFAULT)
|
||||||
this.settings.bind('opacity', scale_opacity.adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
this.settings.bind('l2-vertical', scale_line_2_vertical_position.adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
this.settings.bind('l2-horizontal', scale_line_2_horizontal_position.adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
||||||
return prefsWidget
|
this.settings.bind('size-l1', spinbutton_line_1_text_size.adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
this.settings.bind('size-l2', spinbutton_line_2_text_size.adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
this.settings.bind('opacity', scale_opacity.adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
|
||||||
|
|
||||||
|
group.add(prefsWidget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue