Commit eac7dce1 authored by Alexander Larsson's avatar Alexander Larsson

File chooser: Convert icons to using cairo_surface_t

parent b6b24148
......@@ -1321,7 +1321,7 @@ change_icon_theme_get_info_cb (GCancellable *cancellable,
gpointer user_data)
{
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
struct ChangeIconThemeData *data = user_data;
if (!g_slist_find (data->button->priv->change_icon_theme_cancellables, cancellable))
......@@ -1333,15 +1333,15 @@ change_icon_theme_get_info_cb (GCancellable *cancellable,
if (cancelled || error)
goto out;
pixbuf = _gtk_file_info_render_icon (info, GTK_WIDGET (data->button), data->button->priv->icon_size);
surface = _gtk_file_info_render_icon (info, GTK_WIDGET (data->button), data->button->priv->icon_size);
if (pixbuf)
if (surface)
{
gint width = 0;
GtkTreeIter iter;
GtkTreePath *path;
width = MAX (width, gdk_pixbuf_get_width (pixbuf));
width = MAX (width, data->button->priv->icon_size);
path = gtk_tree_row_reference_get_path (data->row_ref);
if (path)
......@@ -1350,14 +1350,14 @@ change_icon_theme_get_info_cb (GCancellable *cancellable,
gtk_tree_path_free (path);
gtk_list_store_set (GTK_LIST_STORE (data->button->priv->model), &iter,
ICON_COLUMN, pixbuf,
ICON_COLUMN, surface,
-1);
g_object_set (data->button->priv->icon_cell,
"width", width,
NULL);
}
g_object_unref (pixbuf);
cairo_surface_destroy (surface);
}
out:
......@@ -1398,7 +1398,7 @@ change_icon_theme (GtkFileChooserButton *button)
do
{
GdkPixbuf *pixbuf = NULL;
cairo_surface_t *surface = NULL;
gchar type;
gpointer data;
......@@ -1435,39 +1435,47 @@ change_icon_theme (GtkFileChooserButton *button)
info);
button->priv->change_icon_theme_cancellables =
g_slist_append (button->priv->change_icon_theme_cancellables, cancellable);
pixbuf = NULL;
surface = NULL;
}
else
/* Don't call get_info for remote paths to avoid latency and
* auth dialogs.
* If we switch to a better bookmarks file format (XBEL), we
* should use mime info to get a better icon.
*/
pixbuf = gtk_icon_theme_load_icon (theme, "folder-remote",
priv->icon_size, 0, NULL);
{
/* Don't call get_info for remote paths to avoid latency and
* auth dialogs.
* If we switch to a better bookmarks file format (XBEL), we
* should use mime info to get a better icon.
*/
surface = gtk_icon_theme_load_surface (theme, "folder-remote",
priv->icon_size,
gtk_widget_get_scale_factor (GTK_WIDGET (button)),
gtk_widget_get_window (GTK_WIDGET (button)),
0, NULL);
}
}
break;
case ROW_TYPE_VOLUME:
if (data)
pixbuf = _gtk_file_system_volume_render_icon (data,
GTK_WIDGET (button),
priv->icon_size,
NULL);
{
surface = _gtk_file_system_volume_render_icon (data,
GTK_WIDGET (button),
priv->icon_size,
NULL);
}
break;
default:
continue;
break;
}
if (pixbuf)
width = MAX (width, gdk_pixbuf_get_width (pixbuf));
if (surface)
width = MAX (width, priv->icon_size);
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
ICON_COLUMN, pixbuf,
ICON_COLUMN, surface,
-1);
if (pixbuf)
g_object_unref (pixbuf);
if (surface)
cairo_surface_destroy (surface);
}
while (gtk_tree_model_iter_next (priv->model, &iter));
......@@ -1526,7 +1534,7 @@ set_info_get_info_cb (GCancellable *cancellable,
gpointer callback_data)
{
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
GtkTreePath *path;
GtkTreeIter iter;
GCancellable *model_cancellable = NULL;
......@@ -1560,7 +1568,7 @@ set_info_get_info_cb (GCancellable *cancellable,
/* There was an error, leave the fallback name in there */
goto out;
pixbuf = _gtk_file_info_render_icon (info, GTK_WIDGET (data->button), data->button->priv->icon_size);
surface = _gtk_file_info_render_icon (info, GTK_WIDGET (data->button), data->button->priv->icon_size);
if (!data->label)
data->label = g_strdup (g_file_info_get_display_name (info));
......@@ -1568,13 +1576,13 @@ set_info_get_info_cb (GCancellable *cancellable,
is_folder = _gtk_file_info_consider_as_directory (info);
gtk_list_store_set (GTK_LIST_STORE (data->button->priv->model), &iter,
ICON_COLUMN, pixbuf,
ICON_COLUMN, surface,
DISPLAY_NAME_COLUMN, data->label,
IS_FOLDER_COLUMN, is_folder,
-1);
if (pixbuf)
g_object_unref (pixbuf);
if (surface)
cairo_surface_destroy (surface);
out:
g_object_unref (data->button);
......@@ -1716,7 +1724,7 @@ model_add_special_get_info_cb (GCancellable *cancellable,
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
GtkTreeIter iter;
GtkTreePath *path;
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
GCancellable *model_cancellable = NULL;
struct ChangeIconThemeData *data = user_data;
gchar *name;
......@@ -1746,14 +1754,13 @@ model_add_special_get_info_cb (GCancellable *cancellable,
if (cancelled || error)
goto out;
pixbuf = _gtk_file_info_render_icon (info, GTK_WIDGET (data->button), data->button->priv->icon_size);
if (pixbuf)
surface = _gtk_file_info_render_icon (info, GTK_WIDGET (data->button), data->button->priv->icon_size);
if (surface)
{
gtk_list_store_set (GTK_LIST_STORE (data->button->priv->model), &iter,
ICON_COLUMN, pixbuf,
ICON_COLUMN, surface,
-1);
g_object_unref (pixbuf);
cairo_surface_destroy (surface);
}
gtk_tree_model_get (data->button->priv->model, &iter,
......@@ -1881,7 +1888,7 @@ model_add_volumes (GtkFileChooserButton *button,
{
GtkFileSystemVolume *volume;
GtkTreeIter iter;
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
gchar *display_name;
volume = l->data;
......@@ -1906,23 +1913,23 @@ model_add_volumes (GtkFileChooserButton *button,
}
}
pixbuf = _gtk_file_system_volume_render_icon (volume,
GTK_WIDGET (button),
button->priv->icon_size,
NULL);
surface = _gtk_file_system_volume_render_icon (volume,
GTK_WIDGET (button),
button->priv->icon_size,
NULL);
display_name = _gtk_file_system_volume_get_display_name (volume);
gtk_list_store_insert (store, &iter, pos);
gtk_list_store_set (store, &iter,
ICON_COLUMN, pixbuf,
ICON_COLUMN, surface,
DISPLAY_NAME_COLUMN, display_name,
TYPE_COLUMN, ROW_TYPE_VOLUME,
DATA_COLUMN, _gtk_file_system_volume_ref (volume),
IS_FOLDER_COLUMN, TRUE,
-1);
if (pixbuf)
g_object_unref (pixbuf);
if (surface)
cairo_surface_destroy (surface);
g_free (display_name);
button->priv->n_volumes++;
......@@ -1971,7 +1978,7 @@ model_add_bookmarks (GtkFileChooserButton *button,
{
gchar *label;
GtkIconTheme *icon_theme;
GdkPixbuf *pixbuf;
cairo_surface_t *surface = NULL;
if (local_only)
continue;
......@@ -1986,12 +1993,15 @@ model_add_bookmarks (GtkFileChooserButton *button,
label = _gtk_file_chooser_label_for_file (file);
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (button)));
pixbuf = gtk_icon_theme_load_icon (icon_theme, "folder-remote",
button->priv->icon_size, 0, NULL);
surface = gtk_icon_theme_load_surface (icon_theme, "folder-remote",
button->priv->icon_size,
gtk_widget_get_scale_factor (GTK_WIDGET (button)),
gtk_widget_get_window (GTK_WIDGET (button)),
0, NULL);
gtk_list_store_insert (store, &iter, pos);
gtk_list_store_set (store, &iter,
ICON_COLUMN, pixbuf,
ICON_COLUMN, surface,
DISPLAY_NAME_COLUMN, label,
TYPE_COLUMN, ROW_TYPE_BOOKMARK,
DATA_COLUMN, g_object_ref (file),
......@@ -1999,7 +2009,8 @@ model_add_bookmarks (GtkFileChooserButton *button,
-1);
g_free (label);
g_object_unref (pixbuf);
if (surface)
cairo_surface_destroy (surface);
}
button->priv->n_bookmarks++;
......@@ -2077,7 +2088,7 @@ model_update_current_folder (GtkFileChooserButton *button,
{
gchar *label;
GtkIconTheme *icon_theme;
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
/* Don't call get_info for remote paths to avoid latency and
* auth dialogs.
......@@ -2091,14 +2102,20 @@ model_update_current_folder (GtkFileChooserButton *button,
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (button)));
if (g_file_is_native (file))
pixbuf = gtk_icon_theme_load_icon (icon_theme, "folder",
button->priv->icon_size, 0, NULL);
surface = gtk_icon_theme_load_surface (icon_theme, "folder",
button->priv->icon_size,
gtk_widget_get_scale_factor (GTK_WIDGET (button)),
gtk_widget_get_window (GTK_WIDGET (button)),
0, NULL);
else
pixbuf = gtk_icon_theme_load_icon (icon_theme, "folder-remote",
button->priv->icon_size, 0, NULL);
surface = gtk_icon_theme_load_surface (icon_theme, "folder-remote",
button->priv->icon_size,
gtk_widget_get_scale_factor (GTK_WIDGET (button)),
gtk_widget_get_window (GTK_WIDGET (button)),
0, NULL);
gtk_list_store_set (store, &iter,
ICON_COLUMN, pixbuf,
ICON_COLUMN, surface,
DISPLAY_NAME_COLUMN, label,
TYPE_COLUMN, ROW_TYPE_CURRENT_FOLDER,
DATA_COLUMN, g_object_ref (file),
......@@ -2106,7 +2123,8 @@ model_update_current_folder (GtkFileChooserButton *button,
-1);
g_free (label);
g_object_unref (pixbuf);
if (surface)
cairo_surface_destroy (surface);
}
}
......@@ -2442,7 +2460,7 @@ update_label_get_info_cb (GCancellable *cancellable,
gpointer data)
{
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
GtkFileChooserButton *button = data;
GtkFileChooserButtonPrivate *priv = button->priv;
......@@ -2456,11 +2474,10 @@ update_label_get_info_cb (GCancellable *cancellable,
gtk_label_set_text (GTK_LABEL (priv->label), g_file_info_get_display_name (info));
pixbuf = _gtk_file_info_render_icon (info, GTK_WIDGET (priv->image), priv->icon_size);
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), pixbuf);
if (pixbuf)
g_object_unref (pixbuf);
surface = _gtk_file_info_render_icon (info, GTK_WIDGET (priv->image), priv->icon_size);
gtk_image_set_from_surface (GTK_IMAGE (priv->image), surface);
if (surface)
cairo_surface_destroy (surface);
out:
emit_selection_changed_if_changing_selection (button);
......@@ -2500,16 +2517,16 @@ update_label_and_image (GtkFileChooserButton *button)
base_file = _gtk_file_system_volume_get_root (volume);
if (base_file && g_file_equal (base_file, file))
{
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
label_text = _gtk_file_system_volume_get_display_name (volume);
pixbuf = _gtk_file_system_volume_render_icon (volume,
GTK_WIDGET (button),
priv->icon_size,
NULL);
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), pixbuf);
if (pixbuf)
g_object_unref (pixbuf);
surface = _gtk_file_system_volume_render_icon (volume,
GTK_WIDGET (button),
priv->icon_size,
NULL);
gtk_image_set_from_surface (GTK_IMAGE (priv->image), surface);
if (surface)
cairo_surface_destroy (surface);
}
if (base_file)
......@@ -2534,15 +2551,18 @@ update_label_and_image (GtkFileChooserButton *button)
}
else
{
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
label_text = _gtk_bookmarks_manager_get_bookmark_label (button->priv->bookmarks_manager, file);
pixbuf = gtk_icon_theme_load_icon (get_icon_theme (GTK_WIDGET (priv->image)),
"text-x-generic",
priv->icon_size, 0, NULL);
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), pixbuf);
if (pixbuf)
g_object_unref (pixbuf);
surface = gtk_icon_theme_load_surface (get_icon_theme (GTK_WIDGET (priv->image)),
"text-x-generic",
priv->icon_size,
gtk_widget_get_scale_factor (GTK_WIDGET (button)),
gtk_widget_get_window (GTK_WIDGET (button)),
0, NULL);
gtk_image_set_from_surface (GTK_IMAGE (priv->image), surface);
if (surface)
cairo_surface_destroy (surface);
done_changing_selection = TRUE;
}
......@@ -2566,7 +2586,7 @@ out:
else
{
gtk_label_set_text (GTK_LABEL (priv->label), _(FALLBACK_DISPLAY_NAME));
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->image), NULL);
gtk_image_set_from_surface (GTK_IMAGE (priv->image), NULL);
}
if (done_changing_selection)
......
......@@ -84,7 +84,7 @@
<child>
<object class="GtkCellRendererPixbuf" id="icon_cell"/>
<attributes>
<attribute name="pixbuf">0</attribute>
<attribute name="surface">0</attribute>
</attributes>
</child>
<child>
......@@ -104,7 +104,7 @@
<object class="GtkListStore" id="model">
<columns>
<!-- column-name icon -->
<column type="GdkPixbuf"/>
<column type="CairoSurface"/>
<!-- column-name display-name -->
<column type="gchararray"/>
<!-- column-name type -->
......
......@@ -76,6 +76,7 @@
#include "gtkorientable.h"
#include "gtkintl.h"
#include <cairo-gobject.h>
#include <errno.h>
#include <string.h>
#include <time.h>
......@@ -364,7 +365,7 @@ enum {
MODEL_COL_NAME_COLLATED,
MODEL_COL_IS_FOLDER,
MODEL_COL_IS_SENSITIVE,
MODEL_COL_PIXBUF,
MODEL_COL_SURFACE,
MODEL_COL_SIZE_TEXT,
MODEL_COL_MTIME_TEXT,
MODEL_COL_ELLIPSIZE,
......@@ -381,7 +382,7 @@ enum {
G_TYPE_STRING, /* MODEL_COL_NAME_COLLATED */ \
G_TYPE_BOOLEAN, /* MODEL_COL_IS_FOLDER */ \
G_TYPE_BOOLEAN, /* MODEL_COL_IS_SENSITIVE */ \
GDK_TYPE_PIXBUF, /* MODEL_COL_PIXBUF */ \
CAIRO_GOBJECT_TYPE_SURFACE, /* MODEL_COL_SURFACE */ \
G_TYPE_STRING, /* MODEL_COL_SIZE_TEXT */ \
G_TYPE_STRING, /* MODEL_COL_MTIME_TEXT */ \
PANGO_TYPE_ELLIPSIZE_MODE /* MODEL_COL_ELLIPSIZE */
......@@ -3132,7 +3133,7 @@ change_icon_theme (GtkFileChooserDefault *impl)
set_icon_cell_renderer_fixed_size (impl);
if (priv->browse_files_model)
_gtk_file_system_model_clear_cache (priv->browse_files_model, MODEL_COL_PIXBUF);
_gtk_file_system_model_clear_cache (priv->browse_files_model, MODEL_COL_SURFACE);
gtk_widget_queue_resize (priv->browse_files_tree_view);
profile_end ("end", NULL);
......@@ -4152,12 +4153,12 @@ file_system_model_set (GtkFileSystemModel *model,
else
g_value_set_boolean (value, TRUE);
break;
case MODEL_COL_PIXBUF:
case MODEL_COL_SURFACE:
if (info)
{
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_ICON))
{
g_value_take_object (value, _gtk_file_info_render_icon (info, GTK_WIDGET (impl), priv->icon_size));
g_value_take_boxed (value, _gtk_file_info_render_icon (info, GTK_WIDGET (impl), priv->icon_size));
}
else
{
......@@ -7069,7 +7070,7 @@ update_cell_renderer_attributes (GtkFileChooserDefault *impl)
if (GTK_IS_CELL_RENDERER_PIXBUF (renderer))
{
gtk_tree_view_column_set_attributes (column, renderer,
"pixbuf", MODEL_COL_PIXBUF,
"surface", MODEL_COL_SURFACE,
NULL);
}
else
......
......@@ -709,42 +709,45 @@ _gtk_file_system_volume_get_root (GtkFileSystemVolume *volume)
return file;
}
static GdkPixbuf *
get_pixbuf_from_gicon (GIcon *icon,
GtkWidget *widget,
gint icon_size,
GError **error)
static cairo_surface_t *
get_surface_from_gicon (GIcon *icon,
GtkWidget *widget,
gint icon_size,
GError **error)
{
GdkScreen *screen;
GtkIconTheme *icon_theme;
GtkIconInfo *icon_info;
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
screen = gtk_widget_get_screen (GTK_WIDGET (widget));
icon_theme = gtk_icon_theme_get_for_screen (screen);
icon_info = gtk_icon_theme_lookup_by_gicon (icon_theme,
icon,
icon_size,
GTK_ICON_LOOKUP_USE_BUILTIN);
icon_info = gtk_icon_theme_lookup_by_gicon_for_scale (icon_theme,
icon,
icon_size,
gtk_widget_get_scale_factor (widget),
GTK_ICON_LOOKUP_USE_BUILTIN);
if (!icon_info)
return NULL;
pixbuf = gtk_icon_info_load_icon (icon_info, error);
surface = gtk_icon_info_load_surface (icon_info,
gtk_widget_get_window (widget), error);
g_object_unref (icon_info);
return pixbuf;
return surface;
}
GdkPixbuf *
cairo_surface_t *
_gtk_file_system_volume_render_icon (GtkFileSystemVolume *volume,
GtkWidget *widget,
gint icon_size,
GError **error)
{
GIcon *icon = NULL;
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
DEBUG ("volume_get_icon_name");
......@@ -760,11 +763,11 @@ _gtk_file_system_volume_render_icon (GtkFileSystemVolume *volume,
if (!icon)
return NULL;
pixbuf = get_pixbuf_from_gicon (icon, widget, icon_size, error);
surface = get_surface_from_gicon (icon, widget, icon_size, error);
g_object_unref (icon);
return pixbuf;
return surface;
}
GtkFileSystemVolume *
......@@ -795,39 +798,48 @@ _gtk_file_system_volume_unref (GtkFileSystemVolume *volume)
}
/* GFileInfo helper functions */
GdkPixbuf *
cairo_surface_t *
_gtk_file_info_render_icon (GFileInfo *info,
GtkWidget *widget,
gint icon_size)
GtkWidget *widget,
gint icon_size)
{
GIcon *icon;
GdkPixbuf *pixbuf = NULL;
GdkPixbuf *pixbuf;
const gchar *thumbnail_path;
cairo_surface_t *surface = NULL;
int scale;
thumbnail_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
if (thumbnail_path)
pixbuf = gdk_pixbuf_new_from_file_at_size (thumbnail_path,
icon_size, icon_size,
NULL);
{
scale = gtk_widget_get_scale_factor (widget);
pixbuf = gdk_pixbuf_new_from_file_at_size (thumbnail_path,
icon_size*scale, icon_size*scale,
NULL);
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale,
gtk_widget_get_window (widget));
g_object_unref (pixbuf);
}
if (!pixbuf)
if (!surface)
{
icon = g_file_info_get_icon (info);
if (icon)
pixbuf = get_pixbuf_from_gicon (icon, widget, icon_size, NULL);
surface = get_surface_from_gicon (icon, widget, icon_size, NULL);
if (!pixbuf)
if (!surface)
{
/* Use general fallback for all files without icon */
icon = g_themed_icon_new ("text-x-generic");
pixbuf = get_pixbuf_from_gicon (icon, widget, icon_size, NULL);
surface = get_surface_from_gicon (icon, widget, icon_size, NULL);
g_object_unref (icon);
}
}
return pixbuf;
return surface;
}
gboolean
......
......@@ -93,7 +93,7 @@ GtkFileSystemVolume * _gtk_file_system_get_volume_for_file (GtkFileSystem
gchar * _gtk_file_system_volume_get_display_name (GtkFileSystemVolume *volume);
gboolean _gtk_file_system_volume_is_mounted (GtkFileSystemVolume *volume);
GFile * _gtk_file_system_volume_get_root (GtkFileSystemVolume *volume);
GdkPixbuf * _gtk_file_system_volume_render_icon (GtkFileSystemVolume *volume,
cairo_surface_t * _gtk_file_system_volume_render_icon (GtkFileSystemVolume *volume,
GtkWidget *widget,
gint icon_size,
GError **error);
......@@ -102,9 +102,9 @@ GtkFileSystemVolume *_gtk_file_system_volume_ref (GtkFileSystemVol
void _gtk_file_system_volume_unref (GtkFileSystemVolume *volume);
/* GFileInfo helper functions */
GdkPixbuf * _gtk_file_info_render_icon (GFileInfo *info,
GtkWidget *widget,
gint icon_size);
cairo_surface_t * _gtk_file_info_render_icon (GFileInfo *info,
GtkWidget *widget,
gint icon_size);
gboolean _gtk_file_info_consider_as_directory (GFileInfo *info);
......
......@@ -46,9 +46,9 @@ struct _GtkPathBarPrivate
GCancellable *get_info_cancellable;
GdkPixbuf *root_icon;
GdkPixbuf *home_icon;
GdkPixbuf *desktop_icon;
cairo_surface_t *root_icon;
cairo_surface_t *home_icon;
cairo_surface_t *desktop_icon;
GdkWindow *event_window;
......@@ -293,11 +293,11 @@ gtk_path_bar_finalize (GObject *object)
g_object_unref (path_bar->priv->desktop_file);
if (path_bar->priv->root_icon)
g_object_unref (path_bar->priv->root_icon);
cairo_surface_destroy (path_bar->priv->root_icon);
if (path_bar->priv->home_icon)
g_object_unref (path_bar->priv->home_icon);
cairo_surface_destroy (path_bar->priv->home_icon);
if (path_bar->priv->desktop_icon)
g_object_unref (path_bar->priv->desktop_icon);
cairo_surface_destroy (path_bar->priv->desktop_icon);
if (path_bar->priv->file_system)
g_object_unref (path_bar->priv->file_system);
......@@ -1238,17 +1238,17 @@ reload_icons (GtkPathBar *path_bar)
if (path_bar->priv->root_icon)
{
g_object_unref (path_bar->priv->root_icon);
cairo_surface_destroy (path_bar->priv->root_icon);
path_bar->priv->root_icon = NULL;
}
if (path_bar->priv->home_icon)
{
g_object_unref (path_bar->priv->home_icon);
cairo_surface_destroy (path_bar->priv->home_icon);
path_bar->priv->home_icon = NULL;
}
if (path_bar->priv->desktop_icon)
{
g_object_unref (path_bar->priv->desktop_icon);
cairo_surface_destroy (path_bar->priv->desktop_icon);
path_bar->priv->desktop_icon = NULL;
}
......@@ -1375,7 +1375,7 @@ set_button_image_get_info_cb (GCancellable *cancellable,
gpointer user_data)
{
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
struct SetButtonImageData *data = user_data;
if (cancellable != data->button_data->cancellable)
......@@ -1392,24 +1392,24 @@ set_button_image_get_info_cb (GCancellable *cancellable,
if (cancelled || error)
goto out;
pixbuf = _gtk_file_info_render_icon (info, GTK_WIDGET (data->path_bar),
surface = _gtk_file_info_render_icon (info, GTK_WIDGET (data->path_bar),
data->path_bar->priv->icon_size);
gtk_image_set_from_pixbuf (GTK_IMAGE (data->button_data->image), pixbuf);
gtk_image_set_from_surface (GTK_IMAGE (data->button_data->image), surface);
switch (data->button_data->type)
{
case HOME_BUTTON:
if (data->path_bar->priv->home_icon)
g_object_unref (pixbuf);
cairo_surface_destroy (surface);
else
data->path_bar->priv->home_icon = pixbuf;
data->path_bar->priv->home_icon = surface;
break;
case DESKTOP_BUTTON:
if (data->path_bar->priv->desktop_icon)
g_object_unref (pixbuf);
cairo_surface_destroy (surface);
else
data->path_bar->priv->desktop_icon = pixbuf;
data->path_bar->priv->desktop_icon = surface;
break;
default:
......@@ -1434,7 +1434,7 @@ set_button_image (GtkPathBar *path_bar,
if (path_bar->priv->root_icon != NULL)
{
gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), path_bar->priv->root_icon);
gtk_image_set_from_surface (GTK_IMAGE (button_data->image), path_bar->priv->root_icon);
break;
}
......@@ -1443,18 +1443,18 @@ set_button_image (GtkPathBar *path_bar,
return;
path_bar->priv->root_icon = _gtk_file_system_volume_render_icon (volume,
GTK_WIDGET (path_bar),
path_bar->priv->icon_size,
NULL);
GTK_WIDGET (path_bar),
path_bar->priv->icon_size,
NULL);
_gtk_file_system_volume_unref (volume);
gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), path_bar->priv->root_icon);
gtk_image_set_from_surface (GTK_IMAGE (button_data->image), path_bar->priv->root_icon);
break;
case HOME_BUTTON:
if (path_bar->priv->home_icon != NULL)
{
gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), path_bar->priv->home_icon);
gtk_image_set_from_surface (GTK_IMAGE (button_data->image), path_bar->priv->home_icon);
break;
}
......@@ -1476,7 +1476,7 @@ set_button_image (GtkPathBar *path_bar,
case DESKTOP_BUTTON:
if (path_bar->priv->desktop_icon != NULL)
{
gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), path_bar->priv->desktop_icon);
gtk_image_set_from_surface (GTK_IMAGE (button_data->image), path_bar->priv->desktop_icon);