[Xfce-bugs] [Bug 14576] Add support for folder.jpg

bugzilla-daemon at xfce.org bugzilla-daemon at xfce.org
Mon Aug 6 00:47:58 CEST 2018


https://bugzilla.xfce.org/show_bug.cgi?id=14576

--- Comment #16 from HYPERION <h1p8r10n at yandex.com> ---
Comment on attachment 7866
  --> https://bugzilla.xfce.org/attachment.cgi?id=7866
improved patch (memory cleaning)

>diff -rNaud Thunar-1.8.1-OLD/thunar/thunar-icon-factory.c Thunar-1.8.1/thunar/thunar-icon-factory.c
>--- Thunar-1.8.1-OLD/thunar/thunar-icon-factory.c	2018-06-12 03:47:24.000000000 +0200
>+++ Thunar-1.8.1/thunar/thunar-icon-factory.c	2018-08-06 00:42:05.485135360 +0200
>@@ -792,7 +792,50 @@
>   return thunar_icon_factory_lookup_icon (factory, name, size, wants_default);
> }
> 
>-
>+/**
>+ * thunar_icon_factory_check_folder_icon:
>+ * @file       : a #ThunarFile.
>+ *
>+ * Return value: gchar pointer containing full path to 
>+ * folder.xxx image or NULL if no image found.
>+ **/
>+gchar *
>+thunar_icon_factory_check_folder_icon (	ThunarFile			*file)
>+{
>+    
>+	gchar 	  *folder_icon;	
>+	gchar 	  *path;	
>+	
>+	path = g_file_get_path (thunar_file_get_file (file));
>+	
>+	folder_icon = g_strconcat (path, "/", ".folder.jpg", NULL);
>+	if ( g_file_test(folder_icon, G_FILE_TEST_EXISTS)) 
>+	  {
>+		g_free (path);
>+		return folder_icon;
>+	  }
>+	folder_icon = g_strconcat (path, "/", "folder.jpg", NULL);
>+	if ( g_file_test(folder_icon, G_FILE_TEST_EXISTS)) 
>+	  {
>+		g_free (path);
>+		return folder_icon;
>+	  }	
>+	folder_icon = g_strconcat (path, "/", ".folder.png", NULL);
>+	if ( g_file_test(folder_icon, G_FILE_TEST_EXISTS)) 
>+	  {
>+		g_free (path);
>+		return folder_icon;
>+	  }	
>+	folder_icon = g_strconcat (path, "/", "folder.png", NULL);
>+	if ( g_file_test(folder_icon, G_FILE_TEST_EXISTS)) 
>+	  {
>+		g_free (path);
>+		return folder_icon;
>+	  }
>+	g_free (path);
>+	folder_icon = NULL;
>+	return folder_icon;
>+}
> 
> /**
>  * thunar_icon_factory_load_file_icon:
>@@ -819,8 +862,9 @@
>   GIcon           *gicon;
>   const gchar     *icon_name;
>   const gchar     *custom_icon;
>+  const gchar     *folder_icon;
>   ThunarIconStore *store;
>-
>+  
>   _thunar_return_val_if_fail (THUNAR_IS_ICON_FACTORY (factory), NULL);
>   _thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL);
>   _thunar_return_val_if_fail (icon_size > 0, NULL);
>@@ -836,7 +880,7 @@
>       return g_object_ref (store->icon);
>     }
> 
>-  /* check if we have a custom icon for this file */
>+  /* check if we have a custom icon for this file */    
>   custom_icon = thunar_file_get_custom_icon (file);
>   if (custom_icon != NULL)
>     {
>@@ -846,6 +890,21 @@
>         return icon;
>     }
> 
>+  /* check if thumbnails are enabled and we have a "?folder.xxx" icon for this folder */ 
>+  if (thunar_icon_factory_get_show_thumbnail (factory, file)
>+      && thunar_file_is_directory (file))
>+	{
>+	  folder_icon = thunar_icon_factory_check_folder_icon (file);
>+	  if (folder_icon != NULL)
>+		{
>+		  /* try to load the icon */
>+		  icon = thunar_icon_factory_lookup_icon (factory, folder_icon, icon_size, FALSE);
>+		  g_free(folder_icon);
>+		  if (G_LIKELY (icon != NULL))
>+		    return icon;
>+		}
>+	  }
>+
>   /* check if thumbnails are enabled and we can display a thumbnail for the item */
>   if (thunar_icon_factory_get_show_thumbnail (factory, file)
>       && thunar_file_is_regular (file))

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Xfce-bugs mailing list