[glib/wip/oholy/gio-tool-list-display-names] gio-tool-list: Add an option to print display names
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/oholy/gio-tool-list-display-names] gio-tool-list: Add an option to print display names
- Date: Tue, 17 Dec 2019 10:07:29 +0000 (UTC)
commit e6f5b9bf890b9c867873785600d0971ea56b40f7
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 | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/gio/gio-tool-list.c b/gio/gio-tool-list.c
index d1501b8e0..9f52d158d 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 = "";
@@ -81,7 +87,8 @@ show_file_listing (GFileInfo *info, GFile *parent)
char *val_as_string;
if (!show_long ||
- strcmp (attributes[i], G_FILE_ATTRIBUTE_STANDARD_NAME) == 0 ||
+ (!print_display_names && strcmp (attributes[i], G_FILE_ATTRIBUTE_STANDARD_NAME) == 0) ||
+ (print_display_names && strcmp (attributes[i], G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME) == 0) ||
strcmp (attributes[i], G_FILE_ATTRIBUTE_STANDARD_SIZE) == 0 ||
strcmp (attributes[i], G_FILE_ATTRIBUTE_STANDARD_TYPE) == 0 ||
strcmp (attributes[i], G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN) == 0)
@@ -195,7 +202,8 @@ handle_list (int argc, char *argv[], gboolean do_help)
if (attributes != NULL)
show_long = TRUE;
- attributes = g_strconcat (G_FILE_ATTRIBUTE_STANDARD_NAME ","
+ attributes = g_strconcat (!print_display_names ? G_FILE_ATTRIBUTE_STANDARD_NAME "," : "",
+ print_display_names ? 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]