1 # HG changeset patch |
|
2 # Parent fd2da289a3c15b8c96c248df2710d879793f22c9 |
|
3 # User Wolfgang Rosenauer <wr@rosenauer.org> |
|
4 Bug 526717 - remove non-working "Set as desktop background" from the UI for unsupported desktops |
|
5 |
|
6 diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js |
|
7 --- a/browser/base/content/nsContextMenu.js |
|
8 +++ b/browser/base/content/nsContextMenu.js |
|
9 @@ -262,17 +262,17 @@ nsContextMenu.prototype = { |
|
10 |
|
11 // Set as Desktop background depends on whether an image was clicked on, |
|
12 // and only works if we have a shell service. |
|
13 var haveSetDesktopBackground = false; |
|
14 #ifdef HAVE_SHELL_SERVICE |
|
15 // Only enable Set as Desktop Background if we can get the shell service. |
|
16 var shell = getShellService(); |
|
17 if (shell) |
|
18 - haveSetDesktopBackground = true; |
|
19 + haveSetDesktopBackground = shell.canSetDesktopBackground; |
|
20 #endif |
|
21 this.showItem("context-setDesktopBackground", |
|
22 haveSetDesktopBackground && this.onLoadedImage); |
|
23 |
|
24 if (haveSetDesktopBackground && this.onLoadedImage) { |
|
25 document.getElementById("context-setDesktopBackground") |
|
26 .disabled = this.disableSetDesktopBackground(); |
|
27 } |
|
28 diff --git a/browser/components/shell/public/nsIShellService.idl b/browser/components/shell/public/nsIShellService.idl |
|
29 --- a/browser/components/shell/public/nsIShellService.idl |
|
30 +++ b/browser/components/shell/public/nsIShellService.idl |
|
31 @@ -69,16 +69,25 @@ interface nsIShellService : nsISupports |
|
32 /** |
|
33 * Used to determine whether or not to show a "Set Default Browser" |
|
34 * query dialog. This attribute is true if the application is starting |
|
35 * up and "browser.shell.checkDefaultBrowser" is true, otherwise it |
|
36 * is false. |
|
37 */ |
|
38 attribute boolean shouldCheckDefaultBrowser; |
|
39 |
|
40 + /** |
|
41 + * Used to determine whether or not to offer "Set as desktop background" |
|
42 + * context menu item. Even if shell service is available it is not |
|
43 + * guaranteed that it is able to set the background for every desktop |
|
44 + * which is especially true for Linux with its many different desktop |
|
45 + * environments. |
|
46 + */ |
|
47 + readonly attribute boolean canSetDesktopBackground; |
|
48 + |
|
49 /** |
|
50 * Flags for positioning/sizing of the Desktop Background image. |
|
51 */ |
|
52 const long BACKGROUND_TILE = 1; |
|
53 const long BACKGROUND_STRETCH = 2; |
|
54 const long BACKGROUND_CENTER = 3; |
|
55 const long BACKGROUND_FILL = 4; |
|
56 const long BACKGROUND_FIT = 5; |
|
57 diff --git a/browser/components/shell/src/nsGNOMEShellService.cpp b/browser/components/shell/src/nsGNOMEShellService.cpp |
|
58 --- a/browser/components/shell/src/nsGNOMEShellService.cpp |
|
59 +++ b/browser/components/shell/src/nsGNOMEShellService.cpp |
|
60 @@ -377,16 +377,31 @@ nsGNOMEShellService::SetShouldCheckDefau |
|
61 pserve->GetBranch("", getter_AddRefs(prefs)); |
|
62 |
|
63 if (prefs) |
|
64 prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck); |
|
65 |
|
66 return NS_OK; |
|
67 } |
|
68 |
|
69 +NS_IMETHODIMP |
|
70 +nsGNOMEShellService::GetCanSetDesktopBackground(bool* aResult) |
|
71 +{ |
|
72 + // setting desktop background is currently only supported |
|
73 + // for Gnome or desktops using the same GSettings and GConf keys |
|
74 + const char* gnomeSession = getenv("GNOME_DESKTOP_SESSION_ID"); |
|
75 + if (gnomeSession) { |
|
76 + *aResult = true; |
|
77 + } else { |
|
78 + *aResult = false; |
|
79 + } |
|
80 + |
|
81 + return NS_OK; |
|
82 +} |
|
83 + |
|
84 static nsresult |
|
85 WriteImage(const nsCString& aPath, imgIContainer* aImage) |
|
86 { |
|
87 #ifndef MOZ_WIDGET_GTK2 |
|
88 return NS_ERROR_NOT_AVAILABLE; |
|
89 #else |
|
90 nsCOMPtr<nsIImageToPixbuf> imgToPixbuf = |
|
91 do_GetService("@mozilla.org/widget/image-to-gdk-pixbuf;1"); |
|