diff --git a/src/apprt/gtk/App.zig b/src/apprt/gtk/App.zig index 2f76d8064..b00d65bce 100644 --- a/src/apprt/gtk/App.zig +++ b/src/apprt/gtk/App.zig @@ -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, diff --git a/src/apprt/gtk/Surface.zig b/src/apprt/gtk/Surface.zig index 8172b7490..22124becd 100644 --- a/src/apprt/gtk/Surface.zig +++ b/src/apprt/gtk/Surface.zig @@ -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, diff --git a/src/apprt/gtk/Tab.zig b/src/apprt/gtk/Tab.zig index 1a0762719..82384a44a 100644 --- a/src/apprt/gtk/Tab.zig +++ b/src/apprt/gtk/Tab.zig @@ -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); diff --git a/src/apprt/gtk/notebook.zig b/src/apprt/gtk/notebook.zig index 46245ce99..73213e9da 100644 --- a/src/apprt/gtk/notebook.zig +++ b/src/apprt/gtk/notebook.zig @@ -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") {