mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-21 16:41:26 +00:00
Add context menu tab
This commit is contained in:
@@ -28,8 +28,7 @@ const ResizeOverlay = @import("resize_overlay.zig").ResizeOverlay;
|
||||
const SearchOverlay = @import("search_overlay.zig").SearchOverlay;
|
||||
const ChildExited = @import("surface_child_exited.zig").SurfaceChildExited;
|
||||
const ClipboardConfirmationDialog = @import("clipboard_confirmation_dialog.zig").ClipboardConfirmationDialog;
|
||||
const TitleDialog = @import("title_dialog.zig")
|
||||
.TitleDialog;
|
||||
const TitleDialog = @import("title_dialog.zig").TitleDialog;
|
||||
const Window = @import("window.zig").Window;
|
||||
const InspectorWindow = @import("inspector_window.zig").InspectorWindow;
|
||||
const i18n = @import("../../../os/i18n.zig");
|
||||
|
||||
@@ -14,8 +14,7 @@ const Config = @import("config.zig").Config;
|
||||
const Application = @import("application.zig").Application;
|
||||
const SplitTree = @import("split_tree.zig").SplitTree;
|
||||
const Surface = @import("surface.zig").Surface;
|
||||
const TitleDialog = @import("title_dialog.zig")
|
||||
.TitleDialog;
|
||||
const TitleDialog = @import("title_dialog.zig").TitleDialog;
|
||||
|
||||
const log = std.log.scoped(.gtk_ghostty_window);
|
||||
|
||||
|
||||
@@ -252,6 +252,10 @@ pub const Window = extern struct {
|
||||
/// A weak reference to a command palette.
|
||||
command_palette: WeakRef(CommandPalette) = .empty,
|
||||
|
||||
/// Tab page that the context menu was opened for.
|
||||
/// setup by `setup-menu`.
|
||||
context_menu_page: ?*adw.TabPage = null,
|
||||
|
||||
// Template bindings
|
||||
tab_overview: *adw.TabOverview,
|
||||
tab_bar: *adw.TabBar,
|
||||
@@ -336,6 +340,7 @@ pub const Window = extern struct {
|
||||
.init("new-tab", actionNewTab, null),
|
||||
.init("new-window", actionNewWindow, null),
|
||||
.init("prompt-tab-title", actionPromptTabTitle, null),
|
||||
.init("prompt-context-tab-title", actionPromptContextTabTitle, null),
|
||||
.init("ring-bell", actionRingBell, null),
|
||||
.init("split-right", actionSplitRight, null),
|
||||
.init("split-left", actionSplitLeft, null),
|
||||
@@ -1521,6 +1526,13 @@ pub const Window = extern struct {
|
||||
self.as(gtk.Window).close();
|
||||
}
|
||||
}
|
||||
fn setupTabMenu(
|
||||
_: *adw.TabView,
|
||||
page: ?*adw.TabPage,
|
||||
self: *Self,
|
||||
) callconv(.c) void {
|
||||
self.private().context_menu_page = page;
|
||||
}
|
||||
|
||||
fn surfaceClipboardWrite(
|
||||
_: *Surface,
|
||||
@@ -1764,6 +1776,18 @@ pub const Window = extern struct {
|
||||
self.performBindingAction(.new_tab);
|
||||
}
|
||||
|
||||
fn actionPromptContextTabTitle(
|
||||
_: *gio.SimpleAction,
|
||||
_: ?*glib.Variant,
|
||||
self: *Self,
|
||||
) callconv(.c) void {
|
||||
const priv = self.private();
|
||||
const page = priv.context_menu_page orelse return;
|
||||
const child = page.getChild();
|
||||
const tab = gobject.ext.cast(Tab, child) orelse return;
|
||||
tab.promptTabTitle();
|
||||
}
|
||||
|
||||
fn actionPromptTabTitle(
|
||||
_: *gio.SimpleAction,
|
||||
_: ?*glib.Variant,
|
||||
@@ -1997,6 +2021,7 @@ pub const Window = extern struct {
|
||||
class.bindTemplateCallback("close_page", &tabViewClosePage);
|
||||
class.bindTemplateCallback("page_attached", &tabViewPageAttached);
|
||||
class.bindTemplateCallback("page_detached", &tabViewPageDetached);
|
||||
class.bindTemplateCallback("setup_tab_menu", &setupTabMenu);
|
||||
class.bindTemplateCallback("tab_create_window", &tabViewCreateWindow);
|
||||
class.bindTemplateCallback("notify_n_pages", &tabViewNPages);
|
||||
class.bindTemplateCallback("notify_selected_page", &tabViewSelectedPage);
|
||||
|
||||
@@ -162,6 +162,8 @@ template $GhosttyWindow: Adw.ApplicationWindow {
|
||||
page-attached => $page_attached();
|
||||
page-detached => $page_detached();
|
||||
create-window => $tab_create_window();
|
||||
setup-menu => $setup_tab_menu();
|
||||
menu-model: tab_context_menu;
|
||||
shortcuts: none;
|
||||
}
|
||||
}
|
||||
@@ -312,3 +314,10 @@ menu main_menu {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
menu tab_context_menu {
|
||||
item {
|
||||
label: _("Change Title...");
|
||||
action: "win.prompt-context-tab-title";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user