зеркало из https://github.com/mozilla/pjs.git
Bug 43583; new helper app launch confirmation dialog; r=ben@netscape.com
This commit is contained in:
Родитель
aa83a57078
Коммит
b79ab79f81
|
@ -0,0 +1,137 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released March
|
||||
* 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
function nsHelperAppLauncherDialog() {
|
||||
// Initialize data properties.
|
||||
this.chosenApp = null;
|
||||
this.chosenFile = null;
|
||||
|
||||
try {
|
||||
// App launcher is passed as dialog argument.
|
||||
this.appLauncher = window.arguments[0];
|
||||
|
||||
// Initialize the dialog contents.
|
||||
this.initDialog();
|
||||
} catch( e ) {
|
||||
// On error, close dialog.
|
||||
dump( "nsHelperAppLauncherDialog error: " + e + "\n" );
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
nsHelperAppLauncherDialog.prototype= {
|
||||
// Statics.
|
||||
nsIHelperAppLauncher : Components.interfaces.nsIHelperAppLauncher,
|
||||
nsIFilePicker : Components.interfaces.nsIFilePicker,
|
||||
|
||||
// Fill dialog from app launcher attributes.
|
||||
initDialog : function () {
|
||||
document.getElementById( "alwaysAskMe" ).checked = true;
|
||||
if ( this.appLauncher.MIMEInfo.preferredApplicationHandler ) {
|
||||
// Run this app unless requested otherwise.
|
||||
document.getElementById( "runApp" ).checked = true;
|
||||
|
||||
this.chosenApp = this.appLauncher.MIMEInfo.preferredApplicationHandler;
|
||||
|
||||
document.getElementById( "appName" ).value = this.chosenApp.unicodePath;
|
||||
} else {
|
||||
// Save to disk.
|
||||
document.getElementById( "saveToDisk" ).checked = true;
|
||||
}
|
||||
|
||||
// Set up dialog button callbacks.
|
||||
var object = this;
|
||||
doSetOKCancel( function () { return object.onOK(); },
|
||||
function () { return object.onCancel(); } );
|
||||
},
|
||||
|
||||
// If the user presses OK, we do as requested...
|
||||
onOK : function () {
|
||||
var dontAskNextTime = !document.getElementById( "alwaysAskMe" ).checked;
|
||||
|
||||
if ( document.getElementById( "runApp" ).checked ) {
|
||||
this.appLauncher.launchWithApplication( this.chosenApp, dontAskNextTime );
|
||||
} else {
|
||||
this.appLauncher.saveToDisk( this.chosenFile, dontAskNextTime );
|
||||
}
|
||||
|
||||
window.close();
|
||||
},
|
||||
|
||||
// If the user presses cancel, tell the app launcher and close the dialog...
|
||||
onCancel : function () {
|
||||
// Cancel app launcher.
|
||||
this.appLauncher.Cancel();
|
||||
|
||||
// Close up dialog by returning true.
|
||||
return true;
|
||||
},
|
||||
|
||||
// Choose a new/different app...
|
||||
chooseApp : function () {
|
||||
var fp = Components.classes["component://mozilla/filepicker"].createInstance( this.nsIFilePicker );
|
||||
fp.init( window,
|
||||
this.getString( "chooseAppFilePickerTitle" ),
|
||||
this.nsIFilePicker.modeOpen );
|
||||
// XXX - We want to say nsIFilePicker.filterExecutable or something
|
||||
fp.appendFilters( this.nsIFilePicker.filterAll );
|
||||
|
||||
if ( fp.show() == this.nsIFilePicker.returnOK && fp.file ) {
|
||||
this.chosenApp = fp.file;
|
||||
document.getElementById( "appName" ).value = this.chosenApp.unicodePath;
|
||||
}
|
||||
},
|
||||
|
||||
// Choose a file to save to...
|
||||
chooseFile : function () {
|
||||
var fp = Components.classes["component://mozilla/filepicker"].createInstance( this.nsIFilePicker );
|
||||
fp.init( window,
|
||||
this.getString( "chooseFileFilePickerTitle" ),
|
||||
this.nsIFilePicker.modeSave );
|
||||
// XXX - Can we set this to filter on extension of file to be saved?
|
||||
fp.appendFilters( this.nsIFilePicker.filterAll );
|
||||
|
||||
if ( fp.show() == this.nsIFilePicker.returnOK && fp.file ) {
|
||||
this.chosenFile = fp.file;
|
||||
document.getElementById( "fileName" ).value = this.chosenFile.unicodePath;
|
||||
}
|
||||
},
|
||||
|
||||
// Get string from bundle.
|
||||
getString : function ( id ) {
|
||||
// String of last resort is the id.
|
||||
var result = id;
|
||||
|
||||
// Get string bundle (if not done previously).
|
||||
if ( !this.strings ) {
|
||||
this.strings = srGetStrBundle("chrome://global/locale/helperAppLauncher.properties");
|
||||
}
|
||||
|
||||
if ( this.strings ) {
|
||||
// Get string from bundle.
|
||||
result = this.strings.GetStringFromName( id );
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
The contents of this file are subject to the Netscape Public
|
||||
License Version 1.1 (the "License"); you may not use this file
|
||||
except in compliance with the License. You may obtain a copy of
|
||||
the License at http://www.mozilla.org/NPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS
|
||||
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
implied. See the License for the specific language governing
|
||||
rights and limitations under the License.
|
||||
|
||||
The Original Code is Mozilla Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://navigator/skin/navigator.css" type="text/css"?>
|
||||
|
||||
<?xul-overlay href="chrome://global/content/dialogOverlay.xul"?>
|
||||
|
||||
<!DOCTYPE window [
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
|
||||
%brandDTD;
|
||||
<!ENTITY % helperAppLauncherDTD SYSTEM "chrome://global/locale/helperAppLauncher.dtd" >
|
||||
%helperAppLauncherDTD;
|
||||
]>
|
||||
|
||||
<window id="helperAppLaunchConfirmation"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&caption.label;"
|
||||
onload="window.dialog = new nsHelperAppLauncherDialog();"
|
||||
style="width: 40em;"
|
||||
class="dialog"
|
||||
align="vertical"
|
||||
persist="screenX screenY"
|
||||
screenX="24" screenY="24">
|
||||
|
||||
<script language="javascript" src="chrome://global/content/strres.js"/>
|
||||
<script language="javascript" src="chrome://global/content/globalOverlay.js"/>
|
||||
<script language="javascript" src="chrome://global/content/helperAppLauncher.js"/>
|
||||
<script language="javascript" src="chrome://communicator/content/utilityOverlay.js"/>
|
||||
|
||||
<keyset id="keyset"/>
|
||||
|
||||
<box>
|
||||
<box orient="vertical">
|
||||
<image class="question-icon"/>
|
||||
<spring flex="1"/>
|
||||
</box>
|
||||
<separator orient="vertical" class="thin"/>
|
||||
<box orient="vertical" flex="1">
|
||||
<html>&intro.label;</html>
|
||||
<separator orient="horizontal" class="thin"/>
|
||||
<radiogroup id="mode" orient="vertical">
|
||||
<box orient="vertical">
|
||||
<box autostretch="never">
|
||||
<radio id="runApp"
|
||||
group="mode"
|
||||
value="&runApp.label;"
|
||||
accesskey="&runApp.accesskey;"/>
|
||||
</box>
|
||||
<box class="indent">
|
||||
<textfield id="appName" readonly="true" flex="1"/>
|
||||
<button class="dialog"
|
||||
value="&chooseApp.label;"
|
||||
accesskey="&chooseApp.accesskey;"
|
||||
oncommand="dialog.chooseApp();"/>
|
||||
</box>
|
||||
</box>
|
||||
<box orient="vertical">
|
||||
<box autostretch="never">
|
||||
<radio id="saveToDisk"
|
||||
group="mode"
|
||||
value="&saveToDisk.label;"
|
||||
accesskey="&saveToDisk.accesskey;"/>
|
||||
</box>
|
||||
<box class="indent">
|
||||
<textfield id="fileName" readonly="true" flex="1"/>
|
||||
<button class="dialog"
|
||||
value="&chooseFile.label;"
|
||||
accesskey="&chooseFile.accesskey;"
|
||||
oncommand="dialog.chooseFile();"/>
|
||||
</box>
|
||||
</box>
|
||||
</radiogroup>
|
||||
<separator orient="horizontal" class="thin"/>
|
||||
<box autostretch="never">
|
||||
<checkbox id="alwaysAskMe" value="&alwaysAskMe.label;" accesskey="&alwaysAskMe.accesskey;"/>
|
||||
</box>
|
||||
</box>
|
||||
</box>
|
||||
|
||||
<separator class="groove"/>
|
||||
|
||||
<box id="okCancelButtonsRight"/>
|
||||
|
||||
</window>
|
|
@ -0,0 +1,18 @@
|
|||
<!ENTITY caption.label "Downloading">
|
||||
|
||||
<!ENTITY intro.label "This file is unrecognized by Mozilla. You can save it or open it with another application.">
|
||||
|
||||
<!ENTITY runApp.label "Open using">
|
||||
<!ENTITY runApp.accesskey "o">
|
||||
|
||||
<!ENTITY saveToDisk.label "Save to file">
|
||||
<!ENTITY saveToDisk.accesskey "s">
|
||||
|
||||
<!ENTITY alwaysAskMe.label "Always ask me before opening or saving files of this type.">
|
||||
<!ENTITY alwaysAskMe.accesskey "a">
|
||||
|
||||
<!ENTITY chooseApp.label "Choose...">
|
||||
<!ENTITY chooseApp.accesskey "c">
|
||||
|
||||
<!ENTITY chooseFile.label "Choose...">
|
||||
<!ENTITY chooseFile.accesskey "h">
|
|
@ -0,0 +1,2 @@
|
|||
chooseAppFilePickerTitle=Choose Viewer
|
||||
chooseFileFilePickerTitle=Choose File
|
Загрузка…
Ссылка в новой задаче