[nautilus/wip/corey/public-share] window-slot: Show the sharing infobar when for g-u-s fallback




commit 4658a2c1f85104634456fce830c56ad34559defa
Author: Corey Berla <corey berla me>
Date:   Thu Sep 1 15:18:43 2022 -0700

    window-slot: Show the sharing infobar when for g-u-s fallback
    
    Normally we show the Sharing info bar when we are in the
    XDG_PUBLICSHARE_DIR (i.e. G_USER_DIRECTORY_PUBLIC_SHARE).
    gnome-user-share has a fallback to ~/Public when the PUBLIC_SHARE
    folder is set to the user's home directory.  Match the behavior
    that g-u-s uses.
    
    Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2459

 src/nautilus-window-slot.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 64ab6293d..8cf94d705 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -2664,6 +2664,26 @@ view_is_loading_changed_cb (GObject            *object,
     nautilus_profile_end (NULL);
 }
 
+static gboolean
+nautilus_file_is_public_share_folder (NautilusFile *file)
+{
+    if (nautilus_file_is_user_special_directory (file, G_USER_DIRECTORY_PUBLIC_SHARE))
+    {
+        return TRUE;
+    }
+    if (g_strcmp0 (g_get_home_dir (), g_get_user_special_dir (G_USER_DIRECTORY_PUBLIC_SHARE)))
+    {
+        /* In order to match the behavior of gnome-user-share the ~/Public folder
+         * is considered to be the public sharing folder when XDG_PUBLICSHARE_DIR
+         * is set to the home folder. */
+        g_autoptr (GFile) public_folder = g_file_new_build_filename (g_get_home_dir (), "Public", NULL);
+        g_autoptr (GFile) location = nautilus_file_get_location (file);
+
+        return g_file_equal (public_folder, location);
+    }
+    return FALSE;
+}
+
 static void
 nautilus_window_slot_setup_extra_location_widgets (NautilusWindowSlot *self)
 {
@@ -2698,8 +2718,7 @@ nautilus_window_slot_setup_extra_location_widgets (NautilusWindowSlot *self)
     {
         nautilus_window_slot_show_special_location_bar (self, NAUTILUS_SPECIAL_LOCATION_SCRIPTS);
     }
-    else if (check_schema_available (FILE_SHARING_SCHEMA_ID) &&
-             nautilus_file_is_user_special_directory (file, G_USER_DIRECTORY_PUBLIC_SHARE))
+    else if (check_schema_available (FILE_SHARING_SCHEMA_ID) && nautilus_file_is_public_share_folder (file))
     {
         nautilus_window_slot_show_special_location_bar (self, NAUTILUS_SPECIAL_LOCATION_SHARING);
     }


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