Rename GtkIcon to GtkIconPaintable

This commit is contained in:
Alexander Larsson 2020-02-04 17:19:22 +01:00
parent 138de60ab2
commit 410541f82b
21 changed files with 237 additions and 238 deletions

View File

@ -98,7 +98,7 @@ get_image_paintable (GtkImage *image)
{
const gchar *icon_name;
GtkIconTheme *icon_theme;
GtkIcon *icon;
GtkIconPaintable *icon;
switch (gtk_image_get_storage_type (image))
{

View File

@ -132,7 +132,7 @@ insert_text (GtkTextView *view)
GtkTextIter start, end;
GdkTexture *texture;
GtkIconTheme *icon_theme;
GtkIcon *icon;
GtkIconPaintable *icon;
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget));
icon = gtk_icon_theme_lookup_icon (icon_theme,
@ -141,7 +141,7 @@ insert_text (GtkTextView *view)
32, 1,
gtk_widget_get_direction (widget),
0);
texture = gtk_icon_download_texture (icon, NULL);
texture = gtk_icon_paintable_download_texture (icon, NULL);
g_object_unref (icon);
g_assert (texture);

View File

@ -356,7 +356,7 @@ get_image_paintable (GtkImage *image)
{
const gchar *icon_name;
GtkIconTheme *icon_theme;
GtkIcon *icon;
GtkIconPaintable *icon;
int size;
switch (gtk_image_get_storage_type (image))
@ -418,7 +418,7 @@ get_file (GValue *value,
{
GtkIconTheme *icon_theme;
const char *name;
GtkIcon *info;
GtkIconPaintable *info;
GFile *file;
name = gtk_image_get_icon_name (GTK_IMAGE (data));
@ -430,7 +430,7 @@ get_file (GValue *value,
32, 1,
gtk_widget_get_direction (GTK_WIDGET (data)),
0);
file = g_file_new_for_path (gtk_icon_get_filename (info));
file = g_file_new_for_path (gtk_icon_paintable_get_filename (info));
g_value_set_object (value, file);
g_object_unref (file);
g_object_unref (info);

View File

@ -4987,7 +4987,7 @@ GtkIconSize
<SECTION>
<FILE>gtkicontheme</FILE>
<TITLE>GtkIconTheme</TITLE>
GtkIcon
GtkIconPaintable
GtkIconTheme
GtkIconLookupFlags
GTK_ICON_THEME_ERROR
@ -5010,9 +5010,9 @@ gtk_icon_theme_choose_icon_finish
gtk_icon_theme_lookup_by_gicon
gtk_icon_theme_list_icons
gtk_icon_theme_get_icon_sizes
gtk_icon_get_filename
gtk_icon_is_symbolic
gtk_icon_download_texture
gtk_icon_paintable_get_filename
gtk_icon_paintable_is_symbolic
gtk_icon_paintable_download_texture
<SUBSECTION Standard>
GtkIconClass
GTK_ICON_THEME
@ -5022,12 +5022,12 @@ gtk_icon_theme_get_type
GTK_ICON_THEME_CLASS
GTK_IS_ICON_THEME_CLASS
GTK_ICON_THEME_GET_CLASS
gtk_icon_get_type
GTK_ICON
gtk_icon_paintable_get_type
GTK_ICON_PAINTABLE
GTK_IS_ICON
GTK_TYPE_ICON
GTK_ICON_CLASS
GTK_ICON_GET_CLASS
GTK_ICON_PAINTABLE_CLASS
GTK_ICON_PAINTABLE_GET_CLASS
GTK_IS_ICON_CLASS
<SUBSECTION Private>
GtkIconThemePrivate

View File

@ -95,7 +95,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkHeaderBar, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIMContext, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIMContextSimple, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIMMulticontext, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIcon, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIconPaintable, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIconTheme, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkIconView, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkImage, g_object_unref)

View File

@ -103,7 +103,7 @@ icon_loaded (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GtkIcon *icon = GTK_ICON (object);
GtkIconPaintable *icon = GTK_ICON (object);
GNSMenuItem *item = user_data;
GError *error = NULL;
GdkPixbuf *pixbuf;
@ -278,7 +278,7 @@ icon_loaded (GObject *object,
static GdkRGBA error;
GtkIconTheme *theme;
GtkIcon *icon;
GtkIconPaintable *icon;
gint scale = 1;
if (!parsed)

View File

@ -2160,7 +2160,7 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
if (pixbuf == NULL)
{
GtkIconTheme *theme;
GtkIcon *icon;
GtkIconPaintable *icon;
GdkTexture *texture;
g_warning ("Could not load image '%s': %s",
@ -2174,7 +2174,7 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
icon = gtk_icon_theme_lookup_icon (theme, "image-missing", NULL, 16, 1,
GTK_TEXT_DIR_NONE,
0);
texture = gtk_icon_download_texture (icon, NULL);
texture = gtk_icon_paintable_download_texture (icon, NULL);
pixbuf = gdk_pixbuf_get_from_texture (texture);
g_object_unref (icon);
g_object_unref (texture);

View File

@ -2585,7 +2585,7 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture,
GdkDevice *device;
GdkDrag *drag;
GtkIconTheme *theme;
GtkIcon *icon;
GtkIconPaintable *icon;
GdkSurface *surface;
if (!priv->in_drag)

View File

@ -45,7 +45,7 @@ gtk_css_image_icon_theme_snapshot (GtkCssImage *image,
double height)
{
GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
GtkIcon *icon;
GtkIconPaintable *icon;
double icon_width, icon_height;
gint size;
double x, y;
@ -95,13 +95,13 @@ gtk_css_image_icon_theme_snapshot (GtkCssImage *image,
gtk_snapshot_save (snapshot);
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (x, y));
}
gtk_icon_snapshot_with_colors (icon, snapshot,
icon_width,
icon_height,
&icon_theme->color,
&icon_theme->success,
&icon_theme->warning,
&icon_theme->error);
gtk_icon_paintable_snapshot_with_colors (icon, snapshot,
icon_width,
icon_height,
&icon_theme->color,
&icon_theme->success,
&icon_theme->warning,
&icon_theme->error);
if (x != 0 || y != 0)
gtk_snapshot_restore (snapshot);
}

View File

@ -49,7 +49,7 @@ struct _GtkCssImageIconTheme
int cached_size;
gboolean cached_symbolic;
GtkIcon *cached_icon;
GtkIconPaintable *cached_icon;
};
struct _GtkCssImageIconThemeClass

View File

@ -96,7 +96,7 @@ ensure_paintable_for_gicon (GtkIconHelper *self,
{
GtkIconTheme *icon_theme;
gint width, height;
GtkIcon *icon;
GtkIconPaintable *icon;
GtkIconLookupFlags flags;
icon_theme = gtk_css_icon_theme_value_get_icon_theme (style->core->icon_theme);
@ -117,7 +117,7 @@ ensure_paintable_for_gicon (GtkIconHelper *self,
dir,
flags);
*symbolic = gtk_icon_is_symbolic (icon);
*symbolic = gtk_icon_paintable_is_symbolic (icon);
return GDK_PAINTABLE (icon);
}

View File

@ -83,7 +83,7 @@
* looking up icons.
* |[<!-- language="C" -->
* GtkIconTheme *icon_theme;
* GtkIcon *icon;
* GtkIconPaintable *icon;
*
* icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (my_widget));
* icon = gtk_icon_theme_lookup_icon (icon_theme,
@ -175,8 +175,8 @@ typedef enum
#define LRU_CACHE_SIZE 100
#define MAX_LRU_TEXTURE_SIZE 128
typedef struct _GtkIconClass GtkIconClass;
typedef struct _GtkIconThemeClass GtkIconThemeClass;
typedef struct _GtkIconPaintableClass GtkIconPaintableClass;
typedef struct _GtkIconThemeClass GtkIconThemeClass;
typedef struct _GtkIconThemeRef GtkIconThemeRef;
@ -197,10 +197,10 @@ struct _GtkIconTheme
GObject parent_instance;
GtkIconThemeRef *ref;
GHashTable *icon_cache; /* Protected by icon_cache lock */
GHashTable *icon_cache; /* Protected by icon_cache lock */
GtkIcon *lru_cache[LRU_CACHE_SIZE]; /* Protected by icon_cache lock */
int lru_cache_current; /* Protected by icon_cache lock */
GtkIconPaintable *lru_cache[LRU_CACHE_SIZE]; /* Protected by icon_cache lock */
int lru_cache_current; /* Protected by icon_cache lock */
gchar *current_theme;
gchar **search_path;
@ -243,7 +243,7 @@ typedef struct {
GtkIconLookupFlags flags;
} IconKey;
struct _GtkIconClass
struct _GtkIconPaintableClass
{
GObjectClass parent_class;
};
@ -253,12 +253,12 @@ struct _GtkIconClass
G_LOCK_DEFINE_STATIC(icon_cache);
/**
* GtkIcon:
* GtkIconPaintable:
*
* Contains information found when looking up an icon in
* an icon theme and supports painting it as a #GdkPaintable.
*/
struct _GtkIcon
struct _GtkIconPaintable
{
GObject parent_instance;
@ -360,40 +360,40 @@ typedef struct
gboolean exists;
} IconThemeDirMtime;
static void gtk_icon_theme_finalize (GObject *object);
static void gtk_icon_theme_dispose (GObject *object);
static IconTheme * theme_new (const char *theme_name,
GKeyFile *theme_file);
static void theme_dir_size_destroy (IconThemeDirSize *dir_size);
static void theme_dir_destroy (IconThemeDir *dir);
static void theme_destroy (IconTheme *theme);
static GtkIcon * theme_lookup_icon (IconTheme *theme,
const gchar *icon_name,
gint size,
gint scale,
gboolean allow_svg);
static void theme_list_icons (IconTheme *theme,
GHashTable *icons);
static gboolean theme_has_icon (IconTheme *theme,
const gchar *icon_name);
static void theme_subdir_load (GtkIconTheme *self,
IconTheme *theme,
GKeyFile *theme_file,
gchar *subdir);
static void do_theme_change (GtkIconTheme *self);
static void blow_themes (GtkIconTheme *self);
static gboolean rescan_themes (GtkIconTheme *self);
static GtkIcon * icon_new (IconThemeDirType type,
gint dir_size,
gint dir_scale);
static void icon_compute_rendered_size (GtkIcon *icon);
static IconCacheFlag suffix_from_name (const gchar *name);
static gboolean icon_ensure_scale_and_texture__locked (GtkIcon *icon,
gboolean in_thread);
static void unset_display (GtkIconTheme *self);
static void update_current_theme__mainthread (GtkIconTheme *self);
static gboolean ensure_valid_themes (GtkIconTheme *self,
gboolean non_blocking);
static void gtk_icon_theme_finalize (GObject *object);
static void gtk_icon_theme_dispose (GObject *object);
static IconTheme * theme_new (const char *theme_name,
GKeyFile *theme_file);
static void theme_dir_size_destroy (IconThemeDirSize *dir_size);
static void theme_dir_destroy (IconThemeDir *dir);
static void theme_destroy (IconTheme *theme);
static GtkIconPaintable *theme_lookup_icon (IconTheme *theme,
const gchar *icon_name,
gint size,
gint scale,
gboolean allow_svg);
static void theme_list_icons (IconTheme *theme,
GHashTable *icons);
static gboolean theme_has_icon (IconTheme *theme,
const gchar *icon_name);
static void theme_subdir_load (GtkIconTheme *self,
IconTheme *theme,
GKeyFile *theme_file,
gchar *subdir);
static void do_theme_change (GtkIconTheme *self);
static void blow_themes (GtkIconTheme *self);
static gboolean rescan_themes (GtkIconTheme *self);
static GtkIconPaintable *icon_paintable_new (IconThemeDirType type,
gint dir_size,
gint dir_scale);
static void icon_compute_rendered_size (GtkIconPaintable *icon);
static IconCacheFlag suffix_from_name (const gchar *name);
static gboolean icon_ensure_scale_and_texture__locked (GtkIconPaintable *icon,
gboolean in_thread);
static void unset_display (GtkIconTheme *self);
static void update_current_theme__mainthread (GtkIconTheme *self);
static gboolean ensure_valid_themes (GtkIconTheme *self,
gboolean non_blocking);
static guint signal_changed = 0;
@ -538,18 +538,18 @@ icon_key_equal (gconstpointer _a,
/* This is called with icon_cache lock held so must not take any locks */
static gboolean
_icon_cache_should_lru_cache (GtkIcon *icon)
_icon_cache_should_lru_cache (GtkIconPaintable *icon)
{
return icon->desired_size <= MAX_LRU_TEXTURE_SIZE;
}
/* This returns the old lru element because we can't unref it with
* the lock held */
static GtkIcon *
_icon_cache_add_to_lru_cache (GtkIconTheme *theme,
GtkIcon *icon)
static GtkIconPaintable *
_icon_cache_add_to_lru_cache (GtkIconTheme *theme,
GtkIconPaintable *icon)
{
GtkIcon *old_icon = NULL;
GtkIconPaintable *old_icon = NULL;
/* Avoid storing the same info multiple times in a row */
if (theme->lru_cache[theme->lru_cache_current] != icon)
@ -562,12 +562,12 @@ _icon_cache_add_to_lru_cache (GtkIconTheme *theme,
return old_icon;
}
static GtkIcon *
static GtkIconPaintable *
icon_cache_lookup (GtkIconTheme *theme,
IconKey *key)
{
GtkIcon *old_icon = NULL;
GtkIcon *icon;
GtkIconPaintable *old_icon = NULL;
GtkIconPaintable *icon;
G_LOCK (icon_cache);
@ -600,7 +600,7 @@ icon_cache_lookup (GtkIconTheme *theme,
* This is a callback from the icon_cache hashtable, so the icon_cache lock is already held.
*/
static void
icon_uncached_cb (GtkIcon *icon)
icon_uncached_cb (GtkIconPaintable *icon)
{
DEBUG_CACHE (("removing %p (%s %d 0x%x) from cache (icon_them: %p) (cache size %d)\n",
icon,
@ -613,9 +613,9 @@ icon_uncached_cb (GtkIcon *icon)
}
static void
icon_cache_mark_used_if_cached (GtkIcon *icon)
icon_cache_mark_used_if_cached (GtkIconPaintable *icon)
{
GtkIcon *old_icon = NULL;
GtkIconPaintable *old_icon = NULL;
if (!_icon_cache_should_lru_cache (icon))
return;
@ -631,10 +631,10 @@ icon_cache_mark_used_if_cached (GtkIcon *icon)
}
static void
icon_cache_add (GtkIconTheme *theme,
GtkIcon *icon)
icon_cache_add (GtkIconTheme *theme,
GtkIconPaintable *icon)
{
GtkIcon *old_icon = NULL;
GtkIconPaintable *old_icon = NULL;
G_LOCK (icon_cache);
icon->in_cache = theme;
@ -655,7 +655,7 @@ icon_cache_add (GtkIconTheme *theme,
}
static void
icon_cache_remove (GtkIcon *icon)
icon_cache_remove (GtkIconPaintable *icon)
{
G_LOCK (icon_cache);
if (icon->in_cache)
@ -667,7 +667,7 @@ static void
icon_cache_clear (GtkIconTheme *theme)
{
int i;
GtkIcon *old_icons[LRU_CACHE_SIZE];
GtkIconPaintable *old_icons[LRU_CACHE_SIZE];
G_LOCK (icon_cache);
g_hash_table_remove_all (theme->icon_cache);
@ -1809,7 +1809,7 @@ icon_uri_is_symbolic (const gchar *icon_name,
return FALSE;
}
static GtkIcon *
static GtkIconPaintable *
real_choose_icon (GtkIconTheme *self,
const gchar *icon_names[],
gint size,
@ -1819,8 +1819,8 @@ real_choose_icon (GtkIconTheme *self,
gboolean *would_block)
{
GList *l;
GtkIcon *icon = NULL;
GtkIcon *unscaled_icon;
GtkIconPaintable *icon = NULL;
GtkIconPaintable *unscaled_icon;
UnthemedIcon *unthemed_icon = NULL;
const gchar *icon_name = NULL;
IconTheme *theme = NULL;
@ -1905,7 +1905,7 @@ real_choose_icon (GtkIconTheme *self,
if (hIcon)
{
icon = icon_new (ICON_THEME_DIR_UNTHEMED, size, 1);
icon = icon_paintable_new (ICON_THEME_DIR_UNTHEMED, size, 1);
icon->cache_pixbuf = gdk_win32_icon_to_pixbuf_libgtk_only (hIcon, NULL, NULL);
DestroyIcon (hIcon);
}
@ -1915,7 +1915,7 @@ real_choose_icon (GtkIconTheme *self,
if (unthemed_icon)
{
icon = icon_new (ICON_THEME_DIR_UNTHEMED, size, 1);
icon = icon_paintable_new (ICON_THEME_DIR_UNTHEMED, size, 1);
/* A SVG icon, when allowed, beats out a XPM icon, but not a PNG icon */
if (self->pixbuf_supports_svg &&
@ -2020,7 +2020,7 @@ icon_name_list_add_icon (GPtrArray *icons,
g_ptr_array_add (icons, icon_name);
}
static GtkIcon *
static GtkIconPaintable *
choose_icon (GtkIconTheme *self,
const gchar *icon_names[],
gint size,
@ -2031,7 +2031,7 @@ choose_icon (GtkIconTheme *self,
gboolean *would_block)
{
gboolean has_regular = FALSE, has_symbolic = FALSE;
GtkIcon *icon;
GtkIconPaintable *icon;
GPtrArray *new_names;
const gchar *dir_suffix;
guint i;
@ -2157,7 +2157,7 @@ choose_icon (GtkIconTheme *self,
* Looks up a named icon for a desired size and window scale, returning a
* #GtkIcon. The icon can then be rendered by using it as a #GdkPaintable,
* or you can get information such as the filename and size. The pixels
* of the texture can be access by using gtk_icon_download_texture().
* of the texture can be access by using gtk_icon_paintable_download_texture().
*
* The icon icon size will be based on the requested @size, but may
* not be exactly this size; an icon theme may have icons that differ
@ -2175,10 +2175,10 @@ choose_icon (GtkIconTheme *self,
* update the icon. This is usually done by connecting to the
* GtkWidget::style-updated signal.
*
* Returns: (nullable) (transfer full): a #GtkIcon object
* Returns: (nullable) (transfer full): a #GtkIconPaintable object
* containing the icon, or %NULL if the icon wasnt found.
*/
GtkIcon *
GtkIconPaintable *
gtk_icon_theme_lookup_icon (GtkIconTheme *self,
const char *icon_name,
const char *fallbacks[],
@ -2187,7 +2187,7 @@ gtk_icon_theme_lookup_icon (GtkIconTheme *self,
GtkTextDirection direction,
GtkIconLookupFlags flags)
{
GtkIcon *icon;
GtkIconPaintable *icon;
g_return_val_if_fail (GTK_IS_ICON_THEME (self), NULL);
g_return_val_if_fail (icon_name != NULL, NULL);
@ -2710,7 +2710,7 @@ compare_dir_size_matches (IconThemeDirSize *dir_a, gint difference_a,
return diff_a <= diff_b;
}
static GtkIcon *
static GtkIconPaintable *
theme_lookup_icon (IconTheme *theme,
const gchar *icon_name,
gint size,
@ -2768,11 +2768,11 @@ theme_lookup_icon (IconTheme *theme,
if (min_dir_size)
{
GtkIcon *icon;
GtkIconPaintable *icon;
IconThemeDir *dir = &g_array_index (theme->dirs, IconThemeDir, min_file->dir_index);
gchar *filename;
icon = icon_new (min_dir_size->type, min_dir_size->size, min_dir_size->scale);
icon = icon_paintable_new (min_dir_size->type, min_dir_size->size, min_dir_size->scale);
icon->min_size = min_dir_size->min_size;
icon->max_size = min_dir_size->max_size;
@ -3144,25 +3144,25 @@ theme_subdir_load (GtkIconTheme *self,
static void icon_paintable_init (GdkPaintableInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkIcon, gtk_icon, G_TYPE_OBJECT,
G_DEFINE_TYPE_WITH_CODE (GtkIconPaintable, gtk_icon_paintable, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
icon_paintable_init))
static void
gtk_icon_init (GtkIcon *icon)
gtk_icon_paintable_init (GtkIconPaintable *icon)
{
icon->scale = -1.;
g_mutex_init (&icon->texture_lock);
}
static GtkIcon *
icon_new (IconThemeDirType type,
gint dir_size,
gint dir_scale)
static GtkIconPaintable *
icon_paintable_new (IconThemeDirType type,
gint dir_size,
gint dir_scale)
{
GtkIcon *icon;
GtkIconPaintable *icon;
icon = g_object_new (GTK_TYPE_ICON, NULL);
icon = g_object_new (GTK_TYPE_ICON_PAINTABLE, NULL);
icon->dir_type = type;
icon->dir_size = dir_size;
@ -3176,7 +3176,7 @@ icon_new (IconThemeDirType type,
}
static void
icon_compute_rendered_size (GtkIcon *icon)
icon_compute_rendered_size (GtkIconPaintable *icon)
{
int rendered_size;
@ -3215,9 +3215,9 @@ icon_compute_rendered_size (GtkIcon *icon)
}
static void
gtk_icon_finalize (GObject *object)
gtk_icon_paintable_finalize (GObject *object)
{
GtkIcon *icon = (GtkIcon *) object;
GtkIconPaintable *icon = (GtkIconPaintable *) object;
icon_cache_remove (icon);
@ -3232,19 +3232,19 @@ gtk_icon_finalize (GObject *object)
g_mutex_clear (&icon->texture_lock);
G_OBJECT_CLASS (gtk_icon_parent_class)->finalize (object);
G_OBJECT_CLASS (gtk_icon_paintable_parent_class)->finalize (object);
}
static void
gtk_icon_class_init (GtkIconClass *klass)
gtk_icon_paintable_class_init (GtkIconPaintableClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = gtk_icon_finalize;
gobject_class->finalize = gtk_icon_paintable_finalize;
}
/**
* gtk_icon_get_filename:
* gtk_icon_paintable_get_filename:
* @self: a #GtkIcon
*
* Gets the filename for the icon.
@ -3253,7 +3253,7 @@ gtk_icon_class_init (GtkIconClass *klass)
* if the icon is not represented by a filename.
*/
const gchar *
gtk_icon_get_filename (GtkIcon *icon)
gtk_icon_paintable_get_filename (GtkIconPaintable *icon)
{
g_return_val_if_fail (icon != NULL, NULL);
@ -3261,7 +3261,7 @@ gtk_icon_get_filename (GtkIcon *icon)
}
/**
* gtk_icon_is_symbolic:
* gtk_icon_paintable_is_symbolic:
* @self: a #GtkIcon
*
* Checks if the icon is symbolic or not. This currently uses only
@ -3271,16 +3271,16 @@ gtk_icon_get_filename (GtkIcon *icon)
* Returns: %TRUE if the icon is symbolic, %FALSE otherwise
*/
gboolean
gtk_icon_is_symbolic (GtkIcon *icon)
gtk_icon_paintable_is_symbolic (GtkIconPaintable *icon)
{
g_return_val_if_fail (GTK_IS_ICON (icon), FALSE);
g_return_val_if_fail (GTK_IS_ICON_PAINTABLE (icon), FALSE);
return icon->filename != NULL &&
icon_uri_is_symbolic (icon->filename, -1);
}
static GLoadableIcon *
icon_get_loadable (GtkIcon *icon)
icon_get_loadable (GtkIconPaintable *icon)
{
GFile *file;
GLoadableIcon *loadable;
@ -3309,7 +3309,7 @@ icon_get_loadable (GtkIcon *icon)
* that size.
*/
static gboolean
icon_ensure_scale_and_texture__locked (GtkIcon *icon,
icon_ensure_scale_and_texture__locked (GtkIconPaintable *icon,
gboolean in_thread)
{
gint image_width, image_height, image_size;
@ -3378,7 +3378,7 @@ icon_ensure_scale_and_texture__locked (GtkIcon *icon,
else
size = icon->dir_size * dir_scale * icon->scale;
if (gtk_icon_is_symbolic (icon))
if (gtk_icon_paintable_is_symbolic (icon))
source_pixbuf = gtk_make_symbolic_pixbuf_from_resource (icon->filename,
size, size,
icon->desired_scale,
@ -3425,7 +3425,7 @@ icon_ensure_scale_and_texture__locked (GtkIcon *icon,
else
size = icon->dir_size * dir_scale * icon->scale;
if (gtk_icon_is_symbolic (icon))
if (gtk_icon_paintable_is_symbolic (icon))
source_pixbuf = gtk_make_symbolic_pixbuf_from_path (icon->filename,
size, size,
icon->desired_scale,
@ -3524,7 +3524,7 @@ icon_ensure_scale_and_texture__locked (GtkIcon *icon,
}
/**
* gtk_icon_download_texture:
* gtk_icon_paintable_download_texture:
* @self: a #GtkIcon
* @error: (allow-none): location to store error information on failure,
* or %NULL.
@ -3535,7 +3535,7 @@ icon_ensure_scale_and_texture__locked (GtkIcon *icon,
* Returns: (transfer full): An texture with the contents of the icon, or %NULL on failure.
*/
GdkTexture *
gtk_icon_download_texture (GtkIcon *self,
gtk_icon_paintable_download_texture (GtkIconPaintable *self,
GError **error)
{
GdkTexture *texture = NULL;
@ -3601,10 +3601,10 @@ icon_paintable_snapshot (GdkPaintable *paintable,
double width,
double height)
{
GtkIcon *icon = GTK_ICON (paintable);
GtkIconPaintable *icon = GTK_ICON_PAINTABLE (paintable);
GdkTexture *texture;
texture = gtk_icon_download_texture (icon, NULL);
texture = gtk_icon_paintable_download_texture (icon, NULL);
if (texture)
{
if (icon->desired_scale != 1)
@ -3624,7 +3624,7 @@ icon_paintable_snapshot (GdkPaintable *paintable,
}
/**
* gtk_icon_snapshot_with_colors:
* gtk_icon_paintable_snapshot_with_colors:
* @icon: a #GtkIcon
* @snapshot: a #GdkSnapshot to snapshot to
* @width: width to snapshot in
@ -3642,7 +3642,7 @@ icon_paintable_snapshot (GdkPaintable *paintable,
* symbolic it will be recolored with the specified colors (which ususally comes from the theme).
*/
void
gtk_icon_snapshot_with_colors (GtkIcon *icon,
gtk_icon_paintable_snapshot_with_colors (GtkIconPaintable *icon,
GtkSnapshot *snapshot,
double width,
double height,
@ -3653,10 +3653,10 @@ gtk_icon_snapshot_with_colors (GtkIcon *icon,
{
GdkTexture *texture;
texture = gtk_icon_download_texture (icon, NULL);
texture = gtk_icon_paintable_download_texture (icon, NULL);
if (texture)
{
gboolean symbolic = gtk_icon_is_symbolic (icon);
gboolean symbolic = gtk_icon_paintable_is_symbolic (icon);
if (icon->desired_scale != 1)
{
@ -3699,7 +3699,7 @@ icon_paintable_get_flags (GdkPaintable *paintable)
static int
icon_paintable_get_intrinsic_width (GdkPaintable *paintable)
{
GtkIcon *icon = GTK_ICON (paintable);
GtkIconPaintable *icon = GTK_ICON_PAINTABLE (paintable);
return icon->rendered_size;
}
@ -3707,7 +3707,7 @@ icon_paintable_get_intrinsic_width (GdkPaintable *paintable)
static int
icon_paintable_get_intrinsic_height (GdkPaintable *paintable)
{
GtkIcon *icon = GTK_ICON (paintable);
GtkIconPaintable *icon = GTK_ICON_PAINTABLE (paintable);
return icon->rendered_size;
}
@ -3721,14 +3721,14 @@ icon_paintable_init (GdkPaintableInterface *iface)
iface->get_intrinsic_height = icon_paintable_get_intrinsic_height;
}
static GtkIcon *
gtk_icon_new_for_file (GFile *file,
static GtkIconPaintable *
gtk_icon_paintable_new_for_file (GFile *file,
gint size,
gint scale)
{
GtkIcon *icon;
GtkIconPaintable *icon;
icon = icon_new (ICON_THEME_DIR_UNTHEMED, size, 1);
icon = icon_paintable_new (ICON_THEME_DIR_UNTHEMED, size, 1);
icon->loadable = G_LOADABLE_ICON (g_file_icon_new (file));
icon->is_resource = g_file_has_uri_scheme (file, "resource");
@ -3756,18 +3756,18 @@ gtk_icon_new_for_file (GFile *file,
return icon;
}
static GtkIcon *
gtk_icon_new_for_pixbuf (GtkIconTheme *icon_theme,
static GtkIconPaintable *
gtk_icon_paintable_new_for_pixbuf (GtkIconTheme *icon_theme,
GdkPixbuf *pixbuf)
{
GtkIcon *icon;
GtkIconPaintable *icon;
gint width, height, max;
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
max = MAX (width, height);
icon = icon_new (ICON_THEME_DIR_UNTHEMED, 0, 1);
icon = icon_paintable_new (ICON_THEME_DIR_UNTHEMED, 0, 1);
icon->texture = gdk_texture_new_for_pixbuf (pixbuf);
icon->desired_size = max;
icon->desired_scale = 1.0;
@ -3790,11 +3790,11 @@ gtk_icon_new_for_pixbuf (GtkIconTheme *icon_theme,
* #GtkIcon. The icon can then be rendered by using it as a #GdkPaintable,
* or you can get information such as the filename and size.
*
* Returns: (nullable) (transfer full): a #GtkIcon containing
* Returns: (nullable) (transfer full): a #GtkIconPaintable containing
* information about the icon, or %NULL if the icon wasnt
* found. Unref with g_object_unref()
*/
GtkIcon *
GtkIconPaintable *
gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self,
GIcon *gicon,
gint size,
@ -3802,7 +3802,7 @@ gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self,
GtkTextDirection direction,
GtkIconLookupFlags flags)
{
GtkIcon *icon;
GtkIconPaintable *icon;
g_return_val_if_fail (GTK_IS_ICON_THEME (self), NULL);
g_return_val_if_fail (G_IS_ICON (gicon), NULL);
@ -3831,17 +3831,17 @@ gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self,
0.5 + height * pixbuf_scale,
GDK_INTERP_BILINEAR);
icon = gtk_icon_new_for_pixbuf (self, scaled);
icon = gtk_icon_paintable_new_for_pixbuf (self, scaled);
g_object_unref (scaled);
}
else
{
icon = gtk_icon_new_for_pixbuf (self, pixbuf);
icon = gtk_icon_paintable_new_for_pixbuf (self, pixbuf);
}
}
else
{
icon = gtk_icon_new_for_pixbuf (self, pixbuf);
icon = gtk_icon_paintable_new_for_pixbuf (self, pixbuf);
}
return icon;
@ -3850,14 +3850,14 @@ gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self,
{
GFile *file = g_file_icon_get_file (G_FILE_ICON (gicon));
icon = gtk_icon_new_for_file (file, size, scale);
icon = gtk_icon_paintable_new_for_file (file, size, scale);
icon->forced_size = (flags & GTK_ICON_LOOKUP_FORCE_SIZE) != 0;
return icon;
}
else if (G_IS_LOADABLE_ICON (gicon))
{
icon = icon_new (ICON_THEME_DIR_UNTHEMED, size, 1);
icon = icon_paintable_new (ICON_THEME_DIR_UNTHEMED, size, 1);
icon->loadable = G_LOADABLE_ICON (g_object_ref (gicon));
icon->is_svg = FALSE;
icon->desired_size = size;

View File

@ -27,16 +27,16 @@
G_BEGIN_DECLS
#define GTK_TYPE_ICON (gtk_icon_get_type ())
#define GTK_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ICON, GtkIcon))
#define GTK_IS_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ICON))
#define GTK_TYPE_ICON_PAINTABLE (gtk_icon_paintable_get_type ())
#define GTK_ICON_PAINTABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ICON_PAINTABLE, GtkIconPaintable))
#define GTK_IS_ICON_PAINTABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ICON_PAINTABLE))
#define GTK_TYPE_ICON_THEME (gtk_icon_theme_get_type ())
#define GTK_ICON_THEME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ICON_THEME, GtkIconTheme))
#define GTK_IS_ICON_THEME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ICON_THEME))
typedef struct _GtkIcon GtkIcon;
typedef struct _GtkIconTheme GtkIconTheme;
typedef struct _GtkIconPaintable GtkIconPaintable;
typedef struct _GtkIconTheme GtkIconTheme;
/**
* GtkIconLookupFlags:
@ -79,74 +79,73 @@ GDK_AVAILABLE_IN_ALL
GQuark gtk_icon_theme_error_quark (void);
GDK_AVAILABLE_IN_ALL
GType gtk_icon_theme_get_type (void) G_GNUC_CONST;
GType gtk_icon_theme_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkIconTheme *gtk_icon_theme_new (void);
GtkIconTheme *gtk_icon_theme_new (void);
GDK_AVAILABLE_IN_ALL
GtkIconTheme *gtk_icon_theme_get_for_display (GdkDisplay *display);
GtkIconTheme *gtk_icon_theme_get_for_display (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_set_display (GtkIconTheme *self,
GdkDisplay *display);
void gtk_icon_theme_set_display (GtkIconTheme *self,
GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_set_search_path (GtkIconTheme *self,
const gchar *path[],
gint n_elements);
void gtk_icon_theme_set_search_path (GtkIconTheme *self,
const gchar *path[],
gint n_elements);
GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_get_search_path (GtkIconTheme *self,
gchar **path[],
gint *n_elements);
void gtk_icon_theme_get_search_path (GtkIconTheme *self,
gchar **path[],
gint *n_elements);
GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_append_search_path (GtkIconTheme *self,
const gchar *path);
void gtk_icon_theme_append_search_path (GtkIconTheme *self,
const gchar *path);
GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_prepend_search_path (GtkIconTheme *self,
const gchar *path);
void gtk_icon_theme_prepend_search_path (GtkIconTheme *self,
const gchar *path);
GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_add_resource_path (GtkIconTheme *self,
const gchar *path);
void gtk_icon_theme_add_resource_path (GtkIconTheme *self,
const gchar *path);
GDK_AVAILABLE_IN_ALL
void gtk_icon_theme_set_custom_theme (GtkIconTheme *self,
const gchar *theme_name);
void gtk_icon_theme_set_custom_theme (GtkIconTheme *self,
const gchar *theme_name);
GDK_AVAILABLE_IN_ALL
gboolean gtk_icon_theme_has_icon (GtkIconTheme *self,
const gchar *icon_name);
gboolean gtk_icon_theme_has_icon (GtkIconTheme *self,
const gchar *icon_name);
GDK_AVAILABLE_IN_ALL
gint *gtk_icon_theme_get_icon_sizes (GtkIconTheme *self,
const gchar *icon_name);
gint *gtk_icon_theme_get_icon_sizes (GtkIconTheme *self,
const gchar *icon_name);
GDK_AVAILABLE_IN_ALL
GtkIcon * gtk_icon_theme_lookup_icon (GtkIconTheme *self,
const char *icon_name,
const char *fallbacks[],
gint size,
gint scale,
GtkTextDirection direction,
GtkIconLookupFlags flags);
GtkIconPaintable *gtk_icon_theme_lookup_icon (GtkIconTheme *self,
const char *icon_name,
const char *fallbacks[],
gint size,
gint scale,
GtkTextDirection direction,
GtkIconLookupFlags flags);
GDK_AVAILABLE_IN_ALL
GtkIcon * gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self,
GIcon *icon,
gint size,
gint scale,
GtkTextDirection direction,
GtkIconLookupFlags flags);
GtkIconPaintable *gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self,
GIcon *icon,
gint size,
gint scale,
GtkTextDirection direction,
GtkIconLookupFlags flags);
GDK_AVAILABLE_IN_ALL
GList * gtk_icon_theme_list_icons (GtkIconTheme *self);
GList * gtk_icon_theme_list_icons (GtkIconTheme *self);
GDK_AVAILABLE_IN_ALL
GType gtk_icon_get_type (void) G_GNUC_CONST;
GType gtk_icon_paintable_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
const gchar * gtk_icon_get_filename (GtkIcon *self);
const gchar * gtk_icon_paintable_get_filename (GtkIconPaintable *self);
GDK_AVAILABLE_IN_ALL
gboolean gtk_icon_is_symbolic (GtkIcon *self);
gboolean gtk_icon_paintable_is_symbolic (GtkIconPaintable *self);
GDK_AVAILABLE_IN_ALL
GdkTexture * gtk_icon_download_texture (GtkIcon *self,
GError **error);
GdkTexture * gtk_icon_paintable_download_texture (GtkIconPaintable *self,
GError **error);
G_END_DECLS

View File

@ -21,18 +21,18 @@
#include <gtk/gtkicontheme.h>
#include <gtk/gtkcssstyleprivate.h>
void gtk_icon_theme_lookup_symbolic_colors (GtkCssStyle *style,
GdkRGBA *color_out,
GdkRGBA *success_out,
GdkRGBA *warning_out,
GdkRGBA *error_out);
void gtk_icon_snapshot_with_colors (GtkIcon *icon,
GtkSnapshot *snapshot,
double width,
double height,
const GdkRGBA *foreground_color,
const GdkRGBA *success_color,
const GdkRGBA *warning_color,
const GdkRGBA *error_color);
void gtk_icon_theme_lookup_symbolic_colors (GtkCssStyle *style,
GdkRGBA *color_out,
GdkRGBA *success_out,
GdkRGBA *warning_out,
GdkRGBA *error_out);
void gtk_icon_paintable_snapshot_with_colors (GtkIconPaintable *icon,
GtkSnapshot *snapshot,
double width,
double height,
const GdkRGBA *foreground_color,
const GdkRGBA *success_color,
const GdkRGBA *warning_color,
const GdkRGBA *error_color);
#endif /* __GTK_ICON_THEME_PRIVATE_H__ */

View File

@ -1169,7 +1169,7 @@ add_pid_to_process_list_store (GtkMountOperation *mount_operation,
if (texture == NULL)
{
GtkIconTheme *theme;
GtkIcon *icon;
GtkIconPaintable *icon;
theme = gtk_css_icon_theme_value_get_icon_theme
(_gtk_style_context_peek_property (gtk_widget_get_style_context (GTK_WIDGET (mount_operation->priv->dialog)),
@ -1180,7 +1180,7 @@ add_pid_to_process_list_store (GtkMountOperation *mount_operation,
24, 1,
gtk_widget_get_direction (GTK_WIDGET (mount_operation->priv->dialog)),
0);
texture = gtk_icon_download_texture (icon, NULL);
texture = gtk_icon_paintable_download_texture (icon, NULL);
g_object_unref (icon);
}

View File

@ -4008,7 +4008,7 @@ icon_list_from_theme (GtkWindow *window,
GtkStyleContext *context;
GtkCssValue *value;
GtkIconTheme *icon_theme;
GtkIcon *info;
GtkIconPaintable *info;
gint *sizes;
gint i;
@ -4038,7 +4038,7 @@ icon_list_from_theme (GtkWindow *window,
0);
if (info)
{
GdkTexture *texture = gtk_icon_download_texture (info, NULL);
GdkTexture *texture = gtk_icon_paintable_download_texture (info, NULL);
if (texture)
list = g_list_insert_sorted (list, texture, (GCompareFunc) icon_size_compare);
@ -4104,7 +4104,7 @@ gtk_window_get_icon_for_size (GtkWindow *window,
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
const char *name;
GtkIcon *info;
GtkIconPaintable *info;
name = gtk_window_get_icon_name (window);

View File

@ -272,7 +272,7 @@ get_button_list (GdkClipboard *clipboard,
0xc9, 'g', 'a', 'l', 'i', 't', 0xe9, ',', ' ',
'F', 'r', 'a', 't', 'e', 'r', 'n', 'i', 't', 0xe9, 0 };
GtkWidget *box;
GtkIcon *icon;
GtkIconPaintable *icon;
GdkTexture *texture;
GValue value = G_VALUE_INIT;
@ -292,7 +292,7 @@ get_button_list (GdkClipboard *clipboard,
48, 1,
gtk_widget_get_direction (box),
0);
texture = gtk_icon_download_texture (icon, NULL);
texture = gtk_icon_paintable_download_texture (icon, NULL);
g_value_take_object (&value, gdk_pixbuf_get_from_texture (texture));
g_object_unref (texture);
g_object_unref (icon);

View File

@ -10,7 +10,7 @@ get_image_texture (GtkImage *image,
int width = 48;
GdkPaintable *paintable;
GdkTexture *texture = NULL;
GtkIcon *icon;
GtkIconPaintable *icon;
switch (gtk_image_get_storage_type (image))
{
@ -32,7 +32,7 @@ get_image_texture (GtkImage *image,
gtk_widget_get_direction (GTK_WIDGET (image)),
0);
if (icon)
texture = gtk_icon_download_texture (icon, NULL);
texture = gtk_icon_paintable_download_texture (icon, NULL);
g_object_unref (icon);
default:
g_warning ("Image storage type %d not handled",
@ -229,7 +229,7 @@ update_source_icon (GtkDragSource *source,
int hotspot)
{
GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
GtkIcon *icon;
GtkIconPaintable *icon;
int hot_x, hot_y;
int size = 48;

View File

@ -36,7 +36,7 @@ int
main (int argc, char *argv[])
{
GtkIconTheme *icon_theme;
GtkIcon *icon;
GtkIconPaintable *icon;
char *themename;
GList *list;
int size = 48;
@ -69,7 +69,7 @@ main (int argc, char *argv[])
if (strcmp (argv[1], "display") == 0)
{
GtkIcon *icon;
GtkIconPaintable *icon;
GtkWidget *window, *image;
if (argc < 4)
@ -129,7 +129,7 @@ main (int argc, char *argv[])
icon = gtk_icon_theme_lookup_icon (icon_theme, argv[3], NULL, size, scale, direction, flags);
g_print ("icon for %s at %dx%d@%dx is %s\n", argv[3], size, size, scale,
icon ? gtk_icon_get_filename (icon) : "<none>");
icon ? gtk_icon_paintable_get_filename (icon) : "<none>");
if (icon)
{

View File

@ -74,7 +74,7 @@ static void
test_icon_existence (gconstpointer icon_name)
{
GtkIconTheme *icon_theme = gtk_icon_theme_get_for_display (gdk_display_get_default ());
GtkIcon *info;
GtkIconPaintable *info;
/* Not using generic fallback and builtins here, as we explicitly want to check the
* icon theme.

View File

@ -57,7 +57,7 @@ assert_icon_lookup_size (const char *icon_name,
const char *filename,
gint pixbuf_size)
{
GtkIcon *info;
GtkIconPaintable *info;
if (fallbacks)
{
@ -80,17 +80,17 @@ assert_icon_lookup_size (const char *icon_name,
if (filename)
{
if (!g_str_has_suffix (gtk_icon_get_filename (info), filename))
if (!g_str_has_suffix (gtk_icon_paintable_get_filename (info), filename))
{
g_error ("Icon for \"%s\" with flags %s at size %d should be \"...%s\" but is \"...%s\"",
icon_name, lookup_flags_to_string (flags), size,
filename, gtk_icon_get_filename (info) + strlen (g_get_current_dir ()));
filename, gtk_icon_paintable_get_filename (info) + strlen (g_get_current_dir ()));
return;
}
}
else
{
g_assert (gtk_icon_get_filename (info) == NULL);
g_assert (gtk_icon_paintable_get_filename (info) == NULL);
}
if (pixbuf_size > 0)
@ -98,7 +98,7 @@ assert_icon_lookup_size (const char *icon_name,
GdkTexture *texture;
GError *error = NULL;
texture = gtk_icon_download_texture (info, &error);
texture = gtk_icon_paintable_download_texture (info, &error);
g_assert_no_error (error);
g_assert_cmpint (gdk_texture_get_width (texture), ==, pixbuf_size);
g_object_unref (texture);
@ -124,14 +124,14 @@ assert_icon_lookup_fails (const char *icon_name,
GtkTextDirection direction,
GtkIconLookupFlags flags)
{
GtkIcon *info;
GtkIconPaintable *info;
info = gtk_icon_theme_lookup_icon (get_test_icontheme (FALSE), icon_name, NULL, size, 1, direction, flags);
if (info != NULL)
{
g_error ("Should not find an icon for \"%s\" with flags %s at size %d, but found \"%s\"",
icon_name, lookup_flags_to_string (flags), size, gtk_icon_get_filename (info) + strlen (g_get_current_dir ()));
icon_name, lookup_flags_to_string (flags), size, gtk_icon_paintable_get_filename (info) + strlen (g_get_current_dir ()));
g_object_unref (info);
return;
}
@ -182,7 +182,7 @@ assert_lookup_order (const char *icon_name,
guint debug_flags;
va_list args;
const gchar *s;
GtkIcon *info;
GtkIconPaintable *info;
GList *l;
debug_flags = gtk_get_debug_flags ();
@ -747,7 +747,7 @@ test_nonsquare_symbolic (void)
{
gint width, height;
GtkIconTheme *icon_theme;
GtkIcon *info;
GtkIconPaintable *info;
GFile *file;
GIcon *icon;
GError *error = NULL;
@ -776,7 +776,7 @@ test_nonsquare_symbolic (void)
g_assert_nonnull (info);
g_object_unref (pixbuf);
texture = gtk_icon_download_texture (info, &error);
texture = gtk_icon_paintable_download_texture (info, &error);
/* we are loaded successfully */
g_assert_no_error (error);