From e911d53a2edd7d83d669d8c012ad145beab38f57 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 21 Jul 2025 07:15:54 -0700 Subject: [PATCH] apprt/gtk-ng: get-title --- src/apprt/gtk-ng/Surface.zig | 3 +-- src/apprt/gtk-ng/class.zig | 6 +++++- src/apprt/gtk-ng/class/surface.zig | 5 +++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/apprt/gtk-ng/Surface.zig b/src/apprt/gtk-ng/Surface.zig index ab9b6de52..bd40e828b 100644 --- a/src/apprt/gtk-ng/Surface.zig +++ b/src/apprt/gtk-ng/Surface.zig @@ -36,8 +36,7 @@ pub fn close(self: *Self, process_active: bool) void { } pub fn getTitle(self: *Self) ?[:0]const u8 { - _ = self; - return null; + return self.surface.getTitle(); } pub fn getContentScale(self: *const Self) !apprt.ContentScale { diff --git a/src/apprt/gtk-ng/class.zig b/src/apprt/gtk-ng/class.zig index 7c8cfbc06..181259ee7 100644 --- a/src/apprt/gtk-ng/class.zig +++ b/src/apprt/gtk-ng/class.zig @@ -49,7 +49,11 @@ pub fn Common( /// A helper that can be used to create a property that reads and /// writes a private `?[:0]const u8` field type. /// - /// This helper helps properly manage the memory to avoid memory leaks. + /// Reading the property will result in a copy of the string + /// and callers are responsible for freeing it. + /// + /// Writing the property will free the previous value and copy + /// the new value into the private field. /// /// The object class (Self) must still free the private field /// in finalize! diff --git a/src/apprt/gtk-ng/class/surface.zig b/src/apprt/gtk-ng/class/surface.zig index b719cb870..535087d9a 100644 --- a/src/apprt/gtk-ng/class/surface.zig +++ b/src/apprt/gtk-ng/class/surface.zig @@ -881,6 +881,11 @@ pub const Surface = extern struct { //--------------------------------------------------------------- // Properties + /// Returns the title property without a copy. + pub fn getTitle(self: *Self) ?[:0]const u8 { + return self.private().title; + } + fn propMouseHidden( self: *Self, _: *gobject.ParamSpec,