Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: update adwaita widgets in prefs #293

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/prefs/appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ConfigManager } from "../shared/settings.js";
import { PrefsThemeManager } from "./prefs-theme-manager.js";

// Prefs UI
import { ColorRow, PreferencesPage, ResetButton, SpinButtonRow, SwitchRow } from "./widgets.js";
import { ColorRow, PreferencesPage, ResetButton, SpinButtonRow, makeSwitchRow } from "./widgets.js";
import { Logger } from "../shared/logger.js";

export class AppearancePage extends PreferencesPage {
Expand Down Expand Up @@ -61,7 +61,7 @@ export class AppearancePage extends PreferencesPage {
bind: "window-gap-size-increment",
}),
// Gap Hidden when Single Window
new SwitchRow({
makeSwitchRow({
title: _("Gaps Hidden when Single"),
settings,
bind: "window-gap-hidden-on-single",
Expand Down Expand Up @@ -114,7 +114,7 @@ export class AppearancePage extends PreferencesPage {
theme.setCssProperty(selector, "border-width", theme.addPx(borderDefault));
borderSizeRow.activatable_widget.value = borderDefault;
},
})
}),
);

const updateCssColors = (rgbaString) => {
Expand All @@ -141,24 +141,24 @@ export class AppearancePage extends PreferencesPage {
theme.setCssProperty(
`.window-${colorScheme}-tab`,
"border-color",
tabBorderRgba.to_string()
tabBorderRgba.to_string(),
);
theme.setCssProperty(
`.window-${colorScheme}-tab-active`,
"background-color",
tabActiveBackgroundRgba.to_string()
tabActiveBackgroundRgba.to_string(),
);
}
// And then finally the preview when doing drag/drop tiling:
theme.setCssProperty(
`.window-tilepreview-${colorScheme}`,
"border-color",
previewBorderRgba.to_string()
previewBorderRgba.to_string(),
);
theme.setCssProperty(
`.window-tilepreview-${colorScheme}`,
"background-color",
previewBackgroundRgba.to_string()
previewBackgroundRgba.to_string(),
);
}
};
Expand All @@ -179,7 +179,7 @@ export class AppearancePage extends PreferencesPage {
borderColorRow.colorButton.set_rgba(rgba);
}
},
})
}),
);

row.add_row(borderColorRow);
Expand Down
18 changes: 9 additions & 9 deletions lib/prefs/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Logger } from "../shared/logger.js";
import { production } from "../shared/settings.js";

// Prefs UI
import { DropDownRow, SwitchRow, PreferencesPage } from "./widgets.js";
import { DropDownRow, makeSwitchRow, PreferencesPage } from "./widgets.js";

// Extension imports
import { gettext as _ } from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js";
Expand Down Expand Up @@ -57,14 +57,14 @@ export class SettingsPage extends PreferencesPage {
description: _("Toggle Forge's high-level features"),
header_suffix: makeAboutButton(window, metadata),
children: [
new SwitchRow({
makeSwitchRow({
title: _("Stacked Tiling Mode"),
subtitle: _("Stack windows on top of each other while still being tiled"),
experimental: true,
settings,
bind: "stacked-tiling-mode-enabled",
}),
new SwitchRow({
makeSwitchRow({
title: _("Tabbed Tiling Mode"),
subtitle: _("Group tiles windows as tabs"),
experimental: true,
Expand All @@ -77,19 +77,19 @@ export class SettingsPage extends PreferencesPage {
this.add_group({
title: _("Tiling"),
children: [
new SwitchRow({
makeSwitchRow({
title: _("Preview Hint Toggle"),
experimental: true,
settings,
bind: "preview-hint-enabled",
}),
new SwitchRow({
makeSwitchRow({
title: _("Show Focus Hint Border"),
subtitle: _("Display a colored border around the focused window"),
settings,
bind: "focus-border-toggle",
}),
new SwitchRow({
makeSwitchRow({
title: _("Show Window Split Hint Border"),
subtitle: _("Show split direction border on focused window"),
settings,
Expand All @@ -105,21 +105,21 @@ export class SettingsPage extends PreferencesPage {
{ id: "stacked", name: _("Stacked") },
],
}),
new SwitchRow({
makeSwitchRow({
title: _("Auto Split"),
subtitle: _("Quarter Tiling"),
experimental: true,
settings,
bind: "auto-split-enabled",
}),
new SwitchRow({
makeSwitchRow({
title: _("Float Mode Always On Top"),
subtitle: _("Floating windows always above tiling windows"),
experimental: true,
settings,
bind: "float-always-on-top-enabled",
}),
new SwitchRow({
makeSwitchRow({
title: _("Show Tiling Quick Settings"),
subtitle: _("Toggle showing Forge on quick settings"),
experimental: true,
Expand Down
32 changes: 10 additions & 22 deletions lib/prefs/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,15 @@ export class PreferencesPage extends Adw.PreferencesPage {
}
}

export class SwitchRow extends Adw.ActionRow {
static {
GObject.registerClass(this);
}

constructor({ title, settings, bind, subtitle = "", experimental = false }) {
super({ title, subtitle });
const gswitch = new Gtk.Switch({
active: settings.get_boolean(bind),
valign: Gtk.Align.CENTER,
});
settings.bind(bind, gswitch, "active", Gio.SettingsBindFlags.DEFAULT);
if (experimental) {
const icon = new Gtk.Image({ icon_name: "bug-symbolic" });
icon.set_tooltip_markup(
_("<b>CAUTION</b>: Enabling this setting can lead to bugs or cause the shell to crash")
);
this.add_suffix(icon);
}
this.add_suffix(gswitch);
this.activatable_widget = gswitch;
export function makeSwitchRow({ title, subtitle = "", experimental = false, settings, bind }) {
const row = new Adw.SwitchRow({ title, subtitle });
row.active = settings.get_boolean(bind);
settings.bind(bind, row, "active", Gio.SettingsBindFlags.DEFAULT);
if (experimental) {
row.icon_name = "bug-symbolic";
row.set_tooltip_markup(
_("<b>CAUTION</b>: Enabling this setting can lead to bugs or cause the shell to crash"),
);
}
}

Expand Down Expand Up @@ -254,7 +242,7 @@ export class EntryRow extends Adw.EntryRow {
onReset: () => {
this.set_text((map ? map.from(settings, bind) : settings.get_string(bind)) ?? "");
},
})
}),
);
}
}
Expand Down
Loading