[nautilus/wip/antoniof/other-types-filter: 3/3] search-popover: Set default action for other types dialog




commit 3328177b8182d79af8ca038337d530b86707e33c
Author: António Fernandes <antoniof gnome org>
Date:   Wed Jul 20 20:56:35 2022 +0200

    search-popover: Set default action for other types dialog
    
    This gives the button a suggested-action style.
    
    It should also trigger the dialog when the user presses Enter/Return,
    but GtkListView is handling that keybinding instead for activation,
    so we must connect to the activation and trigger dialog response
    that way.

 src/nautilus-search-popover.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/src/nautilus-search-popover.c b/src/nautilus-search-popover.c
index 9945c0f5d..57561f541 100644
--- a/src/nautilus-search-popover.c
+++ b/src/nautilus-search-popover.c
@@ -561,6 +561,16 @@ on_other_types_dialog_response (GtkDialog             *dialog,
     gtk_window_destroy (GTK_WINDOW (dialog));
 }
 
+static void
+on_other_types_activate (GtkListView *self,
+                         guint        position,
+                         gpointer     user_data)
+{
+    GtkDialog *dialog = GTK_DIALOG (user_data);
+
+    gtk_dialog_response (dialog, GTK_RESPONSE_OK);
+}
+
 static void
 on_other_types_bind (GtkSignalListItemFactory *factory,
                      GtkListItem              *listitem,
@@ -629,6 +639,7 @@ show_other_types_dialog (NautilusSearchPopover *popover)
                                           _("_Cancel"), GTK_RESPONSE_CANCEL,
                                           _("Select"), GTK_RESPONSE_OK,
                                           NULL);
+    gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
     gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 600);
 
     /* If there are 0 results, make action insensitive */
@@ -665,6 +676,7 @@ show_other_types_dialog (NautilusSearchPopover *popover)
 
     listview = gtk_list_view_new (GTK_SELECTION_MODEL (g_object_ref (popover->other_types_model)),
                                   factory);
+    g_signal_connect (listview, "activate", G_CALLBACK (on_other_types_activate), dialog);
 
     gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled), listview);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]