Remove GtkIconFactory

Move the icon size lookup API into gtkicontheme.c
This commit is contained in:
Timm Bäder 2016-10-05 18:35:06 +02:00 committed by Benjamin Otte
parent 5b00a31c30
commit ed184b3935
28 changed files with 161 additions and 3238 deletions

View File

@ -5810,7 +5810,6 @@ gtk_style_context_get_font
gtk_style_context_invalidate
gtk_style_context_state_is_running
gtk_style_context_lookup_color
gtk_style_context_lookup_icon_set
gtk_style_context_notify_state_change
gtk_style_context_pop_animatable_region
gtk_style_context_push_animatable_region
@ -5865,7 +5864,6 @@ gtk_render_line
gtk_render_option
gtk_render_slider
gtk_render_activity
gtk_render_icon_pixbuf
gtk_render_icon_surface
gtk_render_icon
gtk_render_insertion_cursor
@ -6413,73 +6411,6 @@ GtkIconThemePrivate
gtk_icon_theme_error_quark
</SECTION>
<SECTION>
<FILE>gtkiconfactory</FILE>
<TITLE>Themeable Stock Images</TITLE>
GtkIconSource
GtkIconFactory
GtkIconFactoryClass
GtkIconSet
GtkIconSize
gtk_icon_source_copy
gtk_icon_source_free
gtk_icon_factory_add
gtk_icon_factory_add_default
gtk_icon_factory_lookup
gtk_icon_factory_lookup_default
gtk_icon_factory_new
gtk_icon_factory_remove_default
gtk_icon_set_add_source
gtk_icon_set_copy
gtk_icon_set_new
gtk_icon_set_new_from_pixbuf
gtk_icon_set_ref
gtk_icon_set_render_icon_pixbuf
gtk_icon_set_render_icon_surface
gtk_icon_set_unref
gtk_icon_size_lookup
gtk_icon_size_lookup_for_settings
gtk_icon_size_register
gtk_icon_size_register_alias
gtk_icon_size_from_name
gtk_icon_size_get_name
gtk_icon_set_get_sizes
gtk_icon_source_get_direction
gtk_icon_source_get_direction_wildcarded
gtk_icon_source_get_filename
gtk_icon_source_get_pixbuf
gtk_icon_source_get_icon_name
gtk_icon_source_get_size
gtk_icon_source_get_size_wildcarded
gtk_icon_source_get_state
gtk_icon_source_get_state_wildcarded
gtk_icon_source_new
gtk_icon_source_set_direction
gtk_icon_source_set_direction_wildcarded
gtk_icon_source_set_filename
gtk_icon_source_set_pixbuf
gtk_icon_source_set_icon_name
gtk_icon_source_set_size
gtk_icon_source_set_size_wildcarded
gtk_icon_source_set_state
gtk_icon_source_set_state_wildcarded
<SUBSECTION Standard>
GTK_TYPE_ICON_FACTORY
GTK_ICON_FACTORY
GTK_IS_ICON_FACTORY
GTK_ICON_FACTORY_CLASS
GTK_ICON_FACTORY_GET_CLASS
GTK_IS_ICON_FACTORY_CLASS
GTK_TYPE_ICON_SET
GTK_TYPE_ICON_SOURCE
<SUBSECTION Private>
GtkIconFactoryPrivate
gtk_icon_factory_get_type
gtk_icon_set_get_type
gtk_icon_source_get_type
</SECTION>
<SECTION>
<FILE>gtkprintoperation</FILE>
<TITLE>High-level Printing API</TITLE>

View File

@ -4,7 +4,6 @@ deprecated_h_sources = \
deprecated/gtkactiongroup.h \
deprecated/gtkalignment.h \
deprecated/gtkgradient.h \
deprecated/gtkiconfactory.h \
deprecated/gtkradioaction.h \
deprecated/gtkrecentaction.h \
deprecated/gtkstock.h \
@ -17,7 +16,6 @@ deprecated_h_sources = \
deprecated_private_h_sources = \
deprecated/gtkgradientprivate.h \
deprecated/gtkiconfactoryprivate.h \
deprecated/gtkstylepropertiesprivate.h \
deprecated/gtksymboliccolorprivate.h
@ -27,7 +25,6 @@ deprecated_c_sources = \
deprecated/gtkactiongroup.c \
deprecated/gtkalignment.c \
deprecated/gtkgradient.c \
deprecated/gtkiconfactory.c \
deprecated/gtkradioaction.c \
deprecated/gtkrecentaction.c \
deprecated/gtkstock.c \

View File

@ -89,7 +89,6 @@
#include "gtkactiongroup.h"
#include "gtkaccellabel.h"
#include "gtkbutton.h"
#include "gtkiconfactory.h"
#include "gtkimage.h"
#include "gtkintl.h"
#include "gtklabel.h"

View File

@ -90,7 +90,6 @@
#include "gtkactiongroup.h"
#include "gtkbuildable.h"
#include "gtkiconfactory.h"
#include "gtkicontheme.h"
#include "gtkstock.h"
#include "gtktoggleaction.h"
@ -1314,14 +1313,7 @@ gtk_action_group_add_toggle_actions_full (GtkActionGroup *action_gro
if (entries[i].stock_id)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if (gtk_icon_factory_lookup_default (entries[i].stock_id))
g_object_set (action, "stock-id", entries[i].stock_id, NULL);
else
g_object_set (action, "icon-name", entries[i].stock_id, NULL);
G_GNUC_END_IGNORE_DEPRECATIONS;
g_object_set (action, "icon-name", entries[i].stock_id, NULL);
}
gtk_toggle_action_set_active (action, entries[i].is_active);
@ -1438,14 +1430,7 @@ gtk_action_group_add_radio_actions_full (GtkActionGroup *action_group
if (entries[i].stock_id)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if (gtk_icon_factory_lookup_default (entries[i].stock_id))
g_object_set (action, "stock-id", entries[i].stock_id, NULL);
else
g_object_set (action, "icon-name", entries[i].stock_id, NULL);
G_GNUC_END_IGNORE_DEPRECATIONS;
g_object_set (action, "icon-name", entries[i].stock_id, NULL);
}
if (i == 0)

File diff suppressed because it is too large Load Diff

View File

@ -1,217 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2000 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GTK_ICON_FACTORY_H__
#define __GTK_ICON_FACTORY_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gdk/gdk.h>
#include <gtk/gtkenums.h>
#include <gtk/gtktypes.h>
G_BEGIN_DECLS
#define GTK_TYPE_ICON_FACTORY (gtk_icon_factory_get_type ())
#define GTK_ICON_FACTORY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_ICON_FACTORY, GtkIconFactory))
#define GTK_ICON_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ICON_FACTORY, GtkIconFactoryClass))
#define GTK_IS_ICON_FACTORY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_ICON_FACTORY))
#define GTK_IS_ICON_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ICON_FACTORY))
#define GTK_ICON_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ICON_FACTORY, GtkIconFactoryClass))
#define GTK_TYPE_ICON_SET (gtk_icon_set_get_type ())
#define GTK_TYPE_ICON_SOURCE (gtk_icon_source_get_type ())
typedef struct _GtkIconFactory GtkIconFactory;
typedef struct _GtkIconFactoryPrivate GtkIconFactoryPrivate;
typedef struct _GtkIconFactoryClass GtkIconFactoryClass;
struct _GtkIconFactory
{
GObject parent_instance;
/*< private >*/
GtkIconFactoryPrivate *priv;
};
/**
* GtkIconFactoryClass:
* @parent_class: The parent class.
*/
struct _GtkIconFactoryClass
{
GObjectClass parent_class;
/*< private >*/
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
GDK_DEPRECATED_IN_3_10
GType gtk_icon_factory_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_3_10
GtkIconFactory* gtk_icon_factory_new (void);
GDK_DEPRECATED_IN_3_10
void gtk_icon_factory_add (GtkIconFactory *factory,
const gchar *stock_id,
GtkIconSet *icon_set);
GDK_DEPRECATED_IN_3_10
GtkIconSet* gtk_icon_factory_lookup (GtkIconFactory *factory,
const gchar *stock_id);
/* Manage the default icon factory stack */
GDK_DEPRECATED_IN_3_10
void gtk_icon_factory_add_default (GtkIconFactory *factory);
GDK_DEPRECATED_IN_3_10
void gtk_icon_factory_remove_default (GtkIconFactory *factory);
GDK_DEPRECATED_IN_3_10
GtkIconSet* gtk_icon_factory_lookup_default (const gchar *stock_id);
/* Get preferred real size from registered semantic size. Note that
* themes SHOULD use this size, but they arent required to; for size
* requests and such, you should get the actual pixbuf from the icon
* set and see what size was rendered.
*
* This function is intended for people who are scaling icons,
* rather than for people who are displaying already-scaled icons.
* That is, if you are displaying an icon, you should get the
* size from the rendered pixbuf, not from here.
*/
#ifndef GDK_MULTIHEAD_SAFE
GDK_AVAILABLE_IN_ALL
gboolean gtk_icon_size_lookup (GtkIconSize size,
gint *width,
gint *height);
#endif /* GDK_MULTIHEAD_SAFE */
GDK_DEPRECATED_IN_3_10_FOR(gtk_icon_size_lookup)
gboolean gtk_icon_size_lookup_for_settings (GtkSettings *settings,
GtkIconSize size,
gint *width,
gint *height);
GDK_DEPRECATED_IN_3_10
GtkIconSize gtk_icon_size_register (const gchar *name,
gint width,
gint height);
GDK_DEPRECATED_IN_3_10
void gtk_icon_size_register_alias (const gchar *alias,
GtkIconSize target);
GDK_DEPRECATED_IN_3_10
GtkIconSize gtk_icon_size_from_name (const gchar *name);
GDK_DEPRECATED_IN_3_10
const gchar* gtk_icon_size_get_name (GtkIconSize size);
/* Icon sets */
GDK_DEPRECATED_IN_3_10
GType gtk_icon_set_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_3_10
GtkIconSet* gtk_icon_set_new (void);
GDK_DEPRECATED_IN_3_10
GtkIconSet* gtk_icon_set_new_from_pixbuf (GdkPixbuf *pixbuf);
GDK_DEPRECATED_IN_3_10
GtkIconSet* gtk_icon_set_ref (GtkIconSet *icon_set);
GDK_DEPRECATED_IN_3_10
void gtk_icon_set_unref (GtkIconSet *icon_set);
GDK_DEPRECATED_IN_3_10
GtkIconSet* gtk_icon_set_copy (GtkIconSet *icon_set);
GDK_DEPRECATED_IN_3_10
void gtk_icon_set_add_source (GtkIconSet *icon_set,
const GtkIconSource *source);
GDK_DEPRECATED_IN_3_10
void gtk_icon_set_get_sizes (GtkIconSet *icon_set,
GtkIconSize **sizes,
gint *n_sizes);
GDK_DEPRECATED_IN_3_10
GType gtk_icon_source_get_type (void) G_GNUC_CONST;
GDK_DEPRECATED_IN_3_10
GtkIconSource* gtk_icon_source_new (void);
GDK_DEPRECATED_IN_3_10
GtkIconSource* gtk_icon_source_copy (const GtkIconSource *source);
GDK_DEPRECATED_IN_3_10
void gtk_icon_source_free (GtkIconSource *source);
GDK_DEPRECATED_IN_3_10
void gtk_icon_source_set_filename (GtkIconSource *source,
const gchar *filename);
GDK_DEPRECATED_IN_3_10
void gtk_icon_source_set_icon_name (GtkIconSource *source,
const gchar *icon_name);
GDK_DEPRECATED_IN_3_10
void gtk_icon_source_set_pixbuf (GtkIconSource *source,
GdkPixbuf *pixbuf);
GDK_DEPRECATED_IN_3_10
const gchar * gtk_icon_source_get_filename (const GtkIconSource *source);
GDK_DEPRECATED_IN_3_10
const gchar * gtk_icon_source_get_icon_name (const GtkIconSource *source);
GDK_DEPRECATED_IN_3_10
GdkPixbuf* gtk_icon_source_get_pixbuf (const GtkIconSource *source);
GDK_DEPRECATED_IN_3_10
void gtk_icon_source_set_direction_wildcarded (GtkIconSource *source,
gboolean setting);
GDK_DEPRECATED_IN_3_10
void gtk_icon_source_set_state_wildcarded (GtkIconSource *source,
gboolean setting);
GDK_DEPRECATED_IN_3_10
void gtk_icon_source_set_size_wildcarded (GtkIconSource *source,
gboolean setting);
GDK_DEPRECATED_IN_3_10
gboolean gtk_icon_source_get_size_wildcarded (const GtkIconSource *source);
GDK_DEPRECATED_IN_3_10
gboolean gtk_icon_source_get_state_wildcarded (const GtkIconSource *source);
GDK_DEPRECATED_IN_3_10
gboolean gtk_icon_source_get_direction_wildcarded (const GtkIconSource *source);
GDK_DEPRECATED_IN_3_10
void gtk_icon_source_set_direction (GtkIconSource *source,
GtkTextDirection direction);
GDK_DEPRECATED_IN_3_10
void gtk_icon_source_set_state (GtkIconSource *source,
GtkStateType state);
GDK_DEPRECATED_IN_3_10
void gtk_icon_source_set_size (GtkIconSource *source,
GtkIconSize size);
GDK_DEPRECATED_IN_3_10
GtkTextDirection gtk_icon_source_get_direction (const GtkIconSource *source);
GDK_DEPRECATED_IN_3_10
GtkStateType gtk_icon_source_get_state (const GtkIconSource *source);
GDK_DEPRECATED_IN_3_10
GtkIconSize gtk_icon_source_get_size (const GtkIconSource *source);
G_END_DECLS
#endif /* __GTK_ICON_FACTORY_H__ */

View File

@ -1,32 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2015 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_ICON_FACTORY_PRIVATE_H__
#define __GTK_ICON_FACTORY_PRIVATE_H__
#include <gtk/deprecated/gtkiconfactory.h>
GList * _gtk_icon_factory_list_ids (void);
void _gtk_icon_factory_ensure_default_icons (void);
GdkPixbuf * gtk_icon_set_render_icon_pixbuf_for_scale (GtkIconSet *icon_set,
GtkCssStyle *style,
GtkTextDirection direction,
GtkIconSize size,
gint scale);
#endif /* __GTK_ICON_FACTORY_PRIVATE_H__ */

View File

@ -30,8 +30,6 @@
#include "gtkprivate.h"
#include "gtkstock.h"
#include "gtkiconfactory.h"
#include "deprecated/gtkiconfactoryprivate.h"
#include "gtkintl.h"
/**
@ -245,7 +243,7 @@ gtk_stock_list_ids (void)
init_stock_hash ();
ids = g_hash_table_get_keys (stock_hash);
icon_ids = _gtk_icon_factory_list_ids ();
icon_ids = NULL;
ids = g_list_concat (ids, icon_ids);
ids = g_list_sort (ids, (GCompareFunc)strcmp);

View File

@ -1183,7 +1183,7 @@ gtk_theming_engine_render_icon_pixbuf (GtkThemingEngine *engine,
const GtkIconSource *source,
GtkIconSize size)
{
return gtk_render_icon_pixbuf (engine->priv->context, source, size);
return NULL;
}
static void

View File

@ -249,7 +249,6 @@
#include <gtk/deprecated/gtkactiongroup.h>
#include <gtk/deprecated/gtkalignment.h>
#include <gtk/deprecated/gtkgradient.h>
#include <gtk/deprecated/gtkiconfactory.h>
#include <gtk/deprecated/gtkradioaction.h>
#include <gtk/deprecated/gtkrecentaction.h>
#include <gtk/deprecated/gtkstock.h>

View File

@ -19,7 +19,6 @@
#include <stdlib.h>
#include <cairo-gobject.h>
#include "gtkcellrendererpixbuf.h"
#include "deprecated/gtkiconfactory.h"
#include "gtkiconhelperprivate.h"
#include "gtkicontheme.h"
#include "gtkintl.h"

View File

@ -28,7 +28,6 @@
#include "config.h"
#include "gtkcellrendererspinner.h"
#include "deprecated/gtkiconfactory.h"
#include "gtkicontheme.h"
#include "gtkintl.h"
#include "gtksettings.h"

View File

@ -31,7 +31,6 @@
#include "gtkdnd.h"
#include "gtkdndprivate.h"
#include "deprecated/gtkiconfactory.h"
#include "gtkicontheme.h"
#include "gtkimageprivate.h"
#include "gtkinvisible.h"

View File

@ -38,7 +38,6 @@
#include "gtkdnd.h"
#include "gtkdragdest.h"
#include "gtkicontheme.h"
#include "deprecated/gtkiconfactory.h"
#include "gtkimage.h"
#include "gtklabel.h"
#include "gtkliststore.h"

View File

@ -31,7 +31,6 @@
#include "gtkcsstransientnodeprivate.h"
#include "gtkiconthemeprivate.h"
#include "gtkrendericonprivate.h"
#include "deprecated/gtkiconfactoryprivate.h"
struct _GtkIconHelperPrivate {
GtkImageDefinition *def;

View File

@ -41,7 +41,6 @@
#include "gtkcsspalettevalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtkdebug.h"
#include "deprecated/gtkiconfactory.h"
#include "gtkiconcache.h"
#include "gtkintl.h"
#include "gtkmain.h"
@ -5554,3 +5553,150 @@ gtk_icon_info_new_for_file (GFile *file,
return info;
}
typedef struct _IconSize IconSize;
struct _IconSize
{
gint size;
gchar *name;
gint width;
gint height;
};
typedef struct _IconAlias IconAlias;
struct _IconAlias
{
gchar *name;
gint target;
};
static GHashTable *icon_aliases = NULL;
static IconSize *icon_sizes = NULL;
static gint icon_sizes_allocated = 0;
static gint icon_sizes_used = 0;
static void
init_icon_sizes (void)
{
if (icon_sizes == NULL)
{
#define NUM_BUILTIN_SIZES 7
/*gint i;*/
icon_aliases = g_hash_table_new (g_str_hash, g_str_equal);
icon_sizes = g_new (IconSize, NUM_BUILTIN_SIZES);
icon_sizes_allocated = NUM_BUILTIN_SIZES;
icon_sizes_used = NUM_BUILTIN_SIZES;
icon_sizes[GTK_ICON_SIZE_INVALID].size = 0;
icon_sizes[GTK_ICON_SIZE_INVALID].name = NULL;
icon_sizes[GTK_ICON_SIZE_INVALID].width = 0;
icon_sizes[GTK_ICON_SIZE_INVALID].height = 0;
/* the name strings aren't copied since we don't ever remove
* icon sizes, so we don't need to know whether they're static.
* Even if we did I suppose removing the builtin sizes would be
* disallowed.
*/
icon_sizes[GTK_ICON_SIZE_MENU].size = GTK_ICON_SIZE_MENU;
icon_sizes[GTK_ICON_SIZE_MENU].name = "gtk-menu";
icon_sizes[GTK_ICON_SIZE_MENU].width = 16;
icon_sizes[GTK_ICON_SIZE_MENU].height = 16;
icon_sizes[GTK_ICON_SIZE_BUTTON].size = GTK_ICON_SIZE_BUTTON;
icon_sizes[GTK_ICON_SIZE_BUTTON].name = "gtk-button";
icon_sizes[GTK_ICON_SIZE_BUTTON].width = 16;
icon_sizes[GTK_ICON_SIZE_BUTTON].height = 16;
icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].size = GTK_ICON_SIZE_SMALL_TOOLBAR;
icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].name = "gtk-small-toolbar";
icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].width = 16;
icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].height = 16;
icon_sizes[GTK_ICON_SIZE_LARGE_TOOLBAR].size = GTK_ICON_SIZE_LARGE_TOOLBAR;
icon_sizes[GTK_ICON_SIZE_LARGE_TOOLBAR].name = "gtk-large-toolbar";
icon_sizes[GTK_ICON_SIZE_LARGE_TOOLBAR].width = 24;
icon_sizes[GTK_ICON_SIZE_LARGE_TOOLBAR].height = 24;
icon_sizes[GTK_ICON_SIZE_DND].size = GTK_ICON_SIZE_DND;
icon_sizes[GTK_ICON_SIZE_DND].name = "gtk-dnd";
icon_sizes[GTK_ICON_SIZE_DND].width = 32;
icon_sizes[GTK_ICON_SIZE_DND].height = 32;
icon_sizes[GTK_ICON_SIZE_DIALOG].size = GTK_ICON_SIZE_DIALOG;
icon_sizes[GTK_ICON_SIZE_DIALOG].name = "gtk-dialog";
icon_sizes[GTK_ICON_SIZE_DIALOG].width = 48;
icon_sizes[GTK_ICON_SIZE_DIALOG].height = 48;
g_assert ((GTK_ICON_SIZE_DIALOG + 1) == NUM_BUILTIN_SIZES);
/* Alias everything to itself. */
/*i = 1; [> skip invalid size <]*/
/*while (i < NUM_BUILTIN_SIZES)*/
/*{*/
/*gtk_icon_size_register_alias (icon_sizes[i].name, icon_sizes[i].size);*/
/*++i;*/
/*}*/
#undef NUM_BUILTIN_SIZES
}
}
static gboolean
icon_size_lookup_intern (GtkIconSize size,
gint *widthp,
gint *heightp)
{
init_icon_sizes ();
if (size == (GtkIconSize)-1)
return FALSE;
if (size >= icon_sizes_used)
return FALSE;
if (size == GTK_ICON_SIZE_INVALID)
return FALSE;
if (widthp)
*widthp = icon_sizes[size].width;
if (heightp)
*heightp = icon_sizes[size].height;
return TRUE;
}
/**
* gtk_icon_size_lookup:
* @size: (type int): an icon size (#GtkIconSize)
* @width: (out) (optional): location to store icon width
* @height: (out) (optional): location to store icon height
*
* Obtains the pixel size of a semantic icon size @size:
* #GTK_ICON_SIZE_MENU, #GTK_ICON_SIZE_BUTTON, etc. This function
* isnt normally needed, gtk_icon_theme_load_icon() is the usual
* way to get an icon for rendering, then just look at the size of
* the rendered pixbuf. The rendered pixbuf may not even correspond to
* the width/height returned by gtk_icon_size_lookup(), because themes
* are free to render the pixbuf however they like, including changing
* the usual size.
*
* Returns: %TRUE if @size was a valid size
*/
gboolean
gtk_icon_size_lookup (GtkIconSize size,
gint *widthp,
gint *heightp)
{
GTK_NOTE (MULTIHEAD,
g_warning ("gtk_icon_size_lookup ()) is not multihead safe"));
return icon_size_lookup_intern (size, widthp, heightp);
}

View File

@ -365,6 +365,14 @@ gboolean gtk_icon_info_get_attach_points (GtkIconInfo *icon_info
GDK_DEPRECATED_IN_3_14
const gchar * gtk_icon_info_get_display_name (GtkIconInfo *icon_info);
#ifndef GDK_MULTIHEAD_SAFE
GDK_AVAILABLE_IN_ALL
gboolean gtk_icon_size_lookup (GtkIconSize size,
gint *width,
gint *height);
#endif /* GDK_MULTIHEAD_SAFE */
G_END_DECLS
#endif /* __GTK_ICON_THEME_H__ */

View File

@ -991,105 +991,6 @@ gtk_render_activity (GtkStyleContext *context,
gtk_css_style_render_icon (gtk_style_context_lookup_style (context), cr, x, y, width, height, GTK_CSS_IMAGE_BUILTIN_SPINNER);
}
static GdkPixbuf *
scale_or_ref (GdkPixbuf *src,
gint width,
gint height)
{
if (width == gdk_pixbuf_get_width (src) &&
height == gdk_pixbuf_get_height (src))
return g_object_ref (src);
else
return gdk_pixbuf_scale_simple (src,
width, height,
GDK_INTERP_BILINEAR);
}
GdkPixbuf *
gtk_render_icon_pixbuf_unpacked (GdkPixbuf *base_pixbuf,
GtkIconSize size,
GtkCssIconEffect icon_effect)
{
GdkPixbuf *scaled;
GdkPixbuf *stated;
cairo_surface_t *surface;
g_return_val_if_fail (base_pixbuf != NULL, NULL);
/* If the size was wildcarded, and we're allowed to scale, then scale; otherwise,
* leave it alone.
*/
if (size != (GtkIconSize) -1)
{
int width = 1;
int height = 1;
if (!gtk_icon_size_lookup (size, &width, &height))
{
g_warning (G_STRLOC ": invalid icon size '%d'", size);
return NULL;
}
scaled = scale_or_ref (base_pixbuf, width, height);
}
else
{
scaled = g_object_ref (base_pixbuf);
}
if (icon_effect != GTK_CSS_ICON_EFFECT_NONE)
{
surface = gdk_cairo_surface_create_from_pixbuf (scaled, 1, NULL);
gtk_css_icon_effect_apply (icon_effect, surface);
stated = gdk_pixbuf_get_from_surface (surface, 0, 0,
cairo_image_surface_get_width (surface),
cairo_image_surface_get_height (surface));
cairo_surface_destroy (surface);
}
else
{
stated = scaled;
}
return stated;
}
/**
* gtk_render_icon_pixbuf:
* @context: a #GtkStyleContext
* @source: the #GtkIconSource specifying the icon to render
* @size: (type int): the size (#GtkIconSize) to render the icon at.
* A size of `(GtkIconSize) -1` means render at the size of the source
* and dont scale.
*
* Renders the icon specified by @source at the given @size, returning the result
* in a pixbuf.
*
* Returns: (transfer full): a newly-created #GdkPixbuf containing the rendered icon
*
* Since: 3.0
*
* Deprecated: 3.10: Use gtk_icon_theme_load_icon() instead.
**/
GdkPixbuf *
gtk_render_icon_pixbuf (GtkStyleContext *context,
const GtkIconSource *source,
GtkIconSize size)
{
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
g_return_val_if_fail (size > GTK_ICON_SIZE_INVALID || size == (GtkIconSize)-1, NULL);
g_return_val_if_fail (source != NULL, NULL);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
return gtk_render_icon_pixbuf_unpacked (gtk_icon_source_get_pixbuf (source),
gtk_icon_source_get_size_wildcarded (source) ? size : -1,
gtk_icon_source_get_state_wildcarded (source)
? _gtk_css_icon_effect_value_get (
_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_ICON_EFFECT))
: GTK_CSS_ICON_EFFECT_NONE);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
/**
* gtk_render_icon:
* @context: a #GtkStyleContext

View File

@ -142,10 +142,6 @@ void gtk_render_activity (GtkStyleContext *context,
gdouble y,
gdouble width,
gdouble height);
GDK_DEPRECATED_IN_3_10_FOR(gtk_icon_theme_load_icon)
GdkPixbuf * gtk_render_icon_pixbuf (GtkStyleContext *context,
const GtkIconSource *source,
GtkIconSize size);
GDK_AVAILABLE_IN_3_2
void gtk_render_icon (GtkStyleContext *context,
cairo_t *cr,

View File

@ -31,8 +31,4 @@ void gtk_render_content_path (GtkStyleContext *context
double width,
double height);
GdkPixbuf * gtk_render_icon_pixbuf_unpacked (GdkPixbuf *base_pixbuf,
GtkIconSize size,
GtkCssIconEffect icon_effect);
#endif /* __GTK_RENDER_PRIVATE_H__ */

View File

@ -1921,38 +1921,6 @@ gtk_style_context_get_style (GtkStyleContext *context,
va_end (args);
}
/**
* gtk_style_context_lookup_icon_set:
* @context: a #GtkStyleContext
* @stock_id: an icon name
*
* Looks up @stock_id in the icon factories associated to @context and
* the default icon factory, returning an icon set if found, otherwise
* %NULL.
*
* Returns: (nullable) (transfer none): The looked up %GtkIconSet, or %NULL
*
* Deprecated: 3.10: Use gtk_icon_theme_lookup_icon() instead.
**/
GtkIconSet *
gtk_style_context_lookup_icon_set (GtkStyleContext *context,
const gchar *stock_id)
{
GtkIconSet *icon_set;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
g_return_val_if_fail (stock_id != NULL, NULL);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
icon_set = gtk_icon_factory_lookup_default (stock_id);
G_GNUC_END_IGNORE_DEPRECATIONS;
return icon_set;
}
/**
* gtk_style_context_set_screen:
* @context: a #GtkStyleContext

View File

@ -1127,9 +1127,6 @@ GDK_AVAILABLE_IN_ALL
void gtk_style_context_get_style (GtkStyleContext *context,
...);
GDK_DEPRECATED_IN_3_10_FOR(gtk_icon_theme_lookup_icon)
GtkIconSet * gtk_style_context_lookup_icon_set (GtkStyleContext *context,
const gchar *stock_id);
GDK_DEPRECATED_IN_3_10
GdkPixbuf * gtk_icon_set_render_icon_pixbuf (GtkIconSet *icon_set,
GtkStyleContext *context,

View File

@ -123,34 +123,3 @@ gtk_style_provider_get_style_property (GtkStyleProvider *provider,
return iface->get_style_property (provider, path, state, pspec, value);
}
/**
* gtk_style_provider_get_icon_factory:
* @provider: a #GtkStyleProvider
* @path: #GtkWidgetPath to query
*
* Returns the #GtkIconFactory defined to be in use for @path, or %NULL if none
* is defined.
*
* Returns: (nullable) (transfer none): The icon factory to use for @path, or %NULL
*
* Since: 3.0
*
* Deprecated: 3.8: Will always return %NULL for all GTK-provided style providers.
**/
GtkIconFactory *
gtk_style_provider_get_icon_factory (GtkStyleProvider *provider,
GtkWidgetPath *path)
{
GtkStyleProviderIface *iface;
g_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
g_return_val_if_fail (path != NULL, NULL);
iface = GTK_STYLE_PROVIDER_GET_IFACE (provider);
if (!iface->get_icon_factory)
return NULL;
return iface->get_icon_factory (provider, path);
}

View File

@ -24,7 +24,6 @@
#include <glib-object.h>
#include <gtk/gtkenums.h>
#include <gtk/deprecated/gtkiconfactory.h>
#include <gtk/deprecated/gtkstyleproperties.h>
#include <gtk/gtktypes.h>
@ -110,9 +109,6 @@ struct _GtkStyleProviderIface
GtkStateFlags state,
GParamSpec *pspec,
GValue *value);
GtkIconFactory * (* get_icon_factory) (GtkStyleProvider *provider,
GtkWidgetPath *path);
};
GDK_AVAILABLE_IN_ALL
@ -129,10 +125,6 @@ gboolean gtk_style_provider_get_style_property (GtkStyleProvider *provider,
GParamSpec *pspec,
GValue *value);
GDK_DEPRECATED_IN_3_8_FOR(NULL)
GtkIconFactory * gtk_style_provider_get_icon_factory (GtkStyleProvider *provider,
GtkWidgetPath *path);
G_END_DECLS
#endif /* __GTK_STYLE_PROVIDER_H__ */

View File

@ -28,6 +28,7 @@
#include "gtkintl.h"
#include "gtktoolbarprivate.h"
#include "deprecated/gtkactivatable.h"
#include "gtkicontheme.h"
#include "gtkactionable.h"
#include "gtkprivate.h"

View File

@ -9644,54 +9644,6 @@ gtk_widget_create_pango_layout (GtkWidget *widget,
return layout;
}
/**
* gtk_widget_render_icon_pixbuf:
* @widget: a #GtkWidget
* @stock_id: a stock ID
* @size: (type int): a stock size (#GtkIconSize). A size of `(GtkIconSize)-1`
* means render at the size of the source and dont scale (if there are
* multiple source sizes, GTK+ picks one of the available sizes).
*
* A convenience function that uses the theme engine and style
* settings for @widget to look up @stock_id and render it to
* a pixbuf. @stock_id should be a stock icon ID such as
* #GTK_STOCK_OPEN or #GTK_STOCK_OK. @size should be a size
* such as #GTK_ICON_SIZE_MENU.
*
* The pixels in the returned #GdkPixbuf are shared with the rest of
* the application and should not be modified. The pixbuf should be freed
* after use with g_object_unref().
*
* Returns: (transfer full) (nullable): a new pixbuf, or %NULL if the
* stock ID wasnt known
*
* Since: 3.0
*
* Deprecated: 3.10: Use gtk_icon_theme_load_icon() instead.
**/
GdkPixbuf*
gtk_widget_render_icon_pixbuf (GtkWidget *widget,
const gchar *stock_id,
GtkIconSize size)
{
GtkStyleContext *context;
GtkIconSet *icon_set;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
g_return_val_if_fail (stock_id != NULL, NULL);
g_return_val_if_fail (size > GTK_ICON_SIZE_INVALID || size == -1, NULL);
context = _gtk_widget_get_style_context (widget);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
icon_set = gtk_style_context_lookup_icon_set (context, stock_id);
if (icon_set == NULL)
return NULL;
return gtk_icon_set_render_icon_pixbuf (icon_set, context, size);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
/**
* gtk_widget_set_parent_window:
* @widget: a #GtkWidget.

View File

@ -1111,11 +1111,6 @@ GDK_AVAILABLE_IN_ALL
PangoLayout *gtk_widget_create_pango_layout (GtkWidget *widget,
const gchar *text);
GDK_DEPRECATED_IN_3_10_FOR(gtk_icon_theme_load_icon)
GdkPixbuf *gtk_widget_render_icon_pixbuf (GtkWidget *widget,
const gchar *stock_id,
GtkIconSize size);
/* Push/pop pairs, to change default values upon a widget's creation.
* This will override the values that got set by the
* gtk_widget_set_default_* () functions.

View File

@ -1858,75 +1858,7 @@ test_reference_counting (void)
g_object_unref (builder);
}
static void
test_icon_factory (void)
{
GtkBuilder *builder;
const gchar buffer1[] =
"<interface>"
" <object class=\"GtkIconFactory\" id=\"iconfactory1\">"
" <sources>"
" <source stock-id=\"apple-red\" filename=\"apple-red.png\"/>"
" </sources>"
" </object>"
"</interface>";
const gchar buffer2[] =
"<interface>"
" <object class=\"GtkIconFactory\" id=\"iconfactory1\">"
" <sources>"
" <source stock-id=\"sliff\" direction=\"rtl\" state=\"active\""
" size=\"menu\" filename=\"sloff.png\"/>"
" <source stock-id=\"sliff\" direction=\"ltr\" state=\"selected\""
" size=\"dnd\" filename=\"slurf.png\"/>"
" </sources>"
" </object>"
"</interface>";
GObject *factory;
GtkIconSet *icon_set;
GtkIconSource *icon_source;
GtkWidget *image;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
builder = builder_new_from_string (buffer1, -1, NULL);
factory = gtk_builder_get_object (builder, "iconfactory1");
g_assert (factory != NULL);
icon_set = gtk_icon_factory_lookup (GTK_ICON_FACTORY (factory), "apple-red");
g_assert (icon_set != NULL);
gtk_icon_factory_add_default (GTK_ICON_FACTORY (factory));
image = gtk_image_new_from_icon_name ("audio-volume-high", GTK_ICON_SIZE_BUTTON);
g_assert (image != NULL);
g_object_ref_sink (image);
g_object_unref (image);
g_object_unref (builder);
builder = builder_new_from_string (buffer2, -1, NULL);
factory = gtk_builder_get_object (builder, "iconfactory1");
g_assert (factory != NULL);
icon_set = gtk_icon_factory_lookup (GTK_ICON_FACTORY (factory), "sliff");
g_assert (icon_set != NULL);
g_assert (g_slist_length (icon_set->sources) == 2);
icon_source = icon_set->sources->data;
g_assert (gtk_icon_source_get_direction (icon_source) == GTK_TEXT_DIR_RTL);
g_assert (gtk_icon_source_get_state (icon_source) == GTK_STATE_ACTIVE);
g_assert (gtk_icon_source_get_size (icon_source) == GTK_ICON_SIZE_MENU);
g_assert (g_str_has_suffix (gtk_icon_source_get_filename (icon_source), "sloff.png"));
icon_source = icon_set->sources->next->data;
g_assert (gtk_icon_source_get_direction (icon_source) == GTK_TEXT_DIR_LTR);
g_assert (gtk_icon_source_get_state (icon_source) == GTK_STATE_SELECTED);
g_assert (gtk_icon_source_get_size (icon_source) == GTK_ICON_SIZE_DND);
g_assert (g_str_has_suffix (gtk_icon_source_get_filename (icon_source), "slurf.png"));
g_object_unref (builder);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
typedef struct {
gboolean weight;
@ -2938,7 +2870,6 @@ main (int argc, char **argv)
g_test_add_func ("/Builder/Value From String", test_value_from_string);
g_test_add_func ("/Builder/Reference Counting", test_reference_counting);
g_test_add_func ("/Builder/Window", test_window);
g_test_add_func ("/Builder/IconFactory", test_icon_factory);
g_test_add_func ("/Builder/PangoAttributes", test_pango_attributes);
g_test_add_func ("/Builder/Requires", test_requires);
g_test_add_func ("/Builder/AddObjects", test_add_objects);