mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
apprt/gtk: handle pwd action
Use it as a tooltip for the tab. Signed-off-by: Tristan Partin <tristan@partin.io>
This commit is contained in:
@ -465,6 +465,7 @@ pub fn performAction(
|
||||
.inspector => self.controlInspector(target, value),
|
||||
.desktop_notification => self.showDesktopNotification(target, value),
|
||||
.set_title => try self.setTitle(target, value),
|
||||
.pwd => try self.setPwd(target, value),
|
||||
.present_terminal => self.presentTerminal(target),
|
||||
.initial_size => try self.setInitialSize(target, value),
|
||||
.mouse_visibility => self.setMouseVisibility(target, value),
|
||||
@ -486,7 +487,6 @@ pub fn performAction(
|
||||
.render_inspector,
|
||||
.renderer_health,
|
||||
.color_change,
|
||||
.pwd,
|
||||
=> log.warn("unimplemented action={}", .{action}),
|
||||
}
|
||||
}
|
||||
@ -717,6 +717,17 @@ fn setTitle(
|
||||
}
|
||||
}
|
||||
|
||||
fn setPwd(
|
||||
_: *App,
|
||||
target: apprt.Target,
|
||||
pwd: apprt.action.Pwd,
|
||||
) !void {
|
||||
switch (target) {
|
||||
.app => {},
|
||||
.surface => |v| try v.rt_surface.setPwd(pwd.pwd),
|
||||
}
|
||||
}
|
||||
|
||||
fn setMouseVisibility(
|
||||
_: *App,
|
||||
target: apprt.Target,
|
||||
|
@ -868,6 +868,13 @@ pub fn getTitle(self: *Surface) ?[:0]const u8 {
|
||||
return null;
|
||||
}
|
||||
|
||||
pub fn setPwd(self: *Surface, pwd: [:0]const u8) !void {
|
||||
// If we have a tab and are the focused child, then we have to update the tab
|
||||
if (self.container.tab()) |tab| {
|
||||
tab.setTooltipText(pwd);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn setMouseShape(
|
||||
self: *Surface,
|
||||
shape: terminal.MouseShape,
|
||||
|
@ -112,6 +112,10 @@ pub fn setLabelText(self: *Tab, title: [:0]const u8) void {
|
||||
self.window.notebook.setTabLabel(self, title);
|
||||
}
|
||||
|
||||
pub fn setTooltipText(self: *Tab, tooltip: [:0]const u8) void {
|
||||
self.window.notebook.setTabTooltip(self, tooltip);
|
||||
}
|
||||
|
||||
/// Remove this tab from the window.
|
||||
pub fn remove(self: *Tab) void {
|
||||
self.window.closeTab(self);
|
||||
|
@ -223,6 +223,17 @@ pub const Notebook = union(enum) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn setTabTooltip(self: Notebook, tab: *Tab, tooltip: [:0]const u8) void {
|
||||
switch (self) {
|
||||
.adw_tab_view => |tab_view| {
|
||||
if (comptime !adwaita.versionAtLeast(0, 0, 0)) unreachable;
|
||||
const page = c.adw_tab_view_get_page(tab_view, @ptrCast(tab.box));
|
||||
c.adw_tab_page_set_tooltip(page, tooltip.ptr);
|
||||
},
|
||||
.gtk_notebook => c.gtk_widget_set_tooltip_text(@ptrCast(@alignCast(tab.label_text)), tooltip.ptr),
|
||||
}
|
||||
}
|
||||
|
||||
fn newTabInsertPosition(self: Notebook, tab: *Tab) c_int {
|
||||
const numPages = self.nPages();
|
||||
return switch (tab.window.app.config.@"window-new-tab-position") {
|
||||
|
Reference in New Issue
Block a user