apprt/gtk-ng: close inspector window when widget loses surface
parent
7548dcfe63
commit
68f337e398
|
|
@ -104,6 +104,10 @@ pub const InspectorWidget = extern struct {
|
|||
));
|
||||
}
|
||||
|
||||
pub fn getSurface(self: *Self) ?*Surface {
|
||||
return self.private().surface;
|
||||
}
|
||||
|
||||
pub fn setSurface(self: *Self, surface_: ?*Surface) void {
|
||||
const priv = self.private();
|
||||
|
||||
|
|
|
|||
|
|
@ -157,6 +157,22 @@ pub const InspectorWindow = extern struct {
|
|||
));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Signal Handlers
|
||||
|
||||
fn propInspectorSurface(
|
||||
inspector: *InspectorWidget,
|
||||
_: *gobject.ParamSpec,
|
||||
self: *Self,
|
||||
) callconv(.c) void {
|
||||
// If the inspector's surface went away, we destroy the window.
|
||||
// The inspector has a weak notify on the surface so it knows
|
||||
// if it goes nil.
|
||||
if (inspector.getSurface() == null) {
|
||||
self.as(gtk.Window).destroy();
|
||||
}
|
||||
}
|
||||
|
||||
const C = Common(Self, Private);
|
||||
pub const as = C.as;
|
||||
pub const ref = C.ref;
|
||||
|
|
@ -184,6 +200,9 @@ pub const InspectorWindow = extern struct {
|
|||
// Template Bindings
|
||||
class.bindTemplateChildPrivate("inspector_widget", .{});
|
||||
|
||||
// Template callbacks
|
||||
class.bindTemplateCallback("notify_inspector_surface", &propInspectorSurface);
|
||||
|
||||
// Properties
|
||||
gobject.ext.registerProperties(class, &.{
|
||||
properties.surface.impl,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ template $GhosttyInspectorWindow: Adw.ApplicationWindow {
|
|||
}
|
||||
|
||||
$GhosttyInspectorWidget inspector_widget {
|
||||
notify::surface => $notify_inspector_surface();
|
||||
surface: bind template.surface;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue