[nautilus/wip/antoniof/search-list-redesign: 1/3] file: Add trailing slash to parent path
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/search-list-redesign: 1/3] file: Add trailing slash to parent path
- Date: Wed, 3 Aug 2022 09:11:50 +0000 (UTC)
commit a4c9825ec8d916981f9aa502027dc0d52fbc2b44
Author: António Fernandes <antoniof gnome org>
Date: Wed Aug 3 10:00:46 2022 +0100
file: Add trailing slash to parent path
This makes it easier to tell it is a folder path.
In a special case, for recursive search, where we omit the common
prefix, this is especially important because direct subfolders would
be a single basename without any slash.
src/nautilus-file.c | 9 +++++----
src/nautilus-name-cell.c | 6 ++++--
2 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index e03d78f90..cc2845441 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -993,13 +993,14 @@ nautilus_file_unref (NautilusFile *file)
* @file: The file in question.
*
* Return value: A string representing the parent's location,
- * formatted for user display (including stripping "file://").
+ * formatted for user display (including stripping "file://"
+ * and adding trailing slash).
* If the parent is NULL, returns the empty string.
*/
char *
nautilus_file_get_parent_uri_for_display (NautilusFile *file)
{
- GFile *parent;
+ g_autoptr (GFile) parent = NULL;
char *result;
g_assert (NAUTILUS_IS_FILE (file));
@@ -1007,8 +1008,8 @@ nautilus_file_get_parent_uri_for_display (NautilusFile *file)
parent = nautilus_file_get_parent_location (file);
if (parent)
{
- result = g_file_get_parse_name (parent);
- g_object_unref (parent);
+ g_autofree gchar *parse_name = g_file_get_parse_name (parent);
+ result = g_strconcat (parse_name, "/", NULL);
}
else
{
diff --git a/src/nautilus-name-cell.c b/src/nautilus-name-cell.c
index 1a0720ea6..6986dff47 100644
--- a/src/nautilus-name-cell.c
+++ b/src/nautilus-name-cell.c
@@ -69,12 +69,14 @@ get_path_text (NautilusFile *file,
if (g_file_has_prefix (dir_location, relative_location_base))
{
g_autofree gchar *relative_path = NULL;
+ g_autofree gchar *display_name = NULL;
relative_path = g_file_get_relative_path (relative_location_base, dir_location);
- return g_filename_display_name (relative_path);
+ display_name = g_filename_display_name (relative_path);
+ return g_strconcat (display_name, "/", NULL);
}
- return g_file_get_path (dir_location);
+ return g_steal_pointer (&path);
}
static gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]