mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Fix for 35866 -- have the splash screen show progress message (for now, just during autoreg).
This commit is contained in:
parent
7c1335fa2a
commit
7992cb8d3c
Binary file not shown.
@ -35,6 +35,7 @@
|
||||
#include "nsIThread.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIAppShellComponent.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "prprf.h"
|
||||
#include "nsCRT.h"
|
||||
@ -744,6 +745,18 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
|
||||
fpsetmask(0);
|
||||
#endif
|
||||
|
||||
// Setup an autoreg obserer, so that we can update a progress
|
||||
// string in the splash screen
|
||||
nsCOMPtr<nsIObserverService> obsService = do_GetService(NS_OBSERVERSERVICE_PROGID);
|
||||
if (obsService)
|
||||
{
|
||||
nsCOMPtr<nsIObserver> splashScreenObserver = do_QueryInterface(nativeApp);
|
||||
if (splashScreenObserver)
|
||||
{
|
||||
obsService->AddObserver(splashScreenObserver, NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).GetUnicode());
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// XPInstall needs to clean up after any updates that couldn't
|
||||
// be completed because components were in use. This must be done
|
||||
@ -775,6 +788,16 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
|
||||
// XXX: This call will be replaced by a registry initialization...
|
||||
NS_SetupRegistry_1( needAutoreg );
|
||||
|
||||
// remove the nativeApp as an XPCOM autoreg observer
|
||||
if (obsService)
|
||||
{
|
||||
nsCOMPtr<nsIObserver> splashScreenObserver = do_QueryInterface(nativeApp);
|
||||
if (splashScreenObserver)
|
||||
{
|
||||
obsService->RemoveObserver(splashScreenObserver, NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).GetUnicode());
|
||||
}
|
||||
}
|
||||
|
||||
// Start up the core services:
|
||||
|
||||
// Initialize the cmd line service
|
||||
@ -811,6 +834,7 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
|
||||
splashScreen->Hide();
|
||||
}
|
||||
}
|
||||
|
||||
// Release argument object.
|
||||
NS_IF_RELEASE( nativeApp );
|
||||
return rv;
|
||||
|
@ -20,89 +20,115 @@
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsNativeAppSupport.h"
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
#include <Gestalt.h>
|
||||
#include <Dialogs.h>
|
||||
#include <Resources.h>
|
||||
|
||||
|
||||
|
||||
#include "nsIObserver.h"
|
||||
|
||||
#define rSplashDialog 512
|
||||
|
||||
class nsSplashScreenMac : public nsISplashScreen {
|
||||
class nsSplashScreenMac : public nsISplashScreen,
|
||||
public nsIObserver
|
||||
{
|
||||
public:
|
||||
nsSplashScreenMac()
|
||||
: mDialog( 0 ), mPicHandle( 0 ), mRefCnt( 0 ) {
|
||||
}
|
||||
~nsSplashScreenMac() {
|
||||
Hide();
|
||||
}
|
||||
|
||||
// dialog itemse
|
||||
enum {
|
||||
eSplashPictureItem = 1,
|
||||
eSplashStatusTextItem
|
||||
};
|
||||
|
||||
nsSplashScreenMac();
|
||||
virtual ~nsSplashScreenMac();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Show();
|
||||
NS_IMETHOD Hide();
|
||||
|
||||
// nsISupports methods
|
||||
NS_IMETHOD_(nsrefcnt) AddRef() {
|
||||
mRefCnt++;
|
||||
return mRefCnt;
|
||||
}
|
||||
NS_IMETHOD_(nsrefcnt) Release() {
|
||||
--mRefCnt;
|
||||
if ( !mRefCnt ) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
NS_IMETHOD QueryInterface( const nsIID &iid, void**p ) {
|
||||
nsresult rv = NS_OK;
|
||||
if ( p ) {
|
||||
*p = 0;
|
||||
if ( iid.Equals( NS_GET_IID( nsISplashScreen ) ) ) {
|
||||
nsISplashScreen *result = this;
|
||||
*p = result;
|
||||
NS_ADDREF( result );
|
||||
} else if ( iid.Equals( NS_GET_IID( nsISupports ) ) ) {
|
||||
nsISupports *result = NS_STATIC_CAST( nsISupports*, this );
|
||||
*p = result;
|
||||
NS_ADDREF( result );
|
||||
} else {
|
||||
rv = NS_NOINTERFACE;
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
protected:
|
||||
|
||||
DialogPtr mDialog;
|
||||
PicHandle mPicHandle;
|
||||
nsrefcnt mRefCnt;
|
||||
|
||||
}; // class nsSplashScreenMac
|
||||
|
||||
|
||||
nsSplashScreenMac::nsSplashScreenMac()
|
||||
: mDialog(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
nsSplashScreenMac::~nsSplashScreenMac()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsSplashScreenMac, nsISplashScreen, nsIObserver);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSplashScreenMac::Show() {
|
||||
mDialog = ::GetNewDialog( rSplashDialog, nil, (WindowPtr)-1L );
|
||||
mPicHandle = GetPicture( rSplashDialog );
|
||||
SetWindowPic( mDialog, mPicHandle );
|
||||
::ShowWindow( mDialog );
|
||||
::SetPort( mDialog );
|
||||
Rect rect = (**mPicHandle).picFrame;
|
||||
::DrawPicture( mPicHandle, &rect );
|
||||
return NS_OK;
|
||||
nsSplashScreenMac::Show()
|
||||
{
|
||||
mDialog = ::GetNewDialog(rSplashDialog, nil, (WindowPtr)-1L);
|
||||
if (!mDialog) return NS_ERROR_FAILURE;
|
||||
|
||||
::ShowWindow(mDialog);
|
||||
::SetPort(mDialog);
|
||||
|
||||
::DrawDialog(mDialog); // we don't handle events for this dialog, so we
|
||||
// need to draw explicitly. Yuck.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSplashScreenMac::Hide() {
|
||||
if ( mDialog ) {
|
||||
ReleaseResource( (Handle)mPicHandle );
|
||||
mPicHandle = 0;
|
||||
SetWindowPic( mDialog, NULL );
|
||||
DisposeWindow( mDialog );
|
||||
mDialog = 0;
|
||||
nsSplashScreenMac::Hide()
|
||||
{
|
||||
if (mDialog)
|
||||
{
|
||||
::DisposeDialog( mDialog );
|
||||
mDialog = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSplashScreenMac::Observe(nsISupports *aSubject, const PRUnichar *aTopic, const PRUnichar *someData)
|
||||
{
|
||||
// update a string in the dialog
|
||||
|
||||
nsCAutoString statusString;
|
||||
statusString.AssignWithConversion(someData);
|
||||
|
||||
Handle item = nsnull;
|
||||
Rect itemRect;
|
||||
short itemType;
|
||||
::GetDialogItem(mDialog, eSplashStatusTextItem, &itemType, &item, &itemRect);
|
||||
if (!item) return NS_OK;
|
||||
|
||||
// convert string to Pascal string
|
||||
Str255 statusPStr;
|
||||
PRInt32 maxLen = statusString.Length();
|
||||
if (maxLen > 254)
|
||||
maxLen = 254;
|
||||
strncpy((char *)&statusPStr[1], (const char *)statusString, maxLen);
|
||||
statusPStr[0] = maxLen;
|
||||
|
||||
::SetDialogItemText(item, statusPStr);
|
||||
::DrawDialog(mDialog);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
nsresult NS_CreateSplashScreen(nsISplashScreen**aResult)
|
||||
{
|
||||
if ( aResult ) {
|
||||
|
Loading…
Reference in New Issue
Block a user