[gtk+/wip/window-scales: 84/84] File chooser: Convert icons to using cairo_pattern_t
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/window-scales: 84/84] File chooser: Convert icons to using cairo_pattern_t
- Date: Wed, 26 Jun 2013 15:11:57 +0000 (UTC)
commit 98acbc1b36a995b00673c7f4e29fd4c45e639b5a
Author: Alexander Larsson <alexl redhat com>
Date: Wed Jun 26 16:35:38 2013 +0200
File chooser: Convert icons to using cairo_pattern_t
This means we draw faster, and automatically handle hidpi icons.
gtk/gtkfilechooserbutton.c | 157 ++++++++++++++++++++++++-------------------
gtk/gtkfilechooserbutton.ui | 4 +-
gtk/gtkfilechooserdefault.c | 13 ++--
gtk/gtkfilesystem.c | 74 +++++++++++++--------
gtk/gtkfilesystem.h | 8 +-
gtk/gtkiconhelperprivate.h | 3 +
gtk/gtkpathbar.c | 40 ++++++------
7 files changed, 169 insertions(+), 130 deletions(-)
---
diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c
index 0b726c9..02866f0 100644
--- a/gtk/gtkfilechooserbutton.c
+++ b/gtk/gtkfilechooserbutton.c
@@ -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_pattern_t *pattern;
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);
+ pattern = _gtk_file_info_render_icon (info, GTK_WIDGET (data->button), data->button->priv->icon_size);
- if (pixbuf)
+ if (pattern)
{
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, pattern,
-1);
g_object_set (data->button->priv->icon_cell,
"width", width,
NULL);
}
- g_object_unref (pixbuf);
+ cairo_pattern_destroy (pattern);
}
out:
@@ -1402,7 +1402,7 @@ change_icon_theme (GtkFileChooserButton *button)
do
{
- GdkPixbuf *pixbuf = NULL;
+ cairo_pattern_t *pattern = NULL;
gchar type;
gpointer data;
@@ -1439,7 +1439,7 @@ change_icon_theme (GtkFileChooserButton *button)
info);
button->priv->change_icon_theme_cancellables =
g_slist_append (button->priv->change_icon_theme_cancellables, cancellable);
- pixbuf = NULL;
+ pattern = NULL;
}
else
/* Don't call get_info for remote paths to avoid latency and
@@ -1447,31 +1447,34 @@ change_icon_theme (GtkFileChooserButton *button)
* 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);
+ pattern = gtk_icon_theme_load_pattern (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);
+ pattern = _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 (pattern)
+ width = MAX (width, priv->icon_size);
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
- ICON_COLUMN, pixbuf,
+ ICON_COLUMN, pattern,
-1);
- if (pixbuf)
- g_object_unref (pixbuf);
+ if (pattern)
+ cairo_pattern_destroy (pattern);
}
while (gtk_tree_model_iter_next (priv->model, &iter));
@@ -1530,7 +1533,7 @@ set_info_get_info_cb (GCancellable *cancellable,
gpointer callback_data)
{
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
- GdkPixbuf *pixbuf;
+ cairo_pattern_t *pattern;
GtkTreePath *path;
GtkTreeIter iter;
GCancellable *model_cancellable = NULL;
@@ -1564,7 +1567,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);
+ pattern = _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));
@@ -1572,13 +1575,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, pattern,
DISPLAY_NAME_COLUMN, data->label,
IS_FOLDER_COLUMN, is_folder,
-1);
- if (pixbuf)
- g_object_unref (pixbuf);
+ if (pattern)
+ cairo_pattern_destroy (pattern);
out:
g_object_unref (data->button);
@@ -1720,7 +1723,7 @@ model_add_special_get_info_cb (GCancellable *cancellable,
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
GtkTreeIter iter;
GtkTreePath *path;
- GdkPixbuf *pixbuf;
+ cairo_pattern_t *pattern;
GCancellable *model_cancellable = NULL;
struct ChangeIconThemeData *data = user_data;
gchar *name;
@@ -1750,14 +1753,14 @@ 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);
+ pattern = _gtk_file_info_render_icon (info, GTK_WIDGET (data->button), data->button->priv->icon_size);
- if (pixbuf)
+ if (pattern)
{
gtk_list_store_set (GTK_LIST_STORE (data->button->priv->model), &iter,
- ICON_COLUMN, pixbuf,
+ ICON_COLUMN, pattern,
-1);
- g_object_unref (pixbuf);
+ cairo_pattern_destroy (pattern);
}
gtk_tree_model_get (data->button->priv->model, &iter,
@@ -1885,7 +1888,7 @@ model_add_volumes (GtkFileChooserButton *button,
{
GtkFileSystemVolume *volume;
GtkTreeIter iter;
- GdkPixbuf *pixbuf;
+ cairo_pattern_t *pattern;
gchar *display_name;
volume = l->data;
@@ -1910,23 +1913,23 @@ model_add_volumes (GtkFileChooserButton *button,
}
}
- pixbuf = _gtk_file_system_volume_render_icon (volume,
- GTK_WIDGET (button),
- button->priv->icon_size,
- NULL);
+ pattern = _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, pattern,
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 (pattern)
+ cairo_pattern_destroy (pattern);
g_free (display_name);
button->priv->n_volumes++;
@@ -1975,7 +1978,7 @@ model_add_bookmarks (GtkFileChooserButton *button,
{
gchar *label;
GtkIconTheme *icon_theme;
- GdkPixbuf *pixbuf;
+ cairo_pattern_t *pattern;
if (local_only)
continue;
@@ -1990,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);
+ pattern = gtk_icon_theme_load_pattern (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, pattern,
DISPLAY_NAME_COLUMN, label,
TYPE_COLUMN, ROW_TYPE_BOOKMARK,
DATA_COLUMN, g_object_ref (file),
@@ -2003,7 +2009,8 @@ model_add_bookmarks (GtkFileChooserButton *button,
-1);
g_free (label);
- g_object_unref (pixbuf);
+ if (pattern)
+ cairo_pattern_destroy (pattern);
}
button->priv->n_bookmarks++;
@@ -2081,7 +2088,7 @@ model_update_current_folder (GtkFileChooserButton *button,
{
gchar *label;
GtkIconTheme *icon_theme;
- GdkPixbuf *pixbuf;
+ cairo_pattern_t *pattern;
/* Don't call get_info for remote paths to avoid latency and
* auth dialogs.
@@ -2095,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);
+ pattern = gtk_icon_theme_load_pattern (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);
+ pattern = gtk_icon_theme_load_pattern (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, pattern,
DISPLAY_NAME_COLUMN, label,
TYPE_COLUMN, ROW_TYPE_CURRENT_FOLDER,
DATA_COLUMN, g_object_ref (file),
@@ -2110,7 +2123,8 @@ model_update_current_folder (GtkFileChooserButton *button,
-1);
g_free (label);
- g_object_unref (pixbuf);
+ if (pattern)
+ cairo_pattern_destroy (pattern);
}
}
@@ -2446,7 +2460,7 @@ update_label_get_info_cb (GCancellable *cancellable,
gpointer data)
{
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
- GdkPixbuf *pixbuf;
+ cairo_pattern_t *pattern;
GtkFileChooserButton *button = data;
GtkFileChooserButtonPrivate *priv = button->priv;
@@ -2460,11 +2474,11 @@ 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);
+ pattern = _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);
+ gtk_image_set_from_pattern (GTK_IMAGE (priv->image), pattern);
+ if (pattern)
+ cairo_pattern_destroy (pattern);
out:
emit_selection_changed_if_changing_selection (button);
@@ -2504,16 +2518,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_pattern_t *pattern;
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);
+ pattern = _gtk_file_system_volume_render_icon (volume,
+ GTK_WIDGET (button),
+ priv->icon_size,
+ NULL);
+ gtk_image_set_from_pattern (GTK_IMAGE (priv->image), pattern);
+ if (pattern)
+ cairo_pattern_destroy (pattern);
}
if (base_file)
@@ -2538,15 +2552,18 @@ update_label_and_image (GtkFileChooserButton *button)
}
else
{
- GdkPixbuf *pixbuf;
+ cairo_pattern_t *pattern;
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);
+ pattern = gtk_icon_theme_load_pattern (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_pattern (GTK_IMAGE (priv->image), pattern);
+ if (pattern)
+ cairo_pattern_destroy (pattern);
done_changing_selection = TRUE;
}
@@ -2570,7 +2587,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_pattern (GTK_IMAGE (priv->image), NULL);
}
if (done_changing_selection)
diff --git a/gtk/gtkfilechooserbutton.ui b/gtk/gtkfilechooserbutton.ui
index 342e808..03ad204 100644
--- a/gtk/gtkfilechooserbutton.ui
+++ b/gtk/gtkfilechooserbutton.ui
@@ -84,7 +84,7 @@
<child>
<object class="GtkCellRendererPixbuf" id="icon_cell"/>
<attributes>
- <attribute name="pixbuf">0</attribute>
+ <attribute name="pattern">0</attribute>
</attributes>
</child>
<child>
@@ -104,7 +104,7 @@
<object class="GtkListStore" id="model">
<columns>
<!-- column-name icon -->
- <column type="GdkPixbuf"/>
+ <column type="CairoPattern"/>
<!-- column-name display-name -->
<column type="gchararray"/>
<!-- column-name type -->
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index c9d916b..77faeaa 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -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_PATTERN,
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_PATTERN, /* MODEL_COL_PATTERN */ \
G_TYPE_STRING, /* MODEL_COL_SIZE_TEXT */ \
G_TYPE_STRING, /* MODEL_COL_MTIME_TEXT */ \
PANGO_TYPE_ELLIPSIZE_MODE /* MODEL_COL_ELLIPSIZE */
@@ -3135,7 +3136,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_PATTERN);
gtk_widget_queue_resize (priv->browse_files_tree_view);
profile_end ("end", NULL);
@@ -4156,12 +4157,12 @@ file_system_model_set (GtkFileSystemModel *model,
else
g_value_set_boolean (value, TRUE);
break;
- case MODEL_COL_PIXBUF:
+ case MODEL_COL_PATTERN:
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
{
@@ -7073,7 +7074,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,
+ "pattern", MODEL_COL_PATTERN,
NULL);
}
else
diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c
index 186992c..0af4a5c 100644
--- a/gtk/gtkfilesystem.c
+++ b/gtk/gtkfilesystem.c
@@ -709,42 +709,44 @@ _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_pattern_t *
+get_pattern_from_gicon (GIcon *icon,
+ GtkWidget *widget,
+ gint icon_size,
+ GError **error)
{
GdkScreen *screen;
GtkIconTheme *icon_theme;
GtkIconInfo *icon_info;
- GdkPixbuf *pixbuf;
+ cairo_pattern_t *pattern;
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);
+ pattern = gtk_icon_info_load_pattern (icon_info,
+ gtk_widget_get_window (widget), error);
g_object_unref (icon_info);
- return pixbuf;
+ return pattern;
}
-GdkPixbuf *
+cairo_pattern_t *
_gtk_file_system_volume_render_icon (GtkFileSystemVolume *volume,
GtkWidget *widget,
gint icon_size,
GError **error)
{
GIcon *icon = NULL;
- GdkPixbuf *pixbuf;
+ cairo_pattern_t *pattern;
DEBUG ("volume_get_icon_name");
@@ -760,11 +762,11 @@ _gtk_file_system_volume_render_icon (GtkFileSystemVolume *volume,
if (!icon)
return NULL;
- pixbuf = get_pixbuf_from_gicon (icon, widget, icon_size, error);
+ pattern = get_pattern_from_gicon (icon, widget, icon_size, error);
g_object_unref (icon);
- return pixbuf;
+ return pattern;
}
GtkFileSystemVolume *
@@ -795,39 +797,55 @@ _gtk_file_system_volume_unref (GtkFileSystemVolume *volume)
}
/* GFileInfo helper functions */
-GdkPixbuf *
+cairo_pattern_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;
+ cairo_pattern_t *pattern = NULL;
const gchar *thumbnail_path;
+ cairo_surface_t *surface;
+ cairo_matrix_t matrix;
+ 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_pixbuf_to_surface (pixbuf,
+ gtk_widget_get_window (widget));
+ g_object_unref (pixbuf);
+ pattern = cairo_pattern_create_for_surface (surface);
+ cairo_surface_destroy (surface);
+
+ cairo_matrix_init_scale (&matrix, scale, scale);
+ cairo_pattern_set_matrix (pattern, &matrix);
+ }
- if (!pixbuf)
+ if (!pattern)
{
icon = g_file_info_get_icon (info);
if (icon)
- pixbuf = get_pixbuf_from_gicon (icon, widget, icon_size, NULL);
+ pattern = get_pattern_from_gicon (icon, widget, icon_size, NULL);
- if (!pixbuf)
+ if (!pattern)
{
/* 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);
+ pattern = get_pattern_from_gicon (icon, widget, icon_size, NULL);
g_object_unref (icon);
}
}
- return pixbuf;
+ return pattern;
}
gboolean
diff --git a/gtk/gtkfilesystem.h b/gtk/gtkfilesystem.h
index c24ae29..b49834b 100644
--- a/gtk/gtkfilesystem.h
+++ b/gtk/gtkfilesystem.h
@@ -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_pattern_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_pattern_t * _gtk_file_info_render_icon (GFileInfo *info,
+ GtkWidget *widget,
+ gint icon_size);
gboolean _gtk_file_info_consider_as_directory (GFileInfo *info);
diff --git a/gtk/gtkiconhelperprivate.h b/gtk/gtkiconhelperprivate.h
index 9011d84..fcee95e 100644
--- a/gtk/gtkiconhelperprivate.h
+++ b/gtk/gtkiconhelperprivate.h
@@ -95,6 +95,8 @@ void _gtk_icon_helper_set_icon_name (GtkIconHelper *self,
void _gtk_icon_helper_set_stock_id (GtkIconHelper *self,
const gchar *stock_id,
GtkIconSize icon_size);
+void _gtk_icon_helper_set_pattern (GtkIconHelper *self,
+ cairo_pattern_t *pattern);
void _gtk_icon_helper_set_icon_size (GtkIconHelper *self,
GtkIconSize icon_size);
@@ -112,6 +114,7 @@ GdkPixbuf *_gtk_icon_helper_peek_pixbuf (GtkIconHelper *self);
GIcon *_gtk_icon_helper_peek_gicon (GtkIconHelper *self);
GtkIconSet *_gtk_icon_helper_peek_icon_set (GtkIconHelper *self);
GdkPixbufAnimation *_gtk_icon_helper_peek_animation (GtkIconHelper *self);
+cairo_pattern_t *_gtk_icon_helper_peek_pattern (GtkIconHelper *self);
const gchar *_gtk_icon_helper_get_stock_id (GtkIconHelper *self);
const gchar *_gtk_icon_helper_get_icon_name (GtkIconHelper *self);
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index 242a55d..e2a6651 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -46,9 +46,9 @@ struct _GtkPathBarPrivate
GCancellable *get_info_cancellable;
- GdkPixbuf *root_icon;
- GdkPixbuf *home_icon;
- GdkPixbuf *desktop_icon;
+ cairo_pattern_t *root_icon;
+ cairo_pattern_t *home_icon;
+ cairo_pattern_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_pattern_destroy (path_bar->priv->root_icon);
if (path_bar->priv->home_icon)
- g_object_unref (path_bar->priv->home_icon);
+ cairo_pattern_destroy (path_bar->priv->home_icon);
if (path_bar->priv->desktop_icon)
- g_object_unref (path_bar->priv->desktop_icon);
+ cairo_pattern_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_pattern_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_pattern_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_pattern_destroy (path_bar->priv->desktop_icon);
path_bar->priv->desktop_icon = NULL;
}
@@ -1379,7 +1379,7 @@ set_button_image_get_info_cb (GCancellable *cancellable,
gpointer user_data)
{
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
- GdkPixbuf *pixbuf;
+ cairo_pattern_t *pattern;
struct SetButtonImageData *data = user_data;
if (cancellable != data->button_data->cancellable)
@@ -1396,24 +1396,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),
+ pattern = _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_pattern (GTK_IMAGE (data->button_data->image), pattern);
switch (data->button_data->type)
{
case HOME_BUTTON:
if (data->path_bar->priv->home_icon)
- g_object_unref (pixbuf);
+ cairo_pattern_destroy (pattern);
else
- data->path_bar->priv->home_icon = pixbuf;
+ data->path_bar->priv->home_icon = pattern;
break;
case DESKTOP_BUTTON:
if (data->path_bar->priv->desktop_icon)
- g_object_unref (pixbuf);
+ cairo_pattern_destroy (pattern);
else
- data->path_bar->priv->desktop_icon = pixbuf;
+ data->path_bar->priv->desktop_icon = pattern;
break;
default:
@@ -1438,7 +1438,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_pattern (GTK_IMAGE (button_data->image), path_bar->priv->root_icon);
break;
}
@@ -1452,13 +1452,13 @@ set_button_image (GtkPathBar *path_bar,
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_pattern (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_pattern (GTK_IMAGE (button_data->image), path_bar->priv->home_icon);
break;
}
@@ -1480,7 +1480,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_pattern (GTK_IMAGE (button_data->image), path_bar->priv->desktop_icon);
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]