Updating branch refs/heads/master to dc4dc713ed71b8efa22e6b69fccc17eaf56336b1 (commit) from 7f36fdf8f76bd771bc0400267985b57608d4d95a (commit)
commit dc4dc713ed71b8efa22e6b69fccc17eaf56336b1 Author: Jannis Pohlmann <jan...@xfce.org> Date: Sun Nov 21 13:05:50 2010 +0100 Use Name field as display name of desktop entries (bug #6860). NEWS | 1 + thunar/thunar-file.c | 60 +++++++++++++++++++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/NEWS b/NEWS index 6407753..3bf9944 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ (bug #6748). - Fix a typo in configure.in.in (bug #6724). - Use GTK_STOCK_FILE as the fallback icon for files (bug #6662). +- Use Name field as display name of desktop entries (bug #6860). 1.1.4 ===== diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index b5544d1..6a341ba 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -778,9 +778,11 @@ thunar_file_load (ThunarFile *file, /* use the filename as custom icon name for thumbnails */ file->custom_icon_name = g_file_get_path (file->gfile); } - else if (thunar_file_is_desktop_file (file)) + + /* check if this file is a desktop entry */ + if (thunar_file_is_desktop_file (file)) { - /* determine the custom icon name for .desktop files */ + /* determine the custom icon and display name for .desktop files */ /* query a key file for the .desktop file */ key_file = thunar_g_file_query_key_file (file->gfile, cancellable, NULL); @@ -810,6 +812,25 @@ thunar_file_load (ThunarFile *file, } } + /* read the display name from the .desktop file (will be overwritten later + * if it's undefined here) */ + file->display_name = g_key_file_get_string (key_file, + G_KEY_FILE_DESKTOP_GROUP, + G_KEY_FILE_DESKTOP_KEY_NAME, + NULL); + + /* check if we have a display name now */ + if (file->display_name != NULL) + { + /* drop the name if it's empty or has invalid encoding */ + if (*file->display_name == '\0' + || !g_utf8_validate (file->display_name, -1, NULL)) + { + g_free (file->display_name); + file->display_name = NULL; + } + } + /* free the key file */ g_key_file_free (key_file); } @@ -830,28 +851,31 @@ thunar_file_load (ThunarFile *file, g_free (thumbnail_dir_path); /* determine the display name */ - if (file->info != NULL) + if (file->display_name == NULL) { - if (g_strcmp0 (g_file_info_get_display_name (file->info), "/") == 0) - file->display_name = g_strdup (_("File System")); - else - file->display_name = g_strdup (g_file_info_get_display_name (file->info)); - } - else - { - if (g_file_is_native (file->gfile)) + if (file->info != NULL) { - uri = g_file_get_path (file->gfile); - if (uri == NULL) - uri = g_file_get_uri (file->gfile); + if (g_strcmp0 (g_file_info_get_display_name (file->info), "/") == 0) + file->display_name = g_strdup (_("File System")); + else + file->display_name = g_strdup (g_file_info_get_display_name (file->info)); } else { - uri = g_file_get_uri (file->gfile); - } + if (g_file_is_native (file->gfile)) + { + uri = g_file_get_path (file->gfile); + if (uri == NULL) + uri = g_file_get_uri (file->gfile); + } + else + { + uri = g_file_get_uri (file->gfile); + } - file->display_name = g_filename_display_name (uri); - g_free (uri); + file->display_name = g_filename_display_name (uri); + g_free (uri); + } } /* set thumb state to unknown */ _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits