[nautilus/wip/corey/list-view: 2/3] files-view: Grab focus when background / selection menu closed




commit 4b38c0a1708741e1d362285b4dafd3d36669bbba
Author: Corey Berla <corey berla me>
Date:   Sun Aug 21 14:13:06 2022 -0700

    files-view: Grab focus when background / selection menu closed
    
    After closes the background or selection menu (by clicking out of the
    menu or escape) the focus goes to the back button in the toolbar,
    rather than the last focused item.  It's not clear if this is a
    gtk issue or because our complex configuration.  Connect the "closed"
    signal to simply grab back the focus to the files view.  This isn't
    perfect because it doesn't necessarily grab the last focussed child,
    but it saves from adding too much complexity.
    
    Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2433

 src/nautilus-files-view.c | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 32f08cce6..54efe32ad 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -8370,6 +8370,7 @@ nautilus_files_view_pop_up_selection_context_menu  (NautilusFilesView *view,
      * closed because it wouldn't activate the actions then. */
     g_clear_pointer (&priv->selection_menu, gtk_widget_unparent);
     priv->selection_menu = gtk_popover_menu_new_from_model (NULL);
+    g_signal_connect_object (priv->selection_menu, "closed", G_CALLBACK (gtk_widget_grab_focus), view, 
G_CONNECT_SWAPPED);
     gtk_widget_set_parent (priv->selection_menu, GTK_WIDGET (view));
     gtk_popover_set_has_arrow (GTK_POPOVER (priv->selection_menu), FALSE);
     gtk_widget_set_halign (priv->selection_menu, GTK_ALIGN_START);
@@ -8422,6 +8423,7 @@ nautilus_files_view_pop_up_background_context_menu (NautilusFilesView *view,
      * closed because it wouldn't activate the actions then. */
     g_clear_pointer (&priv->background_menu, gtk_widget_unparent);
     priv->background_menu = gtk_popover_menu_new_from_model (NULL);
+    g_signal_connect_object (priv->background_menu, "closed", G_CALLBACK (gtk_widget_grab_focus), view, 
G_CONNECT_SWAPPED);
     gtk_widget_set_parent (priv->background_menu, GTK_WIDGET (view));
     gtk_popover_set_has_arrow (GTK_POPOVER (priv->background_menu), FALSE);
     gtk_widget_set_halign (priv->background_menu, GTK_ALIGN_START);


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