1 Commits
Author SHA1 Message Date
Leency 77be090c57 update apps to support new icon2ext.ini 2026-06-28 02:09:19 +03:00
3 changed files with 69 additions and 18 deletions

No files matched your search

+1 -1
View File
@@ -112,7 +112,7 @@ edit_box popin_text = {200,213,180,0xFFFFFF,0x94AECE,0xFFFFFF,0xFFFFFF,0x1000000
PathShow_data FileShow = {0, 56,215, 8, 100, 1, 0, 0x0, 0xFFFfff, #file_name, #temp, 0};
_ini icons_ini = { "/sys/File managers/icons.ini", NULL };
_ini icons_ini = { "/sys/File managers/icon2ext.ini", NULL };
#include "include\settings.h"
#include "include\gui.h"
+62 -10
View File
@@ -3,13 +3,71 @@ struct ICONS_INI {
collection exts;
collection_int i18;
collection_int i32;
byte loaded;
int get();
void load();
void put();
} ini_icons;
// Stores the icon number for a single extension, keeping the exts/i18/i32
// collections aligned by position regardless of the order keys are read in.
void ICONS_INI::put(dword _ext, int size, icon_n)
{
int ext_pos = exts.get_pos_by_name(_ext);
if (ext_pos == -1) {
exts.add(_ext);
ext_pos = exts.count - 1;
}
if (size == 18) i18.set(ext_pos, icon_n);
else i32.set(ext_pos, icon_n);
}
// Callback for ini_enum_keys: key_name is the icon number, key_value is a
// comma-separated list of extensions sharing that icon, e.g.
// 3=doc,docx,exc,inf,log,ob07,odt,rtf,txt,wtx
byte icons_ini_enum_key(dword key_value, key_name, sec_name, f_name)
{
char ext[7];
int icon_n, size, i;
dword src;
icon_n = atoi(key_name);
if (streq(sec_name, "icons18")) size = 18; else size = 32;
src = key_value;
while (ESBYTE[src]) {
i = 0;
while (ESBYTE[src]) && (ESBYTE[src] != ',') {
if (ESBYTE[src] != ' ') && (i < 6) {
ext[i] = ESBYTE[src];
i++;
}
src++;
}
ext[i] = '\0';
if (i) {
strlwr(#ext);
ini_icons.put(#ext, size, icon_n);
}
if (ESBYTE[src] == ',') src++;
}
return true;
}
// Reads the whole icon map once into the collections.
void ICONS_INI::load()
{
if (loaded) return;
loaded = true;
ini_enum_keys stdcall (icons_ini.path, "icons18", #icons_ini_enum_key);
ini_enum_keys stdcall (icons_ini.path, "icons32", #icons_ini_enum_key);
}
int ICONS_INI::get(dword _file_path, _ext, int size)
{
char file_4bytes[4], ext[7];
int ext_pos;
load();
if (!_ext) {
ReadFile(0,4,#file_4bytes,_file_path);
IF(DSDWORD[#file_4bytes]=='KCPK')
@@ -22,16 +80,10 @@ int ICONS_INI::get(dword _file_path, _ext, int size)
ext_pos = exts.get_pos_by_name(#ext);
if (ext_pos != -1) {
if (size == 18) return i18.get(ext_pos);
else if (size == 32) return i32.get(ext_pos);
} else {
exts.add(#ext);
icons_ini.section = "icons18";
i18.set(exts.count-1, icons_ini.GetInt(#ext, 2));
icons_ini.section = "icons32";
i32.set(exts.count-1, icons_ini.GetInt(#ext, 95));
return get(#ext, size);
if (size == 32) return i32.get(ext_pos);
}
if (size == 18) return 2;
return 95;
}
void DrawIconByExtension(dword file_path, extension, xx, yy, fairing_color)
@@ -49,7 +101,7 @@ void DrawIconByExtension(dword file_path, extension, xx, yy, fairing_color)
icons_ini.section = "drives32";
icon_n = icons_ini.GetInt(#ext, 50);
} else {
icons_ini.section = "drives16";
icons_ini.section = "drives18";
icon_n = icons_ini.GetInt(#ext, 50);
}
} else {
+6 -7
View File
@@ -89,7 +89,7 @@ void RESULTS::drop()
void SearchThread()
{
int prev_first, prev_cur_y, clicked_item;
int prev_first, prev_cur_y, clicked_item;
load_dll(Proc_lib, #OpenDialog_init,0);
OpenDialog_init stdcall (#open_folder_dialog);
@@ -112,17 +112,17 @@ void SearchThread()
SelectList_Draw();
} else {
SelectList_DrawLine(select_list.cur_y);
clicked_item = mouse.y - select_list.y / select_list.item_h + select_list.first;
clicked_item = mouse.y - select_list.y / select_list.item_h + select_list.first;
if (select_list.MouseOver(mouse.x, mouse.y))
{
if (mouse.key&MOUSE_LEFT) && (mouse.up) {
if ((prev_cur_y == select_list.cur_y) && (clicked_item < results.count)) EventRunFile();
if ((prev_cur_y == select_list.cur_y) && (clicked_item < results.count)) EventRunFile();
}
if (mouse.key&MOUSE_RIGHT) && (mouse.up) {
if ((prev_cur_y == select_list.cur_y) && (clicked_item < results.count)) EventShowFileInFolder();
if ((prev_cur_y == select_list.cur_y) && (clicked_item < results.count)) EventShowFileInFolder();
}
}
}
@@ -222,8 +222,7 @@ void SelectList_DrawLine(dword i)
} else {
strcpy(#tname, results.name.get(select_list.first + i));
strlwr(#tname);
icons_ini.section = "icons18";
icon = icons_ini.GetInt(#tname + strrchr(#tname, '.'), 2);
icon = ini_icons.get(0, #tname + strrchr(#tname, '.'), 18);
}
#define ICONX 7