Blob Blame History Raw
From 4b142af9dfe19f90ffe5529e2f099dc55298ecef Mon Sep 17 00:00:00 2001
From: Guido Berhoerster <gber@opensuse.org>
Date: Tue, 14 Oct 2014 18:20:47 +0300
Subject: Default application not respected with glib >= 2.41 (Bug #11212)

Ensure thunar_file_list_get_applications() has the default
application as the first element of the returned list.

Signed-off-by: Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at>

diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index c45cf81..0bfe166 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -3999,6 +3999,7 @@ thunar_file_list_get_applications (GList *file_list)
   GList       *next;
   GList       *ap;
   GList       *lp;
+  GAppInfo    *default_application;
   const gchar *previous_type = NULL;
   const gchar *current_type;
 
@@ -4017,7 +4018,25 @@ thunar_file_list_get_applications (GList *file_list)
 
       /* determine the list of applications that can open this file */
       if (G_UNLIKELY (current_type != NULL))
-        list = g_app_info_get_all_for_type (current_type);
+        {
+          list = g_app_info_get_all_for_type (current_type);
+
+          /* move any default application in front of the list */
+          default_application = g_app_info_get_default_for_type (current_type, FALSE);
+          if (G_LIKELY (default_application != NULL))
+            {
+              for (ap = list; ap != NULL; ap = ap->next)
+                {
+                  if (g_app_info_equal (ap->data, default_application))
+                    {
+                      g_object_unref (ap->data);
+                      list = g_list_delete_link (list, ap);
+                      break;
+                    }
+                }
+              list = g_list_prepend (list, default_application);
+            }
+        }
       else
         list = NULL;
 
-- 
cgit v0.10.1