filetypes: support setting icons for directories
The FileTypes Tracker add-on allowed dragging-and-dropping an icon to any open FileTypes information window, but directories were not supported. Changing the icon for a directory (either directly, or via a symlink) now works as expected. Change-Id: I0c435ed789f79897972469f4e238f19789f8df1f Reviewed-on: https://review.haiku-os.org/c/haiku/+/6116 Tested-by: Automation <automation@haiku-os.org> Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
0c062f469a
commit
6d9b21e897
@ -16,6 +16,7 @@
|
||||
#include <Bitmap.h>
|
||||
#include <Catalog.h>
|
||||
#include <ControlLook.h>
|
||||
#include <Directory.h>
|
||||
#include <IconEditorProtocol.h>
|
||||
#include <IconUtils.h>
|
||||
#include <Locale.h>
|
||||
@ -1238,28 +1239,35 @@ IconView::_SetIcon(BBitmap* large, BBitmap* mini, const uint8* data,
|
||||
size_t size, bool force)
|
||||
{
|
||||
if (fHasRef) {
|
||||
BFile file(&fRef, B_READ_WRITE);
|
||||
BNodeInfo node;
|
||||
BEntry entry(&fRef, true);
|
||||
|
||||
if (is_application(file)) {
|
||||
BAppFileInfo info(&file);
|
||||
if (info.InitCheck() == B_OK) {
|
||||
if (large != NULL || force)
|
||||
info.SetIconForType(fType.Type(), large, B_LARGE_ICON);
|
||||
if (mini != NULL || force)
|
||||
info.SetIconForType(fType.Type(), mini, B_MINI_ICON);
|
||||
if (data != NULL || force)
|
||||
info.SetIconForType(fType.Type(), data, size);
|
||||
}
|
||||
} else {
|
||||
BNodeInfo info(&file);
|
||||
if (info.InitCheck() == B_OK) {
|
||||
if (large != NULL || force)
|
||||
info.SetIcon(large, B_LARGE_ICON);
|
||||
if (mini != NULL || force)
|
||||
info.SetIcon(mini, B_MINI_ICON);
|
||||
if (data != NULL || force)
|
||||
info.SetIcon(data, size);
|
||||
}
|
||||
if (entry.IsFile()) {
|
||||
BFile file(&fRef, B_READ_WRITE);
|
||||
if (is_application(file)) {
|
||||
BAppFileInfo info(&file);
|
||||
if (info.InitCheck() == B_OK) {
|
||||
if (large != NULL || force)
|
||||
info.SetIconForType(fType.Type(), large, B_LARGE_ICON);
|
||||
if (mini != NULL || force)
|
||||
info.SetIconForType(fType.Type(), mini, B_MINI_ICON);
|
||||
if (data != NULL || force)
|
||||
info.SetIconForType(fType.Type(), data, size);
|
||||
}
|
||||
} else
|
||||
node.SetTo(&file);
|
||||
}
|
||||
if (entry.IsDirectory()) {
|
||||
BDirectory refdir(&fRef);
|
||||
node.SetTo(&refdir);
|
||||
}
|
||||
if (node.InitCheck() == B_OK) {
|
||||
if (large != NULL || force)
|
||||
node.SetIcon(large, B_LARGE_ICON);
|
||||
if (mini != NULL || force)
|
||||
node.SetIcon(mini, B_MINI_ICON);
|
||||
if (data != NULL || force)
|
||||
node.SetIcon(data, size);
|
||||
}
|
||||
// the icon shown will be updated using node monitoring
|
||||
} else if (fHasType) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user