mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
apprt/gtk-ng: hook up basic quit functionality (no confirm)
This commit is contained in:
@ -396,13 +396,45 @@ pub const Application = extern struct {
|
|||||||
break :q false;
|
break :q false;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (must_quit) {
|
if (must_quit) self.quit();
|
||||||
//self.quit();
|
|
||||||
priv.running = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Quit the application. This will start the process to stop the
|
||||||
|
/// run loop. It will not `posix.exit`.
|
||||||
|
pub fn quit(self: *Self) void {
|
||||||
|
const priv = self.private();
|
||||||
|
|
||||||
|
// If our run loop has already exited then we are done.
|
||||||
|
if (!priv.running) return;
|
||||||
|
|
||||||
|
// If our core app doesn't need to confirm quit then we
|
||||||
|
// can exit immediately.
|
||||||
|
if (!priv.core_app.needsConfirmQuit()) {
|
||||||
|
self.quitNow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.quitNow();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn quitNow(self: *Self) void {
|
||||||
|
// Get all our windows and destroy them, forcing them to
|
||||||
|
// free their memory.
|
||||||
|
const list = gtk.Window.listToplevels();
|
||||||
|
defer list.free();
|
||||||
|
list.foreach(struct {
|
||||||
|
fn callback(data: ?*anyopaque, _: ?*anyopaque) callconv(.c) void {
|
||||||
|
const ptr = data orelse return;
|
||||||
|
const window: *gtk.Window = @ptrCast(@alignCast(ptr));
|
||||||
|
window.destroy();
|
||||||
|
}
|
||||||
|
}.callback, null);
|
||||||
|
|
||||||
|
// Trigger our runloop exit.
|
||||||
|
self.private().running = false;
|
||||||
|
}
|
||||||
|
|
||||||
/// apprt API to perform an action.
|
/// apprt API to perform an action.
|
||||||
pub fn performAction(
|
pub fn performAction(
|
||||||
self: *Self,
|
self: *Self,
|
||||||
@ -430,6 +462,8 @@ pub const Application = extern struct {
|
|||||||
|
|
||||||
.pwd => Action.pwd(target, value),
|
.pwd => Action.pwd(target, value),
|
||||||
|
|
||||||
|
.quit => self.quit(),
|
||||||
|
|
||||||
.quit_timer => try Action.quitTimer(self, value),
|
.quit_timer => try Action.quitTimer(self, value),
|
||||||
|
|
||||||
.render => Action.render(self, target),
|
.render => Action.render(self, target),
|
||||||
@ -437,7 +471,6 @@ pub const Application = extern struct {
|
|||||||
.set_title => Action.setTitle(target, value),
|
.set_title => Action.setTitle(target, value),
|
||||||
|
|
||||||
// Unimplemented but todo on gtk-ng branch
|
// Unimplemented but todo on gtk-ng branch
|
||||||
.quit,
|
|
||||||
.close_window,
|
.close_window,
|
||||||
.toggle_maximize,
|
.toggle_maximize,
|
||||||
.toggle_fullscreen,
|
.toggle_fullscreen,
|
||||||
|
Reference in New Issue
Block a user