@ -1,7 +1,13 @@
local Device = require ( " device " )
local Device = require ( " device " )
local DocumentRegistry = require ( " document/documentregistry " )
local _ = require ( " gettext " )
local _ = require ( " gettext " )
local function getSupportedExtensions ( )
local t = require ( " document/documentregistry " ) : getExtensions ( )
t [ " sh " ] = nil
t [ " py " ] = nil
return t
end
local ExtAssoc = {
local ExtAssoc = {
assoc = G_reader_settings : readSetting ( " file_ext_assoc " ) or { } ,
assoc = G_reader_settings : readSetting ( " file_ext_assoc " ) or { } ,
}
}
@ -10,14 +16,14 @@ function ExtAssoc:commit()
G_reader_settings : saveSetting ( " file_ext_assoc " , self.assoc ) : flush ( )
G_reader_settings : saveSetting ( " file_ext_assoc " , self.assoc ) : flush ( )
-- Translate the boolean map back to map of providers the OS backend can inquire further
-- Translate the boolean map back to map of providers the OS backend can inquire further
local t = { }
local t = { }
for k , v in pairs ( DocumentRegistry: get Extensions( ) ) do
for k , v in pairs ( getSupported Extensions( ) ) do
if self.assoc [ k ] then t [ k ] = v end
if self.assoc [ k ] then t [ k ] = v end
end
end
Device : associateFileExtensions ( t )
Device : associateFileExtensions ( t )
end
end
function ExtAssoc : setAll ( state )
function ExtAssoc : setAll ( state )
for k , dummy in pairs ( DocumentRegistry: get Extensions( ) ) do
for k , dummy in pairs ( getSupported Extensions( ) ) do
self : setOne ( k , state )
self : setOne ( k , state )
end
end
self : commit ( )
self : commit ( )
@ -47,7 +53,7 @@ function ExtAssoc:getSettingsMenuTable()
separator = true ,
separator = true ,
} ,
} ,
}
}
local exts = DocumentRegistry: get Extensions( )
local exts = getSupported Extensions( )
local keys = { }
local keys = { }
for k , dummy in pairs ( exts ) do
for k , dummy in pairs ( exts ) do
table.insert ( keys , k )
table.insert ( keys , k )