Skip to content

Commit c0d60fc

Browse files
cosimoclukefromdc
authored andcommitted
properties-window: support HiDpi for the properties window icon
This was missing from the last commit. origin commit: https://gitlab.gnome.org/GNOME/nautilus/commit/3a6053f1
1 parent bc1405c commit c0d60fc

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/file-manager/fm-properties-window.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,12 @@ get_image_for_properties_window (FMPropertiesWindow *window,
410410

411411

412412
static void
413-
update_properties_window_icon (GtkImage *image)
413+
update_properties_window_icon (FMPropertiesWindow *window)
414414
{
415-
FMPropertiesWindow *window;
416415
GdkPixbuf *pixbuf;
416+
cairo_surface_t *surface;
417417
char *name;
418418

419-
window = g_object_get_data (G_OBJECT (image), "properties_window");
420-
421419
get_image_for_properties_window (window, &name, &pixbuf);
422420

423421
if (name != NULL) {
@@ -426,10 +424,13 @@ update_properties_window_icon (GtkImage *image)
426424
gtk_window_set_icon (GTK_WINDOW (window), pixbuf);
427425
}
428426

429-
gtk_image_set_from_pixbuf (image, pixbuf);
427+
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, gtk_widget_get_scale_factor (GTK_WIDGET (window)),
428+
gtk_widget_get_window (GTK_WIDGET (window)));
429+
gtk_image_set_from_surface (GTK_IMAGE (window->details->icon_image), surface);
430430

431431
g_free (name);
432432
g_object_unref (pixbuf);
433+
cairo_surface_destroy (surface);
433434
}
434435

435436
/* utility to test if a uri refers to a local image */
@@ -535,11 +536,11 @@ create_image_widget (FMPropertiesWindow *window,
535536
{
536537
GtkWidget *button;
537538
GtkWidget *image;
538-
GdkPixbuf *pixbuf;
539-
540-
get_image_for_properties_window (window, NULL, &pixbuf);
541539

542540
image = gtk_image_new ();
541+
window->details->icon_image = image;
542+
543+
update_properties_window_icon (window);
543544
gtk_widget_show (image);
544545

545546
button = NULL;
@@ -559,13 +560,6 @@ create_image_widget (FMPropertiesWindow *window,
559560
G_CALLBACK (select_image_button_callback), window);
560561
}
561562

562-
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
563-
564-
g_object_unref (pixbuf);
565-
566-
g_object_set_data (G_OBJECT (image), "properties_window", window);
567-
568-
window->details->icon_image = image;
569563
window->details->icon_button = button;
570564

571565
return button != NULL ? button : image;
@@ -1163,8 +1157,7 @@ properties_window_update (FMPropertiesWindow *window,
11631157

11641158
if (dirty_original) {
11651159
update_properties_window_title (window);
1166-
update_properties_window_icon (GTK_IMAGE (window->details->icon_image));
1167-
1160+
update_properties_window_icon (window);
11681161
update_name_field (window);
11691162

11701163
for (l = window->details->emblem_buttons; l != NULL; l = l->next) {

0 commit comments

Comments
 (0)