Fix T90862: Texts in Outliner can have wrong icon

In contrast to the Filebrowser, the Outliner (Blender File view) did not
distinguish icons for text-based formats (if they have a filepath this
can be done though).

Maniphest Tasks: T90862

Differential Revision: https://developer.blender.org/D12347
This commit is contained in:
Philipp Oeser 2021-08-30 15:36:39 +02:00
parent 30845b5c8e
commit 1c1be5bdf4
Notes: blender-bot 2023-02-14 01:52:41 +01:00
Referenced by issue #90862, Outliner: Wrong icon for non-py file-types
1 changed files with 12 additions and 2 deletions

View File

@ -32,6 +32,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "DNA_text_types.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
@ -59,6 +60,7 @@
#include "DEG_depsgraph_build.h"
#include "ED_armature.h"
#include "ED_fileselect.h"
#include "ED_outliner.h"
#include "ED_screen.h"
@ -2625,9 +2627,17 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
case ID_NLA:
data.icon = ICON_NLA;
break;
case ID_TXT:
data.icon = ICON_SCRIPT;
case ID_TXT: {
Text *text = (Text *)tselem->id;
if (text->filepath == NULL || (text->flags & TXT_ISMEM)) {
data.icon = ICON_FILE_TEXT;
}
else {
/* Helps distinguish text-based formats like the filebrowser does. */
data.icon = ED_file_extension_icon(text->filepath);
}
break;
}
case ID_GR:
data.icon = ICON_OUTLINER_COLLECTION;
break;