diff options
author | Victor Kareh <[email protected]> | 2019-07-05 12:55:05 -0400 |
---|---|---|
committer | raveit65 <[email protected]> | 2019-07-10 16:31:02 +0200 |
commit | c54687e7d0f841c0bbcca7ce4fc808fd1739366d (patch) | |
tree | 3138fe5b315516977e4458be8f03572dd5ab152b | |
parent | cd688d3ea7935a03a7b8694d24f3e04e0606d610 (diff) | |
download | caja-c54687e7d0f841c0bbcca7ce4fc808fd1739366d.tar.bz2 caja-c54687e7d0f841c0bbcca7ce4fc808fd1739366d.tar.xz |
Render file-conflict icons as cairo_surface vectors
-rw-r--r-- | libcaja-private/caja-file-conflict-dialog.c | 62 | ||||
-rw-r--r-- | libcaja-private/caja-file.c | 21 | ||||
-rw-r--r-- | libcaja-private/caja-file.h | 27 |
3 files changed, 68 insertions, 42 deletions
diff --git a/libcaja-private/caja-file-conflict-dialog.c b/libcaja-private/caja-file-conflict-dialog.c index 86cab0ca..4a671014 100644 --- a/libcaja-private/caja-file-conflict-dialog.c +++ b/libcaja-private/caja-file-conflict-dialog.c @@ -71,25 +71,25 @@ static void file_icons_changed (CajaFile *file, CajaFileConflictDialog *fcd) { - GdkPixbuf *pixbuf; + cairo_surface_t *surface; - pixbuf = caja_file_get_icon_pixbuf (fcd->details->destination, - CAJA_ICON_SIZE_LARGE, - TRUE, - 1, /*Don't double-scale icons*/ - CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS); + surface = caja_file_get_icon_surface (fcd->details->destination, + CAJA_ICON_SIZE_LARGE, + FALSE, + gtk_widget_get_scale_factor (fcd->details->dest_image), + CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS); - gtk_image_set_from_pixbuf (GTK_IMAGE (fcd->details->dest_image), pixbuf); - g_object_unref (pixbuf); + gtk_image_set_from_surface (GTK_IMAGE (fcd->details->dest_image), surface); + cairo_surface_destroy (surface); - pixbuf = caja_file_get_icon_pixbuf (fcd->details->source, - CAJA_ICON_SIZE_LARGE, - TRUE, - 1, /*Don't double-scale icons*/ - CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS); + surface = caja_file_get_icon_surface (fcd->details->source, + CAJA_ICON_SIZE_LARGE, + FALSE, + gtk_widget_get_scale_factor (fcd->details->src_image), + CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS); - gtk_image_set_from_pixbuf (GTK_IMAGE (fcd->details->src_image), pixbuf); - g_object_unref (pixbuf); + gtk_image_set_from_surface (GTK_IMAGE (fcd->details->src_image), surface); + cairo_surface_destroy (surface); } static void @@ -106,7 +106,7 @@ file_list_ready_cb (GList *files, char *dest_name, *dest_dir_name, *edit_name; char *label_text; char *size, *date, *type = NULL; - GdkPixbuf *pixbuf; + cairo_surface_t *surface; GtkWidget *label; GString *str; PangoAttrList *attr_list; @@ -234,27 +234,27 @@ file_list_ready_cb (GList *files, g_free (secondary_text); /* Set up file icons */ - pixbuf = caja_file_get_icon_pixbuf (dest, - CAJA_ICON_SIZE_LARGE, - TRUE, - 1, /*Don't double-scale icons*/ - CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS); - details->dest_image = gtk_image_new_from_pixbuf (pixbuf); + surface = caja_file_get_icon_surface (dest, + CAJA_ICON_SIZE_LARGE, + TRUE, + gtk_widget_get_scale_factor (fcd->details->titles_vbox), + CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS); + details->dest_image = gtk_image_new_from_surface (surface); gtk_box_pack_start (GTK_BOX (details->first_hbox), details->dest_image, FALSE, FALSE, 0); gtk_widget_show (details->dest_image); - g_object_unref (pixbuf); - - pixbuf = caja_file_get_icon_pixbuf (src, - CAJA_ICON_SIZE_LARGE, - TRUE, - 1, /*Don't double-scale icons*/ - CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS); - details->src_image = gtk_image_new_from_pixbuf (pixbuf); + cairo_surface_destroy (surface); + + surface = caja_file_get_icon_surface (src, + CAJA_ICON_SIZE_LARGE, + TRUE, + gtk_widget_get_scale_factor (fcd->details->titles_vbox), + CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS); + details->src_image = gtk_image_new_from_surface (surface); gtk_box_pack_start (GTK_BOX (details->second_hbox), details->src_image, FALSE, FALSE, 0); gtk_widget_show (details->src_image); - g_object_unref (pixbuf); + cairo_surface_destroy (surface); /* Set up labels */ label = gtk_label_new (NULL); diff --git a/libcaja-private/caja-file.c b/libcaja-private/caja-file.c index a1d82d3e..4e29ab36 100644 --- a/libcaja-private/caja-file.c +++ b/libcaja-private/caja-file.c @@ -4659,6 +4659,27 @@ caja_file_get_icon_pixbuf (CajaFile *file, return pixbuf; } +cairo_surface_t * +caja_file_get_icon_surface (CajaFile *file, + int size, + gboolean force_size, + int scale, + CajaFileIconFlags flags) +{ + CajaIconInfo *info; + cairo_surface_t *surface; + + info = caja_file_get_icon (file, size, scale, flags); + if (force_size) { + surface = caja_icon_info_get_surface_at_size (info, size); + } else { + surface = caja_icon_info_get_surface (info); + } + g_object_unref (info); + + return surface; +} + char * caja_file_get_custom_icon (CajaFile *file) { diff --git a/libcaja-private/caja-file.h b/libcaja-private/caja-file.h index 4c24b15a..f279cbe6 100644 --- a/libcaja-private/caja-file.h +++ b/libcaja-private/caja-file.h @@ -459,17 +459,22 @@ char * caja_file_get_drop_target_uri (CajaFile char * caja_file_get_custom_icon (CajaFile *file); -GIcon * caja_file_get_gicon (CajaFile *file, - CajaFileIconFlags flags); -CajaIconInfo * caja_file_get_icon (CajaFile *file, - int size, - int scale, - CajaFileIconFlags flags); -GdkPixbuf * caja_file_get_icon_pixbuf (CajaFile *file, - int size, - gboolean force_size, - int scale, - CajaFileIconFlags flags); +GIcon *caja_file_get_gicon (CajaFile *file, + CajaFileIconFlags flags); +CajaIconInfo *caja_file_get_icon (CajaFile *file, + int size, + int scale, + CajaFileIconFlags flags); +GdkPixbuf *caja_file_get_icon_pixbuf (CajaFile *file, + int size, + gboolean force_size, + int scale, + CajaFileIconFlags flags); +cairo_surface_t *caja_file_get_icon_surface (CajaFile *file, + int size, + gboolean force_size, + int scale, + CajaFileIconFlags flags); gboolean caja_file_has_open_window (CajaFile *file); void caja_file_set_has_open_window (CajaFile *file, |