diff --git a/build.zig.zon b/build.zig.zon index a014195e9..188af450a 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -55,8 +55,8 @@ .gobject = .{ // https://github.com/jcollie/ghostty-gobject based on zig_gobject // Temporary until we generate them at build time automatically. - .url = "https://github.com/jcollie/ghostty-gobject/releases/download/0.14.0-2025-03-18-21-1/ghostty-gobject-0.14.0-2025-03-18-21-1.tar.zst", - .hash = "gobject-0.2.0-Skun7IWDlQAOKu4BV7LapIxL9Imbq1JRmzvcIkazvAxR", + .url = "https://github.com/jcollie/ghostty-gobject/releases/download/0.14.1-2025-07-19-27-1/ghostty-gobject-0.14.1-2025-07-19-27-1.tar.zst", + .hash = "gobject-0.3.0-Skun7KzYnAAsvbz0JzKA4LBdXbLqj0eNXHoKAIE0HkOl", .lazy = true, }, diff --git a/build.zig.zon.json b/build.zig.zon.json index 5d5fb07b4..863dcadf8 100644 --- a/build.zig.zon.json +++ b/build.zig.zon.json @@ -24,10 +24,10 @@ "url": "https://deps.files.ghostty.org/glslang-12201278a1a05c0ce0b6eb6026c65cd3e9247aa041b1c260324bf29cee559dd23ba1.tar.gz", "hash": "sha256-FKLtu1Ccs+UamlPj9eQ12/WXFgS0uDPmPmB26MCpl7U=" }, - "gobject-0.2.0-Skun7IWDlQAOKu4BV7LapIxL9Imbq1JRmzvcIkazvAxR": { + "gobject-0.3.0-Skun7KzYnAAsvbz0JzKA4LBdXbLqj0eNXHoKAIE0HkOl": { "name": "gobject", - "url": "https://github.com/jcollie/ghostty-gobject/releases/download/0.14.0-2025-03-18-21-1/ghostty-gobject-0.14.0-2025-03-18-21-1.tar.zst", - "hash": "sha256-hWcpl0Wd3XydT+RY7+VIoxXPhCzele1Ip76YSh+KmLI=" + "url": "https://github.com/jcollie/ghostty-gobject/releases/download/0.14.1-2025-07-19-27-1/ghostty-gobject-0.14.1-2025-07-19-27-1.tar.zst", + "hash": "sha256-c4szPFC+L2H8ZQ3g7aoVi+lPmF4I6STxN9+fBhxaap8=" }, "N-V-__8AALiNBAA-_0gprYr92CjrMj1I5bqNu0TSJOnjFNSr": { "name": "gtk4_layer_shell", diff --git a/build.zig.zon.nix b/build.zig.zon.nix index f70e43b70..c2114adfc 100644 --- a/build.zig.zon.nix +++ b/build.zig.zon.nix @@ -122,11 +122,11 @@ in }; } { - name = "gobject-0.2.0-Skun7IWDlQAOKu4BV7LapIxL9Imbq1JRmzvcIkazvAxR"; + name = "gobject-0.3.0-Skun7KzYnAAsvbz0JzKA4LBdXbLqj0eNXHoKAIE0HkOl"; path = fetchZigArtifact { name = "gobject"; - url = "https://github.com/jcollie/ghostty-gobject/releases/download/0.14.0-2025-03-18-21-1/ghostty-gobject-0.14.0-2025-03-18-21-1.tar.zst"; - hash = "sha256-hWcpl0Wd3XydT+RY7+VIoxXPhCzele1Ip76YSh+KmLI="; + url = "https://github.com/jcollie/ghostty-gobject/releases/download/0.14.1-2025-07-19-27-1/ghostty-gobject-0.14.1-2025-07-19-27-1.tar.zst"; + hash = "sha256-c4szPFC+L2H8ZQ3g7aoVi+lPmF4I6STxN9+fBhxaap8="; }; } { diff --git a/build.zig.zon.txt b/build.zig.zon.txt index e6580a088..8082390b1 100644 --- a/build.zig.zon.txt +++ b/build.zig.zon.txt @@ -27,7 +27,7 @@ https://deps.files.ghostty.org/wuffs-122037b39d577ec2db3fd7b2130e7b69ef6cc1807d6 https://deps.files.ghostty.org/zig_js-12205a66d423259567764fa0fc60c82be35365c21aeb76c5a7dc99698401f4f6fefc.tar.gz https://deps.files.ghostty.org/ziglyph-b89d43d1e3fb01b6074bc1f7fc980324b04d26a5.tar.gz https://deps.files.ghostty.org/zlib-1220fed0c74e1019b3ee29edae2051788b080cd96e90d56836eea857b0b966742efb.tar.gz -https://github.com/jcollie/ghostty-gobject/releases/download/0.14.0-2025-03-18-21-1/ghostty-gobject-0.14.0-2025-03-18-21-1.tar.zst +https://github.com/jcollie/ghostty-gobject/releases/download/0.14.1-2025-07-19-27-1/ghostty-gobject-0.14.1-2025-07-19-27-1.tar.zst https://github.com/mbadolato/iTerm2-Color-Schemes/archive/92f20650771384b82f981fb0f249e5fbdcb69e9f.tar.gz https://github.com/mitchellh/libxev/archive/7f803181b158a10fec8619f793e3b4df515566cb.tar.gz https://github.com/mitchellh/zig-objc/archive/c9e917a4e15a983b672ca779c7985d738a2d517c.tar.gz diff --git a/flatpak/zig-packages.json b/flatpak/zig-packages.json index 515a7f0fd..9e64be3a1 100644 --- a/flatpak/zig-packages.json +++ b/flatpak/zig-packages.json @@ -31,9 +31,9 @@ }, { "type": "archive", - "url": "https://github.com/jcollie/ghostty-gobject/releases/download/0.14.0-2025-03-18-21-1/ghostty-gobject-0.14.0-2025-03-18-21-1.tar.zst", - "dest": "vendor/p/gobject-0.2.0-Skun7IWDlQAOKu4BV7LapIxL9Imbq1JRmzvcIkazvAxR", - "sha256": "85672997459ddd7c9d4fe458efe548a315cf842cde95ed48a7be984a1f8a98b2" + "url": "https://github.com/jcollie/ghostty-gobject/releases/download/0.14.1-2025-07-19-27-1/ghostty-gobject-0.14.1-2025-07-19-27-1.tar.zst", + "dest": "vendor/p/gobject-0.3.0-Skun7KzYnAAsvbz0JzKA4LBdXbLqj0eNXHoKAIE0HkOl", + "sha256": "738b333c50be2f61fc650de0edaa158be94f985e08e924f137df9f061c5a6a9f" }, { "type": "archive", diff --git a/src/apprt/gtk-ng/class.zig b/src/apprt/gtk-ng/class.zig index 2c3626a16..5d64cb903 100644 --- a/src/apprt/gtk-ng/class.zig +++ b/src/apprt/gtk-ng/class.zig @@ -10,23 +10,6 @@ pub const Window = @import("class/window.zig").Window; pub const Config = @import("class/config.zig").Config; pub const Surface = @import("class/surface.zig").Surface; -/// Unrefs the given GObject on the next event loop tick. -/// -/// This works around an issue with zig-object where dynamically -/// generated gobjects in property getters can't unref themselves -/// normally: https://github.com/ianprime0509/zig-gobject/issues/108 -pub fn unrefLater(obj: anytype) void { - _ = glib.idleAdd((struct { - fn callback(data_: ?*anyopaque) callconv(.c) c_int { - const remove = @intFromBool(glib.SOURCE_REMOVE); - const data = data_ orelse return remove; - const object: *gobject.Object = @ptrCast(@alignCast(data)); - object.unref(); - return remove; - } - }).callback, obj.as(gobject.Object)); -} - /// Common methods for all GObject classes we create. pub fn Common( comptime Self: type, diff --git a/src/apprt/gtk-ng/class/application.zig b/src/apprt/gtk-ng/class/application.zig index 21557d6e8..d65c0df7c 100644 --- a/src/apprt/gtk-ng/class/application.zig +++ b/src/apprt/gtk-ng/class/application.zig @@ -71,10 +71,14 @@ pub const Application = extern struct { .{ .nick = "Config", .blurb = "The current active configuration for the application.", - .default = null, - .accessor = .{ - .getter = Self.getPropConfig, - }, + .accessor = gobject.ext.typedAccessor( + Self, + ?*Config, + .{ + .getter = Self.getConfig, + .getter_transfer = .full, + }, + ), }, ); }; @@ -492,21 +496,7 @@ pub const Application = extern struct { /// /// The reference count is increased. pub fn getConfig(self: *Self) *Config { - var value = gobject.ext.Value.zero; - gobject.Object.getProperty( - self.as(gobject.Object), - properties.config.name, - &value, - ); - - const obj = value.getObject().?; - return gobject.ext.cast(Config, obj).?; - } - - fn getPropConfig(self: *Self) *Config { - // Property return must not increase reference count since - // the gobject getter handles this automatically. - return self.private().config; + return self.private().config.ref(); } /// Returns the core app associated with this application. This is diff --git a/src/apprt/gtk-ng/class/config.zig b/src/apprt/gtk-ng/class/config.zig index 363a2e72e..e40602f47 100644 --- a/src/apprt/gtk-ng/class/config.zig +++ b/src/apprt/gtk-ng/class/config.zig @@ -8,7 +8,6 @@ const gtk = @import("gtk"); const configpkg = @import("../../../config.zig"); const CoreConfig = configpkg.Config; -const unrefLater = @import("../class.zig").unrefLater; const Common = @import("../class.zig").Common; const log = std.log.scoped(.gtk_ghostty_config); @@ -42,10 +41,14 @@ pub const Config = extern struct { .{ .nick = "Diagnostics Buffer", .blurb = "A TextBuffer that contains the diagnostics.", - .default = null, - .accessor = .{ - .getter = Self.diagnosticsBuffer, - }, + .accessor = gobject.ext.typedAccessor( + Self, + ?*gtk.TextBuffer, + .{ + .getter = Self.diagnosticsBuffer, + .getter_transfer = .full, + }, + ), }, ); @@ -57,9 +60,13 @@ pub const Config = extern struct { .nick = "has-diagnostics", .blurb = "Whether the configuration has diagnostics.", .default = false, - .accessor = .{ - .getter = Self.hasDiagnostics, - }, + .accessor = gobject.ext.typedAccessor( + Self, + bool, + .{ + .getter = Self.hasDiagnostics, + }, + ), }, ); }; @@ -129,7 +136,6 @@ pub const Config = extern struct { text_buf.insertAtCursor("\n", 1); } - unrefLater(text_buf); // See unrefLater docs for why this is needed return text_buf; } diff --git a/src/apprt/gtk-ng/class/config_errors_dialog.zig b/src/apprt/gtk-ng/class/config_errors_dialog.zig index 765f4050f..b8b0880d1 100644 --- a/src/apprt/gtk-ng/class/config_errors_dialog.zig +++ b/src/apprt/gtk-ng/class/config_errors_dialog.zig @@ -35,11 +35,14 @@ pub const ConfigErrorsDialog = extern struct { .{ .nick = "config", .blurb = "The configuration that this dialog is showing errors for.", - .default = null, - .accessor = .{ - .getter = Self.getConfig, - .setter = Self.setConfig, - }, + .accessor = gobject.ext.typedAccessor( + Self, + ?*Config, + .{ + .getter = Self.getConfig, + .setter = Self.setConfig, + }, + ), }, ); }; @@ -126,7 +129,9 @@ pub const ConfigErrorsDialog = extern struct { fn setConfig(self: *Self, config: ?*Config) void { const priv = self.private(); if (priv.config) |old| old.unref(); - if (config) |newv| _ = newv.ref(); + + // We don't need to increase the reference count because + // the property setter handles it (uses GValue.get vs. take) priv.config = config; } diff --git a/src/apprt/gtk-ng/class/surface.zig b/src/apprt/gtk-ng/class/surface.zig index f37e0b583..447bd59f4 100644 --- a/src/apprt/gtk-ng/class/surface.zig +++ b/src/apprt/gtk-ng/class/surface.zig @@ -43,7 +43,6 @@ pub const Surface = extern struct { .{ .nick = "Config", .blurb = "The configuration that this surface is using.", - .default = null, .accessor = gobject.ext.privateFieldAccessor( Self, Private, diff --git a/src/apprt/gtk/CommandPalette.zig b/src/apprt/gtk/CommandPalette.zig index d05f195b3..076459dbd 100644 --- a/src/apprt/gtk/CommandPalette.zig +++ b/src/apprt/gtk/CommandPalette.zig @@ -238,7 +238,13 @@ const Command = extern struct { ?[:0]const u8, .{ .default = null, - .accessor = .{ .getter = &accessor.getter }, + .accessor = gobject.ext.typedAccessor( + Command, + ?[:0]const u8, + .{ + .getter = &accessor.getter, + }, + ), }, ); }