mirror of
https://abf.rosa.ru/djam/firefox-esr68.git
synced 2025-02-25 10:52:58 +00:00
92 lines
3.5 KiB
Diff
92 lines
3.5 KiB
Diff
![]() |
# HG changeset patch
|
||
|
# Parent fd2da289a3c15b8c96c248df2710d879793f22c9
|
||
|
# User Wolfgang Rosenauer <wr@rosenauer.org>
|
||
|
Bug 526717 - remove non-working "Set as desktop background" from the UI for unsupported desktops
|
||
|
|
||
|
diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js
|
||
|
--- a/browser/base/content/nsContextMenu.js
|
||
|
+++ b/browser/base/content/nsContextMenu.js
|
||
|
@@ -262,17 +262,17 @@ nsContextMenu.prototype = {
|
||
|
|
||
|
// Set as Desktop background depends on whether an image was clicked on,
|
||
|
// and only works if we have a shell service.
|
||
|
var haveSetDesktopBackground = false;
|
||
|
#ifdef HAVE_SHELL_SERVICE
|
||
|
// 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);
|
||
|
|
||
|
if (haveSetDesktopBackground && this.onLoadedImage) {
|
||
|
document.getElementById("context-setDesktopBackground")
|
||
|
.disabled = this.disableSetDesktopBackground();
|
||
|
}
|
||
|
diff --git a/browser/components/shell/public/nsIShellService.idl b/browser/components/shell/public/nsIShellService.idl
|
||
|
--- a/browser/components/shell/public/nsIShellService.idl
|
||
|
+++ b/browser/components/shell/public/nsIShellService.idl
|
||
|
@@ -69,16 +69,25 @@ interface nsIShellService : nsISupports
|
||
|
/**
|
||
|
* Used to determine whether or not to show a "Set Default Browser"
|
||
|
* query dialog. This attribute is true if the application is starting
|
||
|
* up and "browser.shell.checkDefaultBrowser" is true, otherwise it
|
||
|
* is false.
|
||
|
*/
|
||
|
attribute boolean shouldCheckDefaultBrowser;
|
||
|
|
||
|
+ /**
|
||
|
+ * Used to determine whether or not to offer "Set as desktop background"
|
||
|
+ * context menu item. 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.
|
||
|
*/
|
||
|
const long BACKGROUND_TILE = 1;
|
||
|
const long BACKGROUND_STRETCH = 2;
|
||
|
const long BACKGROUND_CENTER = 3;
|
||
|
const long BACKGROUND_FILL = 4;
|
||
|
const long BACKGROUND_FIT = 5;
|
||
|
diff --git a/browser/components/shell/src/nsGNOMEShellService.cpp b/browser/components/shell/src/nsGNOMEShellService.cpp
|
||
|
--- a/browser/components/shell/src/nsGNOMEShellService.cpp
|
||
|
+++ b/browser/components/shell/src/nsGNOMEShellService.cpp
|
||
|
@@ -377,16 +377,31 @@ nsGNOMEShellService::SetShouldCheckDefau
|
||
|
pserve->GetBranch("", getter_AddRefs(prefs));
|
||
|
|
||
|
if (prefs)
|
||
|
prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, 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)
|
||
|
{
|
||
|
#ifndef MOZ_WIDGET_GTK2
|
||
|
return NS_ERROR_NOT_AVAILABLE;
|
||
|
#else
|
||
|
nsCOMPtr<nsIImageToPixbuf> imgToPixbuf =
|
||
|
do_GetService("@mozilla.org/widget/image-to-gdk-pixbuf;1");
|