Subversion Repositories Kolibri OS

Rev

Rev 8868 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8868 Rev 9576
Line 1... Line 1...
1
_ini icons_ini = { "/sys/File managers/icons.ini", NULL };
1
_ini icons_ini = { "/sys/File managers/icons.ini", NULL };
Line -... Line 2...
-
 
2
 
-
 
3
struct ICONS_INI {
-
 
4
	collection exts;
-
 
5
	collection_int i18;
-
 
6
	collection_int i32;
-
 
7
	int get();
-
 
8
} ini_icons;
-
 
9
 
-
 
10
int ICONS_INI::get(dword _file_path, _ext, int size)
-
 
11
{
-
 
12
	char file_4bytes[4], ext[7];
-
 
13
	int  ext_pos;
-
 
14
	if (!_ext) {
-
 
15
		ReadFile(0,4,#file_4bytes,_file_path);
-
 
16
		IF(DSDWORD[#file_4bytes]=='KCPK')
-
 
17
		||(DSDWORD[#file_4bytes]=='UNEM') {
-
 
18
			_ext = "kex";
-
 
19
		}
-
 
20
	}
-
 
21
	strlcpy(#ext, _ext, sizeof(ext));
-
 
22
	strlwr(#ext);
-
 
23
	ext_pos = exts.get_pos_by_name(#ext);
-
 
24
	if (ext_pos != -1) {
-
 
25
		if (size == 18) return i18.get(ext_pos);
-
 
26
		else if (size == 32) return i32.get(ext_pos);
-
 
27
	} else {
-
 
28
		exts.add(#ext);
-
 
29
			icons_ini.section = "icons16";
-
 
30
			i18.set(exts.count-1, icons_ini.GetInt(#ext, 2));
-
 
31
 
-
 
32
			icons_ini.section = "icons32";
-
 
33
			i32.set(exts.count-1, icons_ini.GetInt(#ext, 95));
-
 
34
		return get(#ext, size);
-
 
35
	}
-
 
36
}
2
 
37
 
3
void DrawIconByExtension(dword file_path, extension, xx, yy, fairing_color)
38
void DrawIconByExtension(dword file_path, extension, xx, yy, fairing_color)
4
{
-
 
5
	char BYTE_HEAD_FILE[4];
39
{
6
	char ext[512];
40
	char ext[7];
7
	int icon_n = 2;
41
	int icon_n = 2;
8
	dword selected_image;
42
	dword selected_image;
9
	dword default_image;
-
 
10
	dword default_icon;
-
 
11
 
-
 
12
	if (big_icons.checked) {
-
 
13
		icons_ini.section = "icons32";
-
 
14
		selected_image = icons32_selected.image;
-
 
15
		default_image = icons32_default.image;
-
 
16
		default_icon=95;
-
 
17
	} else {
-
 
18
		icons_ini.section = "icons16";
-
 
19
		selected_image = icons16_selected.image;
-
 
20
		default_image = icons16_default.image;
-
 
21
		default_icon=2;
-
 
Line 22... Line 43...
22
	}
43
	dword default_image;
23
 
44
 
24
	if (ESBYTE[file_path+1]!='k') && (ESBYTE[file_path+1]!='s') && (chrnum(file_path, '/')==2) {
45
	if (ESBYTE[file_path+1]!='k') && (ESBYTE[file_path+1]!='s') && (chrnum(file_path, '/')==2) {
25
		if (ESBYTE[file_path+1]=='/') ext[0] = ESBYTE[file_path+2];
46
		if (ESBYTE[file_path+1]=='/') ext[0] = ESBYTE[file_path+2];
Line 30... Line 51...
30
			icon_n = icons_ini.GetInt(#ext, 50);
51
			icon_n = icons_ini.GetInt(#ext, 50);
31
		} else {
52
		} else {
32
			icons_ini.section = "drives16";
53
			icons_ini.section = "drives16";
33
			icon_n = icons_ini.GetInt(#ext, 50);
54
			icon_n = icons_ini.GetInt(#ext, 50);
34
		}
55
		}
35
	} else if (extension) {
56
	} else {
36
		strcpy(#ext, extension);
57
		icon_n = ini_icons.get(file_path, extension, icon_size);
-
 
58
	}
-
 
59
 
37
		strlwr(#ext);
60
	if (big_icons.checked) {
-
 
61
		selected_image = icons32_selected.image;
38
		icon_n = icons_ini.GetInt(#ext, default_icon);
62
		default_image = icons32_default.image;
39
	} else if (file_path) {
63
	} else {
40
		ReadFile(0,4,#BYTE_HEAD_FILE,file_path);
64
		selected_image = icons16_selected.image;
41
		IF(DSDWORD[#BYTE_HEAD_FILE]=='KCPK')||(DSDWORD[#BYTE_HEAD_FILE]=='UNEM') 
-
 
42
			icon_n = icons_ini.GetInt("kex", 2);
65
		default_image = icons16_default.image;
43
	}
66
	}
Line 44... Line 67...
44
 
67
 
45
	if (fairing_color==col.selec) {
68
	if (fairing_color==col.selec) {
46
		img_draw stdcall(selected_image, xx, yy, icon_size, icon_size, 0, icon_n*icon_size);
69
		img_draw stdcall(selected_image, xx, yy, icon_size, icon_size, 0, icon_n*icon_size);