Commit 82ef0d0d authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

When finding a matching non-scalable dir, keep going and look for a closer

2007-01-14  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkicontheme.c (theme_lookup_icon): When finding a matching
        non-scalable dir, keep going and look for a closer match.
        (#395830, Luca Ferretti)


svn path=/trunk/; revision=17153
parent 6400dda3
2007-01-14 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkicontheme.c (theme_lookup_icon): When finding a matching
non-scalable dir, keep going and look for a closer match.
(#395830, Luca Ferretti)
2007-01-14 Christian Persch <chpe@svn.gnome.org>
* gtk/gtkclipboard.c: (gtk_clipboard_set_text),
......
......@@ -1873,12 +1873,13 @@ theme_lookup_icon (IconTheme *theme,
char *file;
int min_difference, difference;
BuiltinIcon *closest_builtin = NULL;
gboolean smaller, has_larger;
gboolean smaller, has_larger, match;
IconSuffix suffix;
min_difference = G_MAXINT;
min_dir = NULL;
has_larger = FALSE;
match = FALSE;
/* Builtin icons are logically part of the default theme and
* are searched before other subdirectories of the default theme.
......@@ -1912,31 +1913,55 @@ theme_lookup_icon (IconTheme *theme,
if (difference == 0)
{
min_dir = dir;
break;
}
if (!has_larger)
{
if (difference < min_difference || smaller)
{
min_difference = difference;
min_dir = dir;
closest_builtin = NULL;
has_larger = smaller;
}
}
else
{
if (difference < min_difference && smaller)
{
min_difference = difference;
min_dir = dir;
closest_builtin = NULL;
}
if (dir->type == ICON_THEME_DIR_SCALABLE)
{
/* don't pick scalable if we already found
* a matching non-scalable dir
*/
if (!match)
{
min_dir = dir;
break;
}
}
else
{
/* for a matching non-scalable dir keep
* going and look for a closer match
*/
difference = abs (size - dir->size);
if (!match || difference < min_difference)
{
match = TRUE;
min_difference = difference;
min_dir = dir;
}
if (difference == 0)
break;
}
}
if (!match)
{
if (!has_larger)
{
if (difference < min_difference || smaller)
{
min_difference = difference;
min_dir = dir;
has_larger = smaller;
}
}
else
{
if (difference < min_difference && smaller)
{
min_difference = difference;
min_dir = dir;
}
}
}
}
}
l = l->next;
......@@ -1947,9 +1972,6 @@ theme_lookup_icon (IconTheme *theme,
}
}
if (closest_builtin)
return icon_info_new_builtin (closest_builtin);
if (min_dir)
{
GtkIconInfo *icon_info = icon_info_new ();
......@@ -2015,7 +2037,10 @@ theme_lookup_icon (IconTheme *theme,
return icon_info;
}
if (closest_builtin)
return icon_info_new_builtin (closest_builtin);
return NULL;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment