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