mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 05:50:10 +00:00
Make builtin icons work in gtk_window_set_icon_name() (#321046, Maxim
2005-11-12 Matthias Clasen <mclasen@redhat.com> Make builtin icons work in gtk_window_set_icon_name() (#321046, Maxim Udushlivy) * gtk/gtkicontheme.c (insert_theme): Always insert the default theme. (ensure_valid_themes): Call _gtk_icon_theme_ensure_builtin_cache() from here. (theme_lookup_icon, find_builtin_icon): ...and not from here. (gtk_icon_theme_lookup_icon): Remove an unncessary assert. (gtk_icon_theme_get_icon_sizes): Also check builtin icons.
This commit is contained in:
parent
de28325959
commit
82f12b610d
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
2005-11-12 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
Make builtin icons work in gtk_window_set_icon_name()
|
||||||
|
(#321046, Maxim Udushlivy)
|
||||||
|
|
||||||
|
* gtk/gtkicontheme.c (insert_theme): Always insert the default
|
||||||
|
theme.
|
||||||
|
(ensure_valid_themes): Call _gtk_icon_theme_ensure_builtin_cache()
|
||||||
|
from here.
|
||||||
|
(theme_lookup_icon, find_builtin_icon): ...and not from here.
|
||||||
|
(gtk_icon_theme_lookup_icon): Remove an unncessary assert.
|
||||||
|
(gtk_icon_theme_get_icon_sizes): Also check builtin icons.
|
||||||
|
|
||||||
2005-11-12 Tor Lillqvist <tml@novell.com>
|
2005-11-12 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
* gtk/gtkfilesystemwin32.c (filename_get_info): Don't hide
|
* gtk/gtkfilesystemwin32.c (filename_get_info): Don't hide
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
2005-11-12 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
Make builtin icons work in gtk_window_set_icon_name()
|
||||||
|
(#321046, Maxim Udushlivy)
|
||||||
|
|
||||||
|
* gtk/gtkicontheme.c (insert_theme): Always insert the default
|
||||||
|
theme.
|
||||||
|
(ensure_valid_themes): Call _gtk_icon_theme_ensure_builtin_cache()
|
||||||
|
from here.
|
||||||
|
(theme_lookup_icon, find_builtin_icon): ...and not from here.
|
||||||
|
(gtk_icon_theme_lookup_icon): Remove an unncessary assert.
|
||||||
|
(gtk_icon_theme_get_icon_sizes): Also check builtin icons.
|
||||||
|
|
||||||
2005-11-12 Tor Lillqvist <tml@novell.com>
|
2005-11-12 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
* gtk/gtkfilesystemwin32.c (filename_get_info): Don't hide
|
* gtk/gtkfilesystemwin32.c (filename_get_info): Don't hide
|
||||||
|
@ -937,31 +937,25 @@ insert_theme (GtkIconTheme *icon_theme, const char *theme_name)
|
|||||||
g_free (path);
|
g_free (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (theme_file || strcmp (theme_name, DEFAULT_THEME_NAME) == 0)
|
||||||
|
{
|
||||||
|
theme = g_new0 (IconTheme, 1);
|
||||||
|
theme->name = g_strdup (theme_name);
|
||||||
|
priv->themes = g_list_prepend (priv->themes, theme);
|
||||||
|
}
|
||||||
|
|
||||||
if (theme_file == NULL)
|
if (theme_file == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
theme = g_new (IconTheme, 1);
|
|
||||||
theme->display_name =
|
theme->display_name =
|
||||||
g_key_file_get_locale_string (theme_file, "Icon Theme", "Name", NULL, NULL);
|
g_key_file_get_locale_string (theme_file, "Icon Theme", "Name", NULL, NULL);
|
||||||
if (!theme->display_name)
|
if (!theme->display_name)
|
||||||
{
|
g_warning ("Theme file for %s has no name\n", theme_name);
|
||||||
g_warning ("Theme file for %s has no name\n", theme_name);
|
|
||||||
g_free (theme);
|
|
||||||
g_key_file_free (theme_file);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dirs = g_key_file_get_string_list (theme_file, "Icon Theme", "Directories", NULL, NULL);
|
dirs = g_key_file_get_string_list (theme_file, "Icon Theme", "Directories", NULL, NULL);
|
||||||
if (!dirs)
|
if (!dirs)
|
||||||
{
|
g_warning ("Theme file for %s has no directories\n", theme_name);
|
||||||
g_warning ("Theme file for %s has no directories\n", theme_name);
|
|
||||||
g_free (theme->display_name);
|
|
||||||
g_free (theme);
|
|
||||||
g_key_file_free (theme_file);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
theme->name = g_strdup (theme_name);
|
|
||||||
theme->comment =
|
theme->comment =
|
||||||
g_key_file_get_locale_string (theme_file,
|
g_key_file_get_locale_string (theme_file,
|
||||||
"Icon Theme", "Comment",
|
"Icon Theme", "Comment",
|
||||||
@ -979,9 +973,6 @@ insert_theme (GtkIconTheme *icon_theme, const char *theme_name)
|
|||||||
|
|
||||||
theme->dirs = g_list_reverse (theme->dirs);
|
theme->dirs = g_list_reverse (theme->dirs);
|
||||||
|
|
||||||
/* Prepend the finished theme */
|
|
||||||
priv->themes = g_list_prepend (priv->themes, theme);
|
|
||||||
|
|
||||||
themes = g_key_file_get_string_list (theme_file,
|
themes = g_key_file_get_string_list (theme_file,
|
||||||
"Icon Theme",
|
"Icon Theme",
|
||||||
"Inherits",
|
"Inherits",
|
||||||
@ -1128,12 +1119,48 @@ load_themes (GtkIconTheme *icon_theme)
|
|||||||
priv->last_stat_time = tv.tv_sec;
|
priv->last_stat_time = tv.tv_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gtk_icon_theme_ensure_builtin_cache (void)
|
||||||
|
{
|
||||||
|
static gboolean initialized = FALSE;
|
||||||
|
IconThemeDir *dir;
|
||||||
|
gint sizes[5] = { 16, 20, 24, 32, 48 };
|
||||||
|
gint n_sizes = G_N_ELEMENTS (sizes);
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
if (!initialized)
|
||||||
|
{
|
||||||
|
initialized = TRUE;
|
||||||
|
|
||||||
|
_builtin_cache = _gtk_icon_cache_new ((gchar *)builtin_icons);
|
||||||
|
|
||||||
|
for (i = 0; i < n_sizes; i++)
|
||||||
|
{
|
||||||
|
dir = g_new (IconThemeDir, 1);
|
||||||
|
dir->type = ICON_THEME_DIR_THRESHOLD;
|
||||||
|
dir->context = 0;
|
||||||
|
dir->size = sizes[i];
|
||||||
|
dir->min_size = sizes[i];
|
||||||
|
dir->max_size = sizes[i];
|
||||||
|
dir->threshold = 2;
|
||||||
|
dir->dir = NULL;
|
||||||
|
dir->icon_data = NULL;
|
||||||
|
dir->subdir = g_strdup_printf ("%d", sizes[i]);
|
||||||
|
dir->cache = _gtk_icon_cache_ref (_builtin_cache);
|
||||||
|
|
||||||
|
builtin_dirs = g_list_append (builtin_dirs, dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ensure_valid_themes (GtkIconTheme *icon_theme)
|
ensure_valid_themes (GtkIconTheme *icon_theme)
|
||||||
{
|
{
|
||||||
GtkIconThemePrivate *priv = icon_theme->priv;
|
GtkIconThemePrivate *priv = icon_theme->priv;
|
||||||
GTimeVal tv;
|
GTimeVal tv;
|
||||||
|
|
||||||
|
_gtk_icon_theme_ensure_builtin_cache ();
|
||||||
|
|
||||||
if (priv->themes_valid)
|
if (priv->themes_valid)
|
||||||
{
|
{
|
||||||
g_get_current_time (&tv);
|
g_get_current_time (&tv);
|
||||||
@ -1196,7 +1223,6 @@ gtk_icon_theme_lookup_icon (GtkIconTheme *icon_theme,
|
|||||||
UnthemedIcon *unthemed_icon;
|
UnthemedIcon *unthemed_icon;
|
||||||
gboolean allow_svg;
|
gboolean allow_svg;
|
||||||
gboolean use_builtin;
|
gboolean use_builtin;
|
||||||
gboolean found_default;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_ICON_THEME (icon_theme), NULL);
|
g_return_val_if_fail (GTK_IS_ICON_THEME (icon_theme), NULL);
|
||||||
g_return_val_if_fail (icon_name != NULL, NULL);
|
g_return_val_if_fail (icon_name != NULL, NULL);
|
||||||
@ -1218,24 +1244,15 @@ gtk_icon_theme_lookup_icon (GtkIconTheme *icon_theme,
|
|||||||
|
|
||||||
ensure_valid_themes (icon_theme);
|
ensure_valid_themes (icon_theme);
|
||||||
|
|
||||||
found_default = FALSE;
|
for (l = priv->themes; l; l = l->next)
|
||||||
l = priv->themes;
|
|
||||||
while (l != NULL)
|
|
||||||
{
|
{
|
||||||
IconTheme *theme = l->data;
|
IconTheme *theme = l->data;
|
||||||
|
|
||||||
if (strcmp (theme->name, DEFAULT_THEME_NAME) == 0)
|
|
||||||
found_default = TRUE;
|
|
||||||
|
|
||||||
icon_info = theme_lookup_icon (theme, icon_name, size, allow_svg, use_builtin);
|
icon_info = theme_lookup_icon (theme, icon_name, size, allow_svg, use_builtin);
|
||||||
if (icon_info)
|
if (icon_info)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
l = l->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_assert (found_default);
|
|
||||||
|
|
||||||
unthemed_icon = g_hash_table_lookup (priv->unthemed_icons, icon_name);
|
unthemed_icon = g_hash_table_lookup (priv->unthemed_icons, icon_name);
|
||||||
if (unthemed_icon)
|
if (unthemed_icon)
|
||||||
{
|
{
|
||||||
@ -1450,11 +1467,10 @@ gint *
|
|||||||
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;
|
GList *l, *d, *icons;
|
||||||
GHashTable *sizes;
|
GHashTable *sizes;
|
||||||
gint *result, *r;
|
gint *result, *r;
|
||||||
guint suffix;
|
guint suffix;
|
||||||
|
|
||||||
GtkIconThemePrivate *priv;
|
GtkIconThemePrivate *priv;
|
||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_ICON_THEME (icon_theme), NULL);
|
g_return_val_if_fail (GTK_IS_ICON_THEME (icon_theme), NULL);
|
||||||
@ -1483,6 +1499,32 @@ gtk_icon_theme_get_icon_sizes (GtkIconTheme *icon_theme,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (d = builtin_dirs; d; d = d->next)
|
||||||
|
{
|
||||||
|
IconThemeDir *dir = d->data;
|
||||||
|
|
||||||
|
suffix = theme_dir_get_icon_suffix (dir, icon_name, NULL);
|
||||||
|
if (suffix != ICON_SUFFIX_NONE)
|
||||||
|
{
|
||||||
|
if (suffix == ICON_SUFFIX_SVG)
|
||||||
|
g_hash_table_insert (sizes, GINT_TO_POINTER (-1), NULL);
|
||||||
|
else
|
||||||
|
g_hash_table_insert (sizes, GINT_TO_POINTER (dir->size), NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (icon_theme_builtin_icons)
|
||||||
|
{
|
||||||
|
icons = g_hash_table_lookup (icon_theme_builtin_icons, icon_name);
|
||||||
|
|
||||||
|
for ( ; icons; icons = icons->next);
|
||||||
|
{
|
||||||
|
BuiltinIcon *icon = icons->data;
|
||||||
|
|
||||||
|
g_hash_table_insert (sizes, GINT_TO_POINTER (icon->size), NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
r = result = g_new0 (gint, g_hash_table_size (sizes) + 1);
|
r = result = g_new0 (gint, g_hash_table_size (sizes) + 1);
|
||||||
|
|
||||||
g_hash_table_foreach (sizes, add_size, &r);
|
g_hash_table_foreach (sizes, add_size, &r);
|
||||||
@ -1811,40 +1853,6 @@ theme_dir_get_icon_suffix (IconThemeDir *dir,
|
|||||||
return suffix;
|
return suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_gtk_icon_theme_ensure_builtin_cache (void)
|
|
||||||
{
|
|
||||||
static gboolean initialized = FALSE;
|
|
||||||
IconThemeDir *dir;
|
|
||||||
gint sizes[5] = { 16, 20, 24, 32, 48 };
|
|
||||||
gint n_sizes = G_N_ELEMENTS (sizes);
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
if (!initialized)
|
|
||||||
{
|
|
||||||
initialized = TRUE;
|
|
||||||
|
|
||||||
_builtin_cache = _gtk_icon_cache_new ((gchar *)builtin_icons);
|
|
||||||
|
|
||||||
for (i = 0; i < n_sizes; i++)
|
|
||||||
{
|
|
||||||
dir = g_new (IconThemeDir, 1);
|
|
||||||
dir->type = ICON_THEME_DIR_THRESHOLD;
|
|
||||||
dir->context = 0;
|
|
||||||
dir->size = sizes[i];
|
|
||||||
dir->min_size = sizes[i];
|
|
||||||
dir->max_size = sizes[i];
|
|
||||||
dir->threshold = 2;
|
|
||||||
dir->dir = NULL;
|
|
||||||
dir->icon_data = NULL;
|
|
||||||
dir->subdir = g_strdup_printf ("%d", sizes[i]);
|
|
||||||
dir->cache = _gtk_icon_cache_ref (_builtin_cache);
|
|
||||||
|
|
||||||
builtin_dirs = g_list_append (builtin_dirs, dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkIconInfo *
|
static GtkIconInfo *
|
||||||
theme_lookup_icon (IconTheme *theme,
|
theme_lookup_icon (IconTheme *theme,
|
||||||
const char *icon_name,
|
const char *icon_name,
|
||||||
@ -1867,8 +1875,6 @@ theme_lookup_icon (IconTheme *theme,
|
|||||||
/* Builtin icons are logically part of the default theme and
|
/* Builtin icons are logically part of the default theme and
|
||||||
* are searched before other subdirectories of the default theme.
|
* are searched before other subdirectories of the default theme.
|
||||||
*/
|
*/
|
||||||
_gtk_icon_theme_ensure_builtin_cache ();
|
|
||||||
|
|
||||||
if (strcmp (theme->name, DEFAULT_THEME_NAME) == 0 && use_builtin)
|
if (strcmp (theme->name, DEFAULT_THEME_NAME) == 0 && use_builtin)
|
||||||
{
|
{
|
||||||
closest_builtin = find_builtin_icon (icon_name,
|
closest_builtin = find_builtin_icon (icon_name,
|
||||||
@ -2945,8 +2951,6 @@ find_builtin_icon (const gchar *icon_name,
|
|||||||
gboolean has_larger = FALSE;
|
gboolean has_larger = FALSE;
|
||||||
BuiltinIcon *min_icon = NULL;
|
BuiltinIcon *min_icon = NULL;
|
||||||
|
|
||||||
_gtk_icon_factory_ensure_default_icons ();
|
|
||||||
|
|
||||||
if (!icon_theme_builtin_icons)
|
if (!icon_theme_builtin_icons)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user