icondir support
This commit is contained in:
parent
8dec533a1c
commit
aff798d6f4
2 changed files with 18 additions and 13 deletions
|
@ -150,18 +150,25 @@ grub_resolve_relative_path (const char *base, const char *path)
|
|||
char *abspath;
|
||||
char *canonpath;
|
||||
char *p;
|
||||
grub_size_t l;
|
||||
|
||||
/* If PATH is an absolute path, then just use it as is. */
|
||||
if (path[0] == '/' || path[0] == '(')
|
||||
return canonicalize_path (path);
|
||||
|
||||
abspath = grub_malloc (grub_strlen (base) + grub_strlen (path) + 1);
|
||||
abspath = grub_malloc (grub_strlen (base) + grub_strlen (path) + 3);
|
||||
if (! abspath)
|
||||
return 0;
|
||||
|
||||
/* Concatenate BASE and PATH.
|
||||
Note that BASE is expected to have a trailing slash. */
|
||||
/* Concatenate BASE and PATH. */
|
||||
p = grub_stpcpy (abspath, base);
|
||||
l = grub_strlen (abspath);
|
||||
if (l == 0 || abspath[l-1] != '/')
|
||||
{
|
||||
*p = '/';
|
||||
p++;
|
||||
*p = 0;
|
||||
}
|
||||
grub_stpcpy (p, path);
|
||||
|
||||
canonpath = canonicalize_path (abspath);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <grub/bitmap_scale.h>
|
||||
#include <grub/menu.h>
|
||||
#include <grub/icon_manager.h>
|
||||
#include <grub/env.h>
|
||||
|
||||
/* Currently hard coded to '.png' extension. */
|
||||
static const char icon_extension[] = ".png";
|
||||
|
@ -200,19 +201,16 @@ get_icon_by_class (grub_gfxmenu_icon_manager_t mgr, const char *class_name)
|
|||
icon = try_loading_icon (mgr, icons_dir, class_name);
|
||||
grub_free (icons_dir);
|
||||
}
|
||||
|
||||
grub_free (theme_dir);
|
||||
if (! icon)
|
||||
{
|
||||
/* If the theme doesn't have an appropriate icon, check in
|
||||
"grub/themes/icons". */
|
||||
/* TODO use GRUB prefix "/icons" */
|
||||
icons_dir = grub_resolve_relative_path (theme_dir, "../icons/");
|
||||
if (icons_dir)
|
||||
{
|
||||
icon = try_loading_icon (mgr, icons_dir, class_name);
|
||||
grub_free (icons_dir);
|
||||
}
|
||||
const char *icondir;
|
||||
|
||||
icondir = grub_env_get ("icondir");
|
||||
if (icondir)
|
||||
icon = try_loading_icon (mgr, icondir, class_name);
|
||||
}
|
||||
grub_free (theme_dir);
|
||||
|
||||
/* No icon was found. */
|
||||
/* This should probably be noted in the cache, so that a search is not
|
||||
|
|
Loading…
Reference in a new issue