From 84c435ebdcad653835acc2971e03675239e77da7 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Tue, 12 Jun 2012 14:38:52 +0800 Subject: [PATCH] use getProvider and openDocument in reader.lua we use getProvider for file extension filter --- reader.lua | 9 +++++++-- wtest.lua | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/reader.lua b/reader.lua index 76c70c90e..6601b512a 100755 --- a/reader.lua +++ b/reader.lua @@ -10,7 +10,7 @@ require "alt_getopt" function showReader(file, pass) - local document = DocumentRegistry:getProvider(file) + local document = DocumentRegistry:openDocument(file) if not document then UIManager:show(InfoMessage:new{ text = "No reader engine for this file" }) return @@ -39,7 +39,12 @@ function showFileManager(path) local FileManager = FileChooser:new{ path = path, dimen = Screen:getSize(), - is_borderless = true + is_borderless = true, + filter = function(filename) + if DocumentRegistry:getProvider(filename) then + return true + end + end } function FileManager:onFileSelect(file) diff --git a/wtest.lua b/wtest.lua index dd18eb9c3..caeefaf2a 100644 --- a/wtest.lua +++ b/wtest.lua @@ -145,9 +145,9 @@ readerwindow = CenterContainer:new{ reader = ReaderUI:new{ dialog = readerwindow, dimen = Geom:new{ w = Screen:getWidth() - 100, h = Screen:getHeight() - 100 }, - document = DocumentRegistry:getProvider("test/2col.pdf") - --document = DocumentRegistry:getProvider("test/djvu3spec.djvu") - --document = DocumentRegistry:getProvider("./README.TXT") + document = DocumentRegistry:openDocument("test/2col.pdf") + --document = DocumentRegistry:openDocument("test/djvu3spec.djvu") + --document = DocumentRegistry:openDocument("./README.TXT") } readerwindow[1][1] = reader