Turning on new C++ filepicker code (bug 82854). r=jag, sr=ben.

This commit is contained in:
bryner%netscape.com 2001-11-14 08:19:23 +00:00
Родитель b69ed06ca6
Коммит 53c90e63b4
12 изменённых файлов: 56 добавлений и 18 удалений

Просмотреть файл

@ -29,7 +29,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk include $(DEPTH)/config/autoconf.mk
ifeq (,$(filter beos os2 mac,$(MOZ_WIDGET_TOOLKIT))) ifeq (,$(filter beos os2 mac,$(MOZ_WIDGET_TOOLKIT)))
DIRS = src DIRS = public src
endif endif
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -28,6 +28,11 @@ const nsIFilePicker = Components.interfaces.nsIFilePicker;
const nsIDirectoryServiceProvider = Components.interfaces.nsIDirectoryServiceProvider; const nsIDirectoryServiceProvider = Components.interfaces.nsIDirectoryServiceProvider;
const nsIDirectoryServiceProvider_CONTRACTID = "@mozilla.org/file/directory_service;1"; const nsIDirectoryServiceProvider_CONTRACTID = "@mozilla.org/file/directory_service;1";
const nsIOutlinerBoxObject = Components.interfaces.nsIOutlinerBoxObject; const nsIOutlinerBoxObject = Components.interfaces.nsIOutlinerBoxObject;
const nsIFileView = Components.interfaces.nsIFileView;
const nsFileView_CONTRACTID = "@mozilla.org/filepicker/fileview;1";
const nsIOutlinerView = Components.interfaces.nsIOutlinerView;
const nsILocalFile = Components.interfaces.nsILocalFile;
const nsLocalFile_CONTRACTID = "@mozilla.org/file/local;1";
var sfile = Components.classes[nsLocalFile_CONTRACTID].createInstance(nsILocalFile); var sfile = Components.classes[nsLocalFile_CONTRACTID].createInstance(nsILocalFile);
var retvals; var retvals;
@ -45,8 +50,7 @@ function filepickerLoad() {
textInput = document.getElementById("textInput"); textInput = document.getElementById("textInput");
okButton = document.documentElement.getButton("accept"); okButton = document.documentElement.getButton("accept");
outlinerView = new nsFileView(); outlinerView = Components.classes[nsFileView_CONTRACTID].createInstance(nsIFileView);
outlinerView.selectionCallback = onSelect;
if (window.arguments) { if (window.arguments) {
var o = window.arguments[0]; var o = window.arguments[0];
@ -334,13 +338,13 @@ function convertColumnIDtoSortType(columnID) {
switch (columnID) { switch (columnID) {
case "FilenameColumn": case "FilenameColumn":
sortKey = nsFileView.SORTTYPE_NAME; sortKey = nsIFileView.sortName;
break; break;
case "FileSizeColumn": case "FileSizeColumn":
sortKey = nsFileView.SORTTYPE_SIZE; sortKey = nsIFileView.sortSize;
break; break;
case "LastModifiedColumn": case "LastModifiedColumn":
sortKey = nsFileView.SORTTYPE_DATE; sortKey = nsIFileView.sortDate;
break; break;
default: default:
dump("unsupported sort column: " + columnID + "\n"); dump("unsupported sort column: " + columnID + "\n");
@ -354,7 +358,7 @@ function convertColumnIDtoSortType(columnID) {
function handleColumnClick(columnID) { function handleColumnClick(columnID) {
var sortType = convertColumnIDtoSortType(columnID); var sortType = convertColumnIDtoSortType(columnID);
var sortOrder = (outlinerView.sortType == sortType) ? !outlinerView.reverseSort : false; var sortOrder = (outlinerView.sortType == sortType) ? !outlinerView.reverseSort : false;
outlinerView.sort(sortType, sortOrder, false); outlinerView.sort(sortType, sortOrder);
// set the sort indicator on the column we are sorted by // set the sort indicator on the column we are sorted by
var sortedColumn = document.getElementById(columnID); var sortedColumn = document.getElementById(columnID);
@ -378,10 +382,6 @@ function handleColumnClick(columnID) {
} }
} }
function doSort(sortType) {
outlinerView.sort(sortType, false);
}
function onKeypress(e) { function onKeypress(e) {
if (e.keyCode == 8) /* backspace */ if (e.keyCode == 8) /* backspace */
goUp(); goUp();
@ -406,7 +406,7 @@ function doEnabling() {
function onOutlinerFocus(event) { function onOutlinerFocus(event) {
// Reset the button label and enabled/disabled state. // Reset the button label and enabled/disabled state.
onSelect(outlinerView.getSelectedFile()); onFileSelected(outlinerView.getSelectedFile());
} }
function getOKAction(file) { function getOKAction(file) {
@ -434,7 +434,11 @@ function getOKAction(file) {
return buttonLabel; return buttonLabel;
} }
function onSelect(file) { function onSelect(event) {
onFileSelected(outlinerView.getSelectedFile());
}
function onFileSelected(file) {
if (file) { if (file) {
var path = file.unicodeLeafName; var path = file.unicodeLeafName;
@ -515,10 +519,10 @@ function gotoDirectory(directory) {
addToHistory(directory.unicodePath); addToHistory(directory.unicodePath);
window.setCursor("wait"); window.setCursor("wait");
outlinerView.setDirectory(directory.unicodePath); outlinerView.setDirectory(directory);
window.setCursor("auto"); window.setCursor("auto");
outlinerView.selection.clearSelection(); outlinerView.QueryInterface(nsIOutlinerView).selection.clearSelection();
textInput.focus(); textInput.focus();
sfile = directory; sfile = directory;
} }

Просмотреть файл

@ -40,7 +40,6 @@
persist="screenX screenY"> persist="screenX screenY">
<stringbundle id="bundle_filepicker" src="chrome://global/locale/filepicker.properties"/> <stringbundle id="bundle_filepicker" src="chrome://global/locale/filepicker.properties"/>
<script type="application/x-javascript" src="chrome://global/content/nsFileView.js"/>
<script type="application/x-javascript" src="chrome://global/content/filepicker.js"/> <script type="application/x-javascript" src="chrome://global/content/filepicker.js"/>
<hbox align="center"> <hbox align="center">
@ -66,7 +65,7 @@
<outlinercol id="LastModifiedColumn" label="&lastModified.label;" flex="1" <outlinercol id="LastModifiedColumn" label="&lastModified.label;" flex="1"
class="outlinercol-header outlinercell-inset-header sortDirectionIndicator"/> class="outlinercol-header outlinercell-inset-header sortDirectionIndicator"/>
<outlinerbody flex="1" onselect="this.parentNode.outlinerBoxObject.view.selectionChanged()"/> <outlinerbody flex="1" onselect="onSelect(event);"/>
</outliner> </outliner>
</hbox> </hbox>

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -27,6 +27,26 @@ srcdir = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk include $(DEPTH)/config/autoconf.mk
MODULE = filepicker
LIBRARY_NAME = fileview
SHORT_LIBNAME = fileview
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsFileViewModule
REQUIRES = \
xpcom \
layout \
dom \
string \
locale \
$(NULL)
CPPSRCS = \
nsFileView.cpp \
nsWildCard.cpp \
$(NULL)
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk
install:: install::

Просмотреть файл

@ -21,6 +21,22 @@
DEPTH=..\..\..\.. DEPTH=..\..\..\..
MODULE = filepicker
REQUIRES = xpcom \
layout \
dom \
string \
locale \
$(NULL)
include <$(DEPTH)\config\config.mak>
LIBRARY_NAME=fileview
MODULE_NAME=nsFileViewModule
CPP_OBJS = .\$(OBJDIR)\nsFileView.obj \
.\$(OBJDIR)\nsWildCard.obj \
$(NULL)
include <$(DEPTH)\config\rules.mak> include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -173,4 +173,3 @@ toolkit.jar:
content/global/autocomplete.css (autocomplete/resources/content/autocomplete.css) content/global/autocomplete.css (autocomplete/resources/content/autocomplete.css)
content/global/filepicker.js (filepicker/res/content/filepicker.js) content/global/filepicker.js (filepicker/res/content/filepicker.js)
content/global/filepicker.xul (filepicker/res/content/filepicker.xul) content/global/filepicker.xul (filepicker/res/content/filepicker.xul)
content/global/nsFileView.js (filepicker/res/content/nsFileView.js)