feat: added Files app USB medium detection
This commit is contained in:
@@ -72,6 +72,8 @@ void ensure_filemanager_icons_loaded(DesktopState* ds) {
|
||||
Color defColor = colors::ICON_COLOR;
|
||||
ds->icon_drive = svg_load("0:/icons/drive-harddisk.svg", 16, 16, defColor);
|
||||
ds->icon_drive_lg = svg_load("0:/icons/drive-harddisk.svg", 48, 48, defColor);
|
||||
ds->icon_drive_usb = svg_load("0:/icons/drive-harddisk-usb.svg", 16, 16, defColor);
|
||||
ds->icon_drive_usb_lg = svg_load("0:/icons/drive-harddisk-usb.svg", 48, 48, defColor);
|
||||
ds->icon_home_folder = svg_load("0:/icons/folder-blue-home.svg", 16, 16, defColor);
|
||||
ds->icon_home_folder_lg = svg_load("0:/icons/folder-blue-home.svg", 48, 48, defColor);
|
||||
ds->icon_apps = svg_load("0:/icons/folder-blue-development.svg", 16, 16, defColor);
|
||||
|
||||
@@ -68,6 +68,7 @@ struct FileManagerState {
|
||||
DesktopState* desktop;
|
||||
bool grid_view;
|
||||
int drive_indices[64]; // drive number or special-folder index for Computer view entries
|
||||
int drive_kinds[64]; // kernel BlockDeviceKind for FM_ENTRY_DRIVE entries (4 = USB MSC)
|
||||
|
||||
// Clipboard
|
||||
char clipboard_path[256];
|
||||
|
||||
@@ -39,6 +39,10 @@ static void filemanager_add_root_entry(FileManagerState* fm,
|
||||
fm->entry_sizes[idx] = 0;
|
||||
fm->is_dir[idx] = true;
|
||||
fm->drive_indices[idx] = drive_index;
|
||||
fm->drive_kinds[idx] = 0;
|
||||
if (type == FM_ENTRY_DRIVE && drive_index >= 0) {
|
||||
fm->drive_kinds[idx] = montauk::drivekind(drive_index);
|
||||
}
|
||||
}
|
||||
|
||||
static int filemanager_add_virtual_entry(FileManagerState* fm,
|
||||
|
||||
@@ -333,7 +333,10 @@ void filemanager_on_draw(Window* win, Framebuffer& fb) {
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_HOME && ds->icon_home_folder_lg.pixels) {
|
||||
c.icon(icon_x, icon_y, ds->icon_home_folder_lg);
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_DRIVE && ds->icon_drive_lg.pixels) {
|
||||
c.icon(icon_x, icon_y, ds->icon_drive_lg);
|
||||
// Kind 4 = USB MSC (kernel BlockDeviceKind enum)
|
||||
const SvgIcon& di = (fm->drive_kinds[i] == 4 && ds->icon_drive_usb_lg.pixels)
|
||||
? ds->icon_drive_usb_lg : ds->icon_drive_lg;
|
||||
c.icon(icon_x, icon_y, di);
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_DIR && ds->icon_folder_lg.pixels) {
|
||||
c.icon(icon_x, icon_y, ds->icon_folder_lg);
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_EXEC && ds->icon_exec_lg.pixels) {
|
||||
@@ -464,7 +467,9 @@ void filemanager_on_draw(Window* win, Framebuffer& fb) {
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_HOME && ds->icon_home_folder.pixels) {
|
||||
c.icon(ico_x, ico_y, ds->icon_home_folder);
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_DRIVE && ds->icon_drive.pixels) {
|
||||
c.icon(ico_x, ico_y, ds->icon_drive);
|
||||
const SvgIcon& di = (fm->drive_kinds[i] == 4 && ds->icon_drive_usb.pixels)
|
||||
? ds->icon_drive_usb : ds->icon_drive;
|
||||
c.icon(ico_x, ico_y, di);
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_DIR && ds->icon_folder.pixels) {
|
||||
c.icon(ico_x, ico_y, ds->icon_folder);
|
||||
} else if (ds && fm->entry_types[i] == FM_ENTRY_EXEC && ds->icon_exec.pixels) {
|
||||
|
||||
Reference in New Issue
Block a user