[Xfce4-commits] [xfce/thunar] 01/01: Update mimeapps.list only when necessary (Bug #15533)

noreply at xfce.org noreply at xfce.org
Sat Jun 15 22:53:20 CEST 2019


This is an automated email from the git hooks/post-receive script.

a   l   e   x       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/thunar.

commit 36a57d6cfe7493d031b616f92eb52eaff38c9a77
Author: Theo Linkspfeifer <lastonestanding at tutanota.com>
Date:   Tue Jun 11 00:40:39 2019 +0200

    Update mimeapps.list only when necessary (Bug #15533)
    
    Co-authored-by: Alexander Schwinn <alexxcons at xfce.org>
---
 thunar/thunar-gio-extensions.c | 41 +++++++++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 6 deletions(-)

diff --git a/thunar/thunar-gio-extensions.c b/thunar/thunar-gio-extensions.c
index 629ec01..a3ce0da 100644
--- a/thunar/thunar-gio-extensions.c
+++ b/thunar/thunar-gio-extensions.c
@@ -552,11 +552,14 @@ thunar_g_app_info_launch (GAppInfo          *info,
                           GError           **error)
 {
   ThunarFile   *file;
+  GAppInfo     *default_app_info;
+  GList        *recommended_app_infos;
   GList        *lp;
   const gchar  *content_type;
   gboolean      result = FALSE;
   gchar        *new_path = NULL;
   gchar        *old_path = NULL;
+  gboolean      update_app_info = TRUE;
 
   _thunar_return_val_if_fail (G_IS_APP_INFO (info), FALSE);
   _thunar_return_val_if_fail (working_directory == NULL || G_IS_FILE (working_directory), FALSE);
@@ -588,16 +591,42 @@ thunar_g_app_info_launch (GAppInfo          *info,
       for (lp = path_list; lp != NULL; lp = lp->next)
         {
           file = thunar_file_get (lp->data, NULL);
-          if (file != NULL)
+          if (file == NULL)
+            continue;
+
+          update_app_info = TRUE;
+          content_type = thunar_file_get_content_type (file);
+
+          /* determine default application */
+          default_app_info = thunar_file_get_default_handler (file);
+          if (default_app_info != NULL)
             {
-              content_type = thunar_file_get_content_type (file);
+              /* check if the application is the default one */
+              if (g_app_info_equal (info, default_app_info))
+                update_app_info = FALSE;
+              g_object_unref (default_app_info);
+            }
 
-              /* emit "changed" on the file if we successfully changed the last used application */
-              if (g_app_info_set_as_last_used_for_type (info, content_type, NULL))
-                thunar_file_changed (file);
+          if (update_app_info)
+            {
+              /* obtain list of last used applications */
+              recommended_app_infos = g_app_info_get_recommended_for_type (content_type);
+              if (recommended_app_infos != NULL)
+                {
+                  /* check if the application is already the last used one
+                   * by comparing it with the first entry in the list */
+                  if (g_app_info_equal (info, recommended_app_infos->data))
+                    update_app_info = FALSE;
 
-              g_object_unref (file);
+                  g_list_free (recommended_app_infos);
+                }
             }
+
+          /* emit "changed" on the file if we successfully changed the last used application */
+          if (update_app_info && g_app_info_set_as_last_used_for_type (info, content_type, NULL))
+            thunar_file_changed (file);
+
+          g_object_unref (file);
         }
     }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list