mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
gtk: update zig-gobject to get improved gobject accessors (#7992)
This commit is contained in:
@ -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,
|
||||
},
|
||||
|
||||
|
6
build.zig.zon.json
generated
6
build.zig.zon.json
generated
@ -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",
|
||||
|
6
build.zig.zon.nix
generated
6
build.zig.zon.nix
generated
@ -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=";
|
||||
};
|
||||
}
|
||||
{
|
||||
|
2
build.zig.zon.txt
generated
2
build.zig.zon.txt
generated
@ -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
|
||||
|
@ -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",
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
},
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user