From e86bfb00bfedb6b4f28ea1920f7807793fedcb06 Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Thu, 28 Jan 1999 01:30:38 +0000 Subject: [PATCH] now hookup commands to multiple toolbars and fix compiler warnings. git-svn-id: svn://10.0.0.236/trunk@18871 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xpfe/appshell/src/nsWebShellWindow.cpp | 101 ++++++++++-------- 1 file changed, 54 insertions(+), 47 deletions(-) diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index 01c8f7b5e77..87a63250611 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -420,7 +420,7 @@ void nsWebShellWindow::LoadCommands(nsIWebShell * aWebShell, nsIDOMDocument * aD return; // load up commands - PRUint32 endCount = 0; + int endCount = 0; nsCOMPtr parentCmd ( dont_AddRef(FindNamedDOMNode(nsAutoString("commands"), window, endCount, 1)) ); if (nsnull != parentCmd) { nsCOMPtr node; @@ -454,53 +454,60 @@ void nsWebShellWindow::LoadCommands(nsIWebShell * aWebShell, nsIDOMDocument * aD } } - // Now install the commands onto the Toolbar GUI Nodes - nsCOMPtr toolbar ( dont_AddRef(FindNamedDOMNode(nsAutoString("toolbar"), window, endCount, 1)) ); - if (nsnull != toolbar) { - nsAutoString cmdAtom("cmd"); - nsCOMPtr node; - toolbar->GetFirstChild(getter_AddRefs(node)); - while (nsnull != node) { - nsAutoString value; - nsString nodeCmd; - nsCOMPtr element ( node ); - if ( element ) { - nsString name; - element->GetNodeName(name); - if (name.Equals(nsAutoString("BUTTON"))) { - element->GetAttribute(cmdAtom, nodeCmd); - PRInt32 i, n = mCommands.Count(); - for (i = 0; i < n; i++) { - nsIXULCommand* cmd = (nsIXULCommand*) mCommands.ElementAt(i); - nsAutoString cmdName; - cmd->GetName(cmdName); - //printf("Cmd [%s] Node[%s]\n", cmdName.ToNewCString(), nodeCmd.ToNewCString()); - if (nodeCmd.Equals(cmdName)) { - printf("Linking up cmd to button [%s]\n", cmdName.ToNewCString()); - cmd->AddUINode(node); - } - } - } else if (name.Equals(nsAutoString("INPUT"))) { - nsXULCommand * xulCmd = new nsXULCommand(); - xulCmd->SetName(name); - xulCmd->SetCommand(value); - xulCmd->SetWebShell(aWebShell); - xulCmd->SetDOMElement(element); - nsIXULCommand * icmd; - if (NS_OK == xulCmd->QueryInterface(kIXULCommandIID, (void**) &icmd)) { - mCommands.AppendElement(icmd); - } - xulCmd->AddUINode(node); - //printf("Linking up cmd to button [%s]\n", cmdName.ToNewCString()); - } - } + // Now install the commands onto the Toolbar GUI Nodes for each toolbar in the toolbox + PRUint32 count = 1; + nsCOMPtr toolbar; + do { + toolbar = dont_AddRef(FindNamedDOMNode(nsAutoString("toolbar"), window, endCount, count)); + if (nsnull != toolbar) { + nsAutoString cmdAtom("cmd"); + nsCOMPtr node; + toolbar->GetFirstChild(getter_AddRefs(node)); + while (nsnull != node) { + nsAutoString value; + nsString nodeCmd; + nsCOMPtr element ( node ); + if ( element ) { + nsString name; + element->GetNodeName(name); + if (name.Equals(nsAutoString("BUTTON"))) { + element->GetAttribute(cmdAtom, nodeCmd); + PRInt32 i, n = mCommands.Count(); + for (i = 0; i < n; i++) { + nsIXULCommand* cmd = (nsIXULCommand*) mCommands.ElementAt(i); + nsAutoString cmdName; + cmd->GetName(cmdName); + //printf("Cmd [%s] Node[%s]\n", cmdName.ToNewCString(), nodeCmd.ToNewCString()); + if (nodeCmd.Equals(cmdName)) { + printf("Linking up cmd to button [%s]\n", cmdName.ToNewCString()); + cmd->AddUINode(node); + } + } + } else if (name.Equals(nsAutoString("INPUT"))) { + nsXULCommand * xulCmd = new nsXULCommand(); + xulCmd->SetName(name); + xulCmd->SetCommand(value); + xulCmd->SetWebShell(aWebShell); + xulCmd->SetDOMElement(element); + nsIXULCommand * icmd; + if (NS_OK == xulCmd->QueryInterface(kIXULCommandIID, (void**) &icmd)) { + mCommands.AppendElement(icmd); + } + xulCmd->AddUINode(node); + //printf("Linking up cmd to button [%s]\n", cmdName.ToNewCString()); + } + } - nsCOMPtr oldNode ( node ); - oldNode->GetNextSibling(getter_AddRefs(node)); - } - - } + nsCOMPtr oldNode ( node ); + oldNode->GetNextSibling(getter_AddRefs(node)); + } + } + + ++count; + + } while ( toolbar ) ; + /*PRInt32 i, n = mCommands.Count(); for (i = 0; i < n; i++) { nsIXULCommand* cmd = (nsIXULCommand*) mCommands.ElementAt(i); @@ -520,7 +527,7 @@ void nsWebShellWindow::LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWi return; nsresult rv; - PRUint32 endCount = 0; + int endCount = 0; nsCOMPtr menubarNode ( dont_AddRef(FindNamedDOMNode(nsAutoString("menubar"), window, endCount, 1)) ); if (nsnull != menubarNode) { nsIMenuBar * pnsMenuBar = nsnull;