[nautilus] properties-window: support HiDpi for the properties window icon



commit 3a6053f1d753300f4adc3e0cffc4c6e7d0ddb52f
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sun Aug 4 02:41:54 2013 +0200

    properties-window: support HiDpi for the properties window icon
    
    This was missing from the last commit.

 src/nautilus-properties-window.c |   27 ++++++++++-----------------
 1 files changed, 10 insertions(+), 17 deletions(-)
---
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 7b56981..ece349d 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -411,14 +411,12 @@ get_image_for_properties_window (NautilusPropertiesWindow *window,
 
 
 static void
-update_properties_window_icon (GtkImage *image)
+update_properties_window_icon (NautilusPropertiesWindow *window)
 {
-       NautilusPropertiesWindow *window;
        GdkPixbuf *pixbuf;
+       cairo_surface_t *surface;
        char *name;
 
-       window = g_object_get_data (G_OBJECT (image), "properties_window");
-       
        get_image_for_properties_window (window, &name, &pixbuf);
 
        if (name != NULL) {
@@ -427,10 +425,13 @@ update_properties_window_icon (GtkImage *image)
                gtk_window_set_icon (GTK_WINDOW (window), pixbuf);
        }
 
-       gtk_image_set_from_pixbuf (image, pixbuf);
+       surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, gtk_widget_get_scale_factor (GTK_WIDGET 
(window)),
+                                                       gtk_widget_get_window (GTK_WIDGET (window)));
+       gtk_image_set_from_surface (GTK_IMAGE (window->details->icon_image), surface);
 
        g_free (name);
        g_object_unref (pixbuf);
+       cairo_surface_destroy (surface);
 }
 
 /* utility to test if a uri refers to a local image */
@@ -530,11 +531,11 @@ create_image_widget (NautilusPropertiesWindow *window,
 {
        GtkWidget *button;
        GtkWidget *image;
-       GdkPixbuf *pixbuf;
        
-       get_image_for_properties_window (window, NULL, &pixbuf);
-
        image = gtk_image_new ();
+       window->details->icon_image = image;
+
+       update_properties_window_icon (window);
        gtk_widget_show (image);
 
        button = NULL;
@@ -554,13 +555,6 @@ create_image_widget (NautilusPropertiesWindow *window,
                                  G_CALLBACK (select_image_button_callback), window);
        }
 
-       gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
-
-       g_object_unref (pixbuf);
-
-       g_object_set_data (G_OBJECT (image), "properties_window", window);
-
-       window->details->icon_image = image;
        window->details->icon_button = button;
 
        return button != NULL ? button : image;
@@ -1061,8 +1055,7 @@ properties_window_update (NautilusPropertiesWindow *window,
 
        if (dirty_original) {
                update_properties_window_title (window);
-               update_properties_window_icon (GTK_IMAGE (window->details->icon_image));
-
+               update_properties_window_icon (window);
                update_name_field (window);
 
                /* If any of the value fields start to depend on the original


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