Bug 526717 - remove non-working "Set as desktop background" from the UI for unsupported desktops. r=gavin

This commit is contained in:
Wolfgang Rosenauer 2012-04-02 22:43:12 +02:00
Родитель f6c2a9431d
Коммит b93bb1bc3e
5 изменённых файлов: 39 добавлений и 1 удалений

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

@ -267,7 +267,7 @@ nsContextMenu.prototype = {
// Only enable Set as Desktop Background if we can get the shell service.
var shell = getShellService();
if (shell)
haveSetDesktopBackground = true;
haveSetDesktopBackground = shell.canSetDesktopBackground;
#endif
this.showItem("context-setDesktopBackground",
haveSetDesktopBackground && this.onLoadedImage);

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

@ -74,6 +74,15 @@ interface nsIShellService : nsISupports
*/
attribute boolean shouldCheckDefaultBrowser;
/**
* Used to determine whether or not to offer "Set as desktop background"
* functionality. Even if shell service is available it is not
* guaranteed that it is able to set the background for every desktop
* which is especially true for Linux with its many different desktop
* environments.
*/
readonly attribute boolean canSetDesktopBackground;
/**
* Flags for positioning/sizing of the Desktop Background image.
*/

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

@ -382,6 +382,21 @@ nsGNOMEShellService::SetShouldCheckDefaultBrowser(bool aShouldCheck)
return NS_OK;
}
NS_IMETHODIMP
nsGNOMEShellService::GetCanSetDesktopBackground(bool* aResult)
{
// setting desktop background is currently only supported
// for Gnome or desktops using the same GSettings and GConf keys
const char* gnomeSession = getenv("GNOME_DESKTOP_SESSION_ID");
if (gnomeSession) {
*aResult = true;
} else {
*aResult = false;
}
return NS_OK;
}
static nsresult
WriteImage(const nsCString& aPath, imgIContainer* aImage)
{

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

@ -156,6 +156,13 @@ nsMacShellService::SetShouldCheckDefaultBrowser(bool aShouldCheck)
return NS_OK;
}
NS_IMETHODIMP
nsMacShellService::GetCanSetDesktopBackground(bool* aResult)
{
*aResult = true;
return NS_OK;
}
NS_IMETHODIMP
nsMacShellService::SetDesktopBackground(nsIDOMElement* aElement,
PRInt32 aPosition)

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

@ -561,6 +561,13 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
return NS_OK;
}
NS_IMETHODIMP
nsWindowsShellService::GetCanSetDesktopBackground(bool* aResult)
{
*aResult = true;
return NS_OK;
}
NS_IMETHODIMP
nsWindowsShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers)
{