mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-17 06:31:10 +00:00
apprt/gtk: support new set clipboard API
This commit is contained in:
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user