Browse Source

[Navigator] Get Set as Wallpaper working and redesigned

master
Matt A. Tobin 2 years ago committed by Roy Tam
parent
commit
cd4a4883fa
  1. 17
      navigator/comm/content/nsContextMenu.js
  2. 2
      navigator/comm/locale/contentAreaCommands.dtd
  3. 90
      navigator/components/shell/content/setDesktopBackground.xul
  4. 1
      navigator/components/shell/locale/setDesktopBackground.dtd
  5. 13
      navigator/themes/classic/navigator/setDesktopBackground.css
  6. 13
      navigator/themes/modern/navigator/setDesktopBackground.css

17
navigator/comm/content/nsContextMenu.js

@ -29,6 +29,9 @@ XPCOMUtils.defineLazyGetter(this, "PageMenuParent", function() {
return new tmp.PageMenuParent();
});
XPCOMUtils.defineLazyModuleGetter(this, "ShellService",
"resource:///modules/ShellService.jsm");
function nsContextMenu(aXulMenu, aIsShift, aEvent) {
this.shouldDisplay = true;
this.initMenu(aXulMenu, aIsShift, aEvent);
@ -225,24 +228,18 @@ nsContextMenu.prototype = {
this.onCanvas || this.onVideo || this.onAudio));
// Set Desktop Background depends on whether an image was clicked on,
// and requires the shell service.
var canSetDesktopBackground = false;
if ("@binaryoutcast.com/navigator/shell-service;1" in Components.classes) try {
canSetDesktopBackground =
Components.classes["@binaryoutcast.com/navigator/shell-service;1"]
.getService(Components.interfaces.nsIShellService)
.canSetDesktopBackground;
} catch (e) {
}
var canSetDesktopBackground = ShellService.canSetDesktopBackground;
this.showItem("context-setDesktopBackground",
canSetDesktopBackground && (this.onLoadedImage || this.onStandaloneImage));
this.showItem("context-sep-image",
this.onLoadedImage && !this.onStandaloneImage);
if (canSetDesktopBackground && this.onLoadedImage)
if (canSetDesktopBackground && this.onLoadedImage) {
// Disable the Set Desktop Background menu item if we're still trying to load the image
this.setItemAttr("context-setDesktopBackground", "disabled",
(("complete" in this.target) && !this.target.complete) ? "true" : null);
}
this.showItem("context-fitimage", this.onStandaloneImage &&
content.document.imageResizingEnabled);
@ -951,7 +948,7 @@ nsContextMenu.prototype = {
},
setDesktopBackground: function() {
openDialog("chrome://communicator/content/setDesktopBackground.xul",
openDialog("chrome://navigator/content/setDesktopBackground.xul",
"_blank", "chrome,modal,titlebar,centerscreen", this.target);
},

2
navigator/comm/locale/contentAreaCommands.dtd

@ -57,7 +57,7 @@
<!ENTITY viewVideoCmd.accesskey "i">
<!ENTITY viewBGImageCmd.label "View Background Image">
<!ENTITY viewBGImageCmd.accesskey "w">
<!ENTITY setDesktopBackgroundCmd.label "Set Desktop Background…">
<!ENTITY setDesktopBackgroundCmd.label "Set Desktop Wallpaper…">
<!ENTITY setDesktopBackgroundCmd.accesskey "a">
<!ENTITY bookmarkPageCmd.label "Bookmark This Page…">
<!ENTITY bookmarkPageCmd.accesskey "m">

90
navigator/components/shell/content/setDesktopBackground.xul

@ -7,7 +7,12 @@
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://navigator/skin/setDesktopBackground.css" type="text/css"?>
<!DOCTYPE dialog SYSTEM "chrome://navigator/locale/setDesktopBackground.dtd">
<!DOCTYPE dialog [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
%brandDTD;
<!ENTITY % setDesktopDTD SYSTEM "chrome://navigator/locale/setDesktopBackground.dtd">
%setDesktopDTD;
]>
#ifdef XP_MACOSX
<?xul-overlay href="chrome://browser/content/macBrowserOverlay.xul"?>
@ -21,52 +26,34 @@
#else
buttons="accept"
#endif
buttonlabelaccept="&setDesktopBackground.title;"
buttonlabelaccept="&setDesktopBackground.abtn;"
onload="gSetBackground.load();"
ondialogaccept="gSetBackground.setDesktopBackground();"
title="&setDesktopBackground.title;"
style="width: 30em;">
style="width: 34em;">
<stringbundle id="backgroundBundle"
src="chrome://navigator/locale/shellservice.properties"/>
<script type="application/javascript" src="chrome://communicator/content/utilityOverlay.js"/>
<script type="application/javascript" src="chrome://navigator/content/setDesktopBackground.js"/>
<script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
<stringbundle id="backgroundBundle"
src="chrome://navigator/locale/shellservice.properties"/>
<script type="application/javascript" src="chrome://communicator/content/utilityOverlay.js"/>
<script type="application/javascript" src="chrome://navigator/content/setDesktopBackground.js"/>
<script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
#ifndef XP_MACOSX
<hbox align="center">
<label value="&position.label;"/>
<menulist id="menuPosition"
label="&position.label;"
oncommand="gSetBackground.updatePosition();">
<menupopup>
<menuitem label="&center.label;" value="CENTER"/>
<menuitem label="&tile.label;" value="TILE"/>
<menuitem label="&stretch.label;" value="STRETCH"/>
<menuitem label="&fill.label;" value="FILL" id="fillPosition"/>
<menuitem label="&fit.label;" value="FIT" id="fitPosition"/>
</menupopup>
</menulist>
<spacer flex="1"/>
<label value="&color.label;"/>
<colorpicker id="desktopColor"
type="button"
onchange="gSetBackground.updateColor(this.color);"/>
</hbox>
#endif
<groupbox align="center">
<caption label="&preview.label;"/>
<dialogheader class="header-large"
id="header"
title="&brandFullName;"
description="&setDesktopBackground.title;"/>
<hbox class="container">
<vbox align="center" flex="3">
<stack>
<!-- if width and height are not present, they default to 300x150 and stretch the stack -->
<html:canvas id="screen" width="1" height="1"/>
<image id="monitor"/>
</stack>
</groupbox>
</vbox>
<vbox flex="1">
#ifdef XP_MACOSX
<separator/>
<hbox align="right">
<button id="setDesktopBackground"
label="&setDesktopBackground.title;"
oncommand="gSetBackground.setDesktopBackground();"/>
@ -74,11 +61,32 @@
label="&openDesktopPrefs.label;"
oncommand="gSetBackground.showDesktopPrefs();"
hidden="true"/>
</hbox>
#endif
#ifdef XP_MACOSX
#include ../../../base/content/browserMountPoints.inc
#else
<hbox align="center">
<label value="&color.label;"/>
<spacer class="colorSpacer"/>
<colorpicker id="desktopColor"
type="button"
onchange="gSetBackground.updateColor(this.color);"/>
</hbox>
<spacer style="height: 1em;"/>
<hbox align="center">
<label value="&position.label;"/>
<menulist id="menuPosition"
label="&position.label;"
oncommand="gSetBackground.updatePosition();">
<menupopup>
<menuitem label="&fill.label;" value="FILL" id="fillPosition"/>
<menuitem label="&fit.label;" value="FIT" id="fitPosition"/>
<menuitem label="&stretch.label;" value="STRETCH"/>
<menuitem label="&tile.label;" value="TILE"/>
<menuitem label="&center.label;" value="CENTER"/>
</menupopup>
</menulist>
</hbox>
#endif
</vbox>
</hbox>
<separator class="groove"/>
</dialog>

1
navigator/components/shell/locale/setDesktopBackground.dtd

@ -11,5 +11,6 @@
<!ENTITY preview.label "Preview">
<!ENTITY color.label "Color:">
<!ENTITY setDesktopBackground.title "Set Desktop Wallpaper">
<!ENTITY setDesktopBackground.abtn "Set Wallpaper">
<!ENTITY openDesktopPrefs.label "Open Desktop Preferences">
<!ENTITY closeWindow.key "w">

13
navigator/themes/classic/navigator/setDesktopBackground.css

@ -10,9 +10,18 @@ html|canvas#screen {
}
#monitor {
list-style-image: url("chrome://browser/skin/monitor.png");
list-style-image: url("chrome://navigator/skin/monitor.png");
}
#monitor[aspectratio="16:10"] {
list-style-image: url("chrome://browser/skin/monitor_16-10.png");
list-style-image: url("chrome://navigator/skin/monitor_16-10.png");
}
.container {
margin-top: 1.5em;
margin-bottom: 1em;"
}
.colorSpacer {
width: 1.5em;
}

13
navigator/themes/modern/navigator/setDesktopBackground.css

@ -10,9 +10,18 @@ html|canvas#screen {
}
#monitor {
list-style-image: url("chrome://browser/skin/monitor.png");
list-style-image: url("chrome://navigator/skin/monitor.png");
}
#monitor[aspectratio="16:10"] {
list-style-image: url("chrome://browser/skin/monitor_16-10.png");
list-style-image: url("chrome://navigator/skin/monitor_16-10.png");
}
.container {
margin-top: 1em;
margin-bottom: 1em;
}
.colorSpacer {
width: 1.4em;
}
Loading…
Cancel
Save