Repository: spyder-ide/spyder

Issue:
Improve icons in the File explorer
Icons in the File explorer aren't anymore populated/updated

**What steps will reproduce the problem?**

1. Fresh install WinPython 3.5.2.3QT5 
2. open Spyder, 
3. activate the File Explorer

I get that : 
![](https://cloud.githubusercontent.com/assets/15816165/20972749/31d1f076-bc96-11e6-90bf-f45f977407d0.png)

but in previous version, I had that (icons are the same as in window explorer)
![](https://cloud.githubusercontent.com/assets/15816165/20972804/60e4a4e4-bc96-11e6-9923-d66c3b191e11.png)

* Spyder Version: 3.1.0.dev0
* Python Version: 3.5
* Operating system: Win 7 enterprise

Winpython maintainer (stonebig) did reproduce the problem, see issue : https://github.com/winpython/winpython/issues/446#issuecomment-266191173


Discussion:
Sorry, we decided to unify our theme to display always the same kind of icons instead of taking some from the operating system.
Sorry but that's a bit short !
It would be OK if I get more than 2 icons: one for folder, one for "other".
I had difficulty to understand why I had "file" icon in the middle of my folders... The explanation is that the Symbolic Links to folder has a "file" icon, but is sorted among the folders. Really not intuitive. 
To my point of view, it is a clear regression. 
in engineering, we keep saying : "never change a running system". Previous behaviour was perfect, why change it. Only Spyder developers can appreciate the theme unification
Sorry if I was too blunt. We can look at the issue with symbolic links and also at using a wider range of icons to disambiguate file types (but using the icons from the FontAwesome project and not the ones from the operating system).

Please open an issue for each of these problems :-)
I just updated to Spyder 3.1 and found the same strange behaviour of all icons in the file explorer suddenly being the same. 

I find the answer "we decided to unify our theme to display always the same kind of icons instead of taking some from the operating system" pretty unconstructive. Having the same icons as in the operating system is a great feature and from a user's perspective there is absolutely no reason whatsoever to give this up. For the 1% of users who rate visual design higher than usablility one may of course put a different icon theme in, but surely not as default.

So what is the latest version that still has the default system icons in the file explorer, such that I can revert back to it until I've found a less usability-ignorant IDE for python?
We're no going to revert to using the operating system icons, sorry. As i said, we plan to use the icons FontAwesome has for different file types.
@andfoy, please work on this one using the `file-*-o` icons present in FontAwesome.
Also, you need to detect the file type of a symlink and use the right icon for it.
@andfoy, please stop what you're doing and focus on solving this issue.

Resolving patch:
diff --git a/spyder/utils/icon_manager.py b/spyder/utils/icon_manager.py
--- a/spyder/utils/icon_manager.py
+++ b/spyder/utils/icon_manager.py
@@ -173,6 +173,15 @@
     'MessageBoxInformation':   [('fa.info',), {'color': '3775a9'}],
     'DirOpenIcon':             [('fa.folder-open',), {}],
     'FileIcon':                [('fa.file-o',), {}],
+    'ExcelFileIcon':           [('fa.file-excel-o',), {}],
+    'WordFileIcon':            [('fa.file-word-o',), {}],
+    'PowerpointFileIcon':      [('fa.file-powerpoint-o',), {}],
+    'PDFIcon':                 [('fa.file-pdf-o',), {}],
+    'AudioFileIcon':           [('fa.file-audio-o',), {}],
+    'ImageFileIcon':           [('fa.file-image-o',), {}],
+    'ArchiveFileIcon':         [('fa.file-archive-o',), {}],
+    'VideoFileIcon':           [('fa.file-video-o',), {}],
+    'TextFileIcon':            [('fa.file-text-o',), {}],
     'project':                 [('fa.folder-open-o',), {}],
     'DriveHDIcon':             [('fa.hdd-o',), {}],
     'arrow':                   [('fa.arrow-right',), {}],
diff --git a/spyder/widgets/explorer.py b/spyder/widgets/explorer.py
--- a/spyder/widgets/explorer.py
+++ b/spyder/widgets/explorer.py
@@ -19,6 +19,7 @@
 import shutil
 import subprocess
 import sys
+import mimetypes as mime
 
 # Third party imports
 from qtpy import API, is_pyqt46
@@ -106,10 +107,28 @@ def has_subdirectories(path, include, exclude, show_all):
 
 
 class IconProvider(QFileIconProvider):
+    BIN_FILES = {x: 'ArchiveFileIcon' for x in ['zip', 'x-tar',
+                 'x-7z-compressed', 'rar']}
+    DOCUMENT_FILES = {'vnd.ms-powerpoint': 'PowerpointFileIcon',
+                      'vnd.openxmlformats-officedocument.'
+                      'presentationml.presentation': 'PowerpointFileIcon',
+                      'msword': 'WordFileIcon',
+                      'vnd.openxmlformats-officedocument.'
+                      'wordprocessingml.document': 'WordFileIcon',
+                      'vnd.ms-excel': 'ExcelFileIcon',
+                      'vnd.openxmlformats-officedocument.'
+                      'spreadsheetml.sheet': 'ExcelFileIcon',
+                      'pdf': 'PDFIcon'}
+    OFFICE_FILES = {'.xlsx': 'ExcelFileIcon', '.docx': 'WordFileIcon',
+                    '.pptx': 'PowerpointFileIcon'}
+
     """Project tree widget icon provider"""
     def __init__(self, treeview):
         super(IconProvider, self).__init__()
         self.treeview = treeview
+        self.application_icons = {}
+        self.application_icons.update(self.BIN_FILES)
+        self.application_icons.update(self.DOCUMENT_FILES)
 
     @Slot(int)
     @Slot(QFileInfo)
@@ -123,7 +142,28 @@ def icon(self, icontype_or_qfileinfo):
             if osp.isdir(fname):
                 return ima.icon('DirOpenIcon')
             else:
-                return ima.icon('FileIcon')
+                basename = osp.basename(fname)
+                _, extension = osp.splitext(basename)
+                mime_type, _ = mime.guess_type(basename)
+                icon = ima.icon('FileIcon')
+
+                if extension in self.OFFICE_FILES:
+                    icon = ima.icon(self.OFFICE_FILES[extension])
+
+                if mime_type is not None:
+                    file_type, bin_name = mime_type.split('/')
+                    if file_type == 'text':
+                        icon = ima.icon('TextFileIcon')
+                    elif file_type == 'audio':
+                        icon = ima.icon('AudioFileIcon')
+                    elif file_type == 'video':
+                        icon = ima.icon('VideoFileIcon')
+                    elif file_type == 'image':
+                        icon = ima.icon('ImageFileIcon')
+                    elif file_type == 'application':
+                        if bin_name in self.application_icons:
+                            icon = ima.icon(self.application_icons[bin_name])
+                return icon
 
 
 class DirView(QTreeView):


Test patch: