mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-13 19:15:48 +00:00
gtk: clean up title renaming and fix a small leak (#10997)
Also enables the "Change Title…" item in the main menu.
This commit is contained in:
@@ -330,6 +330,10 @@ pub const Tab = extern struct {
|
||||
glib.free(@ptrCast(@constCast(v)));
|
||||
priv.title = null;
|
||||
}
|
||||
if (priv.title_override) |v| {
|
||||
glib.free(@ptrCast(@constCast(v)));
|
||||
priv.title_override = null;
|
||||
}
|
||||
|
||||
gobject.Object.virtual_methods.finalize.call(
|
||||
Class.parent,
|
||||
|
||||
@@ -339,6 +339,7 @@ pub const Window = extern struct {
|
||||
.init("close-tab", actionCloseTab, s_variant_type),
|
||||
.init("new-tab", actionNewTab, null),
|
||||
.init("new-window", actionNewWindow, null),
|
||||
.init("prompt-surface-title", actionPromptSurfaceTitle, null),
|
||||
.init("prompt-tab-title", actionPromptTabTitle, null),
|
||||
.init("prompt-context-tab-title", actionPromptContextTabTitle, null),
|
||||
.init("ring-bell", actionRingBell, null),
|
||||
@@ -1803,6 +1804,14 @@ pub const Window = extern struct {
|
||||
tab.promptTabTitle();
|
||||
}
|
||||
|
||||
fn actionPromptSurfaceTitle(
|
||||
_: *gio.SimpleAction,
|
||||
_: ?*glib.Variant,
|
||||
self: *Window,
|
||||
) callconv(.c) void {
|
||||
self.performBindingAction(.prompt_surface_title);
|
||||
}
|
||||
|
||||
fn actionPromptTabTitle(
|
||||
_: *gio.SimpleAction,
|
||||
_: ?*glib.Variant,
|
||||
|
||||
@@ -243,7 +243,7 @@ menu main_menu {
|
||||
|
||||
item {
|
||||
label: _("Change Title…");
|
||||
action: "win.prompt-title";
|
||||
action: "win.prompt-surface-title";
|
||||
}
|
||||
|
||||
item {
|
||||
|
||||
@@ -570,12 +570,9 @@ pub const Action = union(enum) {
|
||||
toggle_tab_overview,
|
||||
|
||||
/// Change the title of the current focused surface via a pop-up prompt.
|
||||
///
|
||||
/// This requires libadwaita 1.5 or newer on Linux. The current libadwaita
|
||||
/// version can be found by running `ghostty +version`.
|
||||
prompt_surface_title,
|
||||
|
||||
/// Change the title of the current tab/window via a pop-up prompt. The
|
||||
/// Change the title of the current tab via a pop-up prompt. The
|
||||
/// title set via this prompt overrides any title set by the terminal
|
||||
/// and persists across focus changes within the tab.
|
||||
prompt_tab_title,
|
||||
|
||||
@@ -440,13 +440,13 @@ fn actionCommands(action: Action.Key) []const Command {
|
||||
|
||||
.prompt_surface_title => comptime &.{.{
|
||||
.action = .prompt_surface_title,
|
||||
.title = "Change Terminal Title...",
|
||||
.title = "Change Terminal Title…",
|
||||
.description = "Prompt for a new title for the current terminal.",
|
||||
}},
|
||||
|
||||
.prompt_tab_title => comptime &.{.{
|
||||
.action = .prompt_tab_title,
|
||||
.title = "Change Tab Title...",
|
||||
.title = "Change Tab Title…",
|
||||
.description = "Prompt for a new title for the current tab.",
|
||||
}},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user