Re: stock icon sizes
- From: Havoc Pennington <hp redhat com>
- To: gtk-devel-list gnome org
- Subject: Re: stock icon sizes
- Date: 07 Mar 2001 19:50:49 -0500
Hi,
So here's the patch for that.
Havoc
Index: gtk/gtkenums.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkenums.h,v
retrieving revision 1.35
diff -u -u -r1.35 gtkenums.h
--- gtk/gtkenums.h 2001/03/07 21:10:43 1.35
+++ gtk/gtkenums.h 2001/03/08 00:48:21
@@ -92,6 +92,17 @@
GTK_DIR_RIGHT
} GtkDirectionType;
+/* Built-in stock icon sizes */
+typedef enum
+{
+ GTK_ICON_SIZE_INVALID,
+ GTK_ICON_SIZE_MENU,
+ GTK_ICON_SIZE_SMALL_TOOLBAR,
+ GTK_ICON_SIZE_LARGE_TOOLBAR,
+ GTK_ICON_SIZE_BUTTON,
+ GTK_ICON_SIZE_DIALOG
+} GtkIconSize;
+
/* Reading directions for text */
typedef enum
{
Index: gtk/gtkiconfactory.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkiconfactory.c,v
retrieving revision 1.9
diff -u -u -r1.9 gtkiconfactory.c
--- gtk/gtkiconfactory.c 2001/03/07 21:10:44 1.9
+++ gtk/gtkiconfactory.c 2001/03/08 00:48:21
@@ -291,14 +291,14 @@
static GtkIconSet *
sized_icon_set_from_inline (const guchar *inline_data,
- const gchar *size)
+ GtkIconSize size)
{
GtkIconSet *set;
- GtkIconSource source = { NULL, NULL, 0, 0, NULL,
+ GtkIconSource source = { NULL, NULL, 0, 0, 0,
TRUE, TRUE, FALSE };
- source.size = (gchar*) size;
+ source.size = size;
set = gtk_icon_set_new ();
@@ -338,7 +338,7 @@
static void
add_sized (GtkIconFactory *factory,
const guchar *inline_data,
- const gchar *size,
+ GtkIconSize size,
const gchar *stock_id)
{
GtkIconSet *set;
@@ -393,216 +393,234 @@
/* Sizes */
-static GHashTable *icon_sizes = NULL;
-
typedef struct _IconSize IconSize;
struct _IconSize
{
+ gint size;
gchar *name;
- gboolean is_alias;
-
- union
- {
- gchar *target;
- struct
- {
- gint width;
- gint height;
- } size;
- } d;
+ gint width;
+ gint height;
};
-
-static IconSize*
-icon_size_new (const gchar *name)
-{
- IconSize *is;
-
- is = g_new0 (IconSize, 1);
-
- is->name = g_strdup (name);
-
- return is;
-}
-
-static void
-icon_size_free (IconSize *is)
-{
- g_free (is->name);
-
- if (is->is_alias)
- g_free (is->d.target);
- g_free (is);
-}
+typedef struct _IconAlias IconAlias;
-static void
-icon_size_insert (IconSize *is)
+struct _IconAlias
{
- gpointer old_key, old_value;
-
- /* Remove old ones */
- if (g_hash_table_lookup_extended (icon_sizes,
- is->name,
- &old_key, &old_value))
- {
- g_hash_table_remove (icon_sizes, is->name);
- icon_size_free (old_value);
- }
-
- g_hash_table_insert (icon_sizes,
- is->name, is);
-
-}
-
-static IconSize*
-icon_size_lookup (const gchar *name)
-{
- IconSize *is;
-
- is = g_hash_table_lookup (icon_sizes,
- name);
-
- while (is && is->is_alias)
- {
- is = g_hash_table_lookup (icon_sizes,
- is->d.target);
-
- }
+ gchar *name;
+ gint target;
+};
- return is;
-}
+static GHashTable *icon_aliases = NULL;
+static IconSize *icon_sizes = NULL;
+static gint icon_sizes_allocated = 0;
+static gint icon_sizes_used = 0;
static void
-icon_size_add (const gchar *name,
- gint width,
- gint height)
-{
- IconSize *is;
-
- is = icon_size_new (name);
- is->d.size.width = width;
- is->d.size.height = height;
-
- icon_size_insert (is);
-}
-
-static void
-icon_alias_add (const gchar *name,
- const gchar *target)
-{
- IconSize *is;
-
- is = icon_size_new (name);
- is->is_alias = TRUE;
-
- is->d.target = g_strdup (target);
-
- icon_size_insert (is);
-}
-
-static void
init_icon_sizes (void)
{
if (icon_sizes == NULL)
{
- icon_sizes = g_hash_table_new (g_str_hash, g_str_equal);
+#define NUM_BUILTIN_SIZES 6
+ gint i;
- icon_size_add (GTK_ICON_SIZE_MENU, 16, 16);
- icon_size_add (GTK_ICON_SIZE_BUTTON, 24, 24);
- icon_size_add (GTK_ICON_SIZE_SMALL_TOOLBAR, 18, 18);
- icon_size_add (GTK_ICON_SIZE_LARGE_TOOLBAR, 24, 24);
- icon_size_add (GTK_ICON_SIZE_DIALOG, 48, 48);
+ 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 = 24;
+ icon_sizes[GTK_ICON_SIZE_BUTTON].height = 24;
+
+ 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 = 18;
+ icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].height = 18;
+
+ 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_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
}
}
/**
* gtk_icon_size_lookup:
- * @alias: name of an icon size
+ * @size: an icon size
* @width: location to store icon width
* @height: location to store icon height
*
- * Obtains the pixel size of an icon, normally @alias would be
+ * Obtains the pixel size of a semantic icon size, normally @size would be
* #GTK_ICON_SIZE_MENU, #GTK_ICON_SIZE_BUTTON, etc. This function
* isn't normally needed, gtk_widget_render_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.
+ * are free to render the pixbuf however they like, including changing
+ * the usual size.
*
- * Return value: %TRUE if @alias was known.
+ * Return value: %TRUE if @size was a valid size
**/
gboolean
-gtk_icon_size_lookup (const gchar *alias,
+gtk_icon_size_lookup (GtkIconSize size,
gint *widthp,
gint *heightp)
{
- IconSize *is;
-
- g_return_val_if_fail (alias != NULL, FALSE);
-
init_icon_sizes ();
-
- is = icon_size_lookup (alias);
- if (is == NULL)
+ if (size >= icon_sizes_used)
return FALSE;
+ if (size == GTK_ICON_SIZE_INVALID)
+ return FALSE;
+
if (widthp)
- *widthp = is->d.size.width;
+ *widthp = icon_sizes[size].width;
if (heightp)
- *heightp = is->d.size.height;
+ *heightp = icon_sizes[size].height;
return TRUE;
}
/**
* gtk_icon_size_register:
- * @alias: name of the icon size
+ * @name: name of the icon size
* @width: the icon width
* @height: the icon height
*
* Registers a new icon size, along the same lines as #GTK_ICON_SIZE_MENU,
- * etc.
+ * etc. Returns the integer value for the size.
+ *
+ * Returns: integer value representing the size
*
**/
-void
-gtk_icon_size_register (const gchar *alias,
+GtkIconSize
+gtk_icon_size_register (const gchar *name,
gint width,
gint height)
{
- g_return_if_fail (alias != NULL);
- g_return_if_fail (width > 0);
- g_return_if_fail (height > 0);
+ g_return_val_if_fail (name != NULL, 0);
+ g_return_val_if_fail (width > 0, 0);
+ g_return_val_if_fail (height > 0, 0);
init_icon_sizes ();
+
+ if (icon_sizes_used == icon_sizes_allocated)
+ {
+ icon_sizes_allocated *= 2;
+ icon_sizes = g_renew (IconSize, icon_sizes, icon_sizes_allocated);
+ }
+
+ icon_sizes[icon_sizes_used].size = icon_sizes_used;
+ icon_sizes[icon_sizes_used].name = g_strdup (name);
+ icon_sizes[icon_sizes_used].width = width;
+ icon_sizes[icon_sizes_used].height = height;
+
+ /* alias to self. */
+ gtk_icon_size_register_alias (icon_sizes[icon_sizes_used].name,
+ icon_sizes[icon_sizes_used].size);
+
+ ++icon_sizes_used;
- icon_size_add (alias, width, height);
+ return icon_sizes_used - 1;
}
/**
* gtk_icon_size_register_alias:
* @alias: an alias for @target
- * @target: an existing icon size name
+ * @target: an existing icon size
*
- * Registers @alias as another name for @target, usable when calling
- * gtk_icon_size_lookup().
- *
+ * Registers @alias as another name for @target.
+ * So calling gtk_icon_size_from_name() with @alias as argument
+ * will return @target.
+ *
**/
void
gtk_icon_size_register_alias (const gchar *alias,
- const gchar *target)
+ GtkIconSize target)
{
+ IconAlias *ia;
+
g_return_if_fail (alias != NULL);
- g_return_if_fail (target != NULL);
init_icon_sizes ();
+
+ if (g_hash_table_lookup (icon_aliases, alias))
+ g_warning ("gtk_icon_size_register_alias: Icon size name '%s' already exists", alias);
- icon_alias_add (alias, target);
+ if (!gtk_icon_size_lookup (target, NULL, NULL))
+ g_warning ("gtk_icon_size_register_alias: Icon size %d does not exist", target);
+
+ ia = g_new (IconAlias, 1);
+ ia->name = g_strdup (alias);
+ ia->target = target;
+
+ g_hash_table_insert (icon_aliases, ia->name, ia);
}
+GtkIconSize
+gtk_icon_size_from_name (const gchar *name)
+{
+ IconAlias *ia;
+
+ init_icon_sizes ();
+
+ ia = g_hash_table_lookup (icon_aliases, name);
+
+ if (ia)
+ return ia->target;
+ else
+ return GTK_ICON_SIZE_INVALID;
+}
+
+G_CONST_RETURN gchar*
+gtk_icon_size_get_name (GtkIconSize size)
+{
+ if (size >= icon_sizes_used)
+ return NULL;
+ else
+ return icon_sizes[size].name;
+}
+
/* Icon Set */
@@ -614,12 +632,12 @@
GtkStyle *style,
GtkTextDirection direction,
GtkStateType state,
- const gchar *size);
+ GtkIconSize size);
static void add_to_cache (GtkIconSet *icon_set,
GtkStyle *style,
GtkTextDirection direction,
GtkStateType state,
- const gchar *size,
+ GtkIconSize size,
GdkPixbuf *pixbuf);
static void clear_cache (GtkIconSet *icon_set,
gboolean style_detach);
@@ -691,7 +709,7 @@
{
GtkIconSet *set;
- GtkIconSource source = { NULL, NULL, 0, 0, NULL,
+ GtkIconSource source = { NULL, NULL, 0, 0, 0,
TRUE, TRUE, TRUE };
g_return_val_if_fail (pixbuf != NULL, NULL);
@@ -792,7 +810,8 @@
static gboolean
-sizes_equivalent (const gchar *rhs, const gchar *lhs)
+sizes_equivalent (GtkIconSize lhs,
+ GtkIconSize rhs)
{
gint r_w, r_h, l_w, l_h;
@@ -806,7 +825,7 @@
find_and_prep_icon_source (GtkIconSet *icon_set,
GtkTextDirection direction,
GtkStateType state,
- const gchar *size)
+ GtkIconSize size)
{
GtkIconSource *source;
GSList *tmp_list;
@@ -920,7 +939,7 @@
GtkStyle *style,
GtkTextDirection direction,
GtkStateType state,
- const gchar *size,
+ GtkIconSize size,
GtkWidget *widget,
const char *detail)
{
@@ -1048,7 +1067,7 @@
*copy = *source;
copy->filename = g_strdup (source->filename);
- copy->size = g_strdup (source->size);
+ copy->size = source->size;
if (copy->pixbuf)
g_object_ref (G_OBJECT (copy->pixbuf));
@@ -1068,7 +1087,6 @@
g_return_if_fail (source != NULL);
g_free ((char*) source->filename);
- g_free ((char*) source->size);
if (source->pixbuf)
g_object_unref (G_OBJECT (source->pixbuf));
@@ -1090,7 +1108,7 @@
GtkStyle *style;
GtkTextDirection direction;
GtkStateType state;
- gchar *size;
+ GtkIconSize size;
GdkPixbuf *pixbuf;
};
@@ -1105,7 +1123,6 @@
static void
cached_icon_free (CachedIcon *icon)
{
- g_free (icon->size);
g_object_unref (G_OBJECT (icon->pixbuf));
g_free (icon);
@@ -1116,7 +1133,7 @@
GtkStyle *style,
GtkTextDirection direction,
GtkStateType state,
- const gchar *size)
+ GtkIconSize size)
{
GSList *tmp_list;
GSList *prev;
@@ -1132,7 +1149,7 @@
if (icon->style == style &&
icon->direction == direction &&
icon->state == state &&
- strcmp (icon->size, size) == 0)
+ icon->size == size)
{
if (prev)
{
@@ -1157,7 +1174,7 @@
GtkStyle *style,
GtkTextDirection direction,
GtkStateType state,
- const gchar *size,
+ GtkIconSize size,
GdkPixbuf *pixbuf)
{
CachedIcon *icon;
@@ -1181,7 +1198,7 @@
icon->style = style;
icon->direction = direction;
icon->state = state;
- icon->size = g_strdup (size);
+ icon->size = size;
icon->pixbuf = pixbuf;
if (icon->style)
@@ -1272,7 +1289,7 @@
g_object_ref (G_OBJECT (icon_copy->pixbuf));
- icon_copy->size = g_strdup (icon->size);
+ icon_copy->size = icon->size;
copy = g_slist_prepend (copy, icon_copy);
Index: gtk/gtkiconfactory.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkiconfactory.h,v
retrieving revision 1.4
diff -u -u -r1.4 gtkiconfactory.h
--- gtk/gtkiconfactory.h 2001/02/20 19:07:15 1.4
+++ gtk/gtkiconfactory.h 2001/03/08 00:48:21
@@ -82,23 +82,16 @@
* size from the rendered pixbuf, not from here.
*/
-gboolean gtk_icon_size_lookup (const gchar *alias,
- gint *width,
- gint *height);
-void gtk_icon_size_register (const gchar *alias,
- gint width,
- gint height);
-void gtk_icon_size_register_alias (const gchar *alias,
- const gchar *target);
-
-
-/* Standard sizes */
-
-#define GTK_ICON_SIZE_MENU "gtk-menu"
-#define GTK_ICON_SIZE_SMALL_TOOLBAR "gtk-small-toolbar"
-#define GTK_ICON_SIZE_LARGE_TOOLBAR "gtk-large-toolbar"
-#define GTK_ICON_SIZE_BUTTON "gtk-button"
-#define GTK_ICON_SIZE_DIALOG "gtk-dialog"
+gboolean gtk_icon_size_lookup (GtkIconSize size,
+ gint *width,
+ gint *height);
+GtkIconSize gtk_icon_size_register (const gchar *name,
+ gint width,
+ gint height);
+void gtk_icon_size_register_alias (const gchar *alias,
+ GtkIconSize target);
+GtkIconSize gtk_icon_size_from_name (const gchar *name);
+G_CONST_RETURN gchar* gtk_icon_size_get_name (GtkIconSize size);
/* Icon sets */
@@ -116,7 +109,7 @@
GtkStyle *style,
GtkTextDirection direction,
GtkStateType state,
- const gchar *size,
+ GtkIconSize size,
GtkWidget *widget,
const char *detail);
@@ -138,7 +131,7 @@
GtkTextDirection direction;
GtkStateType state;
- gchar *size;
+ GtkIconSize size;
/* If TRUE, then the parameter is wildcarded, and the above
* fields should be ignored. If FALSE, the parameter is
Index: gtk/gtkimage.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkimage.c,v
retrieving revision 1.19
diff -u -u -r1.19 gtkimage.c
--- gtk/gtkimage.c 2001/03/07 21:10:44 1.19
+++ gtk/gtkimage.c 2001/03/08 00:48:21
@@ -224,7 +224,7 @@
**/
GtkWidget*
gtk_image_new_from_stock (const gchar *stock_id,
- const gchar *size)
+ GtkIconSize size)
{
GtkImage *image;
@@ -257,7 +257,7 @@
**/
GtkWidget*
gtk_image_new_from_icon_set (GtkIconSet *icon_set,
- const gchar *size)
+ GtkIconSize size)
{
GtkImage *image;
@@ -446,7 +446,7 @@
void
gtk_image_set_from_stock (GtkImage *image,
const gchar *stock_id,
- const gchar *size)
+ GtkIconSize size)
{
g_return_if_fail (GTK_IS_IMAGE (image));
@@ -457,7 +457,7 @@
image->storage_type = GTK_IMAGE_STOCK;
image->data.stock.stock_id = g_strdup (stock_id);
- image->data.stock.size = g_strdup (size);
+ image->data.stock.size = size;
/* Size is demand-computed in size request method
* if we're a stock image, since changing the
@@ -478,7 +478,7 @@
void
gtk_image_set_from_icon_set (GtkImage *image,
GtkIconSet *icon_set,
- const gchar *size)
+ GtkIconSize size)
{
g_return_if_fail (GTK_IS_IMAGE (image));
@@ -492,7 +492,7 @@
image->storage_type = GTK_IMAGE_ICON_SET;
image->data.icon_set.icon_set = icon_set;
- image->data.icon_set.size = g_strdup (size);
+ image->data.icon_set.size = size;
/* Size is demand-computed in size request method
* if we're an icon set
@@ -610,14 +610,14 @@
* Gets the stock icon name and size being displayed by the #GtkImage.
* The storage type of the image must be %GTK_IMAGE_EMPTY or
* %GTK_IMAGE_STOCK (see gtk_image_get_storage_type()).
- * The returned strings are owned by the #GtkImage and should not
+ * The returned string is owned by the #GtkImage and should not
* be freed.
*
**/
void
gtk_image_get_stock (GtkImage *image,
gchar **stock_id,
- gchar **size)
+ GtkIconSize *size)
{
g_return_if_fail (GTK_IS_IMAGE (image));
g_return_if_fail (image->storage_type == GTK_IMAGE_STOCK ||
@@ -642,14 +642,12 @@
* Gets the icon set and size being displayed by the #GtkImage.
* The storage type of the image must be %GTK_IMAGE_EMPTY or
* %GTK_IMAGE_ICON_SET (see gtk_image_get_storage_type()).
- * The returned size string is owned by the #GtkImage and should not
- * be freed.
*
**/
void
gtk_image_get_icon_set (GtkImage *image,
GtkIconSet **icon_set,
- gchar **size)
+ GtkIconSize *size)
{
g_return_if_fail (GTK_IS_IMAGE (image));
g_return_if_fail (image->storage_type == GTK_IMAGE_ICON_SET ||
@@ -907,21 +905,18 @@
case GTK_IMAGE_STOCK:
- g_free (image->data.stock.size);
g_free (image->data.stock.stock_id);
image->data.stock.stock_id = NULL;
- image->data.stock.size = NULL;
+ image->data.stock.size = 0;
break;
case GTK_IMAGE_ICON_SET:
if (image->data.icon_set.icon_set)
gtk_icon_set_unref (image->data.icon_set.icon_set);
-
- g_free (image->data.icon_set.size);
- image->data.icon_set.size = NULL;
+ image->data.icon_set.size = 0;
image->data.icon_set.icon_set = NULL;
break;
Index: gtk/gtkimage.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkimage.h,v
retrieving revision 1.9
diff -u -u -r1.9 gtkimage.h
--- gtk/gtkimage.h 2001/02/03 01:09:40 1.9
+++ gtk/gtkimage.h 2001/03/08 00:48:21
@@ -73,13 +73,13 @@
struct _GtkImageStockData
{
gchar *stock_id;
- gchar *size;
+ GtkIconSize size;
};
struct _GtkImageIconSetData
{
GtkIconSet *icon_set;
- gchar *size;
+ GtkIconSize size;
};
typedef enum
@@ -122,9 +122,9 @@
GtkWidget* gtk_image_new_from_file (const gchar *filename);
GtkWidget* gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf);
GtkWidget* gtk_image_new_from_stock (const gchar *stock_id,
- const gchar *size);
+ GtkIconSize size);
GtkWidget* gtk_image_new_from_icon_set (GtkIconSet *icon_set,
- const gchar *size);
+ GtkIconSize size);
void gtk_image_set_from_pixmap (GtkImage *image,
GdkPixmap *pixmap,
@@ -138,10 +138,10 @@
GdkPixbuf *pixbuf);
void gtk_image_set_from_stock (GtkImage *image,
const gchar *stock_id,
- const gchar *size);
+ GtkIconSize size);
void gtk_image_set_from_icon_set (GtkImage *image,
GtkIconSet *icon_set,
- const gchar *size);
+ GtkIconSize size);
GtkImageType gtk_image_get_storage_type (GtkImage *image);
@@ -154,10 +154,10 @@
GdkPixbuf* gtk_image_get_pixbuf (GtkImage *image);
void gtk_image_get_stock (GtkImage *image,
gchar **stock_id,
- gchar **size);
+ GtkIconSize *size);
void gtk_image_get_icon_set (GtkImage *image,
GtkIconSet **icon_set,
- gchar **size);
+ GtkIconSize *size);
#ifndef GTK_DISABLE_DEPRECATED
Index: gtk/gtkrc.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkrc.c,v
retrieving revision 1.77
diff -u -u -r1.77 gtkrc.c
--- gtk/gtkrc.c 2001/03/05 13:57:01 1.77
+++ gtk/gtkrc.c 2001/03/08 00:48:21
@@ -2711,7 +2711,6 @@
cleanup_source (GtkIconSource *source)
{
g_free (source->filename);
- g_free (source->size);
}
static guint
@@ -2848,14 +2847,21 @@
if (token != '*')
{
+ GtkIconSize size;
+
if (token != G_TOKEN_STRING)
{
cleanup_source (&source);
return G_TOKEN_STRING;
}
-
- source.size = g_strdup (scanner->value.v_string);
- source.any_size = FALSE;
+
+ size = gtk_icon_size_from_name (scanner->value.v_string);
+
+ if (size != GTK_ICON_SIZE_INVALID)
+ {
+ source.size = size;
+ source.any_size = FALSE;
+ }
}
/* Check the close brace */
Index: gtk/gtkstyle.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkstyle.c,v
retrieving revision 1.53
diff -u -u -r1.53 gtkstyle.c
--- gtk/gtkstyle.c 2001/03/02 17:06:11 1.53
+++ gtk/gtkstyle.c 2001/03/08 00:48:21
@@ -63,7 +63,7 @@
const GtkIconSource *source,
GtkTextDirection direction,
GtkStateType state,
- const gchar *size,
+ GtkIconSize size,
GtkWidget *widget,
const gchar *detail);
@@ -1270,7 +1270,7 @@
const GtkIconSource *source,
GtkTextDirection direction,
GtkStateType state,
- const gchar *size,
+ GtkIconSize size,
GtkWidget *widget,
const gchar *detail)
{
@@ -1373,12 +1373,12 @@
static GdkPixbuf *
gtk_default_render_icon (GtkStyle *style,
- const GtkIconSource *source,
- GtkTextDirection direction,
- GtkStateType state,
- const gchar *size,
- GtkWidget *widget,
- const gchar *detail)
+ const GtkIconSource *source,
+ GtkTextDirection direction,
+ GtkStateType state,
+ GtkIconSize size,
+ GtkWidget *widget,
+ const gchar *detail)
{
gint width = 1;
gint height = 1;
Index: gtk/gtkstyle.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkstyle.h,v
retrieving revision 1.21
diff -u -u -r1.21 gtkstyle.h
--- gtk/gtkstyle.h 2001/02/03 01:09:40 1.21
+++ gtk/gtkstyle.h 2001/03/08 00:48:21
@@ -157,7 +157,7 @@
const GtkIconSource *source,
GtkTextDirection direction,
GtkStateType state,
- const gchar *size,
+ GtkIconSize size,
GtkWidget *widget,
const gchar *detail);
@@ -413,7 +413,7 @@
const GtkIconSource *source,
GtkTextDirection direction,
GtkStateType state,
- const gchar * size,
+ GtkIconSize size,
GtkWidget *widget,
const gchar *detail);
void gtk_draw_hline (GtkStyle *style,
Index: gtk/gtkwidget.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.c,v
retrieving revision 1.189
diff -u -u -r1.189 gtkwidget.c
--- gtk/gtkwidget.c 2001/03/07 14:49:20 1.189
+++ gtk/gtkwidget.c 2001/03/08 00:48:21
@@ -3637,12 +3637,12 @@
* identifies the widget or code doing the rendering, so that
* theme engines can special-case rendering for that widget or code.
*
- * Return value: a new pixbuf, or NULL if the stock ID wasn't known
+ * Return value: a new pixbuf, or %NULL if the stock ID wasn't known
**/
GdkPixbuf*
gtk_widget_render_icon (GtkWidget *widget,
const gchar *stock_id,
- const gchar *size,
+ GtkIconSize size,
const gchar *detail)
{
GtkIconSet *icon_set;
Index: gtk/gtkwidget.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.h,v
retrieving revision 1.92
diff -u -u -r1.92 gtkwidget.h
--- gtk/gtkwidget.h 2001/03/07 14:49:20 1.92
+++ gtk/gtkwidget.h 2001/03/08 00:48:21
@@ -575,7 +575,7 @@
GdkPixbuf *gtk_widget_render_icon (GtkWidget *widget,
const gchar *stock_id,
- const gchar *size,
+ GtkIconSize size,
const gchar *detail);
/* handle composite names for GTK_COMPOSITE_CHILD widgets,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]