Bug 454017 nsContextMenu should detetct the shell service to enable wallpaper menuitem r=mcsmurf
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Fri, 26 Sep 2008 21:35:41 +0100
changeset 444 60bc2bb36c493bc65f2f163f3113c0a58ffde468
parent 443 d297432d8383690a2dfddde72b2a90a57d734e15
child 445 fff1a4dbb400dced6189fbef33f56742816b9495
push idunknown
push userunknown
push dateunknown
reviewersmcsmurf
bugs454017
Bug 454017 nsContextMenu should detetct the shell service to enable wallpaper menuitem r=mcsmurf
suite/common/nsContextMenu.js
--- a/suite/common/nsContextMenu.js
+++ b/suite/common/nsContextMenu.js
@@ -168,23 +168,24 @@ nsContextMenu.prototype = {
         this.showItem( "context-viewpartialsource-mathml", this.onMathML && !this.isContentSelected );
 
         var showView = !( this.inDirList || this.onImage || this.isContentSelected || this.onLink || this.onTextInput );
 
         this.showItem( "context-viewsource", showView );
         this.showItem( "context-viewinfo", showView );
 
         this.showItem( "context-sep-properties", !( this.inDirList || this.isContentSelected || this.onTextInput ) );
-        // Set As Wallpaper depends on whether an image was clicked on, and only works on Windows.
-        var isWin = navigator.appVersion.indexOf("Windows") != -1;
-        this.showItem( "context-setWallpaper", isWin && (this.onLoadedImage || this.onStandaloneImage));
+        // Set As Wallpaper depends on whether an image was clicked on,
+        // and requires the shell service.
+        var hasShell = "@mozilla.org/suite/shell-service;1" in Components.classes;
+        this.showItem( "context-setWallpaper", hasShell && (this.onLoadedImage || this.onStandaloneImage));
 
         this.showItem( "context-sep-image", this.onLoadedImage || this.onStandaloneImage);
 
-        if( isWin && this.onLoadedImage )
+        if( hasShell && this.onLoadedImage )
             // Disable the Set As Wallpaper menu item if we're still trying to load the image
           this.setItemAttr( "context-setWallpaper", "disabled", (("complete" in this.target) && !this.target.complete) ? "true" : null );
 
         this.showItem( "context-fitimage", this.onStandaloneImage && content.document.imageResizingEnabled );
         if ( this.onStandaloneImage && content.document.imageResizingEnabled ) {
           this.setItemAttr( "context-fitimage", "disabled", content.document.imageIsOverflowing ? null : "true");
           this.setItemAttr( "context-fitimage", "checked", content.document.imageIsResized ? "true" : null);
         }