st/icon-theme: Remove deprecated API

We aren't subject to GTK3's API stability, so there's no reason
for dragging old stuff along.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2620>
This commit is contained in:
Florian Müllner 2023-02-01 14:42:38 +01:00 committed by Marge Bot
parent 5e44e2f3cd
commit 57f67224bb
2 changed files with 19 additions and 547 deletions

View File

@ -29,19 +29,10 @@
#include "st-icon-theme.h" #include "st-icon-theme.h"
#include "gtkcsspalettevalueprivate.h" #include "gtkcsspalettevalueprivate.h"
#include "gtkcssrgbavalueprivate.h" #include "gtkcssrgbavalueprivate.h"
#include "deprecated/gtkiconfactory.h"
#include "st-icon-cache.h" #include "st-icon-cache.h"
#include "gtkintl.h" #include "gtkintl.h"
#include "deprecated/gtknumerableiconprivate.h"
#include "gtkstylecontextprivate.h" #include "gtkstylecontextprivate.h"
#undef GDK_DEPRECATED
#undef GDK_DEPRECATED_FOR
#define GDK_DEPRECATED
#define GDK_DEPRECATED_FOR(f)
#include "deprecated/gtkstyle.h"
#define DEFAULT_ICON_THEME "Adwaita" #define DEFAULT_ICON_THEME "Adwaita"
/** /**
@ -59,40 +50,11 @@
* should install their icons, but additional icon themes can be installed * should install their icons, but additional icon themes can be installed
* as operating system vendors and users choose. * as operating system vendors and users choose.
* *
* Named icons are similar to the deprecated [Stock Items][gtkstock], * In many cases, named themes are used indirectly, via #GtkImage,
* and the distinction between the two may be a bit confusing. * rather than directly, but looking up icons directly is also simple.
* A few things to keep in mind: * The #GtkIconTheme object acts as a database of all the icons in the
* * current theme. You can create new #GtkIconTheme objects, but its
* - Stock images usually are used in conjunction with * much more efficient to use the standard icon theme for the #GdkScreen
* [Stock Items][gtkstock], such as %GTK_STOCK_OK or
* %GTK_STOCK_OPEN. Named icons are easier to set up and therefore
* are more useful for new icons that an application wants to
* add, such as application icons or window icons.
*
* - Stock images can only be loaded at the symbolic sizes defined
* by the #GtkIconSize enumeration, or by custom sizes defined
* by gtk_icon_size_register(), while named icons are more flexible
* and any pixel size can be specified.
*
* - Because stock images are closely tied to stock items, and thus
* to actions in the user interface, stock images may come in
* multiple variants for different widget states or writing
* directions.
*
* A good rule of thumb is that if there is a stock image for what
* you want to use, use it, otherwise use a named icon. It turns
* out that internally stock images are generally defined in
* terms of one or more named icons. (An example of the
* more than one case is icons that depend on writing direction;
* %GTK_STOCK_GO_FORWARD uses the two themed icons
* gtk-stock-go-forward-ltr and gtk-stock-go-forward-rtl.)
*
* In many cases, named themes are used indirectly, via #GtkImage
* or stock items, rather than directly, but looking up icons
* directly is also simple. The #GtkIconTheme object acts
* as a database of all the icons in the current theme. You
* can create new #GtkIconTheme objects, but its much more
* efficient to use the standard icon theme for the #GdkScreen
* so that the icon information is shared with other people * so that the icon information is shared with other people
* looking up icons. * looking up icons.
* |[<!-- language="C" --> * |[<!-- language="C" -->
@ -292,12 +254,6 @@ typedef struct
gboolean is_resource; gboolean is_resource;
} UnthemedIcon; } UnthemedIcon;
typedef struct
{
int size;
GdkPixbuf *pixbuf;
} BuiltinIcon;
typedef struct typedef struct
{ {
char *dir; char *dir;
@ -338,20 +294,13 @@ static GtkIconInfo *icon_info_new (IconThemeDirType type,
static GtkIconInfo *gtk_icon_info_new_for_file (GFile *file, static GtkIconInfo *gtk_icon_info_new_for_file (GFile *file,
int dir_size, int dir_size,
int dir_scale); int dir_scale);
static GtkIconInfo *icon_info_new_builtin (BuiltinIcon *icon);
static IconSuffix suffix_from_name (const char *name); static IconSuffix suffix_from_name (const char *name);
static BuiltinIcon *find_builtin_icon (const char *icon_name,
int size,
int scale,
int *min_difference_p);
static void remove_from_lru_cache (GtkIconTheme *icon_theme, static void remove_from_lru_cache (GtkIconTheme *icon_theme,
GtkIconInfo *icon_info); GtkIconInfo *icon_info);
static gboolean icon_info_ensure_scale_and_pixbuf (GtkIconInfo* icon_info); static gboolean icon_info_ensure_scale_and_pixbuf (GtkIconInfo* icon_info);
static guint signal_changed = 0; static guint signal_changed = 0;
static GHashTable *icon_theme_builtin_icons;
static guint static guint
icon_info_key_hash (gconstpointer _key) icon_info_key_hash (gconstpointer _key)
{ {
@ -1651,7 +1600,6 @@ real_choose_icon (GtkIconTheme *icon_theme,
UnthemedIcon *unthemed_icon = NULL; UnthemedIcon *unthemed_icon = NULL;
const char *icon_name = NULL; const char *icon_name = NULL;
gboolean allow_svg; gboolean allow_svg;
gboolean use_builtin;
IconTheme *theme = NULL; IconTheme *theme = NULL;
int i; int i;
IconInfoKey key; IconInfoKey key;
@ -1687,8 +1635,6 @@ real_choose_icon (GtkIconTheme *icon_theme,
else else
allow_svg = priv->pixbuf_supports_svg; allow_svg = priv->pixbuf_supports_svg;
use_builtin = flags & GTK_ICON_LOOKUP_USE_BUILTIN;
/* For symbolic icons, do a search in all registered themes first; /* For symbolic icons, do a search in all registered themes first;
* a theme that inherits them from a parent theme might provide * a theme that inherits them from a parent theme might provide
* an alternative full-color version, but still expect the symbolic icon * an alternative full-color version, but still expect the symbolic icon
@ -1703,7 +1649,7 @@ real_choose_icon (GtkIconTheme *icon_theme,
for (i = 0; icon_names[i] && icon_name_is_symbolic (icon_names[i]); i++) for (i = 0; icon_names[i] && icon_name_is_symbolic (icon_names[i]); i++)
{ {
icon_name = icon_names[i]; icon_name = icon_names[i];
icon_info = theme_lookup_icon (theme, icon_name, size, scale, allow_svg, use_builtin); icon_info = theme_lookup_icon (theme, icon_name, size, scale, allow_svg);
if (icon_info) if (icon_info)
goto out; goto out;
} }
@ -1716,7 +1662,7 @@ real_choose_icon (GtkIconTheme *icon_theme,
for (i = 0; icon_names[i]; i++) for (i = 0; icon_names[i]; i++)
{ {
icon_name = icon_names[i]; icon_name = icon_names[i];
icon_info = theme_lookup_icon (theme, icon_name, size, scale, allow_svg, use_builtin); icon_info = theme_lookup_icon (theme, icon_name, size, scale, allow_svg);
if (icon_info) if (icon_info)
goto out; goto out;
} }
@ -1786,7 +1732,7 @@ real_choose_icon (GtkIconTheme *icon_theme,
icon_info->unscaled_scale = 1.0; icon_info->unscaled_scale = 1.0;
if (scale != 1 && !icon_info->forced_size && theme != NULL) if (scale != 1 && !icon_info->forced_size && theme != NULL)
{ {
unscaled_icon_info = theme_lookup_icon (theme, icon_name, size, 1, allow_svg, use_builtin); unscaled_icon_info = theme_lookup_icon (theme, icon_name, size, 1, allow_svg);
if (unscaled_icon_info) if (unscaled_icon_info)
{ {
icon_info->unscaled_scale = icon_info->unscaled_scale =
@ -2286,8 +2232,7 @@ gtk_icon_theme_load_icon_for_scale (GtkIconTheme *icon_theme,
g_return_val_if_fail (error == NULL || *error == NULL, NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL);
g_return_val_if_fail (scale >= 1, NULL); g_return_val_if_fail (scale >= 1, NULL);
icon_info = gtk_icon_theme_lookup_icon_for_scale (icon_theme, icon_name, size, scale, icon_info = gtk_icon_theme_lookup_icon_for_scale (icon_theme, icon_name, size, scale, flags);
flags | GTK_ICON_LOOKUP_USE_BUILTIN);
if (!icon_info) if (!icon_info)
{ {
g_set_error (error, GTK_ICON_THEME_ERROR, GTK_ICON_THEME_NOT_FOUND, g_set_error (error, GTK_ICON_THEME_ERROR, GTK_ICON_THEME_NOT_FOUND,
@ -2351,8 +2296,7 @@ gtk_icon_theme_load_surface (GtkIconTheme *icon_theme,
g_return_val_if_fail (error == NULL || *error == NULL, NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL);
g_return_val_if_fail (scale >= 1, NULL); g_return_val_if_fail (scale >= 1, NULL);
icon_info = gtk_icon_theme_lookup_icon_for_scale (icon_theme, icon_name, size, scale, icon_info = gtk_icon_theme_lookup_icon_for_scale (icon_theme, icon_name, size, scale, flags);
flags | GTK_ICON_LOOKUP_USE_BUILTIN);
if (!icon_info) if (!icon_info)
{ {
g_set_error (error, GTK_ICON_THEME_ERROR, GTK_ICON_THEME_NOT_FOUND, g_set_error (error, GTK_ICON_THEME_ERROR, GTK_ICON_THEME_NOT_FOUND,
@ -2408,11 +2352,6 @@ gtk_icon_theme_has_icon (GtkIconTheme *icon_theme,
return TRUE; return TRUE;
} }
if (icon_theme_builtin_icons &&
g_hash_table_lookup_extended (icon_theme_builtin_icons,
icon_name, NULL, NULL))
return TRUE;
return FALSE; return FALSE;
} }
@ -2449,7 +2388,7 @@ int *
gtk_icon_theme_get_icon_sizes (GtkIconTheme *icon_theme, gtk_icon_theme_get_icon_sizes (GtkIconTheme *icon_theme,
const char *icon_name) const char *icon_name)
{ {
GList *l, *d, *icons; GList *l, *d;
GHashTable *sizes; GHashTable *sizes;
int *result, *r; int *result, *r;
guint suffix; guint suffix;
@ -2484,19 +2423,6 @@ gtk_icon_theme_get_icon_sizes (GtkIconTheme *icon_theme,
} }
} }
if (icon_theme_builtin_icons)
{
icons = g_hash_table_lookup (icon_theme_builtin_icons, icon_name);
while (icons)
{
BuiltinIcon *icon = icons->data;
g_hash_table_insert (sizes, GINT_TO_POINTER (icon->size), NULL);
icons = icons->next;
}
}
r = result = g_new0 (int, g_hash_table_size (sizes) + 1); r = result = g_new0 (int, g_hash_table_size (sizes) + 1);
g_hash_table_foreach (sizes, add_size, &r); g_hash_table_foreach (sizes, add_size, &r);
@ -2976,32 +2902,17 @@ theme_lookup_icon (IconTheme *theme,
const char *icon_name, const char *icon_name,
int size, int size,
int scale, int scale,
gboolean allow_svg, gboolean allow_svg)
gboolean use_builtin)
{ {
GList *dirs, *l; GList *dirs, *l;
IconThemeDir *dir, *min_dir; IconThemeDir *dir, *min_dir;
char *file; char *file;
int min_difference, difference; int min_difference, difference;
BuiltinIcon *closest_builtin = NULL;
IconSuffix suffix; IconSuffix suffix;
min_difference = G_MAXINT; min_difference = G_MAXINT;
min_dir = NULL; min_dir = NULL;
/* Builtin icons are logically part of the default theme and
* are searched before other subdirectories of the default theme.
*/
if (use_builtin && strcmp (theme->name, FALLBACK_ICON_THEME) == 0)
{
closest_builtin = find_builtin_icon (icon_name,
size, scale,
&min_difference);
if (min_difference == 0)
return icon_info_new_builtin (closest_builtin);
}
dirs = theme->dirs; dirs = theme->dirs;
l = dirs; l = dirs;
@ -3074,9 +2985,6 @@ theme_lookup_icon (IconTheme *theme,
return icon_info; return icon_info;
} }
if (closest_builtin)
return icon_info_new_builtin (closest_builtin);
return NULL; return NULL;
} }
@ -3460,52 +3368,6 @@ icon_info_dup (GtkIconInfo *icon_info)
return dup; return dup;
} }
static GtkIconInfo *
icon_info_new_builtin (BuiltinIcon *icon)
{
GtkIconInfo *icon_info = icon_info_new (ICON_THEME_DIR_THRESHOLD, icon->size, 1);
icon_info->cache_pixbuf = g_object_ref (icon->pixbuf);
return icon_info;
}
/**
* gtk_icon_info_copy: (skip)
* @icon_info: a #GtkIconInfo
*
* Make a copy of a #GtkIconInfo.
*
* Returns: (transfer full): the new GtkIconInfo
*
* Since: 2.4
*
* Deprecated: 3.8: Use g_object_ref()
*/
GtkIconInfo *
gtk_icon_info_copy (GtkIconInfo *icon_info)
{
g_return_val_if_fail (icon_info != NULL, NULL);
return g_object_ref (icon_info);
}
/**
* gtk_icon_info_free: (skip)
* @icon_info: a #GtkIconInfo
*
* Free a #GtkIconInfo and associated information
*
* Since: 2.4
*
* Deprecated: 3.8: Use g_object_unref()
*/
void
gtk_icon_info_free (GtkIconInfo *icon_info)
{
g_return_if_fail (icon_info != NULL);
g_object_unref (icon_info);
}
static void static void
gtk_icon_info_finalize (GObject *object) gtk_icon_info_finalize (GObject *object)
{ {
@ -3594,13 +3456,8 @@ gtk_icon_info_get_base_scale (GtkIconInfo *icon_info)
* gtk_icon_info_get_filename: * gtk_icon_info_get_filename:
* @icon_info: a #GtkIconInfo * @icon_info: a #GtkIconInfo
* *
* Gets the filename for the icon. If the %GTK_ICON_LOOKUP_USE_BUILTIN * Gets the filename for the icon.
* flag was passed to gtk_icon_theme_lookup_icon(), there may be no
* filename if a builtin icon is returned; in this case, you should
* use gtk_icon_info_get_builtin_pixbuf().
*
* Returns: (nullable) (type filename): the filename for the icon, or %NULL * Returns: (nullable) (type filename): the filename for the icon, or %NULL
* if gtk_icon_info_get_builtin_pixbuf() should be used instead.
* The return value is owned by GTK+ and should not be modified * The return value is owned by GTK+ and should not be modified
* or freed. * or freed.
* *
@ -3614,35 +3471,6 @@ gtk_icon_info_get_filename (GtkIconInfo *icon_info)
return icon_info->filename; return icon_info->filename;
} }
/**
* gtk_icon_info_get_builtin_pixbuf:
* @icon_info: a #GtkIconInfo
*
* Gets the built-in image for this icon, if any. To allow GTK+ to use
* built in icon images, you must pass the %GTK_ICON_LOOKUP_USE_BUILTIN
* to gtk_icon_theme_lookup_icon().
*
* Returns: (nullable) (transfer none): the built-in image pixbuf, or %NULL.
* No extra reference is added to the returned pixbuf, so if
* you want to keep it around, you must use g_object_ref().
* The returned image must not be modified.
*
* Since: 2.4
*
* Deprecated: 3.14: This function is deprecated, use
* gtk_icon_theme_add_resource_path() instead of builtin icons.
*/
GdkPixbuf *
gtk_icon_info_get_builtin_pixbuf (GtkIconInfo *icon_info)
{
g_return_val_if_fail (icon_info != NULL, NULL);
if (icon_info->filename)
return NULL;
return icon_info->cache_pixbuf;
}
/** /**
* gtk_icon_info_is_symbolic: * gtk_icon_info_is_symbolic:
* @icon_info: a #GtkIconInfo * @icon_info: a #GtkIconInfo
@ -5182,322 +5010,6 @@ gtk_icon_info_load_symbolic_for_context_finish (GtkIconInfo *icon_info,
return gtk_icon_info_load_symbolic_finish (icon_info, result, was_symbolic, error); return gtk_icon_info_load_symbolic_finish (icon_info, result, was_symbolic, error);
} }
static GdkRGBA *
color_to_rgba (GdkColor *color,
GdkRGBA *rgba)
{
rgba->red = color->red / 65535.0;
rgba->green = color->green / 65535.0;
rgba->blue = color->blue / 65535.0;
rgba->alpha = 1.0;
return rgba;
}
/**
* gtk_icon_info_load_symbolic_for_style:
* @icon_info: a #GtkIconInfo
* @style: a #GtkStyle to take the colors from
* @state: the widget state to use for colors
* @was_symbolic: (out) (allow-none): a #gboolean, returns whether the
* loaded icon was a symbolic one and whether the @fg color was
* applied to it.
* @error: (allow-none): location to store error information on failure,
* or %NULL.
*
* Loads an icon, modifying it to match the system colours for the foreground,
* success, warning and error colors provided. If the icon is not a symbolic
* one, the function will return the result from gtk_icon_info_load_icon().
*
* This allows loading symbolic icons that will match the system theme.
*
* See gtk_icon_info_load_symbolic() for more details.
*
* Returns: (transfer full): a #GdkPixbuf representing the loaded icon
*
* Since: 3.0
*
* Deprecated: 3.0: Use gtk_icon_info_load_symbolic_for_context() instead
*/
GdkPixbuf *
gtk_icon_info_load_symbolic_for_style (GtkIconInfo *icon_info,
GtkStyle *style,
GtkStateType state,
gboolean *was_symbolic,
GError **error)
{
GdkColor color;
GdkRGBA fg;
GdkRGBA success_color;
GdkRGBA *success_colorp;
GdkRGBA warning_color;
GdkRGBA *warning_colorp;
GdkRGBA error_color;
GdkRGBA *error_colorp;
gboolean is_symbolic;
g_return_val_if_fail (icon_info != NULL, NULL);
g_return_val_if_fail (style != NULL, NULL);
is_symbolic = gtk_icon_info_is_symbolic (icon_info);
if (was_symbolic)
*was_symbolic = is_symbolic;
if (!is_symbolic)
return gtk_icon_info_load_icon (icon_info, error);
color_to_rgba (&style->fg[state], &fg);
success_colorp = warning_colorp = error_colorp = NULL;
if (gtk_style_lookup_color (style, "success_color", &color))
success_colorp = color_to_rgba (&color, &success_color);
if (gtk_style_lookup_color (style, "warning_color", &color))
warning_colorp = color_to_rgba (&color, &warning_color);
if (gtk_style_lookup_color (style, "error_color", &color))
error_colorp = color_to_rgba (&color, &error_color);
return gtk_icon_info_load_symbolic_internal (icon_info,
&fg, success_colorp,
warning_colorp, error_colorp,
TRUE,
error);
}
/**
* gtk_icon_info_set_raw_coordinates:
* @icon_info: a #GtkIconInfo
* @raw_coordinates: whether the coordinates of embedded rectangles
* and attached points should be returned in their original
* (unscaled) form.
*
* Sets whether the coordinates returned by gtk_icon_info_get_embedded_rect()
* and gtk_icon_info_get_attach_points() should be returned in their
* original form as specified in the icon theme, instead of scaled
* appropriately for the pixbuf returned by gtk_icon_info_load_icon().
*
* Raw coordinates are somewhat strange; they are specified to be with
* respect to the unscaled pixmap for PNG and XPM icons, but for SVG
* icons, they are in a 1000x1000 coordinate space that is scaled
* to the final size of the icon. You can determine if the icon is an SVG
* icon by using gtk_icon_info_get_filename(), and seeing if it is non-%NULL
* and ends in .svg.
*
* This function is provided primarily to allow compatibility wrappers
* for older API's, and is not expected to be useful for applications.
*
* Since: 2.4
*
* Deprecated: 3.14: Embedded rectangles and attachment points are deprecated
*/
void
gtk_icon_info_set_raw_coordinates (GtkIconInfo *icon_info,
gboolean raw_coordinates)
{
}
/**
* gtk_icon_info_get_embedded_rect:
* @icon_info: a #GtkIconInfo
* @rectangle: (out): #GdkRectangle in which to store embedded
* rectangle coordinates; coordinates are only stored
* when this function returns %TRUE.
*
* This function is deprecated and always returns %FALSE.
*
* Returns: %FALSE
*
* Since: 2.4
*
* Deprecated: 3.14: Embedded rectangles are deprecated
*/
gboolean
gtk_icon_info_get_embedded_rect (GtkIconInfo *icon_info,
GdkRectangle *rectangle)
{
return FALSE;
}
/**
* gtk_icon_info_get_attach_points:
* @icon_info: a #GtkIconInfo
* @points: (allow-none) (array length=n_points) (out): location to store pointer
* to an array of points, or %NULL free the array of points with g_free().
* @n_points: (allow-none): location to store the number of points in @points,
* or %NULL
*
* This function is deprecated and always returns %FALSE.
*
* Returns: %FALSE
*
* Since: 2.4
*
* Deprecated: 3.14: Attachment points are deprecated
*/
gboolean
gtk_icon_info_get_attach_points (GtkIconInfo *icon_info,
GdkPoint **points,
int *n_points)
{
return FALSE;
}
/**
* gtk_icon_info_get_display_name:
* @icon_info: a #GtkIconInfo
*
* This function is deprecated and always returns %NULL.
*
* Returns: %NULL
*
* Since: 2.4
*
* Deprecated: 3.14: Display names are deprecated
*/
const char *
gtk_icon_info_get_display_name (GtkIconInfo *icon_info)
{
return NULL;
}
/*
* Builtin icons
*/
/**
* gtk_icon_theme_add_builtin_icon:
* @icon_name: the name of the icon to register
* @size: the size in pixels at which to register the icon (different
* images can be registered for the same icon name at different sizes.)
* @pixbuf: #GdkPixbuf that contains the image to use for @icon_name
*
* Registers a built-in icon for icon theme lookups. The idea
* of built-in icons is to allow an application or library
* that uses themed icons to function requiring files to
* be present in the file system. For instance, the default
* images for all of GTK+s stock icons are registered
* as built-icons.
*
* In general, if you use gtk_icon_theme_add_builtin_icon()
* you should also install the icon in the icon theme, so
* that the icon is generally available.
*
* This function will generally be used with pixbufs loaded
* via gdk_pixbuf_new_from_inline().
*
* Since: 2.4
*
* Deprecated: 3.14: Use gtk_icon_theme_add_resource_path()
* to add application-specific icons to the icon theme.
*/
void
gtk_icon_theme_add_builtin_icon (const char *icon_name,
int size,
GdkPixbuf *pixbuf)
{
BuiltinIcon *default_icon;
GSList *icons;
gpointer key;
g_return_if_fail (icon_name != NULL);
g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
if (!icon_theme_builtin_icons)
icon_theme_builtin_icons = g_hash_table_new (g_str_hash, g_str_equal);
icons = g_hash_table_lookup (icon_theme_builtin_icons, icon_name);
if (!icons)
key = g_strdup (icon_name);
else
key = (gpointer)icon_name; /* Won't get stored */
default_icon = g_new (BuiltinIcon, 1);
default_icon->size = size;
default_icon->pixbuf = g_object_ref (pixbuf);
icons = g_slist_prepend (icons, default_icon);
/* Replaces value, leaves key untouched
*/
g_hash_table_insert (icon_theme_builtin_icons, key, icons);
}
/* Look up a builtin icon; the min_difference_p and
* has_larger_p out parameters allow us to combine
* this lookup with searching through the actual directories
* of the hicolor icon theme. See theme_lookup_icon()
* for how they are used.
*/
static BuiltinIcon *
find_builtin_icon (const char *icon_name,
int size,
int scale,
int *min_difference_p)
{
GSList *icons = NULL;
int min_difference = G_MAXINT;
gboolean has_larger = FALSE;
BuiltinIcon *min_icon = NULL;
if (!icon_theme_builtin_icons)
return NULL;
size *= scale;
icons = g_hash_table_lookup (icon_theme_builtin_icons, icon_name);
while (icons)
{
BuiltinIcon *default_icon = icons->data;
int min, max, difference;
gboolean smaller;
min = default_icon->size - 2;
max = default_icon->size + 2;
smaller = size < min;
if (size < min)
difference = min - size;
else if (size > max)
difference = size - max;
else
difference = 0;
if (difference == 0)
{
min_difference = 0;
min_icon = default_icon;
break;
}
if (!has_larger)
{
if (difference < min_difference || smaller)
{
min_difference = difference;
min_icon = default_icon;
has_larger = smaller;
}
}
else
{
if (difference < min_difference && smaller)
{
min_difference = difference;
min_icon = default_icon;
}
}
icons = icons->next;
}
if (min_difference_p)
*min_difference_p = min_difference;
return min_icon;
}
/** /**
* gtk_icon_theme_lookup_by_gicon: * gtk_icon_theme_lookup_by_gicon:
* @icon_theme: a #GtkIconTheme * @icon_theme: a #GtkIconTheme
@ -5631,11 +5143,6 @@ gtk_icon_theme_lookup_by_gicon_for_scale (GtkIconTheme *icon_theme,
GList *list, *l; GList *list, *l;
GtkIconInfo *base_info, *emblem_info; GtkIconInfo *base_info, *emblem_info;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (GTK_IS_NUMERABLE_ICON (icon))
_gtk_numerable_icon_set_background_icon_size (GTK_NUMERABLE_ICON (icon), size / 2);
G_GNUC_END_IGNORE_DEPRECATIONS
base = g_emblemed_icon_get_icon (G_EMBLEMED_ICON (icon)); base = g_emblemed_icon_get_icon (G_EMBLEMED_ICON (icon));
base_info = gtk_icon_theme_lookup_by_gicon_for_scale (icon_theme, base, size, scale, flags); base_info = gtk_icon_theme_lookup_by_gicon_for_scale (icon_theme, base, size, scale, flags);
if (base_info) if (base_info)

View File

@ -104,10 +104,6 @@ struct _GtkIconThemeClass
* @GTK_ICON_LOOKUP_FORCE_SVG: Get SVG icons, even if gdk-pixbuf * @GTK_ICON_LOOKUP_FORCE_SVG: Get SVG icons, even if gdk-pixbuf
* doesnt support them. * doesnt support them.
* Cannot be used together with %GTK_ICON_LOOKUP_NO_SVG. * Cannot be used together with %GTK_ICON_LOOKUP_NO_SVG.
* @GTK_ICON_LOOKUP_USE_BUILTIN: When passed to
* gtk_icon_theme_lookup_icon() includes builtin icons
* as well as files. For a builtin icon, gtk_icon_info_get_filename()
* is %NULL and you need to call gtk_icon_info_get_builtin_pixbuf().
* @GTK_ICON_LOOKUP_GENERIC_FALLBACK: Try to shorten icon name at '-' * @GTK_ICON_LOOKUP_GENERIC_FALLBACK: Try to shorten icon name at '-'
* characters before looking at inherited themes. This flag is only * characters before looking at inherited themes. This flag is only
* supported in functions that take a single icon name. For more general * supported in functions that take a single icon name. For more general
@ -129,13 +125,12 @@ typedef enum
{ {
GTK_ICON_LOOKUP_NO_SVG = 1 << 0, GTK_ICON_LOOKUP_NO_SVG = 1 << 0,
GTK_ICON_LOOKUP_FORCE_SVG = 1 << 1, GTK_ICON_LOOKUP_FORCE_SVG = 1 << 1,
GTK_ICON_LOOKUP_USE_BUILTIN = 1 << 2, GTK_ICON_LOOKUP_GENERIC_FALLBACK = 1 << 2,
GTK_ICON_LOOKUP_GENERIC_FALLBACK = 1 << 3, GTK_ICON_LOOKUP_FORCE_SIZE = 1 << 3,
GTK_ICON_LOOKUP_FORCE_SIZE = 1 << 4, GTK_ICON_LOOKUP_FORCE_REGULAR = 1 << 4,
GTK_ICON_LOOKUP_FORCE_REGULAR = 1 << 5, GTK_ICON_LOOKUP_FORCE_SYMBOLIC = 1 << 5,
GTK_ICON_LOOKUP_FORCE_SYMBOLIC = 1 << 6, GTK_ICON_LOOKUP_DIR_LTR = 1 << 6,
GTK_ICON_LOOKUP_DIR_LTR = 1 << 7, GTK_ICON_LOOKUP_DIR_RTL = 1 << 7
GTK_ICON_LOOKUP_DIR_RTL = 1 << 8
} GtkIconLookupFlags; } GtkIconLookupFlags;
/** /**
@ -271,17 +266,8 @@ char * gtk_icon_theme_get_example_icon_name (GtkIconTheme
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
gboolean gtk_icon_theme_rescan_if_needed (GtkIconTheme *icon_theme); gboolean gtk_icon_theme_rescan_if_needed (GtkIconTheme *icon_theme);
GDK_DEPRECATED_IN_3_14_FOR(gtk_icon_theme_add_resource_path)
void gtk_icon_theme_add_builtin_icon (const char *icon_name,
int size,
GdkPixbuf *pixbuf);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GType gtk_icon_info_get_type (void) G_GNUC_CONST; GType gtk_icon_info_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_3_8_FOR(g_object_ref)
GtkIconInfo * gtk_icon_info_copy (GtkIconInfo *icon_info);
GDK_DEPRECATED_IN_3_8_FOR(g_object_unref)
void gtk_icon_info_free (GtkIconInfo *icon_info);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GtkIconInfo * gtk_icon_info_new_for_pixbuf (GtkIconTheme *icon_theme, GtkIconInfo * gtk_icon_info_new_for_pixbuf (GtkIconTheme *icon_theme,
@ -293,8 +279,6 @@ GDK_AVAILABLE_IN_3_10
int gtk_icon_info_get_base_scale (GtkIconInfo *icon_info); int gtk_icon_info_get_base_scale (GtkIconInfo *icon_info);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
const char * gtk_icon_info_get_filename (GtkIconInfo *icon_info); const char * gtk_icon_info_get_filename (GtkIconInfo *icon_info);
GDK_DEPRECATED_IN_3_14
GdkPixbuf * gtk_icon_info_get_builtin_pixbuf (GtkIconInfo *icon_info);
GDK_AVAILABLE_IN_3_12 GDK_AVAILABLE_IN_3_12
gboolean gtk_icon_info_is_symbolic (GtkIconInfo *icon_info); gboolean gtk_icon_info_is_symbolic (GtkIconInfo *icon_info);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
@ -351,25 +335,6 @@ GdkPixbuf * gtk_icon_info_load_symbolic_for_context_finish (GtkIconInf
GAsyncResult *res, GAsyncResult *res,
gboolean *was_symbolic, gboolean *was_symbolic,
GError **error); GError **error);
GDK_DEPRECATED_IN_3_0_FOR(gtk_icon_info_load_symbol_for_context)
GdkPixbuf * gtk_icon_info_load_symbolic_for_style (GtkIconInfo *icon_info,
GtkStyle *style,
GtkStateType state,
gboolean *was_symbolic,
GError **error);
GDK_DEPRECATED_IN_3_14
void gtk_icon_info_set_raw_coordinates (GtkIconInfo *icon_info,
gboolean raw_coordinates);
GDK_DEPRECATED_IN_3_14
gboolean gtk_icon_info_get_embedded_rect (GtkIconInfo *icon_info,
GdkRectangle *rectangle);
GDK_DEPRECATED_IN_3_14
gboolean gtk_icon_info_get_attach_points (GtkIconInfo *icon_info,
GdkPoint **points,
int *n_points);
GDK_DEPRECATED_IN_3_14
const char * gtk_icon_info_get_display_name (GtkIconInfo *icon_info);
G_END_DECLS G_END_DECLS