Subversion Repositories Kolibri OS

Rev

Rev 8946 | Rev 8949 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8946 Rev 8947
Line 1... Line 1...
1
//Leency, Veliant, Punk_Joker, PavelYakov & KolibriOS Team 2008-2021
1
//Leency, Veliant, Punk_Joker, PavelYakov & KolibriOS Team 2008-2021
2
//GNU GPL license.
2
//GNU GPL license.
Line 3... Line 3...
3
 
3
 
Line 4... Line 4...
4
// 70.5 - get volume info and label
4
// 70.5 - get volume info and label
5
 
5
 
6
#define ABOUT_TITLE "EOLITE 5 RC5"
6
#define ABOUT_TITLE "EOLITE 5 Beta8"
Line 7... Line 7...
7
#define TITLE_EOLITE "Eolite File Manager 5 RC5"
7
#define TITLE_EOLITE "Eolite File Manager 5 Beta8"
8
#define TITLE_KFM "Kolibri File Manager 2 RC5";
8
#define TITLE_KFM "Kolibri File Manager 2 Beta8";
9
 
9
 
10
#define MEMSIZE 1024 * 250
10
#define MEMSIZE 1024 * 250
Line 26... Line 26...
26
#include "../lib/patterns/history.h"
26
#include "../lib/patterns/history.h"
27
#include "../lib/patterns/toolbar_button.h"
27
#include "../lib/patterns/toolbar_button.h"
Line 28... Line 28...
28
 
28
 
Line 29... Line -...
29
#include "imgs/images.h"
-
 
30
 
-
 
31
//Button IDs
-
 
32
enum {
-
 
33
	PATH_BTN = 10,
-
 
34
	POPUP_BTN1 = 201,
-
 
35
	POPUP_BTN2 = 202,
-
 
36
	KFM_DEV_DROPDOWN_1 = 205,
-
 
37
	KFM_DEV_DROPDOWN_2 = 207,
-
 
38
	BREADCRUMB_ID = 300,
-
 
39
 
-
 
40
	BACK_BTN = 400,
-
 
41
	FWRD_BTN,
-
 
42
	GOUP_BTN,
-
 
43
	COPY_BTN,
-
 
44
	CUT_BTN,
-
 
45
	PASTE_BTN,
-
 
46
	KFM_FUNC_ID = 450
-
 
47
};
29
#include "imgs/images.h"
48
 
-
 
49
//NewElement options
-
 
50
enum {
-
 
51
	CREATE_FILE=1, 
-
 
52
	CREATE_FOLDER, 
-
 
53
	RENAME_ITEM
-
 
54
}; 
-
 
55
 
-
 
56
//OpenDir options
-
 
57
enum {
-
 
58
	WITH_REDRAW, 
-
 
Line 59... Line 30...
59
	ONLY_OPEN
30
 
Line 60... Line 31...
60
};
31
#include "include/const.h"
61
 
32
 
Line 82... Line 53...
82
 
53
 
Line 83... Line 54...
83
bool efm = false;
54
bool efm = false;
Line 84... Line -...
84
 
-
 
85
int toolbar_buttons_x[7]={9,46,85,134,167,203};
-
 
86
 
-
 
87
bool active_about = false;
55
 
Line 88... Line -...
88
bool active_settings = false;
-
 
89
bool _not_draw = false;
-
 
90
bool dir_at_fat16 = NULL;
56
int toolbar_buttons_x[7]={9,46,85,134,167,203};
91
 
57
 
-
 
58
bool dir_at_fat16 = NULL;
-
 
59
 
Line 92... Line 60...
92
bool disk_popin_active_on_panel=0;
60
dword about_thread_id;
93
 
61
dword settings_window;
Line 94... Line 62...
94
dword about_thread_id;
62
bool active_about = false;
Line 95... Line 63...
95
dword settings_window;
63
bool active_settings = false;
Line -... Line 64...
-
 
64
 
96
 
65
byte del_active=0;
97
byte del_active=0;
66
byte new_element_active=0;
98
byte new_element_active=0;
67
 
99
 
68
llist files, files_active, files_inactive;
-
 
69
 
-
 
70
bool list_full_redraw;
100
llist files, files_active, files_inactive;
71
 
101
 
72
//Folder data
102
byte list_full_redraw;
73
	dword buf;
103
 
74
	collection_int items=0;
104
dword buf;
75
	int selected_count;
105
collection_int items=0;
76
	int folder_count;
106
int selected_count;
77
	//dword path;
-
 
78
	char path[4096];
-
 
79
 
-
 
80
//Sselected element data
-
 
81
	byte file_path[4096];
-
 
82
	byte file_name[256];
-
 
83
	byte new_element_name[256];
-
 
84
	byte temp[4096];
-
 
85
	bool itdir;
-
 
86
 
Line 107... Line -...
107
int count_dir;
-
 
Line -... Line 87...
-
 
87
//Window data
108
 
88
	proc_info Form;
109
byte path[4096];
89
	int sc_slider_h;
-
 
90
	bool scroll_used=false;
Line 110... Line 91...
110
byte file_path[4096];
91
	char sort_type=2;
Line 111... Line 92...
111
byte file_name[256];
92
	bool sort_desc=false;
112
byte new_element_name[256];
-
 
113
byte temp[4096];
-
 
114
bool itdir;
-
 
115
 
-
 
116
char active_path[4096], inactive_path[4096];
-
 
117
 
-
 
118
dword eolite_ini_path[4096];
-
 
119
_ini ini;
-
 
120
 
93
	int status_bar_h;
Line 121... Line 94...
121
char scroll_used=false;
94
	int icon_size = 18;
122
 
95
 
Line 123... Line 96...
123
dword about_stak=0,properties_stak=0,settings_stak=0;
96
 
124
 
97
int active_panel=0;
Line 125... Line -...
125
proc_info Form;
-
 
126
int sc_slider_h;
-
 
127
int action_buf;
-
 
128
int rand_n;
-
 
129
 
98
int disk_popin_active_on_panel=0;
130
char sort_type=2;
99
#define PANES_COUNT 2
131
bool sort_desc=false;
100
unsigned char location[PANES_COUNT];
132
int active_panel=0;
-
 
133
 
-
 
-
 
101
 
Line 134... Line 102...
134
libimg_image icons16_default;
102
char active_path[4096], inactive_path[4096];
135
libimg_image icons16_selected;
103
 
136
 
104
dword about_stak=0,properties_stak=0,settings_stak=0;
137
libimg_image icons32_default;
105
byte cmd_free=0;
Line 157... Line 125...
157
#include "include\menu.h"
125
#include "include\menu.h"
158
#include "include\about.h"
126
#include "include\about.h"
159
#include "include\properties.h"
127
#include "include\properties.h"
160
#include "include\breadcrumbs.h"
128
#include "include\breadcrumbs.h"
Line 161... Line -...
161
 
-
 
162
void load_libraries()
-
 
163
{
-
 
164
	load_dll(boxlib, #box_lib_init,0);
-
 
165
	load_dll(libini, #lib_init,1);
-
 
166
	load_dll(libimg, #libimg_init,1);
-
 
167
}
-
 
168
 
129
 
169
void handle_param()
130
void handle_param()
170
{
131
{
171
	//-p  : just show file/folder properties dialog
132
	//-p  : just show file/folder properties dialog
172
	//-d  : delete file/folder
133
	//-d  : delete file/folder
-
 
134
	//-v : paste files/folder from clipboard
173
	//-v : paste files/folder from clipboard
135
	int i;
174
	dword p = #param;
136
	dword p = #param;
175
	if (param[0]=='\\') && (param[1]=='E') && (param[2]=='F') && (param[3]=='M') {
137
	if (param[0]=='\\') && (param[1]=='E') && (param[2]=='F') && (param[3]=='M') {
176
		efm = true;
138
		efm = true;
177
		p += 4;
139
		p += 4;
178
		if (param[4]==' ') p++;
140
		if (param[4]==' ') p++;
Line 179... Line 141...
179
	}
141
	}
Line -... Line 142...
-
 
142
 
-
 
143
	LoadIniSettings();
-
 
144
 
-
 
145
	for (i=0; i
-
 
146
		location[i] = malloc(4096);
-
 
147
		strcpy(location[i], #path_start);
180
 
148
	}
Line 181... Line 149...
181
	LoadIniSettings();
149
	//path = location[0];
182
 
150
 
183
	if (ESBYTE[p]=='\0') return;
151
	if (ESBYTE[p]=='\0') return;
Line 223... Line 191...
223
void main() 
191
void main() 
224
{
192
{
225
	dword id;
193
	dword id;
226
	int old_cur_y;
194
	int old_cur_y;
Line 227... Line 195...
227
 
195
 
228
	load_libraries();
196
	load_dll(boxlib, #box_lib_init,0);
229
	SetAppColors();
-
 
230
 
197
	load_dll(libini, #lib_init,1);
Line -... Line 198...
-
 
198
	load_dll(libimg, #libimg_init,1);
231
	ESBYTE[0] = NULL;
199
 
232
 
-
 
Line 233... Line 200...
233
	handle_param();
200
	SetAppColors();
Line 234... Line 201...
234
	rand_n = random(80);
201
	handle_param();
235
 
202
 
236
	ESBYTE[0] = NULL;
203
	ESBYTE[0] = NULL;
237
 
204
 
238
	SystemDiscs.Get();
205
	SystemDiscs.Get();
239
	Open_Dir(#path,ONLY_OPEN);
206
	Open_Dir(#path,ONLY_OPEN);
240
	strcpy(#inactive_path, #path);
207
	strcpy(#inactive_path, #path);
241
	llist_copy(#files_inactive, #files);
208
	llist_copy(#files_inactive, #files);
242
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
209
	SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
243
	loop() switch(@WaitEventTimeout(80))
210
	loop() switch(@WaitEventTimeout(100))
244
	{
211
	{
245
		case evMouse:
212
		case evMouse:
246
			if (del_active) || (disk_popin_active_on_panel) || (Form.status_window&ROLLED_UP) break;
213
			if (del_active) || (disk_popin_active_on_panel) || (Form.status_window&ROLLED_UP) break;
247
			if (new_element_active) 
214
			if (new_element_active) 
Line 248... Line 215...
248
			{
215
			{
Line 249... Line 216...
249
				edit_box_mouse stdcall(#new_file_ed);
216
				edit_box_mouse stdcall(#new_file_ed);
Line 316... Line 283...
316
				DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,sc.work_light,sc.work_dark);
283
				DrawRectangle3D(files.x+files.w+1,files.y+files.h-15,14,14,sc.work_light,sc.work_dark);
317
			}
284
			}
Line 318... Line 285...
318
 
285
 
319
			//Scrooll
286
			//Scrooll
320
			if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+18) && (mouse.y>files.y) 
287
			if (mouse.x>=files.x+files.w) && (mouse.x<=files.x+files.w+18) && (mouse.y>files.y) 
321
				&& (mouse.y
288
				&& (mouse.y
Line 322... Line 289...
322
			if (scroll_used) && (!mouse.key&MOUSE_LEFT) { scroll_used=false; Scroll(); }
289
			if (scroll_used) && (!mouse.key&MOUSE_LEFT) { scroll_used=false; DrawScroll(scroll_used); }
323
			
290
			
324
			if (scroll_used)
291
			if (scroll_used)
325
			{
292
			{
Line 486... Line 453...
486
							break;
453
							break;
487
					case SCAN_CODE_KEY_N:
454
					case SCAN_CODE_KEY_N:
488
							EventOpenNewEolite();
455
							EventOpenNewEolite();
489
							break; 
456
							break; 
490
					case SCAN_CODE_KEY_R:
457
					case SCAN_CODE_KEY_R:
491
							EventRefreshDisksAndFolders();
458
							EventManualFolderRefresh();
492
							break;
459
							break;
493
					case SCAN_CODE_ENTER:
460
					case SCAN_CODE_ENTER:
494
							if (!itdir) ShowOpenWithDialog();
461
							if (!itdir) ShowOpenWithDialog();
495
							else EventOpen(1);
462
							else EventOpen(1);
496
							break;
463
							break;
Line 544... Line 511...
544
			break;
511
			break;
545
		case evIPC:
512
		case evIPC:
546
		case evReDraw:
513
		case evReDraw:
547
			draw_window();
514
			draw_window();
548
			if (CheckActiveProcess(Form.ID)) && (GetMenuClick()) break;
515
			if (CheckActiveProcess(Form.ID)) && (GetMenuClick()) break;
549
			if (action_buf==OPERATION_END) {
-
 
550
				EventRefresh();
-
 
551
				action_buf=0;
-
 
552
			}
-
 
553
			break;
516
			break;
554
		default:
517
		default:
555
			if (Form.status_window<=2) EventRefreshDisksAndFolders();
518
			if (!Form.status_window&ROLLED_UP) EventRefreshDisksAndFolders();
556
			//sprintf(#param, "/tmp0/1/%i", random(99999)); //for testing purpose
-
 
557
			//CreateFile(0, 0, #param);
-
 
558
	}
519
	}
Line 559... Line 520...
559
	
520
	
560
	if(cmd_free)
521
	if(cmd_free)
561
	{
522
	{
Line 569... Line 530...
569
void draw_window()
530
void draw_window()
570
{
531
{
571
	dword i=0;
532
	dword i=0;
572
	incn x;
533
	incn x;
573
	dword title;
534
	dword title;
-
 
535
	static int rand_n;
-
 
536
	if (rand_n) rand_n = random(80);
-
 
537
 
574
	if (show_status_bar.checked) {
538
	if (show_status_bar.checked) {
575
		#define STBAR_EOLITE_H 16;
539
		#define STBAR_EOLITE_H 16;
576
		#define STBAR_KFM_H 21+16;
540
		#define STBAR_KFM_H 21+16;
577
		if (efm) status_bar_h = STBAR_KFM_H;
541
		if (efm) status_bar_h = STBAR_KFM_H;
578
		else status_bar_h = STBAR_EOLITE_H;
542
		else status_bar_h = STBAR_EOLITE_H;
Line 675... Line 639...
675
	}
639
	}
Line 676... Line 640...
676
 
640
 
677
	if (!show_status_bar.checked) return;
641
	if (!show_status_bar.checked) return;
678
	if (files.count>0) && (streq(items.get(0)*304+buf+72,"..")) go_up_folder_exists=1;
642
	if (files.count>0) && (streq(items.get(0)*304+buf+72,"..")) go_up_folder_exists=1;
679
	DrawBar(0, Form.cheight - status_bar_h, Form.cwidth,  status_bar_h, sc.work);
643
	DrawBar(0, Form.cheight - status_bar_h, Form.cwidth,  status_bar_h, sc.work);
680
	sprintf(#status_bar_str, T_STATUS_EVEMENTS, count_dir-go_up_folder_exists, files.count-count_dir);
644
	sprintf(#status_bar_str, T_STATUS_EVEMENTS, folder_count-go_up_folder_exists, files.count-folder_count);
681
	WriteText(6,Form.cheight - 13,0x80,sc.work_text,#status_bar_str);
645
	WriteText(6,Form.cheight - 13,0x80,sc.work_text,#status_bar_str);
682
	if (selected_count) {
646
	if (selected_count) {
683
		sprintf(#status_bar_str, T_STATUS_SELECTED, selected_count);
647
		sprintf(#status_bar_str, T_STATUS_SELECTED, selected_count);
684
		WriteText(Form.cwidth - calc(strlen(#status_bar_str)*6)-6,Form.cheight - 13,
648
		WriteText(Form.cwidth - calc(strlen(#status_bar_str)*6)-6,Form.cheight - 13,
Line 770... Line 734...
770
	all_lines_h = j * files.item_h;
734
	all_lines_h = j * files.item_h;
771
	DrawBar(files.x,all_lines_h + files.y,files.w,files.h - all_lines_h, col.list_bg);
735
	DrawBar(files.x,all_lines_h + files.y,files.w,files.h - all_lines_h, col.list_bg);
772
	if (colored_lines.checked) separator_color = col.list_bg; else separator_color = col.list_vert_line;
736
	if (colored_lines.checked) separator_color = col.list_bg; else separator_color = col.list_vert_line;
773
	DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
737
	DrawBar(files.x+files.w-141,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
774
	DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
738
	DrawBar(files.x+files.w-68,all_lines_h + files.y,1,files.h - all_lines_h, separator_color);
775
	Scroll();
739
	DrawScroll(scroll_used);
Line 776... Line 740...
776
 
740
 
777
	if (del_active) Del_Form();
741
	if (del_active) Del_Form();
778
	if (new_element_active) && (col.selec != 0xCCCccc) NewElement_Form(new_element_active, #new_element_name);
742
	if (new_element_active) && (col.selec != 0xCCCccc) NewElement_Form(new_element_active, #new_element_name);
Line 889... Line 853...
889
		Write_Error(errornum);
853
		Write_Error(errornum);
890
		return;
854
		return;
891
	}
855
	}
892
	if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
856
	if (files.count>0) && (files.cur_y-files.first==-1) files.cur_y=0;
Line 893... Line -...
893
 
-
 
894
	if (files.count!=-1)
-
 
895
	{
-
 
896
		if(!_not_draw) DrawPathBar();
857
 
897
		history.add(#path);
858
	history.add(#path);
898
		SystemDiscs.Draw();
859
	SystemDiscs.Draw();
899
		files.visible = files.h / files.item_h;
860
	files.visible = files.h / files.item_h;
900
		if (files.count < files.visible) files.visible = files.count;
861
	if (files.count < files.visible) files.visible = files.count;
901
		if (!strncmp(dir_path, "/rd/1/",5)) || (!strncmp(dir_path, "/sys/",4)) 
862
	if (!strncmp(dir_path, "/rd/1/",5)) || (!strncmp(dir_path, "/sys/",4)) 
902
			dir_at_fat16 = true; else dir_at_fat16 = false; 
863
		dir_at_fat16 = true; else dir_at_fat16 = false; 
903
		Sorting();
864
	Sorting();
904
		list_full_redraw = true;
-
 
905
		if (redraw!=ONLY_OPEN)&&(!_not_draw) {DrawStatusBar(); List_ReDraw();}
865
	list_full_redraw = true;
906
		SetCurDir(dir_path);
866
	SetCurDir(dir_path);
907
	}
867
	DrawPathBar();
908
	if (files.count==-1) && (redraw!=ONLY_OPEN) 
-
 
909
	{
868
	if (redraw!=ONLY_OPEN) {
910
		files.KeyHome();
869
		List_ReDraw();
911
		if(!_not_draw) { list_full_redraw=true; DrawStatusBar(); List_ReDraw(); }
870
		DrawStatusBar(); 
912
	}
871
	}
Line 913... Line 872...
913
}
872
}
914
 
873
 
Line 921... Line 880...
921
	items.drop();
880
	items.drop();
Line 922... Line 881...
922
 
881
 
923
	if (!strcmp(#path,"/")) //do not sort root folder
882
	if (!strcmp(#path,"/")) //do not sort root folder
924
	{
883
	{
925
		for(d=1;d
884
		for(d=1;d
926
		count_dir = d;
885
		folder_count = d;
927
		return;
886
		return;
928
	}
887
	}
929
	for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
888
	for (j=files.count-1, file_off=files.count-1*304+buf+32; j>=0; j--, file_off-=304;)  //files | folders
930
	{
889
	{
Line 935... Line 894...
935
		} else {
894
		} else {
936
			items.set(files.count-f, j);
895
			items.set(files.count-f, j);
937
			f++;
896
			f++;
938
		}
897
		}
939
	}
898
	}
940
	count_dir = d;
899
	folder_count = d;
941
	//sorting: files first, then folders
900
	//sorting: files first, then folders
942
	Sort_by_Name(0,d-1);
901
	Sort_by_Name(0,d-1);
943
	if (sort_type==1) Sort_by_Name(d,files.count-1);
902
	if (sort_type==1) Sort_by_Name(d,files.count-1);
944
	else if (sort_type==2) Sort_by_Type(d,files.count-1);
903
	else if (sort_type==2) Sort_by_Type(d,files.count-1);
945
	else if (sort_type==3) Sort_by_Size(d,files.count-1);
904
	else if (sort_type==3) Sort_by_Size(d,files.count-1);
Line 1167... Line 1126...
1167
		case 5:
1126
		case 5:
1168
			if (efm) {
1127
			if (efm) {
1169
				CopyFilesListToClipboard(COPY);
1128
				CopyFilesListToClipboard(COPY);
1170
				EventPaste(#inactive_path);
1129
				EventPaste(#inactive_path);
1171
			} else {
1130
			} else {
1172
				EventRefreshDisksAndFolders();
1131
				EventManualFolderRefresh();
1173
			}
1132
			}
1174
			break;
1133
			break;
1175
		case 6:
1134
		case 6:
1176
			if (efm) {
1135
			if (efm) {
1177
				CopyFilesListToClipboard(CUT);
1136
				CopyFilesListToClipboard(CUT);
Line 1200... Line 1159...
1200
			}
1159
			}
1201
			break;
1160
			break;
1202
	}
1161
	}
1203
}
1162
}
Line 1204... Line -...
1204
 
-
 
1205
void EventRefresh()
-
 
1206
{
-
 
1207
	if (efm)
-
 
1208
	{
-
 
1209
		DrawFilePanels();
-
 
1210
	} else {
-
 
1211
		Tip(56, T_DEVICES, 55, "-");
-
 
1212
		Open_Dir(#path,WITH_REDRAW);
-
 
1213
		pause(10);
-
 
1214
		DrawDeviceAndActionsLeftPanel();				
-
 
1215
	}
-
 
1216
}
-
 
1217
 
1163
 
1218
void SetActivePanel(int _active)
1164
void SetActivePanel(int _active)
1219
{
1165
{
1220
	if (active_panel != _active) {	
1166
	if (active_panel != _active) {	
1221
		active_panel = _active;
1167
		active_panel = _active;
Line 1264... Line 1210...
1264
	return fcount;
1210
	return fcount;
1265
}
1211
}
Line 1266... Line 1212...
1266
 
1212
 
1267
void EventRefreshDisksAndFolders()
1213
void EventRefreshDisksAndFolders()
-
 
1214
{
1268
{
1215
	if(efm) {
1269
	if(GetRealFileCountInFolder("/")+dir_exists("/kolibrios") != SystemDiscs.dev_num) {
1216
		if (GetRealFileCountInFolder(#inactive_path) != files_inactive.count) {
1270
		SystemDiscs.Get();
1217
			DrawFilePanels();
-
 
1218
			return;
1271
		EventRefresh();
1219
		}
1272
	} else {
1220
	} else {
1273
		if(GetRealFileCountInFolder(#path) != files.count) EventRefresh();
1221
		if (GetRealFileCountInFolder("/")+dir_exists("/kolibrios") != SystemDiscs.dev_num) {
1274
		else if(efm) && (GetRealFileCountInFolder(#inactive_path) != files_inactive.count) {
1222
			SystemDiscs.Get();
1275
			EventRefresh();
1223
			DrawDeviceAndActionsLeftPanel();
1276
		}
1224
		}
-
 
1225
	}
-
 
1226
	if(GetRealFileCountInFolder(#path) != files.count) Open_Dir(#path,WITH_REDRAW);
-
 
1227
}
-
 
1228
 
-
 
1229
void EventManualFolderRefresh()
-
 
1230
{
-
 
1231
	Tip(56, T_DEVICES, 55, "-");
-
 
1232
	pause(10);
-
 
1233
	EventRefreshDisksAndFolders();
1277
	}
1234
	DrawDeviceAndActionsLeftPanel();
Line 1278... Line 1235...
1278
}
1235
}
1279
 
1236
 
1280
void EventSort(dword id)
1237
void EventSort(dword id)