mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 02:57:38 +00:00
fixing bug #11210. Updated the install progress dialog to have a better
look and feel. r=sgehani. affects only the windows platform.
This commit is contained in:
parent
d35e634fb8
commit
620e812679
@ -28,17 +28,26 @@
|
||||
#include "xpistub.h"
|
||||
#include "xpi.h"
|
||||
|
||||
#define BDIR_RIGHT 1
|
||||
#define BDIR_LEFT 2
|
||||
|
||||
static XpiInit pfnXpiInit;
|
||||
static XpiInstall pfnXpiInstall;
|
||||
static XpiExit pfnXpiExit;
|
||||
|
||||
static long lFileCounter;
|
||||
static long lBarberCounter;
|
||||
static BOOL bBarberBar;
|
||||
static DWORD dwBarberDirection;
|
||||
static DWORD dwCurrentArchive;
|
||||
static DWORD dwTotalArchives;
|
||||
char szStrProcessingFile[MAX_BUF];
|
||||
char szStrCopyingFile[MAX_BUF];
|
||||
char szStrInstalling[MAX_BUF];
|
||||
|
||||
static void UpdateGaugeFileProgressBar(unsigned value);
|
||||
static void UpdateGaugeArchiveProgressBar(unsigned value);
|
||||
static void UpdateFileStatus(const char *szFullFilename);
|
||||
static void UpdateGaugeFileBarber(void);
|
||||
|
||||
struct ExtractFilesDlgInfo
|
||||
{
|
||||
@ -149,6 +158,12 @@ HRESULT SmartUpdateJars()
|
||||
return(1);
|
||||
if(NS_LoadString(hSetupRscInst, IDS_DLG_EXTRACTING_TITLE, szDlgExtractingTitle, MAX_BUF) != WIZ_OK)
|
||||
return(1);
|
||||
if(NS_LoadString(hSetupRscInst, IDS_STR_PROCESSINGFILE, szStrProcessingFile, MAX_BUF) != WIZ_OK)
|
||||
exit(1);
|
||||
if(NS_LoadString(hSetupRscInst, IDS_STR_INSTALLING, szStrInstalling, MAX_BUF) != WIZ_OK)
|
||||
exit(1);
|
||||
if(NS_LoadString(hSetupRscInst, IDS_STR_COPYINGFILE, szStrCopyingFile, MAX_BUF) != WIZ_OK)
|
||||
exit(1);
|
||||
|
||||
ShowMessage(szMsgSmartUpdateStart, TRUE);
|
||||
if(InitializeXPIStub() == WIZ_OK)
|
||||
@ -158,17 +173,21 @@ HRESULT SmartUpdateJars()
|
||||
ShowMessage(szMsgSmartUpdateStart, FALSE);
|
||||
InitProgressDlg();
|
||||
GetTotalArchivesToInstall();
|
||||
SetWindowText(dlgInfo.hWndDlg, szDlgExtractingTitle);
|
||||
|
||||
dwIndex0 = 0;
|
||||
dwCurrentArchive = 0;
|
||||
dwTotalArchives *= 2;
|
||||
siCObject = SiCNodeGetObject(dwIndex0, TRUE);
|
||||
dwTotalArchives = (dwTotalArchives * 2) + 1;
|
||||
bBarberBar = FALSE;
|
||||
siCObject = SiCNodeGetObject(dwIndex0, TRUE);
|
||||
while(siCObject)
|
||||
{
|
||||
/* launch smartupdate engine for earch jar to be installed */
|
||||
if((siCObject->dwAttributes & SIC_SELECTED) && !(siCObject->dwAttributes & SIC_LAUNCHAPP))
|
||||
{
|
||||
lFileCounter = 0;
|
||||
lBarberCounter = 0;
|
||||
dwBarberDirection = BDIR_RIGHT;
|
||||
dlgInfo.nFileBars = 0;
|
||||
UpdateGaugeFileProgressBar(0);
|
||||
|
||||
@ -199,8 +218,15 @@ HRESULT SmartUpdateJars()
|
||||
}
|
||||
}
|
||||
|
||||
wsprintf(szBuf, szDlgExtractingTitle, siCObject->szDescriptionShort);
|
||||
SetWindowText(dlgInfo.hWndDlg, szBuf);
|
||||
if(dwCurrentArchive == 0)
|
||||
{
|
||||
++dwCurrentArchive;
|
||||
UpdateGaugeArchiveProgressBar((unsigned)(((double)(dwCurrentArchive)/(double)dwTotalArchives)*(double)100));
|
||||
}
|
||||
|
||||
wsprintf(szBuf, szStrInstalling, siCObject->szDescriptionShort);
|
||||
SetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS0, szBuf);
|
||||
|
||||
hrResult = pfnXpiInstall(szArchive, "", 0xFFFF);
|
||||
if(hrResult == 999)
|
||||
bReboot = TRUE;
|
||||
@ -240,23 +266,36 @@ HRESULT SmartUpdateJars()
|
||||
|
||||
void cbXPIStart(const char *URL, const char *UIName)
|
||||
{
|
||||
// MessageBox(NULL, UIName, "XpiStub is running", MB_ICONEXCLAMATION);
|
||||
}
|
||||
|
||||
void cbXPIProgress(const char* msg, PRInt32 val, PRInt32 max)
|
||||
{
|
||||
char szFilename[MAX_BUF];
|
||||
char szStrProcessingFileBuf[MAX_BUF];
|
||||
char szStrCopyingFileBuf[MAX_BUF];
|
||||
|
||||
ParsePath((char *)msg, szFilename, sizeof(szFilename), PP_FILENAME_ONLY);
|
||||
|
||||
if(max == 0)
|
||||
{
|
||||
UpdateFileStatus(msg);
|
||||
wsprintf(szStrProcessingFileBuf, szStrProcessingFile, szFilename);
|
||||
SetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS3, szStrProcessingFileBuf);
|
||||
bBarberBar = TRUE;
|
||||
UpdateGaugeFileBarber();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateGaugeFileProgressBar((unsigned)(((double)(val+1)/(double)max)*(double)100));
|
||||
if((dwCurrentArchive % 2) == 0)
|
||||
if(bBarberBar == TRUE)
|
||||
{
|
||||
dlgInfo.nFileBars = 0;
|
||||
++dwCurrentArchive;
|
||||
UpdateGaugeArchiveProgressBar((unsigned)(((double)(dwCurrentArchive)/(double)dwTotalArchives)*(double)100));
|
||||
bBarberBar = FALSE;
|
||||
}
|
||||
|
||||
wsprintf(szStrCopyingFileBuf, szStrCopyingFile, szFilename);
|
||||
SetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS3, szStrCopyingFileBuf);
|
||||
UpdateGaugeFileProgressBar((unsigned)(((double)(val+1)/(double)max)*(double)100));
|
||||
}
|
||||
|
||||
ProcessWindowsMessages();
|
||||
@ -290,42 +329,57 @@ CenterWindow(HWND hWndDlg)
|
||||
LRESULT CALLBACK
|
||||
ProgressDlgProc(HWND hWndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
char szStrFileNumber[MAX_BUF];
|
||||
char szStrFilename[MAX_BUF];
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
if(NS_LoadString(hSetupRscInst, IDS_STR_FILE_NUMBER, szStrFileNumber, MAX_BUF) != WIZ_OK)
|
||||
exit(1);
|
||||
if(NS_LoadString(hSetupRscInst, IDS_STR_FILENAME, szStrFilename, MAX_BUF) != WIZ_OK)
|
||||
exit(1);
|
||||
|
||||
// Center the dialog over the desktop
|
||||
CenterWindow(hWndDlg);
|
||||
SetDlgItemText(hWndDlg, IDC_STATUS0, szStrFileNumber);
|
||||
SetDlgItemText(hWndDlg, IDC_STATUS3, szStrFilename);
|
||||
return FALSE;
|
||||
|
||||
case WM_COMMAND:
|
||||
// DestroyWindow(hWndDlg);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE; // didn't handle the message
|
||||
}
|
||||
|
||||
// This routine will update the File Gauge progress bar to the specified percentage
|
||||
// (value between 0 and 100)
|
||||
static void
|
||||
UpdateFileStatus(const char *szFullFilename)
|
||||
UpdateGaugeFileBarber()
|
||||
{
|
||||
char szFileCounter[MAX_BUF];
|
||||
char szFilename[MAX_BUF];
|
||||
int nBars;
|
||||
HWND hWndGauge = GetDlgItem(dlgInfo.hWndDlg, IDC_GAUGE_FILE);
|
||||
RECT rect;
|
||||
|
||||
ParsePath((char *)szFullFilename, szFilename, sizeof(szFilename), PP_FILENAME_ONLY);
|
||||
++lFileCounter;
|
||||
ltoa(lFileCounter, szFileCounter, 10);
|
||||
SetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS1, szFileCounter);
|
||||
SetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS2, szFilename);
|
||||
if(dwBarberDirection == BDIR_RIGHT)
|
||||
{
|
||||
if(lBarberCounter < 151)
|
||||
++lBarberCounter;
|
||||
else
|
||||
dwBarberDirection = BDIR_LEFT;
|
||||
}
|
||||
else if(dwBarberDirection == BDIR_LEFT)
|
||||
{
|
||||
if(lBarberCounter > 0)
|
||||
--lBarberCounter;
|
||||
else
|
||||
dwBarberDirection = BDIR_RIGHT;
|
||||
}
|
||||
|
||||
// Figure out how many bars should be displayed
|
||||
nBars = (dlgInfo.nMaxFileBars * lBarberCounter / 100);
|
||||
|
||||
// Update the gauge state before painting
|
||||
dlgInfo.nFileBars = nBars;
|
||||
|
||||
// Only invalidate the part that needs updating
|
||||
GetClientRect(hWndGauge, &rect);
|
||||
InvalidateRect(hWndGauge, &rect, FALSE);
|
||||
|
||||
// Update the whole extracting dialog. We do this because we don't
|
||||
// have a message loop to process WM_PAINT messages in case the
|
||||
// extracting dialog was exposed
|
||||
UpdateWindow(dlgInfo.hWndDlg);
|
||||
}
|
||||
|
||||
// This routine will update the File Gauge progress bar to the specified percentage
|
||||
@ -460,6 +514,54 @@ DrawProgressBar(HWND hWnd, int nBars)
|
||||
EndPaint(hWnd, &ps);
|
||||
}
|
||||
|
||||
// Draws the blue progress bar
|
||||
static void
|
||||
DrawBarberBar(HWND hWnd, int nBars)
|
||||
{
|
||||
int i;
|
||||
PAINTSTRUCT ps;
|
||||
HDC hDC;
|
||||
RECT rect;
|
||||
HBRUSH hBrush;
|
||||
HBRUSH hBrushClear;
|
||||
|
||||
hDC = BeginPaint(hWnd, &ps);
|
||||
GetClientRect(hWnd, &rect);
|
||||
if(nBars <= 0)
|
||||
{
|
||||
/* clear the bars */
|
||||
hBrushClear = CreateSolidBrush(GetSysColor(COLOR_MENU));
|
||||
FillRect(hDC, &rect, hBrushClear);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Draw the bars
|
||||
hBrushClear = CreateSolidBrush(GetSysColor(COLOR_MENU));
|
||||
hBrush = CreateSolidBrush(RGB(0, 0, 128));
|
||||
rect.left = rect.top = BAR_MARGIN;
|
||||
rect.bottom -= BAR_MARGIN;
|
||||
rect.right = rect.left + BAR_WIDTH;
|
||||
|
||||
for(i = 0; i < (nBars + 1); i++)
|
||||
{
|
||||
RECT dest;
|
||||
|
||||
if(IntersectRect(&dest, &ps.rcPaint, &rect))
|
||||
{
|
||||
if((i >= (nBars - 15)) && (i < nBars))
|
||||
FillRect(hDC, &rect, hBrush);
|
||||
else
|
||||
FillRect(hDC, &rect, hBrushClear);
|
||||
}
|
||||
|
||||
OffsetRect(&rect, BAR_WIDTH + BAR_SPACING, 0);
|
||||
}
|
||||
}
|
||||
|
||||
DeleteObject(hBrush);
|
||||
EndPaint(hWnd, &ps);
|
||||
}
|
||||
|
||||
// Adjusts the width of the gauge based on the maximum number of bars
|
||||
static void
|
||||
SizeToFitGauge(HWND hWnd, int nMaxBars)
|
||||
@ -507,7 +609,11 @@ GaugeFileWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
return(FALSE);
|
||||
|
||||
case WM_PAINT:
|
||||
DrawProgressBar(hWnd, dlgInfo.nFileBars);
|
||||
if(bBarberBar == TRUE)
|
||||
DrawBarberBar(hWnd, dlgInfo.nFileBars);
|
||||
else
|
||||
DrawProgressBar(hWnd, dlgInfo.nFileBars);
|
||||
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,9 @@
|
||||
#define IDS_ERROR_XPI_INSTALL 23
|
||||
#define IDS_ERROR_SETUP_REQUIREMENT 24
|
||||
#define IDS_DLG_EXTRACTING_TITLE 25
|
||||
#define IDS_STR_PROCESSINGFILE 26
|
||||
#define IDS_STR_INSTALLING 27
|
||||
#define IDS_STR_COPYINGFILE 28
|
||||
#define IDI_ICON1 105
|
||||
#define IDI_SETUP 105
|
||||
#define IDB_BITMAP_WELCOME 108
|
||||
|
@ -52,7 +52,7 @@ END
|
||||
// Dialog
|
||||
//
|
||||
|
||||
DLG_WELCOME DIALOG 51, 56, 315, 205
|
||||
DLG_WELCOME DIALOG DISCARDABLE 51, 56, 315, 205
|
||||
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
@ -67,7 +67,7 @@ BEGIN
|
||||
WS_EX_STATICEDGE
|
||||
END
|
||||
|
||||
DLG_SETUP_TYPE DIALOG 51, 56, 315, 205
|
||||
DLG_SETUP_TYPE DIALOG DISCARDABLE 51, 56, 315, 205
|
||||
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
@ -95,7 +95,7 @@ BEGIN
|
||||
LTEXT "Static",IDC_EDIT_DESTINATION,107,160,144,9
|
||||
END
|
||||
|
||||
DLG_SELECT_COMPONENTS DIALOG 51, 56, 315, 205
|
||||
DLG_SELECT_COMPONENTS DIALOG DISCARDABLE 51, 56, 315, 205
|
||||
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
@ -123,7 +123,7 @@ BEGIN
|
||||
LTEXT "Download Size",IDC_STATIC,201,32,103,8,0,WS_EX_RIGHT
|
||||
END
|
||||
|
||||
DLG_WINDOWS_INTEGRATION DIALOG 51, 56, 315, 205
|
||||
DLG_WINDOWS_INTEGRATION DIALOG DISCARDABLE 51, 56, 315, 205
|
||||
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
@ -146,7 +146,7 @@ BEGIN
|
||||
WS_EX_STATICEDGE
|
||||
END
|
||||
|
||||
DLG_PROGRAM_FOLDER DIALOG 51, 56, 315, 205
|
||||
DLG_PROGRAM_FOLDER DIALOG DISCARDABLE 51, 56, 315, 205
|
||||
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
@ -166,7 +166,7 @@ BEGIN
|
||||
WS_EX_STATICEDGE
|
||||
END
|
||||
|
||||
DLG_LICENSE DIALOG 51, 56, 315, 205
|
||||
DLG_LICENSE DIALOG DISCARDABLE 51, 56, 315, 205
|
||||
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
@ -183,7 +183,7 @@ BEGIN
|
||||
WS_EX_STATICEDGE
|
||||
END
|
||||
|
||||
DLG_START_INSTALL DIALOG 51, 56, 315, 205
|
||||
DLG_START_INSTALL DIALOG DISCARDABLE 51, 56, 315, 205
|
||||
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
@ -201,7 +201,7 @@ BEGIN
|
||||
WS_EX_STATICEDGE
|
||||
END
|
||||
|
||||
DLG_BROWSE_DIR DIALOG 147, 23, 190, 143
|
||||
DLG_BROWSE_DIR DIALOG DISCARDABLE 147, 23, 190, 143
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Select a directory"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
@ -242,16 +242,13 @@ BEGIN
|
||||
END
|
||||
|
||||
DLG_EXTRACTING DIALOG DISCARDABLE 0, 0, 193, 73
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Extracting..."
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
LTEXT "",IDC_STATUS1,48,10,25,8
|
||||
CONTROL "",IDC_GAUGE_FILE,"GaugeFile",0x0,9,37,175,11
|
||||
LTEXT "",IDC_STATUS2,45,22,139,8
|
||||
LTEXT "",IDC_STATUS0,9,10,35,8
|
||||
LTEXT "",IDC_STATUS3,9,22,31,8
|
||||
CONTROL "",IDC_GAUGE_ARCHIVE,"GaugeArchive",0x0,9,55,175,11
|
||||
CONTROL "",IDC_GAUGE_FILE,"GaugeFile",0x0,9,52,175,11
|
||||
LTEXT "",IDC_STATUS0,9,9,175,8
|
||||
LTEXT "",IDC_STATUS3,9,40,175,8
|
||||
CONTROL "",IDC_GAUGE_ARCHIVE,"GaugeArchive",0x0,9,21,175,11
|
||||
END
|
||||
|
||||
|
||||
@ -283,7 +280,7 @@ GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
DLG_EXTRACTING, DIALOG
|
||||
BEGIN
|
||||
BOTTOMMARGIN, 61
|
||||
BOTTOMMARGIN, 72
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
@ -332,7 +329,10 @@ BEGIN
|
||||
IDS_ERROR_XPI_INSTALL "Error ocurred during installation"
|
||||
IDS_ERROR_SETUP_REQUIREMENT
|
||||
"Windows95 or greater Operating System is required! Exiting setup..."
|
||||
IDS_DLG_EXTRACTING_TITLE "Installing %s"
|
||||
IDS_DLG_EXTRACTING_TITLE "Install Progress"
|
||||
IDS_STR_PROCESSINGFILE "Preparing file: %s"
|
||||
IDS_STR_INSTALLING "Currently installing %s"
|
||||
IDS_STR_COPYINGFILE "Copying file: %s"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
|
Loading…
Reference in New Issue
Block a user