Display links in status bar when moused over

This commit is contained in:
law%netscape.com 1999-06-08 20:59:41 +00:00
Родитель a3999d66ef
Коммит d3849e81f3
5 изменённых файлов: 165 добавлений и 9 удалений

Просмотреть файл

@ -92,7 +92,6 @@ NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
// Stuff to implement find/findnext
#include "nsIFindComponent.h"
static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
@ -151,6 +150,8 @@ nsBrowserAppCore::nsBrowserAppCore()
nsBrowserAppCore::~nsBrowserAppCore()
{
EndObserving();
NS_IF_RELEASE(mToolbarWindow);
NS_IF_RELEASE(mToolbarScriptContext);
NS_IF_RELEASE(mContentWindow);
@ -197,6 +198,11 @@ nsBrowserAppCore::QueryInterface(REFNSIID aIID,void** aInstancePtr)
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals( nsIObserver::GetIID())) {
*aInstancePtr = (void*) ((nsIObserver*)this);
NS_ADDREF_THIS();
return NS_OK;
}
return nsBaseAppCore::QueryInterface(aIID, aInstancePtr);
}
@ -270,6 +276,8 @@ nsBrowserAppCore::Init(const nsString& aId)
nsServiceManager::GetService(kCGlobalHistoryCID, kIGlobalHistoryIID,
(nsISupports **)&mGHistory);
BeginObserving();
return rv;
}
@ -1392,3 +1400,84 @@ FindNamedXULElement(nsIWebShell * aShell,
}
return rv;
}
static const char *prefix = "component://netscape/appshell/component/browser/window";
void
nsBrowserAppCore::BeginObserving() {
// Get observer service.
nsIObserverService *svc = 0;
nsresult rv = nsServiceManager::GetService( NS_OBSERVERSERVICE_PROGID,
nsIObserverService::GetIID(),
(nsISupports**)&svc );
if ( NS_SUCCEEDED( rv ) && svc ) {
// Add/Remove object as observer of web shell window topics.
nsString topic1 = prefix;
topic1 += ";status";
nsString topic2 = prefix;
topic2 += ";progress";
rv = svc->AddObserver( this, topic1.GetUnicode() );
rv = svc->AddObserver( this, topic2.GetUnicode() );
// Release the service.
nsServiceManager::ReleaseService( NS_OBSERVERSERVICE_PROGID, svc );
}
return;
}
void
nsBrowserAppCore::EndObserving() {
// Get observer service.
nsIObserverService *svc = 0;
nsresult rv = nsServiceManager::GetService( NS_OBSERVERSERVICE_PROGID,
nsIObserverService::GetIID(),
(nsISupports**)&svc );
if ( NS_SUCCEEDED( rv ) && svc ) {
// Add/Remove object as observer of web shell window topics.
nsString topic1 = prefix;
topic1 += ";status";
nsString topic2 = prefix;
topic2 += ";progress";
rv = svc->RemoveObserver( this, topic1.GetUnicode() );
rv = svc->RemoveObserver( this, topic2.GetUnicode() );
// Release the service.
nsServiceManager::ReleaseService( NS_OBSERVERSERVICE_PROGID, svc );
}
return;
}
NS_IMETHODIMP
nsBrowserAppCore::Observe( nsISupports *aSubject,
const PRUnichar *aTopic,
const PRUnichar *someData ) {
nsresult rv = NS_OK;
// We only are interested if aSubject is our web shell window.
if ( aSubject && mWebShellWin ) {
nsIWebShellWindow *window = 0;
rv = aSubject->QueryInterface( nsIWebShellWindow::GetIID(), (void**)&window );
if ( NS_SUCCEEDED( rv ) && window ) {
nsString topic1 = prefix;
topic1 += ";status";
nsString topic2 = prefix;
topic2 += ";progress";
// Compare to our window.
if ( window == mWebShellWin ) {
// Get topic substring.
if ( topic1 == aTopic ) {
// Update status text.
rv = setAttribute( mWebShell, "Browser:Status", "value", someData );
} else if ( topic2 == aTopic ) {
// We don't process this, yet.
}
} else {
// Not for this app core.
}
// Release the window.
window->Release();
}
}
return rv;
}

Просмотреть файл

@ -29,6 +29,7 @@
#include "nsINetSupport.h"
#include "nsIStreamObserver.h"
#include "nsIDocumentLoaderObserver.h"
#include "nsIObserver.h"
class nsIBrowserWindow;
class nsIWebShell;
@ -48,7 +49,8 @@ class nsBrowserAppCore : public nsBaseAppCore,
public nsIDOMBrowserAppCore,
public nsINetSupport,
// public nsIStreamObserver,
public nsIDocumentLoaderObserver
public nsIDocumentLoaderObserver,
public nsIObserver
{
public:
@ -118,11 +120,16 @@ class nsBrowserAppCore : public nsBaseAppCore,
NS_IMETHOD_(PRBool) PromptPassword(const nsString &aText,
nsString &aPassword);
// nsIObserver
NS_DECL_IOBSERVER
protected:
NS_IMETHOD DoDialog();
NS_IMETHOD ExecuteScript(nsIScriptContext * aContext, const nsString& aScript);
void SetButtonImage(nsIDOMNode * aParentNode, PRInt32 aBtnNum, const nsString &aResName);
void InitializeSearch(nsIFindComponent*);
void InitializeSearch(nsIFindComponent*);
void BeginObserving();
void EndObserving();
nsIScriptContext *mToolbarScriptContext;
nsIScriptContext *mContentScriptContext;

Просмотреть файл

@ -74,6 +74,8 @@
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsIDocumentLoader.h"
#include "nsIObserverService.h"
#include "prprf.h"
//#include "nsIDOMHTMLInputElement.h"
//#include "nsIDOMHTMLImageElement.h"
@ -2301,21 +2303,69 @@ NS_IMETHODIMP nsWebShellWindow::GetTitle(const PRUnichar** aResult)
// no, we didn't store the title for you. why so nosy?
return NS_ERROR_FAILURE;
}
// This should rightfully be somebody's PROGID?
// Will switch when the "app shell browser component" arrives.
static const char *prefix = "component://netscape/appshell/component/browser/window";
nsresult
nsWebShellWindow::NotifyObservers( const nsString &aTopic, const nsString &someData ) {
nsresult rv = NS_OK;
// Get observer service.
nsIObserverService *svc = 0;
rv = nsServiceManager::GetService( NS_OBSERVERSERVICE_PROGID,
nsIObserverService::GetIID(),
(nsISupports**)&svc );
if ( NS_SUCCEEDED( rv ) && svc ) {
// Notify observers as instructed; the subject is "this" web shell window.
nsString topic = prefix;
topic += ";";
topic += aTopic;
rv = svc->Notify( (nsIWebShellWindow*)this, topic.GetUnicode(), someData.GetUnicode() );
// Release the service.
nsServiceManager::ReleaseService( NS_OBSERVERSERVICE_PROGID, svc );
} else {
}
return rv;
}
NS_IMETHODIMP nsWebShellWindow::SetStatus(const PRUnichar* aStatus)
{
// yup. got it.
return NS_OK;
nsresult rv = NS_OK;
// Store status text.
mStatus = aStatus;
// Broadcast status text change to interested parties.
rv = NotifyObservers( "status", aStatus );
return rv;
}
NS_IMETHODIMP nsWebShellWindow::GetStatus(const PRUnichar** aResult)
{
// didn't store the status string, either.
return NS_ERROR_FAILURE;
nsresult rv = NS_OK;
if ( aResult ) {
// Semantics are ill-defined: How to allocate? Who frees it?
*aResult = mStatus.ToNewUnicode();
} else {
rv = NS_ERROR_NULL_POINTER;
}
return rv;
}
NS_IMETHODIMP nsWebShellWindow::SetProgress(PRInt32 aProgress, PRInt32 aProgressMax)
{
// oh yeah. we're on it.
return NS_OK;
nsresult rv = NS_OK;
// Encode progress report in topic (there is no GetProgress for observers
// to query it).
char topic[32];
PR_snprintf( topic,
sizeof topic,
"%ld %ld",
(long)aProgress,
(long)aProgressMax );
// Broadcast progress info to interested parties.
rv = NotifyObservers( "progress", topic );
return rv;
}

Просмотреть файл

@ -250,6 +250,8 @@ protected:
NS_IMETHODIMP ShowModalInternal();
void ExitModalLoop() { mContinueModalLoop = PR_FALSE; }
nsresult NotifyObservers( const nsString &aTopic, const nsString &someData );
nsIWidget* mWindow;
nsIWebShell* mWebShell;
nsIXULWindowCallbacks* mCallbacks;
@ -264,6 +266,8 @@ protected:
// created as the XUL file for this window loads.
nsIDOMNode * contextMenuTest;
nsString mStatus;
private:
static void * HandleModalDialogEvent(PLEvent *aEvent);

Просмотреть файл

@ -1,5 +1,7 @@
var appCore = null;
var appCoreName = "";
var defaultStatus = "default status text";
function Startup()
{
dump("Doing Startup...\n");
@ -699,6 +701,9 @@
var status = document.getElementById("Browser:Status");
if ( status ) {
var text = status.getAttribute("value");
if ( text == "" ) {
text = defaultStatus;
}
var statusText = document.getElementById("statusText");
if ( statusText ) {
statusText.setAttribute( "value", text );
@ -764,6 +769,7 @@
var msg = "Document: Done (" + elapsed + " secs)";
dump( msg + "\n" );
status.setAttribute("value",msg);
defaultStatus = msg;
}
startTime = 0;
}