💥 fix(control-center/notif-history): clean all button not doing anything on ::on-clicked

This commit is contained in:
retrozinndev
2025-07-23 22:20:45 -03:00
parent f0b86a10d2
commit 7b158b8c89
4 changed files with 34 additions and 21 deletions
+11 -4
View File
@@ -9,7 +9,7 @@ import AstalNotifd from "gi://AstalNotifd?version=0.1";
export const NotifHistory = () => export const NotifHistory = () =>
<Gtk.Box orientation={Gtk.Orientation.VERTICAL} <Gtk.Box orientation={Gtk.Orientation.VERTICAL}
class={createBinding(Notifications.getDefault(), "history").as(history => class={createBinding(Notifications.getDefault(), "history").as(history =>
`history ${history.length < 1 ? "hide" : ""}`)}> `notif-history ${history.length < 1 ? "hide" : ""}`)} vexpand={false}>
<Gtk.ScrolledWindow class={"history-scrollable"} hscrollbarPolicy={Gtk.PolicyType.NEVER} <Gtk.ScrolledWindow class={"history-scrollable"} hscrollbarPolicy={Gtk.PolicyType.NEVER}
vscrollbarPolicy={Gtk.PolicyType.AUTOMATIC} propagateNaturalHeight={true} vscrollbarPolicy={Gtk.PolicyType.AUTOMATIC} propagateNaturalHeight={true}
@@ -35,8 +35,15 @@ export const NotifHistory = () =>
</Gtk.Box> </Gtk.Box>
</Gtk.ScrolledWindow> </Gtk.ScrolledWindow>
<Gtk.Box hexpand={true} class={"button-row"} halign={Gtk.Align.END}> <Gtk.Box class={"button-row"} hexpand>
<Gtk.Button class={"clear-all"} iconName={"edit-clear-all-symbolic"} <Gtk.Button class={"clear-all"} halign={Gtk.Align.END}
label={tr("clear")} onClicked={Notifications.getDefault().clearHistory} /> onClicked={() => Notifications.getDefault().clearHistory()}>
<Gtk.Box hexpand>
<Gtk.Image class={"icon"} iconName={"edit-clear-all-symbolic"}
css={"margin-right: 6px;"} />
<Gtk.Label label={tr("clear")} />
</Gtk.Box>
</Gtk.Button>
</Gtk.Box> </Gtk.Box>
</Gtk.Box> as Gtk.Box; </Gtk.Box> as Gtk.Box;
+5 -3
View File
@@ -1,10 +1,12 @@
import { register } from "ags/gobject"; import { register } from "ags/gobject";
import { Gtk } from "ags/gtk4"; import { Gtk } from "ags/gtk4";
import { Page } from "./pages/Page"; import { Page } from "./pages/Page";
import AstalIO from "gi://AstalIO";
import { timeout } from "ags/time"; import { timeout } from "ags/time";
import { variableToBoolean } from "../../scripts/utils"; import { variableToBoolean } from "../../scripts/utils";
import AstalIO from "gi://AstalIO";
import { createRoot } from "ags";
export { Pages }; export { Pages };
export type PagesProps = { export type PagesProps = {
@@ -68,13 +70,13 @@ class Pages extends Gtk.Box {
} }
open(newPage: Page, onOpened?: () => void) { open(newPage: Page, onOpened?: () => void) {
const pageWidget = <Gtk.Revealer const pageWidget = createRoot(() => <Gtk.Revealer
transitionDuration={this.#transDuration} transitionDuration={this.#transDuration}
transitionType={this.#transType} transitionType={this.#transType}
revealChild={false}> revealChild={false}>
{newPage as unknown as Gtk.Widget} {newPage as unknown as Gtk.Widget}
</Gtk.Revealer> as Gtk.Revealer; </Gtk.Revealer> as Gtk.Revealer);
this.prepend(pageWidget); this.prepend(pageWidget);
+8 -5
View File
@@ -3,15 +3,18 @@ import { Wireplumber } from "../../scripts/volume";
import { Pages } from "./Pages"; import { Pages } from "./Pages";
import { PageSound } from "./pages/Sound"; import { PageSound } from "./pages/Sound";
import { PageMicrophone } from "./pages/Microphone"; import { PageMicrophone } from "./pages/Microphone";
import { createBinding, With } from "ags"; import { createBinding, createRoot, With } from "ags";
import AstalWp from "gi://AstalWp"; import AstalWp from "gi://AstalWp";
export let slidersPages: Pages|undefined;
export function Sliders() { export function Sliders() {
const slidersPages = <Pages /> as Pages; slidersPages = createRoot(() => new Pages())!;
return <Gtk.Box class={"sliders"} orientation={Gtk.Orientation.VERTICAL} return <Gtk.Box class={"sliders"} orientation={Gtk.Orientation.VERTICAL}
hexpand={true} spacing={10}> hexpand spacing={10} onDestroy={() => slidersPages = undefined}>
<With value={createBinding(Wireplumber.getWireplumber(), "defaultSpeaker")}> <With value={createBinding(Wireplumber.getWireplumber(), "defaultSpeaker")}>
{(sink: AstalWp.Endpoint) => <Gtk.Box class={"sink speaker"} spacing={3}> {(sink: AstalWp.Endpoint) => <Gtk.Box class={"sink speaker"} spacing={3}>
@@ -30,7 +33,7 @@ export function Sliders() {
onChangeValue={(_, _scrollType, value) => sink.set_volume(value / 100)} /> onChangeValue={(_, _scrollType, value) => sink.set_volume(value / 100)} />
<Gtk.Button class={"more"} iconName={"go-next-symbolic"} onClicked={(_) => <Gtk.Button class={"more"} iconName={"go-next-symbolic"} onClicked={(_) =>
slidersPages.toggle(PageSound())} /> slidersPages!.toggle(PageSound())} />
</Gtk.Box>} </Gtk.Box>}
</With> </With>
<With value={createBinding(Wireplumber.getWireplumber(), "defaultMicrophone")}> <With value={createBinding(Wireplumber.getWireplumber(), "defaultMicrophone")}>
@@ -50,7 +53,7 @@ export function Sliders() {
onChangeValue={(_, _scrollType, value) => source.set_volume(value / 100)} /> onChangeValue={(_, _scrollType, value) => source.set_volume(value / 100)} />
<Gtk.Button class={"more"} iconName={"go-next-symbolic"} onClicked={(_) => <Gtk.Button class={"more"} iconName={"go-next-symbolic"} onClicked={(_) =>
slidersPages.toggle(PageMicrophone())} /> slidersPages!.toggle(PageMicrophone())} />
</Gtk.Box>} </Gtk.Box>}
</With> </With>
{slidersPages} {slidersPages}
+10 -9
View File
@@ -5,31 +5,32 @@ import { TileDND } from "./tiles/DoNotDisturb";
import { TileRecording } from "./tiles/Recording"; import { TileRecording } from "./tiles/Recording";
import { TileNightLight } from "./tiles/NightLight"; import { TileNightLight } from "./tiles/NightLight";
import { Pages } from "./Pages"; import { Pages } from "./Pages";
import { createRoot } from "/usr/share/ags/js/gnim/src/jsx/scope";
export let TilesPages: (Pages|null) = null; export let TilesPages: Pages|undefined;
export const tileList: Array<() => Gtk.Widget> = [ export const tileList: Array<() => JSX.Element|Gtk.Widget> = [
TileNetwork, TileNetwork,
TileBluetooth, TileBluetooth,
TileRecording, TileRecording,
TileDND, TileDND,
TileNightLight TileNightLight
]; ] as Array<() => Gtk.Widget>;
export function Tiles(): Gtk.Widget { export function Tiles(): Gtk.Widget {
return <Gtk.Box class={"tiles-container"} orientation={Gtk.Orientation.VERTICAL} return <Gtk.Box class={"tiles-container"} orientation={Gtk.Orientation.VERTICAL}
onDestroy={() => TilesPages = null} $={(self) => { onDestroy={() => TilesPages = undefined} $={(self) => {
if(!TilesPages) if(!TilesPages)
TilesPages = <Pages class="tile-pages" /> as Pages; TilesPages = createRoot(() => new Pages({ class: "tile-pages" }));
self.append(TilesPages as unknown as Gtk.Widget); self.append(TilesPages!);
}}> }}>
<Gtk.FlowBox orientation={Gtk.Orientation.HORIZONTAL} rowSpacing={6} <Gtk.FlowBox orientation={Gtk.Orientation.HORIZONTAL} rowSpacing={6}
columnSpacing={6} minChildrenPerLine={2} activateOnSingleClick={true} columnSpacing={6} minChildrenPerLine={2} activateOnSingleClick
maxChildrenPerLine={2} hexpand={true} vexpand={true} homogeneous={true}> maxChildrenPerLine={2} hexpand vexpand homogeneous>
{tileList.map(tile => tile())} {tileList.map(t => t())}
</Gtk.FlowBox> </Gtk.FlowBox>
</Gtk.Box> as Gtk.Box; </Gtk.Box> as Gtk.Box;
} }