From 75f788806213e45808a67ef98dbae21c356cb29d Mon Sep 17 00:00:00 2001 From: Ratson Date: Wed, 13 Nov 2024 23:57:02 +0800 Subject: example(simple-bar): fix sass deprecation warnings --- examples/js/simple-bar/style.scss | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/js/simple-bar/style.scss b/examples/js/simple-bar/style.scss index f98286e..1dcf729 100644 --- a/examples/js/simple-bar/style.scss +++ b/examples/js/simple-bar/style.scss @@ -1,3 +1,5 @@ +@use "sass:color"; + $bg: #212223; $fg: #f1f1f1; $accent: #378DF7; @@ -16,12 +18,12 @@ window.Bar { background-color: transparent; &:hover label { - background-color: transparentize($fg, 0.84); - border-color: transparentize($accent, 0.8); + background-color: color.adjust($fg, $alpha: -0.84); + border-color: color.adjust($accent, $alpha: -0.8); } &:active label { - background-color: transparentize($fg, 0.8) + background-color: color.adjust($fg, $alpha: -0.8) } } @@ -64,10 +66,12 @@ window.Bar { margin-right: .6em; } - margin: 0 1em; + & { + margin: 0 1em; + } trough { - background-color: transparentize($fg, 0.8); + background-color: color.adjust($fg, $alpha: -0.8); border-radius: $radius; } -- cgit v1.2.3 From 5c7e82b561ec7fda2df463ad12a2b72d59a720a2 Mon Sep 17 00:00:00 2001 From: Aylur <104676705+Aylur@users.noreply.github.com> Date: Sat, 16 Nov 2024 16:46:59 +0100 Subject: Update README.md --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index d8f4971..248d666 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,3 @@ # Astal -> [!WARNING] -> WIP: nothing is stable yet, every library is subject to change - -## Getting Started - To get started read the [wiki](https://aylur.github.io/astal/) -- cgit v1.2.3 From aab11610d8c9e393ffcb63daf81d24fe5d0ac640 Mon Sep 17 00:00:00 2001 From: kotontrion Date: Sun, 17 Nov 2024 13:32:02 +0100 Subject: circularprogress: fix size calculations --- lib/astal/gtk3/src/widget/circularprogress.vala | 64 ++++++++++++++++++------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/lib/astal/gtk3/src/widget/circularprogress.vala b/lib/astal/gtk3/src/widget/circularprogress.vala index a3ecdf1..3d7e8bd 100644 --- a/lib/astal/gtk3/src/widget/circularprogress.vala +++ b/lib/astal/gtk3/src/widget/circularprogress.vala @@ -44,26 +44,54 @@ public class Astal.CircularProgress : Gtk.Bin { set_css_name("circular-progress"); } + public override Gtk.SizeRequestMode get_request_mode() { + if(get_child() != null) return get_child().get_request_mode(); + return Gtk.SizeRequestMode.HEIGHT_FOR_WIDTH; + } + public override void get_preferred_height(out int minh, out int nath) { - var val = get_style_context().get_property("min-height", Gtk.StateFlags.NORMAL); - if (val.get_int() <= 0) { - minh = 40; - nath = 40; + if(get_child() != null) { + int minw, natw; + get_child().get_preferred_height(out minh, out nath); + get_child().get_preferred_width(out minw, out natw); + + minh = int.max(minw, minh); + nath = int.max(natw, nath); } + var w_val = get_style_context().get_property("min-width", Gtk.StateFlags.NORMAL); + var h_val = get_style_context().get_property("min-height", Gtk.StateFlags.NORMAL); + minh = int.max(w_val.get_int(), minh); + nath = int.max(w_val.get_int(), nath); + minh = int.max(h_val.get_int(), minh); + nath = int.max(h_val.get_int(), nath); + } - minh = val.get_int(); - nath = val.get_int(); + public override void get_preferred_height_for_width(int width, out int minh, out int nath) { + minh = width; + nath = width; } public override void get_preferred_width(out int minw, out int natw) { - var val = get_style_context().get_property("min-width", Gtk.StateFlags.NORMAL); - if (val.get_int() <= 0) { - minw = 40; - natw = 40; + // if(get_child() != null) get_child().get_preferred_width(out minw, out natw); + if(get_child() != null) { + int minh, nath; + get_child().get_preferred_height(out minh, out nath); + get_child().get_preferred_width(out minw, out natw); + + minw = int.max(minw, minh); + natw = int.max(natw, nath); } + var w_val = get_style_context().get_property("min-width", Gtk.StateFlags.NORMAL); + var h_val = get_style_context().get_property("min-height", Gtk.StateFlags.NORMAL); + minw = int.max(w_val.get_int(), minw); + natw = int.max(w_val.get_int(), natw); + minw = int.max(h_val.get_int(), minw); + natw = int.max(h_val.get_int(), natw); + } - minw = val.get_int(); - natw = val.get_int(); + public override void get_preferred_width_for_height(int height, out int minw, out int natw) { + minw = height; + natw = height; } private double to_radian(double percentage) { @@ -115,6 +143,12 @@ public class Astal.CircularProgress : Gtk.Bin { Gtk.Allocation allocation; get_allocation(out allocation); + if (get_child() != null) { + get_child().size_allocate(allocation); + propagate_draw(get_child(), cr); + } + + var styles = get_style_context(); var width = allocation.width; var height = allocation.height; @@ -195,12 +229,6 @@ public class Astal.CircularProgress : Gtk.Bin { cr.arc(end_x, end_y, fg_stroke / 2, 0, 0 - 0.01); cr.fill(); } - - if (get_child() != null) { - get_child().size_allocate(allocation); - propagate_draw(get_child(), cr); - } - return true; } } -- cgit v1.2.3 From 7c33269ac956d30cc7a1c9dcadafeabb03b7740d Mon Sep 17 00:00:00 2001 From: kotontrion Date: Sun, 17 Nov 2024 13:41:27 +0100 Subject: circularprogress: remove comment --- lib/astal/gtk3/src/widget/circularprogress.vala | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/astal/gtk3/src/widget/circularprogress.vala b/lib/astal/gtk3/src/widget/circularprogress.vala index 3d7e8bd..df1635d 100644 --- a/lib/astal/gtk3/src/widget/circularprogress.vala +++ b/lib/astal/gtk3/src/widget/circularprogress.vala @@ -72,7 +72,6 @@ public class Astal.CircularProgress : Gtk.Bin { } public override void get_preferred_width(out int minw, out int natw) { - // if(get_child() != null) get_child().get_preferred_width(out minw, out natw); if(get_child() != null) { int minh, nath; get_child().get_preferred_height(out minh, out nath); -- cgit v1.2.3 From 5f35244b12150b074474f4808115a63ee38366ec Mon Sep 17 00:00:00 2001 From: Aylur Date: Sun, 17 Nov 2024 16:08:33 +0000 Subject: fix: #106 gtk3 Fragment --- lang/gjs/src/gtk3/jsx-runtime.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lang/gjs/src/gtk3/jsx-runtime.ts b/lang/gjs/src/gtk3/jsx-runtime.ts index 22dc424..9da4bb6 100644 --- a/lang/gjs/src/gtk3/jsx-runtime.ts +++ b/lang/gjs/src/gtk3/jsx-runtime.ts @@ -10,7 +10,8 @@ export function Fragment({ children = [], child }: { child?: BindableChild children?: Array }) { - return mergeBindings([...children, child]) + if (child) children.push(child) + return mergeBindings(children) } export function jsx( -- cgit v1.2.3 From 813abcaa49546c10b5bc46c19bac853b6dc9612d Mon Sep 17 00:00:00 2001 From: Aylur Date: Sun, 17 Nov 2024 16:16:42 +0000 Subject: fix #88: hyprland sync workspaces before signal emission --- lib/hyprland/hyprland.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hyprland/hyprland.vala b/lib/hyprland/hyprland.vala index ea95cab..195a3f6 100644 --- a/lib/hyprland/hyprland.vala +++ b/lib/hyprland/hyprland.vala @@ -393,8 +393,8 @@ public class Hyprland : Object { case "closewindow": _clients.get(args[1]).removed(); _clients.remove(args[1]); - client_removed(args[1]); yield sync_workspaces(); + client_removed(args[1]); notify_property("clients"); break; -- cgit v1.2.3 From 291c5b8c73519244b5d7d4a95024d14a54df0b7b Mon Sep 17 00:00:00 2001 From: Ratson Date: Mon, 18 Nov 2024 01:00:58 +0800 Subject: example: fix sass deprecation warnings --- examples/lua/simple-bar/style.scss | 14 +++++++++----- examples/py/simple-bar/style.scss | 14 +++++++++----- examples/vala/simple-bar/style.scss | 14 +++++++++----- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/examples/lua/simple-bar/style.scss b/examples/lua/simple-bar/style.scss index f98286e..1dcf729 100644 --- a/examples/lua/simple-bar/style.scss +++ b/examples/lua/simple-bar/style.scss @@ -1,3 +1,5 @@ +@use "sass:color"; + $bg: #212223; $fg: #f1f1f1; $accent: #378DF7; @@ -16,12 +18,12 @@ window.Bar { background-color: transparent; &:hover label { - background-color: transparentize($fg, 0.84); - border-color: transparentize($accent, 0.8); + background-color: color.adjust($fg, $alpha: -0.84); + border-color: color.adjust($accent, $alpha: -0.8); } &:active label { - background-color: transparentize($fg, 0.8) + background-color: color.adjust($fg, $alpha: -0.8) } } @@ -64,10 +66,12 @@ window.Bar { margin-right: .6em; } - margin: 0 1em; + & { + margin: 0 1em; + } trough { - background-color: transparentize($fg, 0.8); + background-color: color.adjust($fg, $alpha: -0.8); border-radius: $radius; } diff --git a/examples/py/simple-bar/style.scss b/examples/py/simple-bar/style.scss index f98286e..1dcf729 100644 --- a/examples/py/simple-bar/style.scss +++ b/examples/py/simple-bar/style.scss @@ -1,3 +1,5 @@ +@use "sass:color"; + $bg: #212223; $fg: #f1f1f1; $accent: #378DF7; @@ -16,12 +18,12 @@ window.Bar { background-color: transparent; &:hover label { - background-color: transparentize($fg, 0.84); - border-color: transparentize($accent, 0.8); + background-color: color.adjust($fg, $alpha: -0.84); + border-color: color.adjust($accent, $alpha: -0.8); } &:active label { - background-color: transparentize($fg, 0.8) + background-color: color.adjust($fg, $alpha: -0.8) } } @@ -64,10 +66,12 @@ window.Bar { margin-right: .6em; } - margin: 0 1em; + & { + margin: 0 1em; + } trough { - background-color: transparentize($fg, 0.8); + background-color: color.adjust($fg, $alpha: -0.8); border-radius: $radius; } diff --git a/examples/vala/simple-bar/style.scss b/examples/vala/simple-bar/style.scss index f98286e..1dcf729 100644 --- a/examples/vala/simple-bar/style.scss +++ b/examples/vala/simple-bar/style.scss @@ -1,3 +1,5 @@ +@use "sass:color"; + $bg: #212223; $fg: #f1f1f1; $accent: #378DF7; @@ -16,12 +18,12 @@ window.Bar { background-color: transparent; &:hover label { - background-color: transparentize($fg, 0.84); - border-color: transparentize($accent, 0.8); + background-color: color.adjust($fg, $alpha: -0.84); + border-color: color.adjust($accent, $alpha: -0.8); } &:active label { - background-color: transparentize($fg, 0.8) + background-color: color.adjust($fg, $alpha: -0.8) } } @@ -64,10 +66,12 @@ window.Bar { margin-right: .6em; } - margin: 0 1em; + & { + margin: 0 1em; + } trough { - background-color: transparentize($fg, 0.8); + background-color: color.adjust($fg, $alpha: -0.8); border-radius: $radius; } -- cgit v1.2.3 From 852cf24fc0da8945b56f7a7304a4475bb007366e Mon Sep 17 00:00:00 2001 From: Aylur <104676705+Aylur@users.noreply.github.com> Date: Sun, 17 Nov 2024 19:49:12 +0100 Subject: Update question.md --- .github/ISSUE_TEMPLATE/question.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index 936a648..990ede7 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -10,7 +10,7 @@ assignees: '' **Have you read through the documentation?** - [ ] [Astal docs](https://aylur.github.io/astal/) - [ ] [Library references](https://aylur.github.io/astal/guide/libraries/references) -- [ ] [FAQ](https://aylur.github.io/astal/guide/ags/faq) +- [ ] [FAQ](https://aylur.github.io/astal/guide/typescript/faq) **Describe what have you tried so far** A description or example code of what you have got so far. -- cgit v1.2.3 From 48692ff557f5f9e95744f939e3fcd1054badb585 Mon Sep 17 00:00:00 2001 From: Aylur Date: Mon, 18 Nov 2024 00:50:16 +0000 Subject: fix: #110 notifd urgency hint --- lib/notifd/notification.vala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/notifd/notification.vala b/lib/notifd/notification.vala index 29c6c56..c28138f 100644 --- a/lib/notifd/notification.vala +++ b/lib/notifd/notification.vala @@ -142,9 +142,11 @@ public class AstalNotifd.Notification : Object { return 0; var v = hints.get(hint); - if (v.get_type_string() == "b") + // daemon uses byte as per spec + if (v.get_type_string() == "y") return v.get_byte(); + // proxy uses int64 from json if (v.get_type_string() == "x") return (uint8)v.get_int64(); -- cgit v1.2.3 From f5ed9aad2c8ab133b5c188aec70b0f704748015d Mon Sep 17 00:00:00 2001 From: Aylur Date: Mon, 18 Nov 2024 14:53:06 +0000 Subject: fix(gjs): add workaround for array props --- docs/guide/typescript/faq.md | 9 ++++-- lang/gjs/src/_app.ts | 1 + lang/gjs/src/index.ts | 1 + lang/gjs/src/overrides.ts | 69 ++++++++++++++++++++++++++++++++++++++++++++ lang/gjs/tsconfig.json | 1 + 5 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 lang/gjs/src/overrides.ts diff --git a/docs/guide/typescript/faq.md b/docs/guide/typescript/faq.md index a151099..444a0af 100644 --- a/docs/guide/typescript/faq.md +++ b/docs/guide/typescript/faq.md @@ -197,11 +197,14 @@ These happen when accessing list type properties. Gjs fails to correctly bind import Notifd from "gi://AstalNotifd" const notifd = Notifd.get_default() -notifd.notifications // ❌ // [!code error] - -notifd.get_notifications() // ✅ +notifd.notifications // [!code --] +notifd.get_notifications() // [!code ++] ``` +:::tip +Open up an issue/PR to add a [workaround](https://github.com/Aylur/astal/blob/main/lang/gjs/src/overrides.ts). +::: + ## How to create regular floating windows Use `Gtk.Window` with [Widget.astalify](/guide/typescript/widget#how-to-use-non-builtin-gtk-widgets). diff --git a/lang/gjs/src/_app.ts b/lang/gjs/src/_app.ts index 82e8bb5..60fb407 100644 --- a/lang/gjs/src/_app.ts +++ b/lang/gjs/src/_app.ts @@ -1,3 +1,4 @@ +import "./overrides" import { setConsoleLogDomain } from "console" import { exit, programArgs } from "system" import IO from "gi://AstalIO" diff --git a/lang/gjs/src/index.ts b/lang/gjs/src/index.ts index cabc961..f4c5773 100644 --- a/lang/gjs/src/index.ts +++ b/lang/gjs/src/index.ts @@ -1,3 +1,4 @@ +import "./overrides" export { default as AstalIO } from "gi://AstalIO?version=0.1" export * from "./process.js" export * from "./time.js" diff --git a/lang/gjs/src/overrides.ts b/lang/gjs/src/overrides.ts new file mode 100644 index 0000000..6643ba5 --- /dev/null +++ b/lang/gjs/src/overrides.ts @@ -0,0 +1,69 @@ +/** + * Workaround for "Can't convert non-null pointer to JS value " + */ + +export { } + +const snakeify = (str: string) => str + .replace(/([a-z])([A-Z])/g, "$1_$2") + .replaceAll("-", "_") + .toLowerCase() + +async function suppress(mod: Promise<{ default: T }>, patch: (m: T) => void) { + return mod.then(m => patch(m.default)).catch(() => void 0) +} + +function patch

(proto: P, prop: Extract) { + Object.defineProperty(proto, prop, { + get() { return this[`get_${snakeify(prop)}`]() }, + }) +} + +await suppress(import("gi://AstalApps"), ({ Apps, Application }) => { + patch(Apps.prototype, "list") + patch(Application.prototype, "keywords") + patch(Application.prototype, "categories") +}) + +await suppress(import("gi://AstalBattery"), ({ UPower }) => { + patch(UPower.prototype, "devices") +}) + +await suppress(import("gi://AstalBluetooth"), ({ Adapter, Bluetooth, Device }) => { + patch(Adapter.prototype, "uuids") + patch(Bluetooth.prototype, "adapters") + patch(Bluetooth.prototype, "devices") + patch(Device.prototype, "uuids") +}) + +await suppress(import("gi://AstalHyprland"), ({ Hyprland, Monitor, Workspace }) => { + patch(Hyprland.prototype, "monitors") + patch(Hyprland.prototype, "workspaces") + patch(Hyprland.prototype, "clients") + patch(Monitor.prototype, "availableModes") + patch(Monitor.prototype, "available_modes") + patch(Workspace.prototype, "clients") +}) + +await suppress(import("gi://AstalMpris"), ({ Mpris, Player }) => { + patch(Mpris.prototype, "players") + patch(Player.prototype, "supported_uri_schemas") + patch(Player.prototype, "supportedUriSchemas") + patch(Player.prototype, "supported_mime_types") + patch(Player.prototype, "supportedMimeTypes") + patch(Player.prototype, "comments") +}) + +await suppress(import("gi://AstalNetwork"), ({ Wifi }) => { + patch(Wifi.prototype, "access_points") + patch(Wifi.prototype, "accessPoints") +}) + +await suppress(import("gi://AstalNotifd"), ({ Notifd, Notification }) => { + patch(Notifd.prototype, "notifications") + patch(Notification.prototype, "actions") +}) + +await suppress(import("gi://AstalPowerProfiles"), ({ PowerProfiles }) => { + patch(PowerProfiles.prototype, "actions") +}) diff --git a/lang/gjs/tsconfig.json b/lang/gjs/tsconfig.json index 4e57e37..7a3a8c8 100644 --- a/lang/gjs/tsconfig.json +++ b/lang/gjs/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "experimentalDecorators": true, + "module": "ES2022", "target": "ES2023", "outDir": "dist", "strict": true, -- cgit v1.2.3 From 41c002faf826a8ac637e6dece4c9ba1e65b1c608 Mon Sep 17 00:00:00 2001 From: Aylur Date: Mon, 18 Nov 2024 16:05:21 +0100 Subject: docs: add examples pages copies from the supported languages page --- docs/guide/lua/examples.md | 4 ++++ docs/guide/typescript/examples.md | 14 ++++++++++++++ docs/vitepress.config.ts | 2 ++ 3 files changed, 20 insertions(+) create mode 100644 docs/guide/lua/examples.md create mode 100644 docs/guide/typescript/examples.md diff --git a/docs/guide/lua/examples.md b/docs/guide/lua/examples.md new file mode 100644 index 0000000..be46b6e --- /dev/null +++ b/docs/guide/lua/examples.md @@ -0,0 +1,4 @@ +# Lua examples + +## [Simple Bar](https://github.com/Aylur/astal/tree/main/examples/lua/simple-bar) +![simple-bar](https://github.com/user-attachments/assets/a306c864-56b7-44c4-8820-81f424f32b9b) diff --git a/docs/guide/typescript/examples.md b/docs/guide/typescript/examples.md new file mode 100644 index 0000000..ec51e89 --- /dev/null +++ b/docs/guide/typescript/examples.md @@ -0,0 +1,14 @@ +# TypeScript Examples + +## Gtk3 + +### [Simple Bar](https://github.com/Aylur/astal/tree/main/examples/js/simple-bar) +![simple-bar](https://github.com/user-attachments/assets/a306c864-56b7-44c4-8820-81f424f32b9b) + +### [Notification Popups](https://github.com/Aylur/astal/tree/main/examples/js/notifications) +![notification-popups](https://github.com/user-attachments/assets/0df0eddc-5c74-4af0-a694-48dc8ec6bb44) +### [Applauncher](https://github.com/Aylur/astal/tree/main/examples/js/applauncher) +![launcher](https://github.com/user-attachments/assets/2695e3bb-dff4-478a-b392-279fe638bfd3) + +### [Media Player](https://github.com/Aylur/astal/tree/main/examples/js/media-player) +![media-player](https://github.com/user-attachments/assets/891e9706-74db-4505-bd83-c3628d7b4fd0) diff --git a/docs/vitepress.config.ts b/docs/vitepress.config.ts index 7e16eb7..3593b40 100644 --- a/docs/vitepress.config.ts +++ b/docs/vitepress.config.ts @@ -73,6 +73,7 @@ export default defineConfig({ { text: "GObject", link: "/gobject" }, { text: "Utilities", link: "/utilities" }, { text: "FAQ", link: "/faq" }, + { text: "Examples", link: "/examples" }, ], }, { @@ -90,6 +91,7 @@ export default defineConfig({ // { text: "GObject", link: "/gobject" }, { text: "Utilities", link: "/utilities" }, // { text: "FAQ", link: "/faq" }, + { text: "Examples", link: "/examples" }, ], }, { -- cgit v1.2.3 From 664c7a4ddfcf48c6e8accd3c33bb94424b0e8609 Mon Sep 17 00:00:00 2001 From: Aylur Date: Mon, 18 Nov 2024 17:56:25 +0000 Subject: fix: f5ed9aad meson --- lang/gjs/meson.build | 1 + lang/gjs/src/_app.ts | 2 +- lang/gjs/src/index.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lang/gjs/meson.build b/lang/gjs/meson.build index f4272ee..51496dc 100644 --- a/lang/gjs/meson.build +++ b/lang/gjs/meson.build @@ -14,6 +14,7 @@ install_data( 'src/process.ts', 'src/time.ts', 'src/variable.ts', + 'src/overrides.ts', 'src/_app.ts', ], install_dir: dest, diff --git a/lang/gjs/src/_app.ts b/lang/gjs/src/_app.ts index 60fb407..3dadd04 100644 --- a/lang/gjs/src/_app.ts +++ b/lang/gjs/src/_app.ts @@ -1,4 +1,4 @@ -import "./overrides" +import "./overrides.js" import { setConsoleLogDomain } from "console" import { exit, programArgs } from "system" import IO from "gi://AstalIO" diff --git a/lang/gjs/src/index.ts b/lang/gjs/src/index.ts index f4c5773..8fe8d01 100644 --- a/lang/gjs/src/index.ts +++ b/lang/gjs/src/index.ts @@ -1,4 +1,4 @@ -import "./overrides" +import "./overrides.js" export { default as AstalIO } from "gi://AstalIO?version=0.1" export * from "./process.js" export * from "./time.js" -- cgit v1.2.3 From 920e7d2b03e72043f55dbb4bddc020f407748518 Mon Sep 17 00:00:00 2001 From: Aylur Date: Mon, 18 Nov 2024 22:35:45 +0000 Subject: docs: list of how widgets are passed --- docs/guide/typescript/first-widgets.md | 83 ++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 25 deletions(-) diff --git a/docs/guide/typescript/first-widgets.md b/docs/guide/typescript/first-widgets.md index a467382..ac4f739 100644 --- a/docs/guide/typescript/first-widgets.md +++ b/docs/guide/typescript/first-widgets.md @@ -354,42 +354,75 @@ inner state of widgets that does not need to be recreated. In this case you can create a [custom reactive structure](./binding#example-custom-subscribable) ::: -When there is at least one `Binding` passed as a child, the `children` -parameter will always be a flattened `Binding>`. -When there is a single `Binding` passed as a child, the `child` parameter will -be a `Binding` or a flattened `Binding>`. +# How children are passed + +Here is full list of how children and bound children can be passed to custom widgets. ```tsx -import { type Binding } from "astal" +import Binding from "astal/binding" -function MyContainer({ children }: { - children?: Binding> -}) { - // children is a Binding over an Array of widgets -} +function Parent(props: { + child?: JSX.Element | Binding | Binding> + children?: Array | Binding> +}) -return - - {num(n => range(n).map(i => ( - } ``` -- cgit v1.2.3 From dc4d5a43f35b5bf09cde3f73f0ea03aa6c822c3d Mon Sep 17 00:00:00 2001 From: kotontrion Date: Wed, 20 Nov 2024 13:20:51 +0100 Subject: mpris: fix typo in dbus property the property is called SupportedUriSchemes not SupportedUriSchemas --- lib/mpris/cli.vala | 4 ++-- lib/mpris/ifaces.vala | 2 +- lib/mpris/player.vala | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/mpris/cli.vala b/lib/mpris/cli.vala index b71def9..7e15c6e 100644 --- a/lib/mpris/cli.vala +++ b/lib/mpris/cli.vala @@ -179,7 +179,7 @@ int main(string[] argv) { Json.Node to_json(Player p) { var uris = new Json.Builder().begin_array(); - foreach (var uri in p.supported_uri_schemas) + foreach (var uri in p.supported_uri_schemes) uris.add_string_value(uri); uris.end_array(); @@ -189,7 +189,7 @@ Json.Node to_json(Player p) { .set_member_name("available").add_boolean_value(p.available) .set_member_name("identity").add_string_value(p.identity) .set_member_name("entry").add_string_value(p.entry) - .set_member_name("supported_uri_schemas").add_value(uris.get_root()) + .set_member_name("supported_uri_schemes").add_value(uris.get_root()) .set_member_name("loop_status").add_string_value(p.loop_status.to_string()) .set_member_name("shuffle_status").add_string_value(p.shuffle_status.to_string()) .set_member_name("rate").add_double_value(p.rate) diff --git a/lib/mpris/ifaces.vala b/lib/mpris/ifaces.vala index 298a288..8755723 100644 --- a/lib/mpris/ifaces.vala +++ b/lib/mpris/ifaces.vala @@ -21,7 +21,7 @@ private interface AstalMpris.IMpris : PropsIface { public abstract bool has_track_list { get; } public abstract string identity { owned get; } public abstract string desktop_entry { owned get; } - public abstract string[] supported_uri_schemas { owned get; } + public abstract string[] supported_uri_schemes { owned get; } public abstract string[] supported_mime_types { owned get; } } diff --git a/lib/mpris/player.vala b/lib/mpris/player.vala index 2050f61..c69eb21 100644 --- a/lib/mpris/player.vala +++ b/lib/mpris/player.vala @@ -87,7 +87,7 @@ public class AstalMpris.Player : Object { * Almost every media player will include support for the "file" scheme. * Other common schemes are "http" and "rtsp". */ - public string[] supported_uri_schemas { owned get; private set; } + public string[] supported_uri_schemes { owned get; private set; } /** * The mime-types supported by the player. @@ -160,7 +160,7 @@ public class AstalMpris.Player : Object { } /** - * uri scheme should be an element of [property@AstalMpris.Player:supported_uri_schemas] + * uri scheme should be an element of [property@AstalMpris.Player:supported_uri_schemes] * and the mime-type should match one of the elements of [property@AstalMpris.Player:supported_mime_types]. * * @param uri Uri of the track to load. @@ -425,7 +425,7 @@ public class AstalMpris.Player : Object { // has_track_list = proxy.has_track_list; identity = proxy.identity; entry = proxy.desktop_entry; - supported_uri_schemas = proxy.supported_uri_schemas; + supported_uri_schemes = proxy.supported_uri_schemes; supported_mime_types = proxy.supported_mime_types; if (position >= 0) -- cgit v1.2.3 From f9a35261aeb8ea135ff0f279acbf2d12164e427a Mon Sep 17 00:00:00 2001 From: Aylur Date: Thu, 21 Nov 2024 12:48:43 +0000 Subject: fix #114 create client on windowtitlev2 --- lib/hyprland/hyprland.vala | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/hyprland/hyprland.vala b/lib/hyprland/hyprland.vala index 195a3f6..17c426c 100644 --- a/lib/hyprland/hyprland.vala +++ b/lib/hyprland/hyprland.vala @@ -381,13 +381,8 @@ public class Hyprland : Object { break; case "openwindow": - var addr = args[1].split(",")[0]; - var client = new Client(); - _clients.insert(addr, client); yield sync_clients(); yield sync_workspaces(); - client_added(client); - notify_property("clients"); break; case "closewindow": @@ -426,6 +421,17 @@ public class Hyprland : Object { minimize(get_client(argv[0]), argv[1] == "0"); break; + // first event that signals a new window not openwindow + case "windowtitlev2": + var addr = args[1].split(",")[0]; + var client = new Client(); + _clients.insert(addr, client); + yield sync_clients(); + yield sync_workspaces(); + client_added(client); + notify_property("clients"); + break; + case "windowtitle": yield sync_clients(); break; -- cgit v1.2.3 From 03b720929d64dcdaaef7ab3a7234596977b6ea08 Mon Sep 17 00:00:00 2001 From: tyrael <116419708+44mira@users.noreply.github.com> Date: Sat, 23 Nov 2024 00:26:42 +0800 Subject: doc: fix broken links to gtk docs --- docs/guide/lua/widget.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/guide/lua/widget.md b/docs/guide/lua/widget.md index d9f99fa..593628e 100644 --- a/docs/guide/lua/widget.md +++ b/docs/guide/lua/widget.md @@ -139,18 +139,18 @@ These widgets are available by default in Lua. - Button: [Astal.Button](https://aylur.github.io/libastal/astal3/class.Button.html) - CenterBox: [Astal.CenterBox](https://aylur.github.io/libastal/astal3/class.CenterBox.html) - CircularProgress: [Astal.CircularProgress](https://aylur.github.io/libastal/astal3/class.CircularProgress.html) -- DrawingArea: [Gtk.DrawingArea](https://docs.gtk.org/gtk3/astal3/class.DrawingArea.html) -- Entry: [Gtk.Entry](https://docs.gtk.org/gtk3/astal3/class.Entry.html) +- DrawingArea: [Gtk.DrawingArea](https://docs.gtk.org/gtk3/class.DrawingArea.html) +- Entry: [Gtk.Entry](https://docs.gtk.org/gtk3/class.Entry.html) - Eventbox: [Astal.EventBox](https://aylur.github.io/libastal/astal3/class.EventBox.html) - Icon: [Astal.Icon](https://aylur.github.io/libastal/astal3/class.Icon.html) - Label: [Astal.Label](https://aylur.github.io/libastal/astal3/class.Label.html) - Levelbar: [Astal.LevelBar](https://aylur.github.io/libastal/astal3/class.LevelBar.html) - Overlay: [Astal.Overlay](https://aylur.github.io/libastal/astal3/class.Overlay.html) -- Revealer: [Gtk.Revealer](https://docs.gtk.org/gtk3/astal3/class.Revealer.html) +- Revealer: [Gtk.Revealer](https://docs.gtk.org/gtk3/class.Revealer.html) - Scrollable: [Astal.Scrollable](https://aylur.github.io/libastal/astal3/class.Scrollable.html) - Slider: [Astal.Slider](https://aylur.github.io/libastal/astal3/class.Slider.html) - Stack: [Astal.Stack](https://aylur.github.io/libastal/astal3/class.Stack.html) -- Switch: [Gtk.Switch](https://docs.gtk.org/gtk3/astal3/class.Switch.html) +- Switch: [Gtk.Switch](https://docs.gtk.org/gtk3/class.Switch.html) - Window: [Astal.Window](https://aylur.github.io/libastal/astal3/class.Window.html) ## Gtk4 -- cgit v1.2.3 From 4b87bb6c86b345aea63793a2f88ebdaec88c0d52 Mon Sep 17 00:00:00 2001 From: Aylur Date: Fri, 22 Nov 2024 20:10:22 +0000 Subject: docs: highlight global module tip --- docs/guide/typescript/faq.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/guide/typescript/faq.md b/docs/guide/typescript/faq.md index 444a0af..4ee616b 100644 --- a/docs/guide/typescript/faq.md +++ b/docs/guide/typescript/faq.md @@ -92,7 +92,7 @@ printerr("print this line to stderr") ## Populate the global scope with frequently accessed variables -It might be annoying to always import Gtk only for `Gtk.Align` enums. +It might be annoying to always import Gtk only for the `Gtk.Align` enum. :::code-group @@ -118,7 +118,7 @@ Object.assign(globalThis, { :::code-group -```tsx [Bar.tsx] +```tsx [Bar.tsx] {3} export default function Bar() { return @@ -131,11 +131,13 @@ export default function Bar() { :::code-group ```ts [app.ts] -import "./globals" +import "./globals" // don't forget to import it first // [!code ++] import Bar from "./Bar" App.start({ - main: Bar + main() { + Bar() + } }) ``` -- cgit v1.2.3 From d953f4bae6c0a29cbee509015799fbb223d17188 Mon Sep 17 00:00:00 2001 From: Aylur <104676705+Aylur@users.noreply.github.com> Date: Sat, 23 Nov 2024 11:01:44 +0100 Subject: Update gobject.md --- docs/guide/typescript/gobject.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/typescript/gobject.md b/docs/guide/typescript/gobject.md index f7f001d..4e40845 100644 --- a/docs/guide/typescript/gobject.md +++ b/docs/guide/typescript/gobject.md @@ -74,7 +74,7 @@ class MyObj extends GObject.Object { declare myProp: string constructor() { - super({ myProp: "default-value" }) + super({ myProp: "default-value" } as any) } } ``` -- cgit v1.2.3 From 57c3bf427bba34399b7eecd3833fbbe3b35c59da Mon Sep 17 00:00:00 2001 From: tyrael <116419708+44mira@users.noreply.github.com> Date: Sun, 24 Nov 2024 01:23:55 +0800 Subject: doc: fix incorrect arch package --- docs/guide/lua/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/lua/installation.md b/docs/guide/lua/installation.md index b99d8df..f647ed7 100644 --- a/docs/guide/lua/installation.md +++ b/docs/guide/lua/installation.md @@ -9,7 +9,7 @@ Read more about it on the [nix page](../getting-started/nix) ## Arch ```sh -yay -S lua-libastal-git +yay -S libastal-lua-git ``` ## From Source -- cgit v1.2.3 From 3e6c7eeb1c96b5afba82f5fdc2ab35c78f383b38 Mon Sep 17 00:00:00 2001 From: Aylur Date: Sun, 24 Nov 2024 02:11:57 +0100 Subject: add changelog empty for now though close #121 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..df8746e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## 0.1.0 + +WIP -- cgit v1.2.3 From 3f554403ff92d6603ff04d13f26a71aba41375df Mon Sep 17 00:00:00 2001 From: Aylur Date: Sun, 24 Nov 2024 20:21:30 +0000 Subject: fix(hyprland): client creation resolve #124 resolve #131 --- lib/hyprland/hyprland.vala | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/hyprland/hyprland.vala b/lib/hyprland/hyprland.vala index 17c426c..663eb19 100644 --- a/lib/hyprland/hyprland.vala +++ b/lib/hyprland/hyprland.vala @@ -318,8 +318,19 @@ public class Hyprland : Object { focused_workspace = get_workspace_by_name(argv[1]); break; + // first event that signals a new client case "activewindowv2": - focused_client = get_client(args[1]); + if (args[1] != "" && get_client(args[1]) == null) { + var client = new Client(); + _clients.insert(args[1], client); + yield sync_clients(); + yield sync_workspaces(); + client_added(client); + notify_property("clients"); + focused_client = client; + } else { + focused_client = get_client(args[1]); + } break; // TODO: nag vaxry for fullscreenv2 that passes address @@ -421,19 +432,9 @@ public class Hyprland : Object { minimize(get_client(argv[0]), argv[1] == "0"); break; - // first event that signals a new window not openwindow - case "windowtitlev2": - var addr = args[1].split(",")[0]; - var client = new Client(); - _clients.insert(addr, client); - yield sync_clients(); - yield sync_workspaces(); - client_added(client); - notify_property("clients"); - break; - + // nothing to update case "windowtitle": - yield sync_clients(); + case "windowtitlev2": break; // TODO: -- cgit v1.2.3 From ac304ef346be220dd5c5d3c818c8151bdb78d730 Mon Sep 17 00:00:00 2001 From: Aylur Date: Sun, 24 Nov 2024 20:23:59 +0000 Subject: fix(hyprland): sync monitors on activeworkspace close #130 --- lib/hyprland/hyprland.vala | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/hyprland/hyprland.vala b/lib/hyprland/hyprland.vala index 663eb19..803380d 100644 --- a/lib/hyprland/hyprland.vala +++ b/lib/hyprland/hyprland.vala @@ -309,6 +309,7 @@ public class Hyprland : Object { switch (args[0]) { case "workspacev2": yield sync_workspaces(); + yield sync_monitors(); focused_workspace = get_workspace(int.parse(args[1])); break; -- cgit v1.2.3 From 3d9c50cb8ade0319c33fbd2daefeaaa698141256 Mon Sep 17 00:00:00 2001 From: Aylur Date: Sun, 24 Nov 2024 22:30:21 +0000 Subject: fix(hyprland): update title --- lib/hyprland/hyprland.vala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/hyprland/hyprland.vala b/lib/hyprland/hyprland.vala index 803380d..9825a91 100644 --- a/lib/hyprland/hyprland.vala +++ b/lib/hyprland/hyprland.vala @@ -433,9 +433,8 @@ public class Hyprland : Object { minimize(get_client(argv[0]), argv[1] == "0"); break; - // nothing to update - case "windowtitle": case "windowtitlev2": + yield sync_clients(); break; // TODO: -- cgit v1.2.3 From b7af61d770510b1c797e1c7137a4da934cdca7a2 Mon Sep 17 00:00:00 2001 From: Aylur Date: Sun, 24 Nov 2024 23:43:28 +0000 Subject: example: cleanup --- examples/js/notifications/notifications/NotificationPopups.tsx | 4 ++-- examples/js/simple-bar/widget/Bar.tsx | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/js/notifications/notifications/NotificationPopups.tsx b/examples/js/notifications/notifications/NotificationPopups.tsx index a8088c9..9b84d84 100644 --- a/examples/js/notifications/notifications/NotificationPopups.tsx +++ b/examples/js/notifications/notifications/NotificationPopups.tsx @@ -2,7 +2,7 @@ import { Astal, Gtk, Gdk } from "astal/gtk3" import Notifd from "gi://AstalNotifd" import Notification from "./Notification" import { type Subscribable } from "astal/binding" -import { GLib, Variable, bind, timeout } from "astal" +import { Variable, bind, timeout } from "astal" // see comment below in constructor const TIMEOUT_DELAY = 5000 @@ -23,7 +23,7 @@ class NotifiationMap implements Subscribable { this.var.set([...this.map.values()].reverse()) } - private constructor() { + constructor() { const notifd = Notifd.get_default() /** diff --git a/examples/js/simple-bar/widget/Bar.tsx b/examples/js/simple-bar/widget/Bar.tsx index efc065a..8a0126e 100644 --- a/examples/js/simple-bar/widget/Bar.tsx +++ b/examples/js/simple-bar/widget/Bar.tsx @@ -133,15 +133,13 @@ function Time({ format = "%H:%M - %A %e." }) { } export default function Bar(monitor: Gdk.Monitor) { - const anchor = Astal.WindowAnchor.TOP - | Astal.WindowAnchor.LEFT - | Astal.WindowAnchor.RIGHT + const { TOP, LEFT, RIGHT } = Astal.WindowAnchor return + anchor={TOP | LEFT | RIGHT}> -- cgit v1.2.3 From 12fa0fbf1c05319a6b7a9a772a7b1f03e7ca4cae Mon Sep 17 00:00:00 2001 From: kotontrion Date: Tue, 26 Nov 2024 09:22:35 +0100 Subject: gjs: add workarounds for AstalWp --- lang/gjs/src/overrides.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lang/gjs/src/overrides.ts b/lang/gjs/src/overrides.ts index 6643ba5..5b1ebad 100644 --- a/lang/gjs/src/overrides.ts +++ b/lang/gjs/src/overrides.ts @@ -67,3 +67,18 @@ await suppress(import("gi://AstalNotifd"), ({ Notifd, Notification }) => { await suppress(import("gi://AstalPowerProfiles"), ({ PowerProfiles }) => { patch(PowerProfiles.prototype, "actions") }) + +await suppress(import("gi://AstalWp"), ({ Wp, Audio, Video }) => { + patch(Wp.prototype, "endpoints") + patch(Wp.prototype, "devices") + patch(Audio.prototype, "streams") + patch(Audio.prototype, "recorders") + patch(Audio.prototype, "microphones") + patch(Audio.prototype, "speakers") + patch(Audio.prototype, "devices") + patch(Video.prototype, "streams") + patch(Video.prototype, "recorders") + patch(Video.prototype, "sinks") + patch(Video.prototype, "sources") + patch(Video.prototype, "devices") +}) -- cgit v1.2.3 From 7b4d2ebdf525f98d1fddffb433ab350c335d168f Mon Sep 17 00:00:00 2001 From: Aylur Date: Fri, 29 Nov 2024 15:35:22 +0100 Subject: fix(hyprland): sync monitors on focusedmon #147 --- lib/hyprland/hyprland.vala | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/hyprland/hyprland.vala b/lib/hyprland/hyprland.vala index 9825a91..5bdff81 100644 --- a/lib/hyprland/hyprland.vala +++ b/lib/hyprland/hyprland.vala @@ -315,6 +315,7 @@ public class Hyprland : Object { case "focusedmon": var argv = args[1].split(",", 2); + yield sync_monitors(); focused_monitor = get_monitor_by_name(argv[0]); focused_workspace = get_workspace_by_name(argv[1]); break; -- cgit v1.2.3 From 990f031507b21f8a18c0710016fb76b1f260afe8 Mon Sep 17 00:00:00 2001 From: Aylur Date: Fri, 29 Nov 2024 16:08:15 +0100 Subject: fix(mpris): reset cover_art fix #142 --- lib/mpris/player.vala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/mpris/player.vala b/lib/mpris/player.vala index c69eb21..f4ba8ec 100644 --- a/lib/mpris/player.vala +++ b/lib/mpris/player.vala @@ -498,8 +498,10 @@ public class AstalMpris.Player : Object { } private async void cache_cover() { - if (art_url == null || art_url == "") + if (art_url == null || art_url == "") { + cover_art = null; return; + } var file = File.new_for_uri(art_url); if (file.get_path() != null) { -- cgit v1.2.3 From 92ed24778937b454c5a2c37e664cdd5c865820dc Mon Sep 17 00:00:00 2001 From: municorn Date: Wed, 4 Dec 2024 12:39:10 -0700 Subject: fix(network): specify values for State enum --- lib/network/network.vala | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/network/network.vala b/lib/network/network.vala index 96e19c8..b5a6c61 100644 --- a/lib/network/network.vala +++ b/lib/network/network.vala @@ -104,14 +104,14 @@ public enum AstalNetwork.Primary { // alias for NM.State public enum AstalNetwork.State { - UNKNOWN, - ASLEEP, - DISCONNECTED, - DISCONNECTING, - CONNECTING, - CONNECTED_LOCAL, - CONNECTED_SITE, - CONNECTED_GLOBAL; + UNKNOWN = 0, + ASLEEP = 10, + DISCONNECTED = 20, + DISCONNECTING = 30, + CONNECTING = 40, + CONNECTED_LOCAL = 50, + CONNECTED_SITE = 60, + CONNECTED_GLOBAL = 70; public string to_string() { switch (this) { -- cgit v1.2.3 From ae85ea90419401e726262b466a5c67b533f0746c Mon Sep 17 00:00:00 2001 From: danielwerg <35052399+danielwerg@users.noreply.github.com> Date: Fri, 6 Dec 2024 01:41:00 +0300 Subject: fix(mpris): shuffle/loop unsupported --- lib/mpris/player.vala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/mpris/player.vala b/lib/mpris/player.vala index f4ba8ec..e6d84bf 100644 --- a/lib/mpris/player.vala +++ b/lib/mpris/player.vala @@ -440,6 +440,9 @@ public class AstalMpris.Player : Object { _loop_status = Loop.from_string(proxy.loop_status); notify_property("loop-status"); } + } else { + _loop_status = Loop.UNSUPPORTED; + notify_property("loop-status"); } if (rate != proxy.rate) { @@ -452,6 +455,9 @@ public class AstalMpris.Player : Object { _shuffle_status = Shuffle.from_bool(proxy.shuffle); notify_property("shuffle-status"); } + } else { + _shuffle_status = Shuffle.UNSUPPORTED; + notify_property("shuffle-status"); } if (volume != proxy.volume) { -- cgit v1.2.3 From 6fbeb920eae7f5201d828230ac2ac00d78369251 Mon Sep 17 00:00:00 2001 From: kotontrion Date: Wed, 11 Dec 2024 13:18:47 +0100 Subject: gjs: fix typo in overrides --- lang/gjs/src/overrides.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lang/gjs/src/overrides.ts b/lang/gjs/src/overrides.ts index 5b1ebad..0d09e7b 100644 --- a/lang/gjs/src/overrides.ts +++ b/lang/gjs/src/overrides.ts @@ -47,8 +47,8 @@ await suppress(import("gi://AstalHyprland"), ({ Hyprland, Monitor, Workspace }) await suppress(import("gi://AstalMpris"), ({ Mpris, Player }) => { patch(Mpris.prototype, "players") - patch(Player.prototype, "supported_uri_schemas") - patch(Player.prototype, "supportedUriSchemas") + patch(Player.prototype, "supported_uri_schemes") + patch(Player.prototype, "supportedUriSchemes") patch(Player.prototype, "supported_mime_types") patch(Player.prototype, "supportedMimeTypes") patch(Player.prototype, "comments") -- cgit v1.2.3 From d8d62d748f526eb47622009264d87727a074f7fc Mon Sep 17 00:00:00 2001 From: Aylur Date: Fri, 13 Dec 2024 13:08:52 +0100 Subject: fix(gjs): string property default value --- lang/gjs/src/gobject.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/gjs/src/gobject.ts b/lang/gjs/src/gobject.ts index b744cfb..6bd9969 100644 --- a/lang/gjs/src/gobject.ts +++ b/lang/gjs/src/gobject.ts @@ -178,7 +178,7 @@ function defaultValue(declaration: PropertyDeclaration) { switch (declaration) { case String: - return "default-string" + return "" case Number: return 0 case Boolean: -- cgit v1.2.3 From 4f47b69946dd7127ba66e6333af4945afaba15de Mon Sep 17 00:00:00 2001 From: Aylur Date: Fri, 13 Dec 2024 13:28:14 +0100 Subject: fix #179: power profiles missing profile key --- lib/powerprofiles/cli.vala | 2 +- lib/powerprofiles/power-profiles.vala | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/powerprofiles/cli.vala b/lib/powerprofiles/cli.vala index 1e5cc70..87ffe82 100644 --- a/lib/powerprofiles/cli.vala +++ b/lib/powerprofiles/cli.vala @@ -100,7 +100,7 @@ string to_json_string(AstalPowerProfiles.PowerProfiles profiles) { foreach (var prof in profiles.profiles) { profs.add_value(new Json.Builder() .begin_object() - .set_member_name("profie").add_string_value(prof.profile) + .set_member_name("profile").add_string_value(prof.profile) .set_member_name("driver").add_string_value(prof.driver) .set_member_name("cpu_driver").add_string_value(prof.cpu_driver) .set_member_name("platform_driver").add_string_value(prof.platform_driver) diff --git a/lib/powerprofiles/power-profiles.vala b/lib/powerprofiles/power-profiles.vala index a104d2e..931fc04 100644 --- a/lib/powerprofiles/power-profiles.vala +++ b/lib/powerprofiles/power-profiles.vala @@ -113,6 +113,11 @@ public class PowerProfiles : Object { owned get { return proxy.performance_degraded; } } + private string? get_hashtable_string(HashTable table, string key) { + var v = table.get(key); + return v == null ? null : v.get_string(); + } + /** * List of each profile. */ @@ -122,10 +127,10 @@ public class PowerProfiles : Object { for (var i = 0; i < proxy.profiles.length; ++i) { var prof = proxy.profiles[i]; profs[i] = Profile() { - profile = prof.get("Profile").get_string(), - cpu_driver = prof.get("CpuDriver").get_string(), - platform_driver = prof.get("PlatformDriver").get_string(), - driver = prof.get("Driver").get_string() + profile = get_hashtable_string(prof, "Profile"), + cpu_driver = get_hashtable_string(prof, "CpuDriver"), + platform_driver = get_hashtable_string(prof, "PlatformDriver"), + driver = get_hashtable_string(prof, "Driver"), }; } return profs; -- cgit v1.2.3 From c12fb05408c1cd1b1bca545fec636abda52f6755 Mon Sep 17 00:00:00 2001 From: Aylur Date: Sat, 14 Dec 2024 20:14:29 +0100 Subject: style: IO.Process constructor --- lib/astal/io/process.vala | 13 +++++++++++-- lib/astal/io/variable.vala | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/astal/io/process.vala b/lib/astal/io/process.vala index cfd05b9..4b77aee 100644 --- a/lib/astal/io/process.vala +++ b/lib/astal/io/process.vala @@ -76,7 +76,7 @@ public class AstalIO.Process : Object { * * The first element of the vector is executed with the remaining elements as the argument list. */ - public Process.subprocessv(string[] cmd) throws Error { + public Process(string[] cmd) throws Error { Object(argv: cmd); process = new Subprocess.newv(cmd, SubprocessFlags.STDIN_PIPE | @@ -90,6 +90,15 @@ public class AstalIO.Process : Object { read_stream(err_stream, false); } + /** + * Start a new subprocess with the given command. + * + * The first element of the vector is executed with the remaining elements as the argument list. + */ + public static Process subprocessv(string[] cmd) throws Error { + return new Process(cmd); + } + /** * Start a new subprocess with the given command * which is parsed using [func@GLib.shell_parse_argv]. @@ -97,7 +106,7 @@ public class AstalIO.Process : Object { public static Process subprocess(string cmd) throws Error { string[] argv; Shell.parse_argv(cmd, out argv); - return new Process.subprocessv(argv); + return Process.subprocessv(argv); } /** diff --git a/lib/astal/io/variable.vala b/lib/astal/io/variable.vala index 312a27a..e4105f8 100644 --- a/lib/astal/io/variable.vala +++ b/lib/astal/io/variable.vala @@ -172,7 +172,7 @@ public class AstalIO.Variable : VariableBase { return_if_fail(watch_proc == null); return_if_fail(watch_exec != null); - watch_proc = new Process.subprocessv(watch_exec); + watch_proc = Process.subprocessv(watch_exec); watch_proc.stdout.connect((str) => set_closure(str, watch_transform)); watch_proc.stderr.connect((str) => this.error(str)); } -- cgit v1.2.3