mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +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 "nsIThread.h"
|
||||||
#include "nsIAppShellService.h"
|
#include "nsIAppShellService.h"
|
||||||
#include "nsIAppShellComponent.h"
|
#include "nsIAppShellComponent.h"
|
||||||
|
#include "nsIObserverService.h"
|
||||||
#include "nsAppShellCIDs.h"
|
#include "nsAppShellCIDs.h"
|
||||||
#include "prprf.h"
|
#include "prprf.h"
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
@ -744,6 +745,18 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
|
|||||||
fpsetmask(0);
|
fpsetmask(0);
|
||||||
#endif
|
#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
|
// XPInstall needs to clean up after any updates that couldn't
|
||||||
// be completed because components were in use. This must be done
|
// 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...
|
// XXX: This call will be replaced by a registry initialization...
|
||||||
NS_SetupRegistry_1( needAutoreg );
|
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:
|
// Start up the core services:
|
||||||
|
|
||||||
// Initialize the cmd line service
|
// Initialize the cmd line service
|
||||||
@ -811,6 +834,7 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
|
|||||||
splashScreen->Hide();
|
splashScreen->Hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release argument object.
|
// Release argument object.
|
||||||
NS_IF_RELEASE( nativeApp );
|
NS_IF_RELEASE( nativeApp );
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -20,89 +20,115 @@
|
|||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*/
|
*/
|
||||||
#include "nsNativeAppSupport.h"
|
#include "nsNativeAppSupport.h"
|
||||||
|
#include "nsString.h"
|
||||||
|
|
||||||
#include <Gestalt.h>
|
#include <Gestalt.h>
|
||||||
#include <Dialogs.h>
|
#include <Dialogs.h>
|
||||||
#include <Resources.h>
|
#include <Resources.h>
|
||||||
|
|
||||||
|
#include "nsIObserver.h"
|
||||||
|
|
||||||
#define rSplashDialog 512
|
#define rSplashDialog 512
|
||||||
|
|
||||||
class nsSplashScreenMac : public nsISplashScreen {
|
class nsSplashScreenMac : public nsISplashScreen,
|
||||||
|
public nsIObserver
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
nsSplashScreenMac()
|
|
||||||
: mDialog( 0 ), mPicHandle( 0 ), mRefCnt( 0 ) {
|
// dialog itemse
|
||||||
}
|
enum {
|
||||||
~nsSplashScreenMac() {
|
eSplashPictureItem = 1,
|
||||||
Hide();
|
eSplashStatusTextItem
|
||||||
}
|
};
|
||||||
|
|
||||||
|
nsSplashScreenMac();
|
||||||
|
virtual ~nsSplashScreenMac();
|
||||||
|
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
NS_IMETHOD Show();
|
NS_IMETHOD Show();
|
||||||
NS_IMETHOD Hide();
|
NS_IMETHOD Hide();
|
||||||
|
|
||||||
// nsISupports methods
|
NS_DECL_NSIOBSERVER
|
||||||
NS_IMETHOD_(nsrefcnt) AddRef() {
|
|
||||||
mRefCnt++;
|
protected:
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
DialogPtr mDialog;
|
DialogPtr mDialog;
|
||||||
PicHandle mPicHandle;
|
|
||||||
nsrefcnt mRefCnt;
|
|
||||||
}; // class nsSplashScreenMac
|
}; // class nsSplashScreenMac
|
||||||
|
|
||||||
|
|
||||||
|
nsSplashScreenMac::nsSplashScreenMac()
|
||||||
|
: mDialog(nsnull)
|
||||||
|
{
|
||||||
|
NS_INIT_REFCNT();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nsSplashScreenMac::~nsSplashScreenMac()
|
||||||
|
{
|
||||||
|
Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NS_IMPL_ISUPPORTS2(nsSplashScreenMac, nsISplashScreen, nsIObserver);
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSplashScreenMac::Show() {
|
nsSplashScreenMac::Show()
|
||||||
|
{
|
||||||
mDialog = ::GetNewDialog(rSplashDialog, nil, (WindowPtr)-1L);
|
mDialog = ::GetNewDialog(rSplashDialog, nil, (WindowPtr)-1L);
|
||||||
mPicHandle = GetPicture( rSplashDialog );
|
if (!mDialog) return NS_ERROR_FAILURE;
|
||||||
SetWindowPic( mDialog, mPicHandle );
|
|
||||||
::ShowWindow(mDialog);
|
::ShowWindow(mDialog);
|
||||||
::SetPort(mDialog);
|
::SetPort(mDialog);
|
||||||
Rect rect = (**mPicHandle).picFrame;
|
|
||||||
::DrawPicture( mPicHandle, &rect );
|
::DrawDialog(mDialog); // we don't handle events for this dialog, so we
|
||||||
|
// need to draw explicitly. Yuck.
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsSplashScreenMac::Hide() {
|
nsSplashScreenMac::Hide()
|
||||||
if ( mDialog ) {
|
{
|
||||||
ReleaseResource( (Handle)mPicHandle );
|
if (mDialog)
|
||||||
mPicHandle = 0;
|
{
|
||||||
SetWindowPic( mDialog, NULL );
|
::DisposeDialog( mDialog );
|
||||||
DisposeWindow( mDialog );
|
mDialog = nsnull;
|
||||||
mDialog = 0;
|
|
||||||
}
|
}
|
||||||
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)
|
nsresult NS_CreateSplashScreen(nsISplashScreen**aResult)
|
||||||
{
|
{
|
||||||
if ( aResult ) {
|
if ( aResult ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user