[gtk/issue-377: 2/2] Show the default app for a content type only if recommended



commit d0d5939569945f1a0bcba228df33bee1063834c6
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Fri Nov 15 16:29:13 2019 +0000

    Show the default app for a content type only if recommended
    
    The default application for a content type is selected depending on
    whether it matches the given content type or any of its sub-classes.
    This means that we might end up showing a text editor for the
    `text/calendar` MIME type because it matches the `text/*` super-class.
    The recommended applications, on the other hand, match the exact content
    type.
    
    Fixes: #377

 gtk/gtkappchooserbutton.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkappchooserbutton.c b/gtk/gtkappchooserbutton.c
index 4c8dc45ee4..1dc1e32483 100644
--- a/gtk/gtkappchooserbutton.c
+++ b/gtk/gtkappchooserbutton.c
@@ -364,12 +364,28 @@ gtk_app_chooser_button_populate (GtkAppChooserButton *self)
 
       if (default_app != NULL)
         {
-          get_first_iter (priv->store, &iter);
-          cycled_recommended = TRUE;
-
-          insert_one_application (self, default_app, &iter);
-
-          g_object_unref (default_app);
+          /* The default app matches all types and sub-types of the
+           * content type we're looking at, whereas the recomended
+           * apps match the content type exactly. If the default app
+           * does not appear in the recommended apps then we might
+           * end up showing a text editor for calendar-related files,
+           * which is not helpful.
+           *
+           * See: https://gitlab.gnome.org/GNOME/gtk/issues/377
+           */
+          if (g_list_find (recommended_apps, default_app) != NULL)
+            {
+              get_first_iter (priv->store, &iter);
+              cycled_recommended = TRUE;
+
+              insert_one_application (self, default_app, &iter);
+
+              g_object_unref (default_app);
+            }
+          else
+            {
+              g_clear_object (&default_app);
+            }
         }
     }
 


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