apprt/gtk: support new set clipboard API

pull/9418/head
Mitchell Hashimoto 2025-10-30 14:09:39 -07:00
parent 26bdb12f64
commit 9a198b47a0
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
2 changed files with 15 additions and 8 deletions

View File

@ -80,15 +80,15 @@ pub fn clipboardRequest(
);
}
pub fn setClipboardString(
pub fn setClipboard(
self: *Self,
val: [:0]const u8,
clipboard_type: apprt.Clipboard,
contents: []const apprt.ClipboardContent,
confirm: bool,
) !void {
self.surface.setClipboardString(
val,
self.surface.setClipboard(
clipboard_type,
contents,
confirm,
);
}

View File

@ -1553,16 +1553,16 @@ pub const Surface = extern struct {
);
}
pub fn setClipboardString(
pub fn setClipboard(
self: *Self,
val: [:0]const u8,
clipboard_type: apprt.Clipboard,
contents: []const apprt.ClipboardContent,
confirm: bool,
) void {
Clipboard.set(
self,
val,
clipboard_type,
contents,
confirm,
);
}
@ -3334,12 +3334,19 @@ const Clipboard = struct {
/// Set the clipboard contents.
pub fn set(
self: *Surface,
val: [:0]const u8,
clipboard_type: apprt.Clipboard,
contents: []const apprt.ClipboardContent,
confirm: bool,
) void {
const priv = self.private();
// For GTK, we only support text/plain type to set strings currently.
const val: [:0]const u8 = for (contents) |content| {
if (std.mem.eql(u8, content.mime, "text/plain")) {
break content.data;
}
} else return;
// If no confirmation is necessary, set the clipboard.
if (!confirm) {
const clipboard = get(