mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-17 07:16:12 +00:00
apprt/gtk: add menu to new tab button to create splits (#7137)
Closes: https://github.com/ghostty-org/ghostty/discussions/6828
This commit is contained in:
@@ -25,6 +25,7 @@ const input = @import("../../input.zig");
|
||||
const CoreSurface = @import("../../Surface.zig");
|
||||
|
||||
const App = @import("App.zig");
|
||||
const Builder = @import("Builder.zig");
|
||||
const Color = configpkg.Config.Color;
|
||||
const Surface = @import("Surface.zig");
|
||||
const Menu = @import("menu.zig").Menu;
|
||||
@@ -242,12 +243,19 @@ pub fn init(self: *Window, app: *App) !void {
|
||||
}
|
||||
|
||||
{
|
||||
const btn = gtk.Button.newFromIconName("tab-new-symbolic");
|
||||
const btn = adw.SplitButton.new();
|
||||
btn.setIconName("tab-new-symbolic");
|
||||
btn.as(gtk.Widget).setTooltipText(i18n._("New Tab"));
|
||||
_ = gtk.Button.signals.clicked.connect(
|
||||
btn.setDropdownTooltip(i18n._("New Split"));
|
||||
|
||||
var builder = Builder.init("menu-headerbar-split_menu", 1, 0, .blp);
|
||||
defer builder.deinit();
|
||||
btn.setMenuModel(builder.getObject(gio.MenuModel, "menu"));
|
||||
|
||||
_ = adw.SplitButton.signals.clicked.connect(
|
||||
btn,
|
||||
*Window,
|
||||
gtkTabNewClick,
|
||||
adwNewTabClick,
|
||||
self,
|
||||
.{},
|
||||
);
|
||||
@@ -824,6 +832,11 @@ fn gtkTabNewClick(_: *gtk.Button, self: *Window) callconv(.c) void {
|
||||
self.performBindingAction(.{ .new_tab = {} });
|
||||
}
|
||||
|
||||
/// Create a new surface (tab or split).
|
||||
fn adwNewTabClick(_: *adw.SplitButton, self: *Window) callconv(.c) void {
|
||||
self.performBindingAction(.{ .new_tab = {} });
|
||||
}
|
||||
|
||||
/// Create a new tab from the AdwTabOverview. We can't copy gtkTabNewClick
|
||||
/// because we need to return an AdwTabPage from this function.
|
||||
fn gtkNewTabFromOverview(_: *adw.TabOverview, self: *Window) callconv(.c) *adw.TabPage {
|
||||
|
@@ -75,6 +75,7 @@ pub const VersionedBlueprint = struct {
|
||||
pub const blueprint_files = [_]VersionedBlueprint{
|
||||
.{ .major = 1, .minor = 5, .name = "prompt-title-dialog" },
|
||||
.{ .major = 1, .minor = 5, .name = "config-errors-dialog" },
|
||||
.{ .major = 1, .minor = 0, .name = "menu-headerbar-split_menu" },
|
||||
.{ .major = 1, .minor = 0, .name = "menu-surface-context_menu" },
|
||||
.{ .major = 1, .minor = 0, .name = "menu-window-titlebar_menu" },
|
||||
.{ .major = 1, .minor = 5, .name = "ccw-osc-52-read" },
|
||||
|
25
src/apprt/gtk/ui/1.0/menu-headerbar-split_menu.blp
Normal file
25
src/apprt/gtk/ui/1.0/menu-headerbar-split_menu.blp
Normal file
@@ -0,0 +1,25 @@
|
||||
using Gtk 4.0;
|
||||
|
||||
menu menu {
|
||||
section {
|
||||
item {
|
||||
label: _("Split Up");
|
||||
action: "win.split-up";
|
||||
}
|
||||
|
||||
item {
|
||||
label: _("Split Down");
|
||||
action: "win.split-down";
|
||||
}
|
||||
|
||||
item {
|
||||
label: _("Split Left");
|
||||
action: "win.split-left";
|
||||
}
|
||||
|
||||
item {
|
||||
label: _("Split Right");
|
||||
action: "win.split-right";
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user