From: srs5694 Date: Wed, 19 Dec 2012 06:44:31 +0000 (-0500) Subject: Use filesystem name as potential base for loader icon filename. X-Git-Url: https://code.delx.au/refind/commitdiff_plain/1ab208f41bd05dd49203fc8d5d5b44e5525374c2 Use filesystem name as potential base for loader icon filename. --- diff --git a/NEWS.txt b/NEWS.txt index 534c400..5bfd5c0 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -1,6 +1,13 @@ 0.6.1 (12/??/2012): ------------------- +- Added the filesystem's label (up to the first space, dash, or underscore, + if present) as a search base for a menu icon. For instance, if the + filesystem is called "Arch", rEFInd will try to find an icon called + os_Arch.icns; if it's called "Mac boot", rEFInd will try to use + os_Mac.icns; and if it's "suse_root", rEFInd will search for + os_suse.icns. + - Refined hints displays to be more context-sensitive, particularly in text mode. diff --git a/refind/main.c b/refind/main.c index 15b8771..7a785cd 100644 --- a/refind/main.c +++ b/refind/main.c @@ -87,7 +87,7 @@ // a ".efi" extension to be found when scanning for boot loaders. #define LINUX_MATCH_PATTERNS L"vmlinuz*,bzImage*" -// Default hint text +// Default hint text for program-launch submenus #define SUBSCREEN_HINT1 L"Use arrow keys to move cursor; Enter to boot;" #define SUBSCREEN_HINT2 L"Insert or F2 to edit options; Esc to return to main menu" #define SUBSCREEN_HINT2_NO_EDITOR L"Esc to return to main menu" @@ -726,9 +726,10 @@ static CHAR16 * GetMainLinuxOptions(IN CHAR16 * LoaderPath, IN REFIT_VOLUME *Vol // code and shortcut letter. For Linux EFI stub loaders, also sets kernel options // that will (with luck) work fairly automatically. VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME *Volume) { - CHAR16 IconFileName[256]; - CHAR16 *FileName, *PathOnly, *OSIconName = NULL, *Temp; - CHAR16 ShortcutLetter = 0; + CHAR16 IconFileName[256]; + CHAR16 *FileName, *PathOnly, *OSIconName = NULL, *Temp; + CHAR16 ShortcutLetter = 0; + UINTN i, Length; FileName = Basename(LoaderPath); PathOnly = FindPath(LoaderPath); @@ -750,6 +751,22 @@ VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, IN REFIT_VOLUME ShortcutLetter = OSIconName[0]; } + // Add the volume's label up to the first space, dash, or underscore (if present) + // as a potential base for finding an icon + if ((Volume->VolName) && (StrLen(Volume->VolName) > 0)) { + Temp = StrDuplicate(Volume->VolName); + if (Temp != NULL) { + i = 0; + Length = StrLen(Temp); + do { + if ((Temp[i] == L' ') || (Temp[i] == L'_') || (Temp[i] == L'-')) + Temp[i] = 0; + } while ((Temp[i] != 0) && (++i < Length)); + MergeStrings(&OSIconName, Temp, L','); + MyFreePool(Temp); + } // if + } // if + // detect specific loaders if (StriSubCmp(L"bzImage", LoaderPath) || StriSubCmp(L"vmlinuz", LoaderPath)) { MergeStrings(&OSIconName, L"linux", L','); @@ -838,7 +855,7 @@ LOADER_ENTRY * AddLoaderEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle, IN // (Time1 == Time2). Precision is only to the nearest second; since // this is used for sorting boot loader entries, differences smaller // than this are likely to be meaningless (and unlikely!). -INTN TimeComp(EFI_TIME *Time1, EFI_TIME *Time2) { +INTN TimeComp(IN EFI_TIME *Time1, IN EFI_TIME *Time2) { INT64 Time1InSeconds, Time2InSeconds; // Following values are overestimates; I'm assuming 31 days in every month.