[gtk+/spinner: 9/10] GtkIconTheme: Load symbolic icons at the same size



commit 2e87020704b9221109dff8ea079e116d2cae6db8
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jun 20 15:47:00 2014 -0400

    GtkIconTheme: Load symbolic icons at the same size
    
    Reuse the scale information that we have from loading icons
    normally, when loading a symbolic icon, so that we apply the
    same size constraints.

 gtk/gtkicontheme.c |   28 ++++++++--------------------
 1 files changed, 8 insertions(+), 20 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 1ea892e..f64f13a 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -4171,7 +4171,8 @@ gtk_icon_info_load_symbolic_internal (GtkIconInfo    *icon_info,
     }
 
   /* css_fg can't possibly have failed, otherwise
-   * that would mean we have a broken style */
+   * that would mean we have a broken style
+   */
   g_return_val_if_fail (fg != NULL, NULL);
 
   css_fg = gdk_rgba_to_string (fg);
@@ -4196,24 +4197,11 @@ gtk_icon_info_load_symbolic_internal (GtkIconInfo    *icon_info,
   if (!g_file_load_contents (icon_info->icon_file, NULL, &file_data, &file_len, NULL, error))
     return NULL;
 
-  if (!icon_info->symbolic_pixbuf_size)
-    {
-      /* Fetch size from the original icon */
-      stream = g_memory_input_stream_new_from_data (file_data, file_len, NULL);
-      pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, error);
-      g_object_unref (stream);
-
-      if (!pixbuf)
-        return NULL;
-
-      icon_info->symbolic_pixbuf_size = gtk_requisition_new ();
-      icon_info->symbolic_pixbuf_size->width = gdk_pixbuf_get_width (pixbuf);
-      icon_info->symbolic_pixbuf_size->height = gdk_pixbuf_get_height (pixbuf);
-      g_object_unref (pixbuf);
-    }
+  if (!icon_info_ensure_scale_and_pixbuf (icon_info, FALSE))
+    return NULL;
 
-  width = g_strdup_printf ("%d", icon_info->symbolic_pixbuf_size->width);
-  height = g_strdup_printf ("%d", icon_info->symbolic_pixbuf_size->height);
+  width = g_strdup_printf ("%d", gdk_pixbuf_get_width (icon_info->pixbuf));
+  height = g_strdup_printf ("%d", gdk_pixbuf_get_height (icon_info->pixbuf));
 
   escaped_file_data = g_markup_escape_text (file_data, file_len);
   g_free (file_data);
@@ -4251,8 +4239,8 @@ gtk_icon_info_load_symbolic_internal (GtkIconInfo    *icon_info,
 
   stream = g_memory_input_stream_new_from_data (data, -1, g_free);
   pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream,
-                                                icon_info->desired_size * icon_info->desired_scale,
-                                                icon_info->desired_size * icon_info->desired_scale,
+                                                gdk_pixbuf_get_width (icon_info->pixbuf),
+                                                gdk_pixbuf_get_height (icon_info->pixbuf),
                                                 TRUE,
                                                 NULL,
                                                 error);


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