From 345b378aa08bec77fe766fb6cd195fecbe76ce8d Mon Sep 17 00:00:00 2001 From: "law%netscape.com" Date: Wed, 13 Feb 2002 02:57:29 +0000 Subject: [PATCH] Bug 113936; tailor WinXP start menu so Mozilla's Preferences are used instead of opening IE's; r=ben, sr=hyatt git-svn-id: svn://10.0.0.236/trunk@114370 18797224-902f-48f8-a5cc-f745e15eee43 --- .../prefwindow/resources/content/pref.xul | 13 +++++++++++ .../locale/en-US/nsWindowsHooks.properties | 1 + .../winhooks/nsWindowsHooksUtil.cpp | 23 ++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/mozilla/xpfe/components/prefwindow/resources/content/pref.xul b/mozilla/xpfe/components/prefwindow/resources/content/pref.xul index 57ad6989c59..5736b8f0273 100644 --- a/mozilla/xpfe/components/prefwindow/resources/content/pref.xul +++ b/mozilla/xpfe/components/prefwindow/resources/content/pref.xul @@ -31,6 +31,19 @@ **/ function Startup() { + // Check for an existing pref window. + const kWindowMediatorContractID = "@mozilla.org/rdf/datasource;1?name=window-mediator"; + const kWindowMediatorIID = Components.interfaces.nsIWindowMediator; + const kWindowMediator = Components.classes[kWindowMediatorContractID].getService(kWindowMediatorIID); + var windows = kWindowMediator.getEnumerator("mozilla:preferences"); + var prefWindow; + while ((prefWindow = windows.getNext().QueryInterface(Components.interfaces.nsIDOMWindow)) && + prefWindow != window) { + // Prefs already open, activate it and close this one. + prefWindow.focus(); + window.close(); + } + hPrefWindow = new nsPrefWindow('panelFrame'); if( !hPrefWindow ) diff --git a/mozilla/xpfe/components/winhooks/locale/en-US/nsWindowsHooks.properties b/mozilla/xpfe/components/winhooks/locale/en-US/nsWindowsHooks.properties index b070e8525dc..e3848a3fb91 100644 --- a/mozilla/xpfe/components/winhooks/locale/en-US/nsWindowsHooks.properties +++ b/mozilla/xpfe/components/winhooks/locale/en-US/nsWindowsHooks.properties @@ -3,3 +3,4 @@ noButtonLabel=No cancelButtonLabel=Cancel checkBoxLabel=Check at startup next time, too. promptText=%S is not currently set as your default browser. Would you like to make it your default browser? +prefsLabel=Pr&eferences diff --git a/mozilla/xpfe/components/winhooks/nsWindowsHooksUtil.cpp b/mozilla/xpfe/components/winhooks/nsWindowsHooksUtil.cpp index 0054b721b86..cfe1eadf5cd 100644 --- a/mozilla/xpfe/components/winhooks/nsWindowsHooksUtil.cpp +++ b/mozilla/xpfe/components/winhooks/nsWindowsHooksUtil.cpp @@ -40,6 +40,7 @@ #include "nsString.h" #include "nsINativeAppSupportWin.h" +#include "nsIStringBundle.h" // Where Mozilla stores its own registry values. const char * const mozillaKeyName = "Software\\Mozilla\\Desktop"; @@ -364,6 +365,26 @@ static void setWindowsXP() { nsCAutoString( subkey + NS_LITERAL_CSTRING( "\\shell\\open\\command" ) ).get(), "", thisApplication().get() ).set(); + // "Properties" verb. The default value is the text that will appear in the menu. + // The default value under the command subkey is the name of this application, with + // arguments to cause the Preferences window to appear. + nsCOMPtr bundleService( do_GetService( "@mozilla.org/intl/stringbundle;1" ) ); + nsCOMPtr bundle; + nsXPIDLString label; + if ( bundleService && + NS_SUCCEEDED( bundleService->CreateBundle( "chrome://global-platform/locale/nsWindowsHooks.properties", + getter_AddRefs( bundle ) ) ) && + NS_SUCCEEDED( bundle->GetStringFromName( NS_LITERAL_STRING( "prefsLabel" ).get(), getter_Copies( label ) ) ) ) { + // Set the label that will appear in the start menu context menu. + RegistryEntry( HKEY_LOCAL_MACHINE, + nsCAutoString( subkey + NS_LITERAL_CSTRING( "\\shell\\properties" ) ).get(), + "", + NS_ConvertUCS2toUTF8( label ).get() ).set(); + } + RegistryEntry( HKEY_LOCAL_MACHINE, + nsCAutoString( subkey + NS_LITERAL_CSTRING( "\\shell\\properties\\command" ) ).get(), + "", + nsCAutoString( thisApplication() + NS_LITERAL_CSTRING( "-chrome \"chrome://communicator/content/pref/pref.xul\"" ) ).get() ).set(); // Now we need to select our application as the default start menu internet application. // This is accomplished by first trying to store our subkey name in @@ -412,7 +433,7 @@ nsresult RegistryEntry::reset() { if ( rc == ERROR_SUCCESS ) { rc = ::RegDeleteValue( key, valueNameArg() ); #ifdef DEBUG_law -if ( rc == ERROR_SUCCESS ) printf( "Deleting key=%s\n", (const char*)fullName() ); +if ( rc == ERROR_SUCCESS ) printf( "Deleting key=%s\n", (const char*)fullName().get() ); #endif } return NS_OK;