commit
57f1033198
|
|
@ -887,10 +887,10 @@ pub const Application = extern struct {
|
||||||
self.syncActionAccelerator("win.reset", .{ .reset = {} });
|
self.syncActionAccelerator("win.reset", .{ .reset = {} });
|
||||||
self.syncActionAccelerator("win.clear", .{ .clear_screen = {} });
|
self.syncActionAccelerator("win.clear", .{ .clear_screen = {} });
|
||||||
self.syncActionAccelerator("win.prompt-title", .{ .prompt_surface_title = {} });
|
self.syncActionAccelerator("win.prompt-title", .{ .prompt_surface_title = {} });
|
||||||
self.syncActionAccelerator("split-tree.new-left", .{ .new_split = .left });
|
self.syncActionAccelerator("split-tree.new-split::left", .{ .new_split = .left });
|
||||||
self.syncActionAccelerator("split-tree.new-right", .{ .new_split = .right });
|
self.syncActionAccelerator("split-tree.new-split::right", .{ .new_split = .right });
|
||||||
self.syncActionAccelerator("split-tree.new-up", .{ .new_split = .up });
|
self.syncActionAccelerator("split-tree.new-split::up", .{ .new_split = .up });
|
||||||
self.syncActionAccelerator("split-tree.new-down", .{ .new_split = .down });
|
self.syncActionAccelerator("split-tree.new-split::down", .{ .new_split = .down });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn syncActionAccelerator(
|
fn syncActionAccelerator(
|
||||||
|
|
@ -1815,12 +1815,12 @@ const Action = struct {
|
||||||
|
|
||||||
.surface => |core| {
|
.surface => |core| {
|
||||||
const surface = core.rt_surface.surface;
|
const surface = core.rt_surface.surface;
|
||||||
return surface.as(gtk.Widget).activateAction(switch (direction) {
|
|
||||||
.right => "split-tree.new-right",
|
return surface.as(gtk.Widget).activateAction(
|
||||||
.left => "split-tree.new-left",
|
"split-tree.new-split",
|
||||||
.down => "split-tree.new-down",
|
"&s",
|
||||||
.up => "split-tree.new-up",
|
@tagName(direction).ptr,
|
||||||
}, null) != 0;
|
) != 0;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -175,16 +175,16 @@ pub const SplitTree = extern struct {
|
||||||
//
|
//
|
||||||
// For action names:
|
// For action names:
|
||||||
// https://docs.gtk.org/gio/type_func.Action.name_is_valid.html
|
// https://docs.gtk.org/gio/type_func.Action.name_is_valid.html
|
||||||
const actions = .{
|
const actions: []const struct {
|
||||||
|
[:0]const u8,
|
||||||
|
*const fn (*gio.SimpleAction, ?*glib.Variant, *Self) callconv(.c) void,
|
||||||
|
?*glib.VariantType,
|
||||||
|
} = &.{
|
||||||
// All of these will eventually take a target surface parameter.
|
// All of these will eventually take a target surface parameter.
|
||||||
// For now all our targets originate from the focused surface.
|
// For now all our targets originate from the focused surface.
|
||||||
.{ "new-left", actionNewLeft, null },
|
.{ "new-split", &actionNewSplit, glib.ext.VariantType.newFor([:0]const u8) },
|
||||||
.{ "new-right", actionNewRight, null },
|
.{ "equalize", &actionEqualize, null },
|
||||||
.{ "new-up", actionNewUp, null },
|
.{ "zoom", &actionZoom, null },
|
||||||
.{ "new-down", actionNewDown, null },
|
|
||||||
|
|
||||||
.{ "equalize", actionEqualize, null },
|
|
||||||
.{ "zoom", actionZoom, null },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// We need to collect our actions into a group since we're just
|
// We need to collect our actions into a group since we're just
|
||||||
|
|
@ -192,12 +192,16 @@ pub const SplitTree = extern struct {
|
||||||
const group = gio.SimpleActionGroup.new();
|
const group = gio.SimpleActionGroup.new();
|
||||||
errdefer group.unref();
|
errdefer group.unref();
|
||||||
const map = group.as(gio.ActionMap);
|
const map = group.as(gio.ActionMap);
|
||||||
inline for (actions) |entry| {
|
for (actions) |entry| {
|
||||||
const action = gio.SimpleAction.new(
|
const action = gio.SimpleAction.new(
|
||||||
entry[0],
|
entry[0],
|
||||||
entry[2],
|
entry[2],
|
||||||
);
|
);
|
||||||
defer action.unref();
|
defer {
|
||||||
|
action.unref();
|
||||||
|
if (entry[2]) |ptype| ptype.free();
|
||||||
|
}
|
||||||
|
|
||||||
_ = gio.SimpleAction.signals.activate.connect(
|
_ = gio.SimpleAction.signals.activate.connect(
|
||||||
action,
|
action,
|
||||||
*Self,
|
*Self,
|
||||||
|
|
@ -567,56 +571,30 @@ pub const SplitTree = extern struct {
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
// Signal handlers
|
// Signal handlers
|
||||||
|
|
||||||
pub fn actionNewLeft(
|
pub fn actionNewSplit(
|
||||||
_: *gio.SimpleAction,
|
_: *gio.SimpleAction,
|
||||||
parameter_: ?*glib.Variant,
|
args_: ?*glib.Variant,
|
||||||
self: *Self,
|
self: *Self,
|
||||||
) callconv(.c) void {
|
) callconv(.c) void {
|
||||||
_ = parameter_;
|
const args = args_ orelse {
|
||||||
self.newSplit(
|
log.warn("split-tree.new-split called without a parameter", .{});
|
||||||
.left,
|
return;
|
||||||
self.getActiveSurface(),
|
|
||||||
) catch |err| {
|
|
||||||
log.warn("new split failed error={}", .{err});
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
pub fn actionNewRight(
|
var dir: ?[*:0]const u8 = null;
|
||||||
_: *gio.SimpleAction,
|
args.get("&s", &dir);
|
||||||
parameter_: ?*glib.Variant,
|
|
||||||
self: *Self,
|
const direction = std.meta.stringToEnum(
|
||||||
) callconv(.c) void {
|
Surface.Tree.Split.Direction,
|
||||||
_ = parameter_;
|
std.mem.span(dir) orelse return,
|
||||||
self.newSplit(
|
) orelse {
|
||||||
.right,
|
// Need to be defensive here since actions can be triggered externally.
|
||||||
self.getActiveSurface(),
|
log.warn("invalid split direction for split-tree.new-split: {s}", .{dir.?});
|
||||||
) catch |err| {
|
return;
|
||||||
log.warn("new split failed error={}", .{err});
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
pub fn actionNewUp(
|
|
||||||
_: *gio.SimpleAction,
|
|
||||||
parameter_: ?*glib.Variant,
|
|
||||||
self: *Self,
|
|
||||||
) callconv(.c) void {
|
|
||||||
_ = parameter_;
|
|
||||||
self.newSplit(
|
self.newSplit(
|
||||||
.up,
|
direction,
|
||||||
self.getActiveSurface(),
|
|
||||||
) catch |err| {
|
|
||||||
log.warn("new split failed error={}", .{err});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn actionNewDown(
|
|
||||||
_: *gio.SimpleAction,
|
|
||||||
parameter_: ?*glib.Variant,
|
|
||||||
self: *Self,
|
|
||||||
) callconv(.c) void {
|
|
||||||
_ = parameter_;
|
|
||||||
self.newSplit(
|
|
||||||
.down,
|
|
||||||
self.getActiveSurface(),
|
self.getActiveSurface(),
|
||||||
) catch |err| {
|
) catch |err| {
|
||||||
log.warn("new split failed error={}", .{err});
|
log.warn("new split failed error={}", .{err});
|
||||||
|
|
|
||||||
|
|
@ -194,22 +194,26 @@ menu context_menu_model {
|
||||||
|
|
||||||
item {
|
item {
|
||||||
label: _("Split Up");
|
label: _("Split Up");
|
||||||
action: "split-tree.new-up";
|
action: "split-tree.new-split";
|
||||||
|
target: "up";
|
||||||
}
|
}
|
||||||
|
|
||||||
item {
|
item {
|
||||||
label: _("Split Down");
|
label: _("Split Down");
|
||||||
action: "split-tree.new-down";
|
action: "split-tree.new-split";
|
||||||
|
target: "down";
|
||||||
}
|
}
|
||||||
|
|
||||||
item {
|
item {
|
||||||
label: _("Split Left");
|
label: _("Split Left");
|
||||||
action: "split-tree.new-left";
|
action: "split-tree.new-split";
|
||||||
|
target: "left";
|
||||||
}
|
}
|
||||||
|
|
||||||
item {
|
item {
|
||||||
label: _("Split Right");
|
label: _("Split Right");
|
||||||
action: "split-tree.new-right";
|
action: "split-tree.new-split";
|
||||||
|
target: "right";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue