[gnome] Update gnome extensions

This commit is contained in:
2026-01-13 17:20:07 -05:00
parent 88bae496fd
commit 21fd01aa82
181 changed files with 1145 additions and 7773 deletions

View File

@ -8,7 +8,6 @@ import { gettext as _ } from "resource:///org/gnome/Shell/Extensions/js/extensio
// Shared state
import { ConfigManager } from "../shared/settings.js";
import { PrefsThemeManager } from "./prefs-theme-manager.js";
// Prefs UI
@ -42,8 +41,8 @@ export class AppearancePage extends PreferencesPage {
constructor({ settings, dir }) {
super({ title: _("Appearance"), icon_name: "brush-symbolic" });
this.settings = settings;
this.configMgr = new ConfigManager({ dir });
this.themeMgr = new PrefsThemeManager(this);
let configMgr = new ConfigManager({ dir });
this.themeMgr = new PrefsThemeManager({ configMgr: configMgr, settings: settings });
this.add_group({
title: _("Gaps"),
description: _("Change the gap size between windows"),

View File

@ -0,0 +1,82 @@
// Gtk imports
import Gtk from "gi://Gtk";
import GObject from "gi://GObject";
// Gnome imports
import { gettext as _ } from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js";
// Extension imports
import { PreferencesPage, RemoveItemRow, ResetButton } from "./widgets.js";
import { ConfigManager } from "../shared/settings.js";
export class FloatingPage extends PreferencesPage {
static {
GObject.registerClass(this);
}
constructor({ settings, dir }) {
super({ title: _("Windows"), icon_name: "window-symbolic" });
this.settings = settings;
this.configMgr = new ConfigManager({ dir });
let overrides = this.configMgr.windowProps.overrides;
this.rows = this.loadItemsFromConfig(overrides);
this.floatingWindowGroup = this.add_group({
title: _("Floating Windows"),
description: _("Windows that will not be tiled"),
header_suffix: new ResetButton({ onReset: () => this.onResetHandler() }),
children: this.rows,
});
}
loadItemsFromConfig(overrides) {
let children = [];
for (let override of overrides) {
if (override.mode === "float") {
let itemrow = new RemoveItemRow({
title: override.wmTitle ?? override.wmClass,
subtitle: override.wmClass,
onRemove: (item, parent) => this.onRemoveHandler(item, parent),
});
children.push(itemrow);
}
}
return children;
}
onRemoveHandler(item, parent) {
this.floatingWindowGroup.remove(parent);
this.rows = this.rows.filter((row) => row != parent);
const existing = this.configMgr.windowProps.overrides;
const modified = existing.filter((row) => item != row.wmClass);
this.saveOverrides(modified);
}
saveOverrides(modified) {
if (modified) {
this.configMgr.windowProps = {
overrides: modified,
};
// Signal the main extension to reload floating overrides
const changed = Math.floor(Date.now() / 1000);
this.settings.set_uint("window-overrides-reload-trigger", changed);
}
}
onResetHandler() {
const defaultWindowProps = this.configMgr.loadDefaultWindowConfigContents();
const original = defaultWindowProps.overrides;
this.saveOverrides(original);
for (const child of this.rows) {
this.floatingWindowGroup.remove(child);
}
this.rows = this.loadItemsFromConfig(original);
for (const item of this.rows) {
this.floatingWindowGroup.add(item);
}
}
}

View File

@ -17,6 +17,7 @@ import { PACKAGE_VERSION } from "resource:///org/gnome/Shell/Extensions/js/misc/
import { developers } from "./metadata.js";
function showAboutWindow(parent, { version, description: comments }) {
version = version ?? "development";
const abt = new Adw.AboutWindow({
...(parent && { transient_for: parent }),
// TODO: fetch these from github at build time
@ -136,7 +137,7 @@ export class SettingsPage extends PreferencesPage {
title: _("Logger"),
children: [
new DropDownRow({
title: _("Logger Level"),
title: _("Log level"),
settings,
bind: "log-level",
items: Object.entries(Logger.LOG_LEVELS).map(([name, id]) => ({ id, name })),

View File

@ -22,6 +22,7 @@ export class PreferencesPage extends Adw.PreferencesPage {
for (const child of children) group.add(child);
if (header_suffix) group.set_header_suffix(header_suffix);
this.add(group);
return group;
}
}
@ -87,7 +88,7 @@ export class SpinButtonRow extends Adw.ActionRow {
}) {
super({ title, subtitle });
const gspin = Gtk.SpinButton.new_with_range(low, high, step);
gspin.valign = Gtk.Align.CENTER;
gspin.xalign = 1;
if (bind && settings) {
settings.bind(bind, gspin, "value", Gio.SettingsBindFlags.DEFAULT);
} else if (init) {
@ -97,6 +98,7 @@ export class SpinButtonRow extends Adw.ActionRow {
});
}
this.add_suffix(gspin);
this.set_css_classes(["spin"]);
this.activatable_widget = gspin;
}
}
@ -211,15 +213,32 @@ export class DropDownRow extends Adw.ActionRow {
}
}
export class ClearButton extends Gtk.Button {
static {
GObject.registerClass(this);
}
constructor({ settings = undefined, bind = undefined, onClear }) {
super({
icon_name: "edit-clear-symbolic",
tooltip_text: _("Clear shortcut"),
css_classes: ["flat", "circular"],
valign: Gtk.Align.CENTER,
});
this.connect("clicked", () => {
onClear?.();
});
}
}
export class ResetButton extends Gtk.Button {
static {
GObject.registerClass(this);
}
constructor({ settings = undefined, bind = undefined, onReset }) {
super({
icon_name: "edit-undo-symbolic",
tooltip_text: _("Reset"),
tooltip_text: _("Reset to default"),
css_classes: ["flat", "circular"],
valign: Gtk.Align.CENTER,
});
this.connect("clicked", () => {
@ -229,6 +248,23 @@ export class ResetButton extends Gtk.Button {
}
}
export class RemoveButton extends Gtk.Button {
static {
GObject.registerClass(this);
}
constructor({ item, parent, onRemove }) {
super({
icon_name: "edit-delete-symbolic",
tooltip_text: _("Remove Item"),
css_classes: ["flat", "circular"],
valign: Gtk.Align.CENTER,
});
this.connect("clicked", () => {
onRemove?.(item, parent);
});
}
}
export class EntryRow extends Adw.EntryRow {
static {
GObject.registerClass(this);
@ -247,6 +283,15 @@ export class EntryRow extends Adw.EntryRow {
});
const current = map ? map.from(settings, bind) : settings.get_string(bind);
this.set_text(current ?? "");
this.add_suffix(
new ClearButton({
settings,
bind,
onClear: () => {
this.set_text("");
},
})
);
this.add_suffix(
new ResetButton({
settings,
@ -266,7 +311,7 @@ export class RadioRow extends Adw.ActionRow {
static orientation = Gtk.Orientation.HORIZONTAL;
static spacing = 10;
static spacing = 3;
static valign = Gtk.Align.CENTER;
@ -281,6 +326,7 @@ export class RadioRow extends Adw.ActionRow {
const toggle = new Gtk.ToggleButton({ label, ...(group && { group }) });
group ||= toggle;
toggle.active = key === current;
toggle.set_css_classes(["flat"]);
toggle.connect("clicked", () => {
if (toggle.active) {
settings.set_string(bind, labels[toggle.label]);
@ -291,3 +337,20 @@ export class RadioRow extends Adw.ActionRow {
this.add_suffix(hbox);
}
}
export class RemoveItemRow extends Adw.ActionRow {
static {
GObject.registerClass(this);
}
constructor({ title, subtitle = "", onRemove = undefined }) {
super({ title, subtitle });
const rmbutton = new RemoveButton({
item: subtitle,
parent: this,
onRemove: onRemove,
});
this.add_suffix(rmbutton);
}
}