apprt/gtk-ng: close surface, close window
parent
f27fd0f550
commit
5b37e86391
|
|
@ -32,7 +32,7 @@ pub fn rtApp(self: *Self) *ApprtApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn close(self: *Self, process_active: bool) void {
|
pub fn close(self: *Self, process_active: bool) void {
|
||||||
self.surface.close(process_active);
|
self.surface.close(.{ .surface = process_active });
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cgroup(self: *Self) ?[]const u8 {
|
pub fn cgroup(self: *Self) ?[]const u8 {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ const ApprtApp = @import("../App.zig");
|
||||||
const Common = @import("../class.zig").Common;
|
const Common = @import("../class.zig").Common;
|
||||||
const WeakRef = @import("../weak_ref.zig").WeakRef;
|
const WeakRef = @import("../weak_ref.zig").WeakRef;
|
||||||
const Config = @import("config.zig").Config;
|
const Config = @import("config.zig").Config;
|
||||||
|
const Surface = @import("surface.zig").Surface;
|
||||||
const Window = @import("window.zig").Window;
|
const Window = @import("window.zig").Window;
|
||||||
const CloseConfirmationDialog = @import("close_confirmation_dialog.zig").CloseConfirmationDialog;
|
const CloseConfirmationDialog = @import("close_confirmation_dialog.zig").CloseConfirmationDialog;
|
||||||
const ConfigErrorsDialog = @import("config_errors_dialog.zig").ConfigErrorsDialog;
|
const ConfigErrorsDialog = @import("config_errors_dialog.zig").ConfigErrorsDialog;
|
||||||
|
|
@ -469,6 +470,9 @@ pub const Application = extern struct {
|
||||||
value: apprt.Action.Value(action),
|
value: apprt.Action.Value(action),
|
||||||
) !bool {
|
) !bool {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
.close_tab => Action.close(target, .tab),
|
||||||
|
.close_window => Action.close(target, .window),
|
||||||
|
|
||||||
.config_change => try Action.configChange(
|
.config_change => try Action.configChange(
|
||||||
self,
|
self,
|
||||||
target,
|
target,
|
||||||
|
|
@ -495,7 +499,7 @@ pub const Application = extern struct {
|
||||||
|
|
||||||
.progress_report => return Action.progressReport(target, value),
|
.progress_report => return Action.progressReport(target, value),
|
||||||
|
|
||||||
.render => Action.render(self, target),
|
.render => Action.render(target),
|
||||||
|
|
||||||
.ring_bell => Action.ringBell(target),
|
.ring_bell => Action.ringBell(target),
|
||||||
|
|
||||||
|
|
@ -506,11 +510,9 @@ pub const Application = extern struct {
|
||||||
.show_gtk_inspector => Action.showGtkInspector(),
|
.show_gtk_inspector => Action.showGtkInspector(),
|
||||||
|
|
||||||
// Unimplemented but todo on gtk-ng branch
|
// Unimplemented but todo on gtk-ng branch
|
||||||
.close_window,
|
|
||||||
.toggle_maximize,
|
.toggle_maximize,
|
||||||
.toggle_fullscreen,
|
.toggle_fullscreen,
|
||||||
.new_tab,
|
.new_tab,
|
||||||
.close_tab,
|
|
||||||
.goto_tab,
|
.goto_tab,
|
||||||
.move_tab,
|
.move_tab,
|
||||||
.new_split,
|
.new_split,
|
||||||
|
|
@ -1047,6 +1049,16 @@ pub const Application = extern struct {
|
||||||
|
|
||||||
/// All apprt action handlers
|
/// All apprt action handlers
|
||||||
const Action = struct {
|
const Action = struct {
|
||||||
|
pub fn close(
|
||||||
|
target: apprt.Target,
|
||||||
|
scope: Surface.CloseScope,
|
||||||
|
) void {
|
||||||
|
switch (target) {
|
||||||
|
.app => {},
|
||||||
|
.surface => |v| v.rt_surface.surface.close(scope),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn configChange(
|
pub fn configChange(
|
||||||
self: *Application,
|
self: *Application,
|
||||||
target: apprt.Target,
|
target: apprt.Target,
|
||||||
|
|
@ -1180,7 +1192,7 @@ const Action = struct {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render(_: *Application, target: apprt.Target) void {
|
pub fn render(target: apprt.Target) void {
|
||||||
switch (target) {
|
switch (target) {
|
||||||
.app => {},
|
.app => {},
|
||||||
.surface => |v| v.rt_surface.surface.redraw(),
|
.surface => |v| v.rt_surface.surface.redraw(),
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,7 @@ pub const Surface = extern struct {
|
||||||
const impl = gobject.ext.defineSignal(
|
const impl = gobject.ext.defineSignal(
|
||||||
name,
|
name,
|
||||||
Self,
|
Self,
|
||||||
&.{bool},
|
&.{*const CloseScope},
|
||||||
void,
|
void,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
@ -829,11 +829,11 @@ pub const Surface = extern struct {
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
// Libghostty Callbacks
|
// Libghostty Callbacks
|
||||||
|
|
||||||
pub fn close(self: *Self, process_active: bool) void {
|
pub fn close(self: *Self, scope: CloseScope) void {
|
||||||
signals.@"close-request".impl.emit(
|
signals.@"close-request".impl.emit(
|
||||||
self,
|
self,
|
||||||
null,
|
null,
|
||||||
.{process_active},
|
.{&scope},
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -1262,7 +1262,7 @@ pub const Surface = extern struct {
|
||||||
self: *Self,
|
self: *Self,
|
||||||
) callconv(.c) void {
|
) callconv(.c) void {
|
||||||
// This closes the surface with no confirmation.
|
// This closes the surface with no confirmation.
|
||||||
self.close(false);
|
self.close(.{ .surface = false });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dtDrop(
|
fn dtDrop(
|
||||||
|
|
@ -2093,6 +2093,25 @@ pub const Surface = extern struct {
|
||||||
pub const bindTemplateChildPrivate = C.Class.bindTemplateChildPrivate;
|
pub const bindTemplateChildPrivate = C.Class.bindTemplateChildPrivate;
|
||||||
pub const bindTemplateCallback = C.Class.bindTemplateCallback;
|
pub const bindTemplateCallback = C.Class.bindTemplateCallback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// The scope of a close request.
|
||||||
|
pub const CloseScope = union(enum) {
|
||||||
|
/// Close the surface. The boolean determines if there is a
|
||||||
|
/// process active.
|
||||||
|
surface: bool,
|
||||||
|
|
||||||
|
/// Close the tab. We can't know if there are processes active
|
||||||
|
/// for the entire tab scope so listners must query the app.
|
||||||
|
tab,
|
||||||
|
|
||||||
|
/// Close the window.
|
||||||
|
window,
|
||||||
|
|
||||||
|
pub const getGObjectType = gobject.ext.defineBoxed(
|
||||||
|
CloseScope,
|
||||||
|
.{ .name = "GhosttySurfaceCloseScope" },
|
||||||
|
);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The state of the key event while we're doing IM composition.
|
/// The state of the key event while we're doing IM composition.
|
||||||
|
|
|
||||||
|
|
@ -132,11 +132,11 @@ pub const Window = extern struct {
|
||||||
|
|
||||||
fn surfaceCloseRequest(
|
fn surfaceCloseRequest(
|
||||||
surface: *Surface,
|
surface: *Surface,
|
||||||
process_active: bool,
|
scope: *const Surface.CloseScope,
|
||||||
self: *Self,
|
self: *Self,
|
||||||
) callconv(.c) void {
|
) callconv(.c) void {
|
||||||
// Todo
|
// Todo
|
||||||
_ = process_active;
|
_ = scope;
|
||||||
|
|
||||||
assert(surface == self.private().surface);
|
assert(surface == self.private().surface);
|
||||||
self.as(gtk.Window).close();
|
self.as(gtk.Window).close();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue