[nautilus] gtkplacesview: Do not show properties menu for unmounted drives



commit 462cc1a0b6e63671c828704a3ba660219ea7a88c
Author: Eric Daigle <49949-edaigle users noreply gitlab gnome org>
Date:   Tue Aug 23 18:06:18 2022 +0000

    gtkplacesview: Do not show properties menu for unmounted drives
    
    As described in #2412, the Other Locations context menu currently shows a useless
    Properties option when an unmounted drive is right-clicked. Adds a check
    when enabling the Properties widget to ensure it is only enabled if a drive is mounted
    and/or is the root filesystem (the root case must be handled separately as the mount
    field is not set in the GtkPlacesViewRow representing the root filesystem)
    
    Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2412

 src/gtk/nautilusgtkplacesview.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/gtk/nautilusgtkplacesview.c b/src/gtk/nautilusgtkplacesview.c
index 4d470eff7..0d062c9ee 100644
--- a/src/gtk/nautilusgtkplacesview.c
+++ b/src/gtk/nautilusgtkplacesview.c
@@ -28,6 +28,7 @@
 #include "nautilusgtkplacesviewprivate.h"
 #include "nautilusgtkplacesviewrowprivate.h"
 #include "nautilus-file.h"
+#include "nautilus-file-utilities.h"
 #include "nautilus-properties-window.h"
 
 /*< private >
@@ -1768,13 +1769,14 @@ real_popup_menu (GtkWidget *widget,
   NautilusGtkPlacesView *view;
   GMount *mount;
   GFile *file;
-  gboolean is_network;
+  gboolean is_root, is_network;
   double x_in_view, y_in_view;
 
   view = NAUTILUS_GTK_PLACES_VIEW (gtk_widget_get_ancestor (GTK_WIDGET (row), 
NAUTILUS_TYPE_GTK_PLACES_VIEW));
 
   mount = nautilus_gtk_places_view_row_get_mount (row);
   file = nautilus_gtk_places_view_row_get_file (row);
+  is_root = file && nautilus_is_root_directory (file);
   is_network = nautilus_gtk_places_view_row_get_is_network (row);
 
   gtk_widget_action_set_enabled (GTK_WIDGET (view), "location.disconnect",
@@ -1786,7 +1788,8 @@ real_popup_menu (GtkWidget *widget,
   gtk_widget_action_set_enabled (GTK_WIDGET (view), "location.mount",
                                  !file && !mount && !is_network);
   gtk_widget_action_set_enabled (GTK_WIDGET (view), "location.properties",
-                                 !(file && is_network));
+                                 (is_root ||
+                                  (mount && !(file && is_network))));
 
   if (!view->popup_menu)
     {


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