Commit ed184b39 authored by Timm Bäder's avatar Timm Bäder 🤔 Committed by Benjamin Otte
Browse files

Remove GtkIconFactory

Move the icon size lookup API into gtkicontheme.c
parent 5b00a31c
......@@ -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>
......
......@@ -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 \
......
......@@ -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"
......
......@@ -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)
......
This diff is collapsed.
/* 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 aren’t 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__ */
/* 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__ */
......@@ -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);
......
......@@ -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
......
......@@ -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>
......
......@@ -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"
......
......@@ -28,7 +28,6 @@
#include "config.h"
#include "gtkcellrendererspinner.h"
#include "deprecated/gtkiconfactory.h"
#include "gtkicontheme.h"
#include "gtkintl.h"
#include "gtksettings.h"
......
......@@ -31,7 +31,6 @@
#include "gtkdnd.h"
#include "gtkdndprivate.h"
#include "deprecated/gtkiconfactory.h"
#include "gtkicontheme.h"
#include "gtkimageprivate.h"
#include "gtkinvisible.h"
......
......@@ -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"
......
......@@ -31,7 +31,6 @@
#include "gtkcsstransientnodeprivate.h"
#include "gtkiconthemeprivate.h"
#include "gtkrendericonprivate.h"
#include "deprecated/gtkiconfactoryprivate.h"
struct _GtkIconHelperPrivate {
GtkImageDefinition *def;
......
......@@ -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)