mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-22 19:56:08 +03:00
Merge pull request #2014 from jcollie/gtk-context-menu-additions
Additions to GTK context menu
This commit is contained in:
@ -370,6 +370,7 @@ fn syncActionAccelerators(self: *App) !void {
|
|||||||
try self.syncActionAccelerator("win.split_down", .{ .new_split = .down });
|
try self.syncActionAccelerator("win.split_down", .{ .new_split = .down });
|
||||||
try self.syncActionAccelerator("win.copy", .{ .copy_to_clipboard = {} });
|
try self.syncActionAccelerator("win.copy", .{ .copy_to_clipboard = {} });
|
||||||
try self.syncActionAccelerator("win.paste", .{ .paste_from_clipboard = {} });
|
try self.syncActionAccelerator("win.paste", .{ .paste_from_clipboard = {} });
|
||||||
|
try self.syncActionAccelerator("win.reset", .{ .reset = {} });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn syncActionAccelerator(
|
fn syncActionAccelerator(
|
||||||
@ -811,6 +812,7 @@ fn initContextMenu(self: *App) void {
|
|||||||
const section = c.g_menu_new();
|
const section = c.g_menu_new();
|
||||||
defer c.g_object_unref(section);
|
defer c.g_object_unref(section);
|
||||||
c.g_menu_append_section(menu, null, @ptrCast(@alignCast(section)));
|
c.g_menu_append_section(menu, null, @ptrCast(@alignCast(section)));
|
||||||
|
c.g_menu_append(section, "Reset", "win.reset");
|
||||||
c.g_menu_append(section, "Terminal Inspector", "win.toggle_inspector");
|
c.g_menu_append(section, "Terminal Inspector", "win.toggle_inspector");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,6 +184,7 @@ fn initActions(self: *Window) void {
|
|||||||
.{ "toggle_inspector", >kActionToggleInspector },
|
.{ "toggle_inspector", >kActionToggleInspector },
|
||||||
.{ "copy", >kActionCopy },
|
.{ "copy", >kActionCopy },
|
||||||
.{ "paste", >kActionPaste },
|
.{ "paste", >kActionPaste },
|
||||||
|
.{ "reset", >kActionReset },
|
||||||
};
|
};
|
||||||
|
|
||||||
inline for (actions) |entry| {
|
inline for (actions) |entry| {
|
||||||
@ -629,6 +630,19 @@ fn gtkActionPaste(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn gtkActionReset(
|
||||||
|
_: *c.GSimpleAction,
|
||||||
|
_: *c.GVariant,
|
||||||
|
ud: ?*anyopaque,
|
||||||
|
) callconv(.C) void {
|
||||||
|
const self: *Window = @ptrCast(@alignCast(ud orelse return));
|
||||||
|
const surface = self.actionSurface() orelse return;
|
||||||
|
_ = surface.performBindingAction(.{ .reset = {} }) catch |err| {
|
||||||
|
log.warn("error performing binding action error={}", .{err});
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the surface to use for an action.
|
/// Returns the surface to use for an action.
|
||||||
fn actionSurface(self: *Window) ?*CoreSurface {
|
fn actionSurface(self: *Window) ?*CoreSurface {
|
||||||
const page_idx = c.gtk_notebook_get_current_page(self.notebook);
|
const page_idx = c.gtk_notebook_get_current_page(self.notebook);
|
||||||
|
Reference in New Issue
Block a user