Merge 3d95804200 into a4cb73db84
commit
81ddbbf32b
|
|
@ -736,6 +736,8 @@ pub const Application = extern struct {
|
|||
.search_total => Action.searchTotal(target, value),
|
||||
.search_selected => Action.searchSelected(target, value),
|
||||
|
||||
.readonly => return Action.toggleReadOnly(target),
|
||||
|
||||
// Unimplemented
|
||||
.secure_input,
|
||||
.close_all_windows,
|
||||
|
|
@ -751,7 +753,6 @@ pub const Application = extern struct {
|
|||
.check_for_updates,
|
||||
.undo,
|
||||
.redo,
|
||||
.readonly,
|
||||
=> {
|
||||
log.warn("unimplemented action={}", .{action});
|
||||
return false;
|
||||
|
|
@ -2659,6 +2660,15 @@ const Action = struct {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toggleReadOnly(target: apprt.Target) bool {
|
||||
switch (target) {
|
||||
.app => return false,
|
||||
.surface => |surface| {
|
||||
return surface.rt_surface.gobj().toggleReadOnly();
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/// This sets various GTK-related environment variables as necessary
|
||||
|
|
|
|||
|
|
@ -305,6 +305,24 @@ pub const Surface = extern struct {
|
|||
);
|
||||
};
|
||||
|
||||
pub const @"read-only" = struct {
|
||||
pub const name = "read-only";
|
||||
const impl = gobject.ext.defineProperty(
|
||||
name,
|
||||
Self,
|
||||
bool,
|
||||
.{
|
||||
.default = false,
|
||||
.accessor = gobject.ext.privateFieldAccessor(
|
||||
Self,
|
||||
Private,
|
||||
&Private.offset,
|
||||
"read_only",
|
||||
),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
pub const hadjustment = struct {
|
||||
pub const name = "hadjustment";
|
||||
const impl = gobject.ext.defineProperty(
|
||||
|
|
@ -608,6 +626,10 @@ pub const Surface = extern struct {
|
|||
// unfocused-split-* options
|
||||
is_split: bool = false,
|
||||
|
||||
// True if this surface is read only. When true the user is shown
|
||||
// an overlay
|
||||
read_only: bool = false,
|
||||
|
||||
action_group: ?*gio.SimpleActionGroup = null,
|
||||
|
||||
// Gtk.Scrollable interface adjustments
|
||||
|
|
@ -983,6 +1005,15 @@ pub const Surface = extern struct {
|
|||
return true;
|
||||
}
|
||||
|
||||
pub fn toggleReadOnly(self: *Self) bool {
|
||||
const priv = self.private();
|
||||
priv.read_only = !priv.read_only;
|
||||
self.as(gobject.Object).notifyByPspec(
|
||||
properties.@"read-only".impl.param_spec,
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Key press event (press or release).
|
||||
///
|
||||
/// At a high level, we want to construct an `input.KeyEvent` and
|
||||
|
|
@ -3316,6 +3347,7 @@ pub const Surface = extern struct {
|
|||
properties.@"title-override".impl,
|
||||
properties.zoom.impl,
|
||||
properties.@"is-split".impl,
|
||||
properties.@"read-only".impl,
|
||||
|
||||
// For Gtk.Scrollable
|
||||
properties.hadjustment.impl,
|
||||
|
|
|
|||
|
|
@ -148,11 +148,36 @@ Overlay terminal_page {
|
|||
}
|
||||
|
||||
[overlay]
|
||||
$GhosttySearchOverlay search_overlay {
|
||||
stop-search => $search_stop();
|
||||
search-changed => $search_changed();
|
||||
next-match => $search_next_match();
|
||||
previous-match => $search_previous_match();
|
||||
Box {
|
||||
orientation: vertical;
|
||||
|
||||
$GhosttySearchOverlay search_overlay {
|
||||
stop-search => $search_stop();
|
||||
search-changed => $search_changed();
|
||||
next-match => $search_next_match();
|
||||
previous-match => $search_previous_match();
|
||||
}
|
||||
|
||||
MenuButton {
|
||||
styles [
|
||||
"read-only",
|
||||
]
|
||||
|
||||
visible: bind template.read-only;
|
||||
halign: end;
|
||||
valign: start;
|
||||
margin-end: 15;
|
||||
margin-top: 15;
|
||||
always-show-arrow: false;
|
||||
direction: none;
|
||||
label: _("Read-only");
|
||||
|
||||
popover: Popover {
|
||||
child: Label {
|
||||
label: _("This terminal is in read-only mode.\nYou can still view, select, and scroll through the content,\nbut no input events will be sent to the running application.");
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[overlay]
|
||||
|
|
|
|||
Loading…
Reference in New Issue