[gtk+] gtkicontheme: Don't query CONTENT_TYPE to determine svg
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gtkicontheme: Don't query CONTENT_TYPE to determine svg
- Date: Sat, 14 Jun 2014 23:33:17 +0000 (UTC)
commit 62f8dae7a8fe35a1dd31c10b96474cf6c2b7496c
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jun 14 18:54:24 2014 -0400
gtkicontheme: Don't query CONTENT_TYPE to determine svg
We already know based on the suffix of the filename.
https://bugzilla.gnome.org/show_bug.cgi?id=721895
gtk/gtkicontheme.c | 45 ++++++++++-----------------------------------
1 files changed, 10 insertions(+), 35 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 8385d41..0b51806 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -261,6 +261,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.
@@ -1760,6 +1761,7 @@ real_choose_icon (GtkIconTheme *icon_theme,
out:
if (icon_info)
{
+ icon_info->is_svg = (suffix_from_name (icon_info->filename) == ICON_SUFFIX_SVG);
icon_info->desired_size = size;
icon_info->desired_scale = scale;
icon_info->forced_size = (flags & GTK_ICON_LOOKUP_FORCE_SIZE) != 0;
@@ -3844,10 +3846,9 @@ static gboolean
icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info,
gboolean scale_only)
{
- int image_width, image_height;
- int scaled_desired_size;
+ gint image_width, image_height, image_size;
+ gint scaled_desired_size;
GdkPixbuf *source_pixbuf;
- gboolean is_svg;
/* First check if we already succeeded have the necessary
* information (or failed earlier)
@@ -3872,29 +3873,6 @@ 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);
- }
- }
-
/* In many cases, the scale can be determined without actual access
* to the icon file. This is generally true when we have a size
* for the directory where the icon is; the image size doesn't
@@ -3918,7 +3896,7 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info,
icon_info->scale = (gdouble) scaled_desired_size / (icon_info->dir_size * icon_info->dir_scale);
}
- if (icon_info->scale >= 0. && scale_only && !is_svg)
+ if (icon_info->scale >= 0. && scale_only && !icon_info->is_svg)
return TRUE;
/* At this point, we need to actually get the icon; either from the
@@ -3938,7 +3916,7 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info,
&icon_info->load_error);
if (stream)
{
- if (is_svg)
+ if (icon_info->is_svg)
{
gint size = icon_info->dir_size * icon_info->dir_scale * icon_info->scale;
source_pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream,
@@ -3963,15 +3941,12 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info,
*/
image_width = gdk_pixbuf_get_width (source_pixbuf);
image_height = gdk_pixbuf_get_height (source_pixbuf);
+ image_size = MAX (image_width, image_height);
- if (is_svg)
- {
- gint image_size = MAX (image_width, image_height);
- icon_info->scale = image_size / 1000.;
- }
+ if (icon_info->is_svg)
+ icon_info->scale = image_size / 1000.;
else if (icon_info->scale < 0.0)
{
- gint image_size = MAX (image_width, image_height);
if (image_size > 0)
icon_info->scale = (gdouble)scaled_desired_size / (gdouble)image_size;
else
@@ -3989,7 +3964,7 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info,
* extra complexity, we could keep the source pixbuf around
* but not actually scale it until needed.
*/
- if (is_svg)
+ if (icon_info->is_svg)
icon_info->pixbuf = source_pixbuf;
else if (icon_info->scale == 1.0)
icon_info->pixbuf = source_pixbuf;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]