gtk-ng: use action helper in window

pull/8228/head
Jeffrey C. Ollie 2025-08-13 18:48:23 -05:00
parent a10b95f052
commit d66212dcce
No known key found for this signature in database
GPG Key ID: 6F86035A6D97044E
1 changed files with 18 additions and 33 deletions

View File

@ -331,42 +331,27 @@ pub const Window = extern struct {
/// Setup our action map. /// Setup our action map.
fn initActionMap(self: *Self) void { fn initActionMap(self: *Self) void {
const actions = .{ const actions = [_]ext.Action(Self){
.{ "about", actionAbout, null }, .init("about", actionAbout, null),
.{ "close", actionClose, null }, .init("close", actionClose, null),
.{ "close-tab", actionCloseTab, null }, .init("close-tab", actionCloseTab, null),
.{ "new-tab", actionNewTab, null }, .init("new-tab", actionNewTab, null),
.{ "new-window", actionNewWindow, null }, .init("new-window", actionNewWindow, null),
.{ "ring-bell", actionRingBell, null }, .init("ring-bell", actionRingBell, null),
.{ "split-right", actionSplitRight, null }, .init("split-right", actionSplitRight, null),
.{ "split-left", actionSplitLeft, null }, .init("split-left", actionSplitLeft, null),
.{ "split-up", actionSplitUp, null }, .init("split-up", actionSplitUp, null),
.{ "split-down", actionSplitDown, null }, .init("split-down", actionSplitDown, null),
.{ "copy", actionCopy, null }, .init("copy", actionCopy, null),
.{ "paste", actionPaste, null }, .init("paste", actionPaste, null),
.{ "reset", actionReset, null }, .init("reset", actionReset, null),
.{ "clear", actionClear, null }, .init("clear", actionClear, null),
// TODO: accept the surface that toggled the command palette // TODO: accept the surface that toggled the command palette
.{ "toggle-command-palette", actionToggleCommandPalette, null }, .init("toggle-command-palette", actionToggleCommandPalette, null),
.{ "toggle-inspector", actionToggleInspector, null }, .init("toggle-inspector", actionToggleInspector, null),
}; };
const action_map = self.as(gio.ActionMap); ext.addActions(Self, self, &actions);
inline for (actions) |entry| {
const action = gio.SimpleAction.new(
entry[0],
entry[2],
);
defer action.unref();
_ = gio.SimpleAction.signals.activate.connect(
action,
*Self,
entry[1],
self,
.{},
);
action_map.addAction(action.as(gio.Action));
}
} }
/// Winproto backend for this window. /// Winproto backend for this window.