[gtk+] gtkicontheme: Don't query CONTENT_TYPE to determine if something is an SVG



commit f929a613999bd4f895bb466f497b9d009cae4e85
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sat Jan 18 11:47:43 2014 -0500

    gtkicontheme: Don't query CONTENT_TYPE to determine if something is an SVG
    
    We already know based on the suffix of the filename.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=721895

 gtk/gtkicontheme.c |   34 +++++++++-------------------------
 1 files changed, 9 insertions(+), 25 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 959fc03..898898a 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -266,6 +266,7 @@ struct _GtkIconInfo
   guint raw_coordinates : 1;
   guint forced_size     : 1;
   guint emblems_applied : 1;
+  guint is_svg          : 1;
 
   /* Cached information if we go ahead and try to load
    * the icon.
@@ -1729,6 +1730,13 @@ choose_icon (GtkIconTheme       *icon_theme,
  out:
   if (icon_info)
     {
+      if (icon_info->filename)
+        icon_info->is_svg = (suffix_from_name (icon_info->filename) == ICON_SUFFIX_SVG);
+      else
+        /* This can only happen when we have an icon cache. In this case, we know we're
+         * not dealing with an SVG, but with raw pixel data. */
+        icon_info->is_svg = FALSE;
+
       icon_info->desired_size = size;
       icon_info->desired_scale = scale;
       icon_info->forced_size = (flags & GTK_ICON_LOOKUP_FORCE_SIZE) != 0;
@@ -3683,7 +3691,6 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo  *icon_info,
   int image_width, image_height;
   int scaled_desired_size;
   GdkPixbuf *source_pixbuf;
-  gboolean is_svg;
 
   /* First check if we already succeeded have the necessary
    * information (or failed earlier)
@@ -3708,30 +3715,7 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo  *icon_info,
 
   scaled_desired_size = icon_info->desired_size * icon_info->desired_scale;
 
-  is_svg = FALSE;
-  if (G_IS_FILE_ICON (icon_info->loadable))
-    {
-      GFile *file;
-      GFileInfo *file_info;
-      const gchar *content_type;
-
-      file = g_file_icon_get_file (G_FILE_ICON (icon_info->loadable));
-      file_info = g_file_query_info (file, 
-                                     G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
-                                     G_FILE_QUERY_INFO_NONE,
-                                     NULL, NULL);
-      if (file_info) 
-        {
-          content_type = g_file_info_get_content_type (file_info);
-
-          if (content_type && strcmp (content_type, "image/svg+xml") == 0)
-            is_svg = TRUE;
-
-          g_object_unref (file_info);
-       }
-    }
-
-  if (is_svg)
+  if (icon_info->is_svg)
     {
       GInputStream *stream;
 


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