Set default Python icon and improve logic for default app prompt dialog

This commit is contained in:
Nariman Jelveh 2024-03-22 11:49:57 -07:00
parent b31c5a672d
commit 1e3fcc8bdb
2 changed files with 16 additions and 4 deletions

View File

@ -976,9 +976,18 @@ function UIItem(options){
icon: `<img src="${html_encode(suggested_app.icon ?? window.icons['app.svg'])}" style="width:16px; height: 16px; margin-bottom: -4px;">`,
onClick: async function(){
var extension = path.extname($(el_item).attr('data-path')).toLowerCase();
if(user_preferences[`default_apps${extension}`] !== suggested_app.name){
if(
user_preferences[`default_apps${extension}`] !== suggested_app.name
&&
(
(!user_preferences[`default_apps${extension}`] && index > 0)
||
(user_preferences[`default_apps${extension}`])
)
){
const alert_resp = await UIAlert({
message: `${i18n('change_allways_open_with')} ` + suggested_app.title + '?',
message: `${i18n('change_allways_open_with')} ` + html_encode(suggested_app.title) + '?',
body_icon: suggested_app.icon,
buttons:[
{
label: i18n('yes'),

View File

@ -989,6 +989,10 @@ window.item_icon = async (fsentry)=>{
else if(fsentry.name.toLowerCase().endsWith('.psd')){
return {image: window.icons['file-psd.svg'], type: 'icon'};
}
// *.py
else if(fsentry.name.toLowerCase().endsWith('.py')){
return {image: window.icons['file-py.svg'], type: 'icon'};
}
// *.xlsx
else if(fsentry.name.toLowerCase().endsWith('.xlsx')){
return {image: window.icons['file-xlsx.svg'], type: 'icon'};
@ -2126,10 +2130,9 @@ window.open_item = async function(options){
}
}
//----------------------------------------------------------------
// Do the user have a preference for this file type?
// Does the user have a preference for this file type?
//----------------------------------------------------------------
else if(user_preferences[`default_apps${path.extname(item_path).toLowerCase()}`]) {
console.log('launching default app')
launch_app({
name: user_preferences[`default_apps${path.extname(item_path).toLowerCase()}`],
file_path: item_path,