[gtk/wip/hadess/fix-remote-filechooser: 2/2] filechooser: Fallback if content-type unavailable



commit 53b0c5fd88def0bbaa5bff16c43703cb68dc21f3
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Feb 28 16:59:19 2020 +0100

    filechooser: Fallback if content-type unavailable
    
    Fallback to fast-content-type if the content-type attribute isn't
    available, as is the case for most remote filesystems.
    
    Closes: #2482

 gtk/gtkfilechooserwidget.c | 4 +++-
 gtk/gtkfilesystemmodel.c   | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 2e9832524c..562b2f7f5a 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -404,7 +404,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
 
 #define MODEL_ATTRIBUTES "standard::name,standard::type,standard::display-name," \
                          "standard::is-hidden,standard::is-backup,standard::size," \
-                         "standard::content-type,time::modified,time::access," \
+                         "standard::content-type,standard::fast-content-type,time::modified,time::access," \
                          "access::can-rename,access::can-delete,access::can-trash," \
                          "standard::target-uri"
 enum {
@@ -5049,6 +5049,8 @@ get_type_information (GtkFileChooserWidget *impl,
   char *description;
 
   content_type = g_file_info_get_content_type (info);
+  if (!content_type)
+    content_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
   if (!content_type)
     goto end;
 
diff --git a/gtk/gtkfilesystemmodel.c b/gtk/gtkfilesystemmodel.c
index 33714a81aa..6a304a358a 100644
--- a/gtk/gtkfilesystemmodel.c
+++ b/gtk/gtkfilesystemmodel.c
@@ -397,6 +397,10 @@ node_should_be_filtered_out (GtkFileSystemModel *model, guint id)
   if (required & GTK_FILE_FILTER_MIME_TYPE)
     {
       const char *s = g_file_info_get_content_type (node->info);
+
+      if (!s)
+        s = g_file_info_get_attribute_string (node->info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
+
       if (s)
        {
          mime_type = g_content_type_get_mime_type (s);


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