[glib/wip/oholy/gio-tool-list-display-names] gio-tool-list: Add an option to print display names



commit c5132d172191c725410cb3d5069f1fa8335cc924
Author: Ondrej Holy <oholy redhat com>
Date:   Tue Dec 17 10:27:24 2019 +0100

    gio-tool-list: Add an option to print display names
    
    There are some GVfs locations (i.e. google-drive://, recent://), where
    G_FILE_ATTRIBUTE_STANDARD_NAME is something tottaly different than
    G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME. Thus it would be nice to have
    an easy way to show the display names. The only way currently to show
    the display names is to use --attributes option, which is a bit
    cumbersome. Let's add new --show-display-names option.
    
    https://gitlab.gnome.org/GNOME/gvfs/issues/402

 gio/gio-tool-list.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/gio/gio-tool-list.c b/gio/gio-tool-list.c
index d1501b8e0..5afc5a41d 100644
--- a/gio/gio-tool-list.c
+++ b/gio/gio-tool-list.c
@@ -29,6 +29,7 @@ static char *attributes = NULL;
 static gboolean show_hidden = FALSE;
 static gboolean show_long = FALSE;
 static gboolean nofollow_symlinks = FALSE;
+static gboolean print_display_names = FALSE;
 static gboolean print_uris = FALSE;
 
 static const GOptionEntry entries[] = {
@@ -36,6 +37,7 @@ static const GOptionEntry entries[] = {
   { "hidden", 'h', 0, G_OPTION_ARG_NONE, &show_hidden, N_("Show hidden files"), NULL },
   { "long", 'l', 0, G_OPTION_ARG_NONE, &show_long, N_("Use a long listing format"), NULL },
   { "nofollow-symlinks", 'n', 0, G_OPTION_ARG_NONE, &nofollow_symlinks, N_("Don’t follow symbolic links"), 
NULL},
+  { "print-display-names", 'd', 0, G_OPTION_ARG_NONE, &print_display_names, N_("Print display names"), NULL 
},
   { "print-uris", 'u', 0, G_OPTION_ARG_NONE, &print_uris, N_("Print full URIs"), NULL},
   { NULL }
 };
@@ -54,7 +56,11 @@ show_file_listing (GFileInfo *info, GFile *parent)
   if ((g_file_info_get_is_hidden (info)) && !show_hidden)
     return;
 
-  name = g_file_info_get_name (info);
+  if (print_display_names)
+    name = g_file_info_get_display_name (info);
+  else
+    name = g_file_info_get_name (info);
+
   if (name == NULL)
     name = "";
 
@@ -196,6 +202,7 @@ handle_list (int argc, char *argv[], gboolean do_help)
     show_long = TRUE;
 
   attributes = g_strconcat (G_FILE_ATTRIBUTE_STANDARD_NAME ","
+                            G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME ","
                             G_FILE_ATTRIBUTE_STANDARD_TYPE ","
                             G_FILE_ATTRIBUTE_STANDARD_SIZE ","
                             G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN,


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