gnome 45, version 10

This commit is contained in:
JerryXiao 2023-09-20 10:37:03 +08:00
parent 62f9ad1cd3
commit 7f394453c8
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5
3 changed files with 171 additions and 176 deletions

View file

@ -14,16 +14,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* 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 {
constructor() {
import St from 'gi://St'
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.settings = null
this.handlers = []
@ -65,7 +64,7 @@ class Extension {
}
enable() {
this.settings = ExtensionUtils.getSettings(Me.metadata['settings-schema'])
this.settings = this.getSettings()
this.handlers.push({
owner: this.settings,
id: this.settings.connect('changed', () => this.update())
@ -90,8 +89,3 @@ class Extension {
this.settings = null
}
}
function init() {
log(`initializing ${Me.metadata.name}`)
return new Extension()
}

View file

@ -4,12 +4,8 @@
"uuid": "activate_gnome@isjerryxiao",
"settings-schema": "org.gnome.shell.extensions.activate_gnome",
"shell-version": [
"40",
"41",
"42",
"43",
"44"
"45"
],
"version": 9,
"version": 10,
"url": "https://github.com/isjerryxiao/gnome-shell-extension-activate-gnome"
}

View file

@ -1,158 +1,163 @@
const Gio = imports.gi.Gio
const Gtk = imports.gi.Gtk
import Gio from 'gi://Gio'
import Gtk from 'gi://Gtk'
import Adw from 'gi://Adw'
const ExtensionUtils = imports.misc.extensionUtils
const Me = ExtensionUtils.getCurrentExtension()
import { ExtensionPreferences } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'
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 label_line_1 = new Gtk.Label({
label: '<b>Line 1</b>',
margin_top: 6,
use_markup: true,
})
prefsWidget.append(label_line_1)
let entry_line_1 = new Gtk.Entry({
margin_top: 6,
hexpand: true,
})
entry_line_1.set_width_chars(30)
prefsWidget.append(entry_line_1)
// line 2
let label_line_2 = new Gtk.Label({
label: '<b>Line 2</b>',
margin_top: 6,
use_markup: true,
})
prefsWidget.append(label_line_2)
let entry_line_2 = new Gtk.Entry({
margin_top: 6,
hexpand: true,
})
entry_line_2.set_width_chars(30)
prefsWidget.append(entry_line_2)
// line 2 vertical position
let label_line_2_vertical_position = new Gtk.Label({
label: '<b>Vertical Position</b>',
margin_top: 12,
use_markup: true,
})
prefsWidget.append(label_line_2_vertical_position)
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}),
margin_top: 6,
draw_value: false,
digits: 4,
})
prefsWidget.append(scale_line_2_vertical_position)
// line 2 horizontal position
let label_line_2_horizontal_position = new Gtk.Label({
label: '<b>Horizontal Position</b>',
margin_top: 6,
use_markup: true,
})
prefsWidget.append(label_line_2_horizontal_position)
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}),
margin_top: 6,
draw_value: false,
digits: 4,
})
prefsWidget.append(scale_line_2_horizontal_position)
// line 1 text size
let label_line_1_text_size = new Gtk.Label({
label: '<b>Line 1 Text Size</b>',
margin_top: 12,
use_markup: true,
})
prefsWidget.append(label_line_1_text_size)
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}),
margin_top: 6,
numeric: true,
digits: 1,
})
prefsWidget.append(spinbutton_line_1_text_size)
// line 2 text size
let label_line_2_text_size = new Gtk.Label({
label: '<b>Line 2 Text Size</b>',
margin_top: 6,
use_markup: true,
})
prefsWidget.append(label_line_2_text_size)
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}),
margin_top: 6,
numeric: true,
digits: 1,
})
prefsWidget.append(spinbutton_line_2_text_size)
// opacity
let label_opacity = new Gtk.Label({
label: '<b>Opacity</b>',
margin_top: 6,
use_markup: true,
})
prefsWidget.append(label_opacity)
let scale_opacity = new Gtk.Scale({
adjustment: new Gtk.Adjustment({lower: 0.1, upper: 255, step_increment: 0.1, page_increment: 1}),
margin_top: 6,
draw_value: false,
digits: 1,
})
prefsWidget.append(scale_opacity)
let button_reset = new Gtk.Button({
label: 'reset',
margin_top: 12,
margin_bottom: 6,
})
button_reset.connect('clicked', () => {
this.settings.reset('text-l1')
this.settings.reset('text-l2')
this.settings.reset('l2-vertical')
this.settings.reset('l2-horizontal')
this.settings.reset('size-l1')
this.settings.reset('size-l2')
this.settings.reset('opacity')
})
prefsWidget.append(button_reset)
this.settings.bind('text-l1', entry_line_1, 'text', Gio.SettingsBindFlags.DEFAULT)
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)
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('size-l2', spinbutton_line_2_text_size.adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
this.settings.bind('opacity', scale_opacity.adjustment, 'value', Gio.SettingsBindFlags.DEFAULT)
return prefsWidget
export default class ActivateGnomeExtensionPreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
const page = new Adw.PreferencesPage()
window.add(page)
const group = new Adw.PreferencesGroup()
page.add(group)
this.settings = this.getSettings()
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 label_line_1 = new Gtk.Label({
label: '<b>Line 1</b>',
margin_top: 6,
use_markup: true,
})
prefsWidget.append(label_line_1)
let entry_line_1 = new Gtk.Entry({
margin_top: 6,
hexpand: true,
})
entry_line_1.set_width_chars(30)
prefsWidget.append(entry_line_1)
// line 2
let label_line_2 = new Gtk.Label({
label: '<b>Line 2</b>',
margin_top: 6,
use_markup: true,
})
prefsWidget.append(label_line_2)
let entry_line_2 = new Gtk.Entry({
margin_top: 6,
hexpand: true,
})
entry_line_2.set_width_chars(30)
prefsWidget.append(entry_line_2)
// line 2 vertical position
let label_line_2_vertical_position = new Gtk.Label({
label: '<b>Vertical Position</b>',
margin_top: 12,
use_markup: true,
})
prefsWidget.append(label_line_2_vertical_position)
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}),
margin_top: 6,
draw_value: false,
digits: 4,
})
prefsWidget.append(scale_line_2_vertical_position)
// line 2 horizontal position
let label_line_2_horizontal_position = new Gtk.Label({
label: '<b>Horizontal Position</b>',
margin_top: 6,
use_markup: true,
})
prefsWidget.append(label_line_2_horizontal_position)
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}),
margin_top: 6,
draw_value: false,
digits: 4,
})
prefsWidget.append(scale_line_2_horizontal_position)
// line 1 text size
let label_line_1_text_size = new Gtk.Label({
label: '<b>Line 1 Text Size</b>',
margin_top: 12,
use_markup: true,
})
prefsWidget.append(label_line_1_text_size)
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}),
margin_top: 6,
numeric: true,
digits: 1,
})
prefsWidget.append(spinbutton_line_1_text_size)
// line 2 text size
let label_line_2_text_size = new Gtk.Label({
label: '<b>Line 2 Text Size</b>',
margin_top: 6,
use_markup: true,
})
prefsWidget.append(label_line_2_text_size)
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}),
margin_top: 6,
numeric: true,
digits: 1,
})
prefsWidget.append(spinbutton_line_2_text_size)
// opacity
let label_opacity = new Gtk.Label({
label: '<b>Opacity</b>',
margin_top: 6,
use_markup: true,
})
prefsWidget.append(label_opacity)
let scale_opacity = new Gtk.Scale({
adjustment: new Gtk.Adjustment({lower: 0.1, upper: 255, step_increment: 0.1, page_increment: 1}),
margin_top: 6,
draw_value: false,
digits: 1,
})
prefsWidget.append(scale_opacity)
let button_reset = new Gtk.Button({
label: 'reset',
margin_top: 12,
margin_bottom: 6,
})
button_reset.connect('clicked', () => {
this.settings.reset('text-l1')
this.settings.reset('text-l2')
this.settings.reset('l2-vertical')
this.settings.reset('l2-horizontal')
this.settings.reset('size-l1')
this.settings.reset('size-l2')
this.settings.reset('opacity')
})
prefsWidget.append(button_reset)
this.settings.bind('text-l1', entry_line_1, 'text', Gio.SettingsBindFlags.DEFAULT)
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)
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('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);
}
}