[Xfce4-commits] r30347 - in thunar/branches/migration-to-gio: . thunar

Jannis Pohlmann jannis at xfce.org
Sat Jul 18 19:28:56 CEST 2009


Author: jannis
Date: 2009-07-18 17:28:56 +0000 (Sat, 18 Jul 2009)
New Revision: 30347

Modified:
   thunar/branches/migration-to-gio/ChangeLog
   thunar/branches/migration-to-gio/thunar/thunar-file.c
Log:
	* thunar/thunar-file.c: Only return true from
	  thunar_file_is_executable() if the file is either a desktop file or
	  is an application/x-executable or application/x-shellscript. On
	  Windows we use g_content_type_can_be_executable() directly instead
	  of checking for these two content types. Patch by Nick.

Modified: thunar/branches/migration-to-gio/ChangeLog
===================================================================
--- thunar/branches/migration-to-gio/ChangeLog	2009-07-18 16:55:47 UTC (rev 30346)
+++ thunar/branches/migration-to-gio/ChangeLog	2009-07-18 17:28:56 UTC (rev 30347)
@@ -1,5 +1,13 @@
 2009-07-18	Jannis Pohlmann <jannis at xfce.org>
 
+	* thunar/thunar-file.c: Only return true from
+	  thunar_file_is_executable() if the file is either a desktop file or
+	  is an application/x-executable or application/x-shellscript. On
+	  Windows we use g_content_type_can_be_executable() directly instead
+	  of checking for these two content types. Patch by Nick.
+
+2009-07-18	Jannis Pohlmann <jannis at xfce.org>
+
 	* thunar/thunar-file.{c,h}: Introduce new function
 	  thunar_file_same_filesystem() which uses
 	  G_FILE_ATTRIBUTE_ID_FILESYSTEM to check whether two files reside on

Modified: thunar/branches/migration-to-gio/thunar/thunar-file.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.c	2009-07-18 16:55:47 UTC (rev 30346)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.c	2009-07-18 17:28:56 UTC (rev 30347)
@@ -2026,16 +2026,36 @@
 gboolean
 thunar_file_is_executable (const ThunarFile *file)
 {
-  gboolean can_execute;
+  gboolean     can_execute = FALSE;
+  const gchar *content_type;
 
   _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
 
   if (file->info == NULL)
     return FALSE;
-  
-  can_execute = g_file_info_get_attribute_boolean (file->info, 
-                                                   G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE);
 
+  if (g_file_info_get_attribute_boolean (file->info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE))
+    {
+      /* get the content type of the file */
+      content_type = g_file_info_get_content_type (file->info);
+      if (G_LIKELY (content_type != NULL))
+        {
+#ifdef G_OS_WIN32
+          /* check for .exe, .bar or .com */
+          can_execute = g_content_type_can_be_executable (content_type);
+#else
+          /* check if the content type is save to execute, we don't use
+           * g_content_type_can_be_executable() for unix because it also returns
+           * true for "text/plain" and we don't want that */
+          if (g_content_type_is_a (content_type, "application/x-executable")
+              || g_content_type_is_a (content_type, "application/x-shellscript"))
+            {
+              can_execute = TRUE;
+            }
+#endif
+        }
+    }
+
   return can_execute || thunar_file_is_desktop_file (file);
 }
 




More information about the Xfce4-commits mailing list