Browse Source

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

Nariman Jelveh 1 năm trước cách đây
mục cha
commit
1e3fcc8bdb
2 tập tin đã thay đổi với 16 bổ sung4 xóa
  1. 11 2
      src/UI/UIItem.js
  2. 5 2
      src/helpers.js

+ 11 - 2
src/UI/UIItem.js

@@ -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'),

+ 5 - 2
src/helpers.js

@@ -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,