summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/gjs/src/variable.ts1
-rw-r--r--core/lua/astal/variable.lua3
-rw-r--r--examples/vala/simple-bar/app.vala14
-rw-r--r--examples/vala/simple-bar/flake.lock62
-rw-r--r--examples/vala/simple-bar/flake.nix36
-rw-r--r--examples/vala/simple-bar/meson.build23
-rw-r--r--examples/vala/simple-bar/widget/Bar.vala50
7 files changed, 185 insertions, 4 deletions
diff --git a/core/gjs/src/variable.ts b/core/gjs/src/variable.ts
index 84f8cc5..8739ef6 100644
--- a/core/gjs/src/variable.ts
+++ b/core/gjs/src/variable.ts
@@ -101,7 +101,6 @@ class VariableWrapper<T> extends Function {
drop() {
this.variable.emit("dropped")
- idle(() => this.variable.run_dispose())
}
onDropped(callback: () => void) {
diff --git a/core/lua/astal/variable.lua b/core/lua/astal/variable.lua
index da2e894..377b448 100644
--- a/core/lua/astal/variable.lua
+++ b/core/lua/astal/variable.lua
@@ -124,9 +124,6 @@ end
function Variable:drop()
self.variable.emit_dropped()
- Astal.Time.idle(GObject.Closure(function()
- self.variable.run_dispose()
- end))
end
---@param callback function
diff --git a/examples/vala/simple-bar/app.vala b/examples/vala/simple-bar/app.vala
new file mode 100644
index 0000000..ccd3957
--- /dev/null
+++ b/examples/vala/simple-bar/app.vala
@@ -0,0 +1,14 @@
+class Application : Astal.Application {
+ Application() {
+
+ }
+
+ public override void activate () {
+ this.add_window(new Bar());
+ }
+
+ public static int main() {
+ var app = new Application();
+ return app.run(null);
+ }
+}
diff --git a/examples/vala/simple-bar/flake.lock b/examples/vala/simple-bar/flake.lock
new file mode 100644
index 0000000..34fb84f
--- /dev/null
+++ b/examples/vala/simple-bar/flake.lock
@@ -0,0 +1,62 @@
+{
+ "nodes": {
+ "astal": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ },
+ "locked": {
+ "lastModified": 1726702968,
+ "narHash": "sha256-kRS/WZzwBiVgfBVz0HTRl4FnmUEHDIRp0962rrFtvk8=",
+ "owner": "aylur",
+ "repo": "astal",
+ "rev": "a819c41afcdde7b4bbe0ecf04dc8a84c87cc3c75",
+ "type": "github"
+ },
+ "original": {
+ "owner": "aylur",
+ "repo": "astal",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1716293225,
+ "narHash": "sha256-pU9ViBVE3XYb70xZx+jK6SEVphvt7xMTbm6yDIF4xPs=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "3eaeaeb6b1e08a016380c279f8846e0bd8808916",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs_2": {
+ "locked": {
+ "lastModified": 1726463316,
+ "narHash": "sha256-gI9kkaH0ZjakJOKrdjaI/VbaMEo9qBbSUl93DnU7f4c=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "99dc8785f6a0adac95f5e2ab05cc2e1bf666d172",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "astal": "astal",
+ "nixpkgs": "nixpkgs_2"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/examples/vala/simple-bar/flake.nix b/examples/vala/simple-bar/flake.nix
new file mode 100644
index 0000000..9b977a2
--- /dev/null
+++ b/examples/vala/simple-bar/flake.nix
@@ -0,0 +1,36 @@
+{
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
+ astal.url = "github:aylur/astal";
+ };
+
+ outputs = {
+ self,
+ nixpkgs,
+ astal,
+ }: let
+ system = "x86_64-linux";
+ pkgs = nixpkgs.legacyPackages.${system};
+ in {
+ packages.${system} = {
+ default = pkgs.stdenv.mkDerivation {
+ pname = "simple-bar";
+ version = "git";
+ src = ./.;
+
+ nativeBuildInputs = [
+ pkgs.meson
+ pkgs.ninja
+ pkgs.pkg-config
+ pkgs.vala
+ pkgs.gobject-introspection
+ ];
+
+ buildInputs = [
+ astal.packages.${system}.default
+ astal.packages.${system}.battery
+ ];
+ };
+ };
+ };
+}
diff --git a/examples/vala/simple-bar/meson.build b/examples/vala/simple-bar/meson.build
new file mode 100644
index 0000000..960ce0d
--- /dev/null
+++ b/examples/vala/simple-bar/meson.build
@@ -0,0 +1,23 @@
+project('simple-bar', 'vala', 'c')
+
+sources = files(
+ 'widget/Bar.vala',
+ 'app.vala',
+)
+
+pkgconfig_deps = [
+ dependency('glib-2.0'),
+ dependency('gobject-2.0'),
+ dependency('gtk+-3.0'),
+ dependency('astal-0.1'),
+ dependency('astal-battery-0.1'),
+]
+
+# needed for GLib.Math
+deps = pkgconfig_deps + meson.get_compiler('c').find_library('m')
+
+executable(
+ 'simple-bar',
+ sources,
+ dependencies: deps,
+)
diff --git a/examples/vala/simple-bar/widget/Bar.vala b/examples/vala/simple-bar/widget/Bar.vala
new file mode 100644
index 0000000..4d42f9c
--- /dev/null
+++ b/examples/vala/simple-bar/widget/Bar.vala
@@ -0,0 +1,50 @@
+class Battery : Gtk.Box {
+ Astal.Icon icon = new Astal.Icon();
+ Astal.Label label = new Astal.Label();
+
+ public Battery() {
+ add(icon);
+ add(label);
+
+ var bat = AstalBattery.get_default();
+ bat.bind_property("battery-icon-name", icon, "icon", BindingFlags.SYNC_CREATE);
+ bat.bind_property("percentage", label, "label", BindingFlags.SYNC_CREATE, (_, src, ref trgt) => {
+ var p = Math.floor(src.get_double() * 100);
+ trgt.set_string(@"$p%");
+ return true;
+ });
+ }
+}
+
+class Clock : Astal.Label {
+ string format;
+ Astal.Time interval;
+
+ void sync() {
+ label = new DateTime.now_local().format(format);
+ }
+
+ public Clock(string format = "%H:%M - %A %e.") {
+ this.format = format;
+ interval = Astal.Time.interval(1000, null);
+ interval.now.connect(sync);
+ destroy.connect(interval.cancel);
+ }
+}
+
+class Left : Gtk.Box {
+ public Left() {
+ add(new Clock());
+ add(new Battery());
+ }
+}
+
+class Bar : Astal.Window {
+ public Bar() {
+ add(new Astal.CenterBox() {
+ start_widget = new Left()
+ });
+
+ show_all();
+ }
+}