[ui] misc. UI improvements

* improved ISO selection
* set default FS according to ISO boot method
* fix exFAT selection
This commit is contained in:
Pete Batard 2012-02-16 11:37:59 +00:00
parent 3cd83869c4
commit c79bfa0cb4
2 changed files with 71 additions and 35 deletions

View File

@ -384,6 +384,25 @@ static BOOL GetDriveInfo(void)
return SetClusterSizes((int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)));
}
static void SetFSFromISO(void)
{
int i, fs;
if (iso_path == NULL)
return;
for (i=ComboBox_GetCount(hFileSystem)-1; i>=0; i--) {
fs = ComboBox_GetItemData(hFileSystem, i);
if ( ((iso_report.has_bootmgr) && (fs == FS_NTFS))
|| ((iso_report.has_isolinux) && ((fs == FS_FAT32) || (fs == FS_FAT16))) ) {
IGNORE_RETVAL(ComboBox_SetCurSel(hFileSystem, i));
break;
}
}
SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_FILESYSTEM,
ComboBox_GetCurSel(hFileSystem));
}
/*
* Populate the UI properties
*/
@ -411,8 +430,9 @@ static BOOL PopulateProperties(int ComboIndex)
}
SelectedDrive.DeviceNumber = (DWORD)ComboBox_GetItemData(hDeviceList, ComboIndex);
if (!GetDriveInfo())
if (!GetDriveInfo()) // This also populates FS
return FALSE;
SetFSFromISO();
HumanReadableSize = (double)SelectedDrive.DiskSize;
for (i=0; i<ARRAYSIZE(suffix); i++) {
@ -426,21 +446,25 @@ static BOOL PopulateProperties(int ComboIndex)
IGNORE_RETVAL(ComboBox_SetCurSel(hCapacity, 0));
hDeviceTooltip = CreateTooltip(hDeviceList, DriveID.Table[ComboIndex], -1);
// If no existing label is available, propose one according to the size (eg: "256MB", "8GB")
if (safe_strcmp(no_label, DriveLabel.Table[ComboIndex]) == 0) {
if (HumanReadableSize < 1.0) {
HumanReadableSize *= 1024.0;
i--;
}
// If we're beneath the tolerance, round proposed label to an integer, if not, show one decimal point
if (fabs(HumanReadableSize / ceil(HumanReadableSize) - 1.0) < PROPOSEDLABEL_TOLERANCE) {
safe_sprintf(proposed_label, sizeof(proposed_label), "%0.0f%s", ceil(HumanReadableSize), suffix[i]);
// If no existing label is available and no ISO is selected, propose one according to the size (eg: "256MB", "8GB")
if ((iso_path == NULL) || (iso_report.label[0] == 0)) {
if (safe_strcmp(no_label, DriveLabel.Table[ComboIndex]) == 0) {
if (HumanReadableSize < 1.0) {
HumanReadableSize *= 1024.0;
i--;
}
// If we're beneath the tolerance, round proposed label to an integer, if not, show one decimal point
if (fabs(HumanReadableSize / ceil(HumanReadableSize) - 1.0) < PROPOSEDLABEL_TOLERANCE) {
safe_sprintf(proposed_label, sizeof(proposed_label), "%0.0f%s", ceil(HumanReadableSize), suffix[i]);
} else {
safe_sprintf(proposed_label, sizeof(proposed_label), "%0.1f%s", HumanReadableSize, suffix[i]);
}
SetWindowTextU(hLabel, proposed_label);
} else {
safe_sprintf(proposed_label, sizeof(proposed_label), "%0.1f%s", HumanReadableSize, suffix[i]);
SetWindowTextU(hLabel, DriveLabel.Table[ComboIndex]);
}
SetWindowTextA(hLabel, proposed_label);
} else {
SetWindowTextA(hLabel, DriveLabel.Table[ComboIndex]);
SetWindowTextU(hLabel, iso_report.label);
}
return TRUE;
@ -962,6 +986,7 @@ DWORD WINAPI ISOScanThread(LPVOID param)
PrintStatus(0, TRUE, "Scanning ISO image...\n");
if (!ExtractISO(iso_path, "", TRUE)) {
PrintStatus(0, TRUE, "Failed to scan ISO image.");
safe_free(iso_path);
goto out;
}
uprintf("ISO label: '%s'\n size: %lld bytes, 4GB:%c, bootmgr:%c, isolinux:%c\n",
@ -973,6 +998,9 @@ DWORD WINAPI ISOScanThread(LPVOID param)
"This ISO image doesn't appear to use either...", "Unsupported ISO", MB_OK|MB_ICONINFORMATION);
safe_free(iso_path);
} else {
// Enable DOS, set DOS Type to ISO (last item) and set FS accordingly
CheckDlgButton(hMainDialog, IDC_DOS, BST_CHECKED);
SetFSFromISO();
for (i=(int)safe_strlen(iso_path); (i>0)&&(iso_path[i]!='\\'); i--);
PrintStatus(0, TRUE, "Using ISO: %s\n", &iso_path[i+1]);
// Some Linux distros, such as Arch Linux, require the USB drive to have
@ -980,6 +1008,10 @@ DWORD WINAPI ISOScanThread(LPVOID param)
if (iso_report.label[0] != 0) {
SetWindowTextU(hLabel, iso_report.label);
}
// Lose the focus on the select ISO (but place it on Close)
SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)FALSE, 0);
// Lose the focus from Close and set it back to Start
SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hMainDialog, IDC_START), TRUE);
}
out:
@ -1217,14 +1249,16 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
break;
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
SetClusterSizes(fs);
if (((fs == FS_EXFAT) || (fs <0)) && IsWindowEnabled(hDOS)) {
// unlikely to be supported by BIOSes => don't bother
IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, 0));
uDOSChecked = IsDlgButtonChecked(hMainDialog, IDC_DOS);
CheckDlgButton(hDlg, IDC_DOS, BST_UNCHECKED);
EnableWindow(hDOS, FALSE);
EnableWindow(hDOSType, FALSE);
ShowWindow(hSelectISO, SW_HIDE);
if ((fs == FS_EXFAT) || (fs <0)) {
if (IsWindowEnabled(hDOS)) {
// unlikely to be supported by BIOSes => don't bother
IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, 0));
uDOSChecked = IsDlgButtonChecked(hMainDialog, IDC_DOS);
CheckDlgButton(hDlg, IDC_DOS, BST_UNCHECKED);
EnableWindow(hDOS, FALSE);
EnableWindow(hDOSType, FALSE);
EnableWindow(hSelectISO, FALSE);
}
break;
}
IGNORE_RETVAL(ComboBox_ResetContent(hDOSType));
@ -1238,23 +1272,25 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
if (fs == FS_NTFS) {
IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "ISO Image"), DT_ISO_NTFS));
}
IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, (bWithFreeDOS && (fs != FS_NTFS))?1:0));
if (iso_path != NULL)
IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, ComboBox_GetCount(hDOSType) - 1));
else
IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, (bWithFreeDOS && (fs != FS_NTFS))?1:0));
if (!IsWindowEnabled(hDOS)) {
EnableWindow(hDOS, TRUE);
EnableWindow(hDOSType, TRUE);
EnableWindow(hSelectISO, TRUE);
CheckDlgButton(hDlg, IDC_DOS, uDOSChecked);
}
// Fall through to enable/disable the ISO selection
break;
case IDC_DOSTYPE:
if (HIWORD(wParam) != CBN_SELCHANGE)
break;
dt = (int)ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType));
if ((dt != DT_ISO_NTFS) && (dt != DT_ISO_FAT)) {
ShowWindow(hSelectISO, SW_HIDE);
break;
if ((dt == DT_ISO_NTFS) || (dt == DT_ISO_FAT)) {
SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)hSelectISO, TRUE);
}
ShowWindow(hSelectISO, SW_SHOW);
break;
return (INT_PTR)TRUE;
case IDC_SELECT_ISO:
DestroyTooltip(hISOToolTip);
safe_free(iso_path);

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 278
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.1.1.135"
CAPTION "Rufus v1.1.1.136"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,236,50,14
@ -57,7 +57,7 @@ BEGIN
COMBOBOX IDC_DOSTYPE,119,183,49,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_NBPASSES,119,159,49,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "Test",IDC_TEST,62,236,20,14,NOT WS_VISIBLE
PUSHBUTTON "...",IDC_SELECT_ISO,171,182,22,14,BS_ICON | NOT WS_VISIBLE
PUSHBUTTON "...",IDC_SELECT_ISO,171,182,22,14,BS_ICON
END
IDD_ABOUTBOX DIALOGEX 0, 0, 287, 195
@ -71,7 +71,7 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
"SysLink",WS_TABSTOP,46,47,114,9
LTEXT "Version 1.1.1 (Build 135)",IDC_STATIC,46,19,78,8
LTEXT "Version 1.1.1 (Build 136)",IDC_STATIC,46,19,78,8
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
@ -222,8 +222,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,1,135
PRODUCTVERSION 1,1,1,135
FILEVERSION 1,1,1,136
PRODUCTVERSION 1,1,1,136
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -240,13 +240,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.1.1.135"
VALUE "FileVersion", "1.1.1.136"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.1.1.135"
VALUE "ProductVersion", "1.1.1.136"
END
END
BLOCK "VarFileInfo"