From 8a40e37b863aa42ae4f4d6b7d25f242d050e3333 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Mon, 16 Mar 2026 18:26:37 -0500 Subject: [PATCH] gtk: refactor application id and resource path --- src/apprt/gtk/App.zig | 10 ++-------- src/apprt/gtk/build/gresource.zig | 16 +++++++--------- src/apprt/gtk/build/info.zig | 18 ++++++++++++++++++ src/apprt/gtk/class/application.zig | 5 +++-- 4 files changed, 30 insertions(+), 19 deletions(-) create mode 100644 src/apprt/gtk/build/info.zig diff --git a/src/apprt/gtk/App.zig b/src/apprt/gtk/App.zig index 6c7310339..39c13c19d 100644 --- a/src/apprt/gtk/App.zig +++ b/src/apprt/gtk/App.zig @@ -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, diff --git a/src/apprt/gtk/build/gresource.zig b/src/apprt/gtk/build/gresource.zig index bcece4caa..c50ea8cd5 100644 --- a/src/apprt/gtk/build/gresource.zig +++ b/src/apprt/gtk/build/gresource.zig @@ -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( \\ \\ - , .{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 { \\ {s} \\ , - .{ alias, app_id, source }, + .{ alias, build_info.base_application_id, source }, ); } @@ -199,7 +197,7 @@ fn genIcons(writer: *std.Io.Writer) !void { \\ {s} \\ , - .{ 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( \\ \\ - , .{prefix}); + , .{build_info.resource_path}); const cwd = std.fs.cwd(); inline for (css) |name| { @@ -249,7 +247,7 @@ fn genUi( try writer.print( \\ \\ - , .{prefix}); + , .{build_info.resource_path}); for (files.items) |ui_file| { for (blueprints) |bp| { diff --git a/src/apprt/gtk/build/info.zig b/src/apprt/gtk/build/info.zig new file mode 100644 index 000000000..fc6478d81 --- /dev/null +++ b/src/apprt/gtk/build/info.zig @@ -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, +}; diff --git a/src/apprt/gtk/class/application.zig b/src/apprt/gtk/class/application.zig index 63f1c35d0..544bdd127 100644 --- a/src/apprt/gtk/class/application.zig +++ b/src/apprt/gtk/class/application.zig @@ -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