From: srs5694 Date: Wed, 9 May 2012 05:59:17 +0000 (-0400) Subject: Added new "icons_dir" configuration file token. X-Git-Url: https://code.delx.au/refind/commitdiff_plain/dfa921b680497937566695dfefd20a8751947c51 Added new "icons_dir" configuration file token. --- diff --git a/BUILDING.txt b/BUILDING.txt index 2c59bb4..91d86f9 100644 --- a/BUILDING.txt +++ b/BUILDING.txt @@ -140,3 +140,14 @@ follows: You'll then need to activate rEFInd in your EFI. This can be done with tools such as "efibootmgr" under Linux or "bless" under OS X. See the docs/refind/installing.html file for details. + +Note to Distribution Maintainers +================================ + +The install.sh script, and therefore the "install" target in the Makefile, +installs the program directly to the ESP and it modifies the *CURRENT +COMPUTER's* NVRAM. Thus, you should *NOT* use this target as part of the +build process for your binary packages (RPMs, Debian packages, etc.). +(Gentoo could use it in an ebuild, though....) You COULD, however, copy the +files to a directory somewhere (/usr/share/refind or whatever) and then +call install.sh as part of the binary package installation process. diff --git a/Makefile b/Makefile index 704334f..e6f6ca0 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,17 @@ clean: make -C $(LIB_DIR) clean make -C $(LOADER_DIR) clean +# NOTE TO DISTRIBUTION MAINTAINERS: +# The "install" target installs the program directly to the ESP +# and it modifies the *CURRENT COMPUTER's* NVRAM. Thus, you should +# *NOT* use this target as part of the build process for your +# binary packages (RPMs, Debian packages, etc.). (Gentoo could +# use it in an ebuild, though....) You COULD, however, copy the +# files to a directory somewhere (/usr/share/refind or whatever) +# and then call install.sh as part of the binary package +# installation process. + install: ./install.sh + # DO NOT DELETE diff --git a/NEWS.txt b/NEWS.txt index 13c8107..23d3378 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -1,8 +1,22 @@ 0.3.4 (?/??/2012): ------------------ +- Added new configuration file option: "icons_dir", which sets the name + of the subdirectory in which icons are found. See the documentation or + sample configuration file for a full description. + +- Modified Makefile to generate rEFInd binary that includes architecture + code -- refind_ia32.efi or refind_x64.efi, rather than the generic + refind.efi. This is done mainly to help the install.sh script. The + program can be named anything you like on the disk. (The generic name + refind.efi is used on unknown architectures.) + +- Improved install.sh script: Fixed bug on OS X 10.7 and enable it to be + used after building from source code (or via new "make install" Makefile + target). + - Improved screen redraws to produce less flicker when moving among the - second-row tags. + second-row tags or to the last tag on the first row. 0.3.3 (5/6/2012): ----------------- diff --git a/docs/refind/configfile.html b/docs/refind/configfile.html index 3e145bb..2a13366 100644 --- a/docs/refind/configfile.html +++ b/docs/refind/configfile.html @@ -148,6 +148,11 @@ timeout 20 banner, label, singleuser, hwtest, arrows, or all Removes the specified user interface features. banner removes the banner graphic, label removes the text description of each tag, singleuser removes the single-user option from the Mac OS sub-menu, hwtest removes the Mac OS hardware test option, arrows removes the arrows to the right or left of the OS tags when rEFInd finds too many OSes to display simultaneously, and all removes all of these options. You can specify multiple parameters with this option. The default is to set none of these values. + + icons_dir + directory name + Specifies a directory in which custom icons may be found. This directory should contain files with the same names as the files in the standard icons directory. The directory name is specified relative to the directory in which the rEFInd binary resides. + banner filename diff --git a/docs/refind/getting.html b/docs/refind/getting.html index 2dc86fb..41c31d0 100644 --- a/docs/refind/getting.html +++ b/docs/refind/getting.html @@ -93,7 +93,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com

Getting rEFInd from Sourceforge

-

You can find the rEFInd source code and binary packages at its SourceForge page. Note that rEFInd is OS-independent—it runs before the OS, so you download the same binary package for any OS. You can obtain rEFInd in three different forms:

+

You can find the rEFInd source code and binary packages at its SourceForge page. Note that rEFInd is OS-independent—it runs before the OS, so you download the same binary package for any OS. You can obtain rEFInd in four different forms:

If you're using another platform, you can give rEFInd a try; however, you'll need to build it from source code yourself or track down a binary from another source. (Perhaps by the time you read this it will be included in Linux distributions built for unusual CPUs.)

diff --git a/docs/refind/themes.html b/docs/refind/themes.html index 66c60dc..261a61d 100644 --- a/docs/refind/themes.html +++ b/docs/refind/themes.html @@ -15,7 +15,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com

Originally written: 4/19/2012; last Web page update: -5/6/2012, referencing rEFInd 0.3.3

+5/6/2012, referencing rEFInd 0.3.4

I'm a technical writer and consultant specializing in Linux technologies. This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!

@@ -96,7 +96,9 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com

-

Of course, not all of these elements are likely to be included in themes. A minimal rEFInd theme would include just some changes to the icons in the icons subdirectory. A more thorough theme would include a changed background image or selection backgrounds.

+

Of course, not all of these elements are likely to be included in themes. A minimal rEFInd theme would provide just a new icons subdirectory, to be set via icons_dir. A more thorough theme would include a changed background image or selection backgrounds.

Note: If you'd like to design a logo for rEFInd, please do so! I lack the sort of artistic talent required for creating logos, so I just used plain text. I'd like to have something more eye-catching, though. I don't promise to use the first logo I'm given, but if you have some ideas, or would like to discuss some ideas, feel free to e-mail me.

diff --git a/docs/refind/todo.html b/docs/refind/todo.html index b482f26..19c4d33 100644 --- a/docs/refind/todo.html +++ b/docs/refind/todo.html @@ -121,11 +121,14 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com

theming by replacing icon files. If you'd like to design a new theme for rEFInd, feel free to submit it. I might or might not replace the icons it uses now (most of which come from the Oxygen Icons package), - but I may provide a way to make selecting a theme from one of several - installed themes easy, and provide links to themes on this Web site (or - even host them on the project's Sourceforge page). For more information - on designing themes for rEFInd, see the Theming - rEFInd page. + but I may provide links to themes on this Web site (or even host them + on the project's Sourceforge page). For more information on designing + themes for rEFInd, see the Theming rEFInd + page. + +
  • If the icons_dir option points to a non-existent directory, + the program displays ugly "icon-missing" icons. It would be better to + drop back to the default icon set.
  • The code could be more flexible in its handling of the sizes of various graphical elements, and particularly drawn text. Prior to version diff --git a/refind.conf-sample b/refind.conf-sample index 2c04c63..1f44731 100644 --- a/refind.conf-sample +++ b/refind.conf-sample @@ -21,6 +21,13 @@ timeout 20 #hideui singleuser #hideui all +# Set the name of a subdirectory in which icons are stored. Icons must +# have the same names they have in the standard directory. The directory +# name is specified relative to the main rEFInd binary's directory. +# Default is "icons". +# +#icons_dir myicons + # Use a custom title banner instead of the rEFInd icon and name. The file # path is relative to the directory where refind.efi is located. The color # in the top left corner of the image is used as the background color diff --git a/refind/config.c b/refind/config.c index 0a15cc6..ebc7d08 100644 --- a/refind/config.c +++ b/refind/config.c @@ -350,6 +350,11 @@ VOID ReadConfig(VOID) } } + } else if ((StriCmp(TokenList[0], L"icons_dir") == 0) && (TokenCount == 2)) { + if (GlobalConfig.IconsDir != NULL) + FreePool(GlobalConfig.IconsDir); + GlobalConfig.IconsDir = StrDuplicate(TokenList[1]); + } else if (StriCmp(TokenList[0], L"scanfor") == 0) { for (i = 0; i < NUM_SCAN_OPTIONS; i++) { if (i < TokenCount) diff --git a/refind/global.h b/refind/global.h index 2cd9b37..678054b 100644 --- a/refind/global.h +++ b/refind/global.h @@ -66,6 +66,7 @@ #define NUM_SCAN_OPTIONS 10 +#define DEFAULT_ICONS_DIR L"icons" // // global definitions @@ -164,6 +165,7 @@ typedef struct { CHAR16 *DefaultSelection; CHAR16 *AlsoScan; CHAR16 *DriverDirs; + CHAR16 *IconsDir; UINTN ShowTools[NUM_TOOLS]; CHAR8 ScanFor[NUM_SCAN_OPTIONS]; // codes of types of loaders for which to scan } REFIT_CONFIG; diff --git a/refind/icns.c b/refind/icns.c index 459dece..1bc3202 100644 --- a/refind/icns.c +++ b/refind/icns.c @@ -45,30 +45,35 @@ typedef struct { EG_IMAGE *Image; - CHAR16 *Path; + CHAR16 *FileName; UINTN PixelSize; } BUILTIN_ICON; BUILTIN_ICON BuiltinIconTable[BUILTIN_ICON_COUNT] = { - { NULL, L"icons\\func_about.icns", 48 }, - { NULL, L"icons\\func_reset.icns", 48 }, - { NULL, L"icons\\func_shutdown.icns", 48 }, - { NULL, L"icons\\func_exit.icns", 48 }, - { NULL, L"icons\\tool_shell.icns", 48 }, - { NULL, L"icons\\tool_part.icns", 48 }, - { NULL, L"icons\\tool_rescue.icns", 48 }, - { NULL, L"icons\\vol_internal.icns", 32 }, - { NULL, L"icons\\vol_external.icns", 32 }, - { NULL, L"icons\\vol_optical.icns", 32 }, + { NULL, L"func_about.icns", 48 }, + { NULL, L"func_reset.icns", 48 }, + { NULL, L"func_shutdown.icns", 48 }, + { NULL, L"func_exit.icns", 48 }, + { NULL, L"tool_shell.icns", 48 }, + { NULL, L"tool_part.icns", 48 }, + { NULL, L"tool_rescue.icns", 48 }, + { NULL, L"vol_internal.icns", 32 }, + { NULL, L"vol_external.icns", 32 }, + { NULL, L"vol_optical.icns", 32 }, }; EG_IMAGE * BuiltinIcon(IN UINTN Id) { + CHAR16 FileName[256]; + if (Id >= BUILTIN_ICON_COUNT) return NULL; - if (BuiltinIconTable[Id].Image == NULL) - BuiltinIconTable[Id].Image = LoadIcnsFallback(SelfDir, BuiltinIconTable[Id].Path, BuiltinIconTable[Id].PixelSize); + if (BuiltinIconTable[Id].Image == NULL) { + SPrint(FileName, 255, L"%s\\%s", GlobalConfig.IconsDir ? GlobalConfig.IconsDir : DEFAULT_ICONS_DIR, + BuiltinIconTable[Id].FileName); + BuiltinIconTable[Id].Image = LoadIcnsFallback(SelfDir, FileName, BuiltinIconTable[Id].PixelSize); + } // if return BuiltinIconTable[Id].Image; } @@ -90,7 +95,8 @@ EG_IMAGE * LoadOSIcon(IN CHAR16 *OSIconName OPTIONAL, IN CHAR16 *FallbackIconNam // try the names from OSIconName while ((CutoutName = FindCommaDelimited(OSIconName, Index++)) != NULL) { - SPrint(FileName, 255, L"icons\\%s_%s.icns", BootLogo ? L"boot" : L"os", CutoutName); + SPrint(FileName, 255, L"%s\\%s_%s.icns", GlobalConfig.IconsDir ? GlobalConfig.IconsDir : DEFAULT_ICONS_DIR, + BootLogo ? L"boot" : L"os", CutoutName); // try to load it Image = egLoadIcon(SelfDir, FileName, 128); @@ -100,7 +106,8 @@ EG_IMAGE * LoadOSIcon(IN CHAR16 *OSIconName OPTIONAL, IN CHAR16 *FallbackIconNam } // while // try the fallback name - SPrint(FileName, 255, L"icons\\%s_%s.icns", BootLogo ? L"boot" : L"os", FallbackIconName); + SPrint(FileName, 255, L"%s\\%s_%s.icns", GlobalConfig.IconsDir ? GlobalConfig.IconsDir : DEFAULT_ICONS_DIR, + BootLogo ? L"boot" : L"os", FallbackIconName); Image = egLoadIcon(SelfDir, FileName, 128); if (Image != NULL) return Image; diff --git a/refind/lib.h b/refind/lib.h index 8b63c22..9f1cb4e 100644 --- a/refind/lib.h +++ b/refind/lib.h @@ -83,6 +83,7 @@ VOID ExtractLegacyLoaderPaths(EFI_DEVICE_PATH **PathList, UINTN MaxPaths, EFI_DE VOID ScanVolumes(VOID); BOOLEAN FileExists(IN EFI_FILE *BaseDir, IN CHAR16 *RelativePath); +BOOLEAN DirectoryExists(IN EFI_FILE *BaseDir, IN CHAR16 *RelativePath); EFI_STATUS DirNextEntry(IN EFI_FILE *Directory, IN OUT EFI_FILE_INFO **DirEntry, IN UINTN FilterMode); diff --git a/refind/main.c b/refind/main.c index 8c4a78e..55ddf89 100644 --- a/refind/main.c +++ b/refind/main.c @@ -85,7 +85,7 @@ static REFIT_MENU_ENTRY MenuEntryExit = { L"Exit rEFInd", TAG_EXIT, 1, 0, 0, static REFIT_MENU_SCREEN MainMenu = { L"Main Menu", NULL, 0, NULL, 0, NULL, 0, L"Automatic boot" }; static REFIT_MENU_SCREEN AboutMenu = { L"About", NULL, 0, NULL, 0, NULL, 0, NULL }; -REFIT_CONFIG GlobalConfig = { FALSE, FALSE, 0, 0, 20, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, +REFIT_CONFIG GlobalConfig = { FALSE, FALSE, 0, 0, 20, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, {TAG_SHELL, TAG_ABOUT, TAG_SHUTDOWN, TAG_REBOOT, 0, 0, 0, 0, 0 }}; // Structure used to hold boot loader filenames and time stamps in @@ -104,7 +104,7 @@ static VOID AboutrEFInd(VOID) { if (AboutMenu.EntryCount == 0) { AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT); - AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.3.3.1"); + AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.3.3.2"); AddMenuInfoLine(&AboutMenu, L""); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer"); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith"); @@ -273,8 +273,8 @@ static CHAR16 * FindInitrd(IN CHAR16 *LoaderPath, IN REFIT_VOLUME *Volume) { while ((DirIterNext(&DirIter, 2, L"init*", &DirEntry)) && (InitrdName == NULL)) { InitrdVersion = FindNumbers(DirEntry->FileName); if (KernelVersion != NULL) { - if (StriCmp(InitrdVersion, KernelVersion) == 0) - InitrdName = PoolPrint(L"%s%s", Path, DirEntry->FileName); + if (StriCmp(InitrdVersion, KernelVersion) == 0) + InitrdName = PoolPrint(L"%s%s", Path, DirEntry->FileName); } else { if (InitrdVersion == NULL) InitrdName = PoolPrint(L"%s%s", Path, DirEntry->FileName); diff --git a/refind/menu.c b/refind/menu.c index ad8d39c..24b5526 100644 --- a/refind/menu.c +++ b/refind/menu.c @@ -85,9 +85,6 @@ static EG_IMAGE *SelectionImages[4] = { NULL, NULL, NULL, NULL }; static EG_PIXEL SelectionBackgroundPixel = { 0xff, 0xff, 0xff, 0 }; static EG_IMAGE *TextBuffer = NULL; -// Used in MainMenuStyle(), but must be persistent.... -UINTN row0PosX = 0, row0PosXRunning = 0, row1PosY = 0, row0Loaders = 0; - // // Graphics helper functions // @@ -180,7 +177,7 @@ static VOID InitScroll(OUT SCROLL_STATE *State, IN UINTN ItemCount, IN UINTN Vis // Adjust variables relating to the scrolling of tags, for when a selected icon isn't // visible given the current scrolling condition.... -static VOID AdjustScrollState(/* IN REFIT_MENU_SCREEN *Screen, */ IN SCROLL_STATE *State) { +static VOID AdjustScrollState(IN SCROLL_STATE *State) { if (State->CurrentSelection > State->LastVisible) { State->LastVisible = State->CurrentSelection; State->FirstVisible = 1 + State->CurrentSelection - State->MaxVisible; @@ -295,7 +292,7 @@ static VOID UpdateScroll(IN OUT SCROLL_STATE *State, IN UINTN Movement) if (!State->PaintAll && State->CurrentSelection != State->PreviousSelection) State->PaintSelection = TRUE; State->LastVisible = State->FirstVisible + State->MaxVisible - 1; -} +} // static VOID UpdateScroll() // // menu helper functions @@ -772,7 +769,7 @@ static VOID PaintSelection(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, UINTN row0PosY, UINTN row1PosY, UINTN textPosY) { UINTN XSelectPrev, XSelectCur, YPosPrev, YPosCur; - if (((State->CurrentSelection < State->LastVisible) && (State->CurrentSelection >= State->FirstVisible)) || + if (((State->CurrentSelection <= State->LastVisible) && (State->CurrentSelection >= State->FirstVisible)) || (State->CurrentSelection >= State->InitialRow1) ) { if (Screen->Entries[State->PreviousSelection]->Row == 0) { XSelectPrev = State->PreviousSelection - State->FirstVisible; @@ -822,10 +819,11 @@ static VOID PaintIcon(IN EG_EMBEDDED_IMAGE *BuiltInIcon, IN CHAR16 *ExternalFile VOID MainMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINTN Function, IN CHAR16 *ParamText) { INTN i; - extern UINTN row0PosX, row0PosXRunning, row1PosY, row0Loaders; + static UINTN row0PosX, row0PosXRunning, row1PosY, row0Loaders; UINTN row0Count, row1Count, row1PosX, row1PosXRunning; static UINTN *itemPosX; static UINTN row0PosY, textPosY; + CHAR16 FileName[256]; State->ScrollMode = SCROLL_MODE_ICONS; switch (Function) { @@ -882,13 +880,17 @@ VOID MainMenuStyle(IN REFIT_MENU_SCREEN *Screen, IN SCROLL_STATE *State, IN UINT // For PaintIcon() calls, the starting Y position is moved to the midpoint // of the surrounding row; PaintIcon() adjusts this back up by half the // icon's height to properly center it. - if ((State->FirstVisible > 0) && (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_ARROWS))) - PaintIcon(&egemb_arrow_left, L"icons\\arrow_left.icns", row0PosX - TILE_XSPACING, + if ((State->FirstVisible > 0) && (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_ARROWS))) { + SPrint(FileName, 255, L"%s\\arrow_left.icns", GlobalConfig.IconsDir ? GlobalConfig.IconsDir : DEFAULT_ICONS_DIR); + PaintIcon(&egemb_arrow_left, FileName, row0PosX - TILE_XSPACING, row0PosY + (ROW0_TILESIZE / 2), ALIGN_RIGHT); - if ((State->LastVisible < (row0Loaders - 1)) && (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_ARROWS))) - PaintIcon(&egemb_arrow_right, L"icons\\arrow_right.icns", + } // if + if ((State->LastVisible < (row0Loaders - 1)) && (!(GlobalConfig.HideUIFlags & HIDEUI_FLAG_ARROWS))) { + SPrint(FileName, 255, L"%s\\arrow_left.icns", GlobalConfig.IconsDir ? GlobalConfig.IconsDir : DEFAULT_ICONS_DIR); + PaintIcon(&egemb_arrow_right, FileName, (UGAWidth + (ROW0_TILESIZE + TILE_XSPACING) * State->MaxVisible) / 2 + TILE_XSPACING, row0PosY + (ROW0_TILESIZE / 2), ALIGN_LEFT); + } // if break; case MENU_FUNCTION_PAINT_SELECTION: