mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 07:46:12 +03:00
Set the paste button in the GTK dialog as default
This commit is contained in:
@ -89,6 +89,8 @@ fn init(
|
||||
const view = try PrimaryView.init(self, data);
|
||||
self.view = view;
|
||||
c.gtk_window_set_child(@ptrCast(window), view.root);
|
||||
_ = c.gtk_widget_grab_focus(view.buttons.confirm_button);
|
||||
|
||||
c.gtk_widget_show(window);
|
||||
|
||||
// Block the main window from input.
|
||||
@ -104,6 +106,7 @@ fn gtkDestroy(_: *c.GtkWidget, ud: ?*anyopaque) callconv(.C) void {
|
||||
const PrimaryView = struct {
|
||||
root: *c.GtkWidget,
|
||||
text: *c.GtkTextView,
|
||||
buttons: ButtonsView,
|
||||
|
||||
pub fn init(root: *ClipboardConfirmation, data: []const u8) !PrimaryView {
|
||||
// All our widgets
|
||||
@ -135,7 +138,7 @@ const PrimaryView = struct {
|
||||
c.gtk_text_view_set_right_margin(@ptrCast(text), 8);
|
||||
c.gtk_text_view_set_monospace(@ptrCast(text), 1);
|
||||
|
||||
return .{ .root = view.root, .text = @ptrCast(text) };
|
||||
return .{ .root = view.root, .text = @ptrCast(text), .buttons = buttons };
|
||||
}
|
||||
|
||||
/// Returns the GtkTextBuffer for the data that was unsafe.
|
||||
@ -158,6 +161,7 @@ const PrimaryView = struct {
|
||||
|
||||
const ButtonsView = struct {
|
||||
root: *c.GtkWidget,
|
||||
confirm_button: *c.GtkWidget,
|
||||
|
||||
pub fn init(root: *ClipboardConfirmation) !ButtonsView {
|
||||
const cancel_text, const confirm_text = switch (root.pending_req) {
|
||||
@ -172,7 +176,7 @@ const ButtonsView = struct {
|
||||
errdefer c.g_object_unref(confirm_button);
|
||||
|
||||
// TODO: Focus on the paste button
|
||||
// c.gtk_widget_grab_focus(confirm_button);
|
||||
_ = c.gtk_widget_grab_focus(confirm_button);
|
||||
|
||||
// Create our view
|
||||
const view = try View.init(&.{
|
||||
@ -198,7 +202,7 @@ const ButtonsView = struct {
|
||||
c.G_CONNECT_DEFAULT,
|
||||
);
|
||||
|
||||
return .{ .root = view.root };
|
||||
return .{ .root = view.root, .confirm_button = confirm_button };
|
||||
}
|
||||
|
||||
fn gtkCancelClick(_: *c.GtkWidget, ud: ?*anyopaque) callconv(.C) void {
|
||||
|
Reference in New Issue
Block a user