gtk: refactor application id and resource path (#11580)

This commit is contained in:
Jeffrey C. Ollie
2026-03-16 18:43:35 -05:00
committed by GitHub
4 changed files with 30 additions and 19 deletions

View File

@@ -22,16 +22,10 @@ const log = std.log.scoped(.gtk);
pub const must_draw_from_app_thread = true;
/// GTK application ID
pub const application_id = switch (builtin.mode) {
.Debug, .ReleaseSafe => "com.mitchellh.ghostty-debug",
.ReleaseFast, .ReleaseSmall => "com.mitchellh.ghostty",
};
pub const application_id = @import("build/info.zig").application_id;
/// GTK object path
pub const object_path = switch (builtin.mode) {
.Debug, .ReleaseSafe => "/com/mitchellh/ghostty_debug",
.ReleaseFast, .ReleaseSmall => "/com/mitchellh/ghostty",
};
pub const object_path = @import("build/info.zig").object_path;
/// The GObject Application instance
app: *Application,

View File

@@ -7,9 +7,7 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
/// Prefix/appid for the gresource file.
pub const prefix = "/com/mitchellh/ghostty";
pub const app_id = "com.mitchellh.ghostty";
const build_info = @import("info.zig");
/// The path to the Blueprint files. The folder structure is expected to be
/// `{version}/{name}.blp` where `version` is the major and minor
@@ -112,7 +110,7 @@ pub fn blueprint(comptime bp: Blueprint) [:0]const u8 {
std.mem.eql(u8, candidate.name, bp.name))
{
return std.fmt.comptimePrint("{s}/ui/{d}.{d}/{s}.ui", .{
prefix,
build_info.resource_path,
candidate.major,
candidate.minor,
candidate.name,
@@ -173,7 +171,7 @@ fn genIcons(writer: *std.Io.Writer) !void {
try writer.print(
\\ <gresource prefix="{s}/icons">
\\
, .{prefix});
, .{build_info.resource_path});
const cwd = std.fs.cwd();
inline for (icon_sizes) |size| {
@@ -186,7 +184,7 @@ fn genIcons(writer: *std.Io.Writer) !void {
\\ <file alias="{s}/apps/{s}.png">{s}</file>
\\
,
.{ alias, app_id, source },
.{ alias, build_info.base_application_id, source },
);
}
@@ -199,7 +197,7 @@ fn genIcons(writer: *std.Io.Writer) !void {
\\ <file alias="{s}/apps/{s}.png">{s}</file>
\\
,
.{ alias, app_id, source },
.{ alias, build_info.base_application_id, source },
);
}
}
@@ -215,7 +213,7 @@ fn genRoot(writer: *std.Io.Writer) !void {
try writer.print(
\\ <gresource prefix="{s}">
\\
, .{prefix});
, .{build_info.resource_path});
const cwd = std.fs.cwd();
inline for (css) |name| {
@@ -249,7 +247,7 @@ fn genUi(
try writer.print(
\\ <gresource prefix="{s}/ui">
\\
, .{prefix});
, .{build_info.resource_path});
for (files.items) |ui_file| {
for (blueprints) |bp| {

View File

@@ -0,0 +1,18 @@
const builtin = @import("builtin");
/// Base application ID
pub const base_application_id = "com.mitchellh.ghostty";
/// GTK application ID
pub const application_id = switch (builtin.mode) {
.Debug, .ReleaseSafe => base_application_id ++ "-debug",
.ReleaseFast, .ReleaseSmall => base_application_id,
};
pub const resource_path = "/com/mitchellh/ghostty";
/// GTK object path
pub const object_path = switch (builtin.mode) {
.Debug, .ReleaseSafe => resource_path ++ "_debug",
.ReleaseFast, .ReleaseSmall => resource_path,
};

View File

@@ -9,6 +9,7 @@ const gobject = @import("gobject");
const gtk = @import("gtk");
const build_config = @import("../../../build_config.zig");
const build_info = @import("../build/info.zig");
const state = &@import("../../../global.zig").state;
const i18n = @import("../../../os/main.zig").i18n;
const apprt = @import("../../../apprt.zig");
@@ -327,7 +328,7 @@ pub const Application = extern struct {
}
}
break :app_id ApprtApp.application_id;
break :app_id build_info.application_id;
};
const display: *gdk.Display = gdk.Display.getDefault() orelse {
@@ -381,7 +382,7 @@ pub const Application = extern struct {
// Force the resource path to a known value so it doesn't depend
// on the app id (which changes between debug/release and can be
// user-configured) and force it to load in compiled resources.
.resource_base_path = "/com/mitchellh/ghostty",
.resource_base_path = build_info.resource_path,
});
// Setup our private state. More setup is done in the init