Subversion Repositories Kolibri OS

Rev

Rev 7041 | Rev 7220 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5447 punk_joker 1
#ifdef LANG_RUS
5451 leency 2
	?define WINDOW_TITLE_PROPERTIES "Свойства"
5447 punk_joker 3
	?define BTN_CLOSE "Закрыть"
5688 punk_joker 4
	?define BTN_APPLY "Применить"
5
	?define QUEST_1 "Применить ко всем вложенным"
6278 leency 6
	?define QUEST_2 "файлам и папкам?"
5457 leency 7
	?define PR_T_NAME "Имя:"
8
	?define PR_T_DEST "Расположение:"
9
	?define PR_T_SIZE "Размер:"
5962 leency 10
	?define CREATED_OPENED_MODIFIED "Создан:\nОткрыт:\nИзменен:"
5447 punk_joker 11
	?define SET_6 "Файлов: "
12
	?define SET_7 " Папок: "
5457 leency 13
	?define PR_T_CONTAINS "Содержит: "
5450 leency 14
	?define FLAGS " Аттрибуты "
5457 leency 15
	?define PR_T_HIDDEN "Скрытый"
16
	?define PR_T_SYSTEM "Системный"
17
	?define PR_T_ONLY_READ "Только чтение"
5591 pavelyakov 18
	?define SET_BYTE_LANG "байт"
5833 pavelyakov 19
#else // Apply to all subfolders
6281 punk_joker 20
	?define WINDOW_TITLE_PROPERTIES "Properties"
5450 leency 21
	?define BTN_CLOSE "Close"
5688 punk_joker 22
	?define BTN_APPLY "Apply"
5833 pavelyakov 23
	?define QUEST_1 "Apply to all subfolders"
6278 leency 24
	?define QUEST_2 "files and Folders?"
5457 leency 25
	?define PR_T_NAME "Name:"
26
	?define PR_T_DEST "Destination:"
27
	?define PR_T_SIZE "Size:"
5962 leency 28
	?define CREATED_OPENED_MODIFIED "Created:\nOpened:\nModified:"
5450 leency 29
	?define SET_6 "Files: "
30
	?define SET_7 " Folders: "
5457 leency 31
	?define PR_T_CONTAINS "Contains: "
5450 leency 32
	?define FLAGS " Attributes "
5457 leency 33
	?define PR_T_HIDDEN "Hidden"
34
	?define PR_T_SYSTEM "System"
35
	?define PR_T_ONLY_READ "Read-only"
5591 pavelyakov 36
	?define SET_BYTE_LANG "byte"
5447 punk_joker 37
#endif
38
 
7041 leency 39
dword mouse_2;
40
char path_to_file[4096];
41
char file_name2[4096];
42
edit_box file_name_ed = {230,55,35,0xffffff,0x94AECE,0xFFFfff,0xffffff,0x10000000,sizeof(file_name2),#file_name2,#mouse_2, 1000000000000000b,2,2};
43
edit_box path_to_file_ed = {160,120,79,0xffffff,0x94AECE,0xFFFfff,0xffffff,2,sizeof(path_to_file),#path_to_file,#mouse_2, 1000000000000000b,2,2};
6403 punk_joker 44
frame flags_frame = { 0, NULL, 10, 92, 212, 0x000111, 0xFFFfff, 1, FLAGS, 0, 1, 12, 0x000111, 0xFFFFFF };
5447 punk_joker 45
 
46
int file_count, dir_count, size_dir;
47
char folder_info[200];
5688 punk_joker 48
dword element_size;
49
char element_size_label[32];
5463 leency 50
BDVK file_info_general;
51
BDVK file_info_dirsize;
5447 punk_joker 52
 
5688 punk_joker 53
proc_info settings_form;
6278 leency 54
bool quest_active, atr_readonly, atr_hidden, atr_system;
5688 punk_joker 55
 
56
void SetPropertiesDir(dword way)
5554 punk_joker 57
{
5688 punk_joker 58
	dword dirbuf, fcount, i, filename;
59
	dword cur_file;
6251 leency 60
	if (dir_exists(way))
5688 punk_joker 61
	{
62
		cur_file = malloc(4096);
63
		GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
64
		for (i=0; i
65
		{
66
			filename = i*304+dirbuf+72;
67
			strcpy(cur_file, way);
68
			chrcat(cur_file, '/');
69
			strcat(cur_file, filename);
70
			if ( TestBit(ESDWORD[filename-40], 4) )
71
			{
72
				SetPropertiesDir(cur_file);
73
			}
74
			GetFileInfo(cur_file, #file_info_dirsize);
75
			file_info_dirsize.readonly = atr_readonly;
76
			file_info_dirsize.hidden = atr_hidden;
77
			file_info_dirsize.system = atr_system;
78
			SetFileInfo(cur_file, #file_info_dirsize);
79
		}
80
		free(cur_file);
81
	}
82
}
83
 
84
void SetProperties(byte prop)
85
{
86
	dword cur_file;
87
 
88
	if (prop==1) || (prop==2)
89
	{
90
		if (selected_count)
91
		{
92
			cur_file = malloc(4096);
93
			for (i=0; i
94
			{
6646 leency 95
				if (getElementSelectedFlag(i) == true)
5688 punk_joker 96
				{
97
					strcpy(cur_file, #path);
98
					strcat(cur_file, file_mas[i]*304+buf+72);
99
					GetFileInfo(cur_file, #file_info_general);
100
					file_info_general.readonly = atr_readonly;
101
					file_info_general.hidden = atr_hidden;
102
					file_info_general.system = atr_system;
103
					SetFileInfo(cur_file, #file_info_general);
104
					if (prop==2)
105
					{
6251 leency 106
						if (dir_exists(cur_file))
5688 punk_joker 107
						{
108
							SetPropertiesDir(cur_file);
109
						}
110
					}
111
				}
112
			}
113
			free(cur_file);
114
		}
115
		else
116
		{
117
			GetFileInfo(#file_path, #file_info_general);
118
			file_info_general.readonly = atr_readonly;
119
			file_info_general.hidden = atr_hidden;
120
			file_info_general.system = atr_system;
121
			SetFileInfo(#file_path, #file_info_general);
122
			if (prop==2) SetPropertiesDir(#file_path);
123
		}
124
		quest_active = 0;
125
		DrawPropertiesWindow();
126
	}
5554 punk_joker 127
	else
128
	{
5688 punk_joker 129
		GetFileInfo(#file_path, #file_info_general);
130
		file_info_general.readonly = atr_readonly;
131
		file_info_general.hidden = atr_hidden;
132
		file_info_general.system = atr_system;
5554 punk_joker 133
		SetFileInfo(#file_path, #file_info_general);
134
	}
5688 punk_joker 135
	cmd_free=3;
136
	_not_draw = true;
6646 leency 137
	Open_Dir(#path,WITH_REDRAW);
138
	_not_draw = false;
139
	EventRedrawWindow(Form.left,Form.top);
5688 punk_joker 140
	ExitProcess();
5554 punk_joker 141
}
5487 leency 142
 
6278 leency 143
void ShowConfirmQuestionPopin()
5688 punk_joker 144
{
6278 leency 145
	quest_active = 1;
6280 punk_joker 146
	DrawPopup(15,80,250,90,1,system.color.work, system.color.work_graph);
147
	WriteText(35, 102, 0x90, 0x000000, QUEST_1);
148
	WriteText(65, 117, 0x90, 0x000000, QUEST_2);
6678 leency 149
	DrawFlatButton(62,138,301,T_YES);
150
	DrawFlatButton(155,138,302,T_NO);
5688 punk_joker 151
}
152
 
5447 punk_joker 153
void GetSizeDir(dword way)
154
{
155
	dword dirbuf, fcount, i, filename;
5591 pavelyakov 156
	dword cur_file;
6251 leency 157
	if (dir_exists(way))
5447 punk_joker 158
	{
5591 pavelyakov 159
		cur_file = malloc(4096);
6008 leency 160
		// In the process of recursive descent, memory must be allocated dynamically,
161
		// because the static memory -> was a bug !!! But unfortunately pass away to sacrifice speed.
5447 punk_joker 162
		GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
163
		for (i=0; i
164
		{
165
			filename = i*304+dirbuf+72;
5591 pavelyakov 166
			sprintf(cur_file,"%s/%s",way,filename);
167
 
168
			if (TestBit(ESDWORD[filename-40], 4) )
5447 punk_joker 169
			{
170
				dir_count++;
5591 pavelyakov 171
				GetSizeDir(cur_file);
5447 punk_joker 172
			}
173
			else
174
			{
5591 pavelyakov 175
				GetFileInfo(cur_file, #file_info_dirsize);
176
				size_dir += file_info_dirsize.sizelo;
5447 punk_joker 177
				file_count++;
178
			}
179
		}
5591 pavelyakov 180
		free(cur_file);
5447 punk_joker 181
	}
182
}
183
 
5510 punk_joker 184
void GetSizeMoreFiles(dword way)
185
{
186
	char cur_file[4096];
5957 punk_joker 187
 
5510 punk_joker 188
	for (i=0; i
6646 leency 189
	{
190
		if (getElementSelectedFlag(i) == true)
191
		{
6635 leency 192
			sprintf(#cur_file,"%s/%s",way,file_mas[i]*304+buf+72);
5691 punk_joker 193
			if (TestBit(ESDWORD[file_mas[i]*304+buf+32], 4) )
5510 punk_joker 194
			{
5957 punk_joker 195
				GetSizeDir(#cur_file);
5691 punk_joker 196
				dir_count++;
5510 punk_joker 197
			}
198
			else
199
			{
5957 punk_joker 200
				GetFileInfo(#cur_file, #file_info_dirsize);
201
				size_dir += file_info_dirsize.sizelo;
5691 punk_joker 202
				file_count++;
5510 punk_joker 203
			}
6646 leency 204
		}
5510 punk_joker 205
	}
206
}
207
 
5447 punk_joker 208
void properties_dialog()
209
{
210
	byte id;
211
 
5576 pavelyakov 212
	DSBYTE[#folder_info]=0;
5447 punk_joker 213
	file_count = 0;
214
	dir_count = 0;
215
	size_dir = 0;
5510 punk_joker 216
 
5688 punk_joker 217
	if (selected_count)
218
	{
219
		GetSizeMoreFiles(#path);
220
		atr_readonly = 0;
221
		atr_hidden = 0;
222
		atr_system = 0;
223
	}
5510 punk_joker 224
	else
225
	{
226
		GetFileInfo(#file_path, #file_info_general);
227
		strcpy(#file_name2, #file_name);
5591 pavelyakov 228
		file_name_ed.size = strlen(#file_name2);
5957 punk_joker 229
		if(itdir) GetSizeDir(#file_path);
5688 punk_joker 230
		atr_readonly = file_info_general.readonly;
231
		atr_hidden = file_info_general.hidden;
232
		atr_system = file_info_general.system;
5510 punk_joker 233
	}
5447 punk_joker 234
	strcpy(#path_to_file, #path);
235
	path_to_file_ed.size = strlen(#path_to_file);
236
 
237
	SetEventMask(0x27);
238
	loop() switch(WaitEvent())
239
	{
240
		case evButton:
241
				id=GetButtonID();
5688 punk_joker 242
				if (quest_active)
243
				{
244
					IF (id==301) SetProperties(2);
245
					IF (id==302) SetProperties(1);
6278 leency 246
					quest_active=false;
5688 punk_joker 247
					break;
248
				}
5591 pavelyakov 249
				if (id==1) || (id==10)
250
				{
251
					cmd_free=3;
252
					ExitProcess();
253
				}
5688 punk_joker 254
				IF (id==11)
5606 pavelyakov 255
				{
5688 punk_joker 256
					if (selected_count) || (itdir)
257
					{
6278 leency 258
						ShowConfirmQuestionPopin();
5688 punk_joker 259
					}
260
					else
261
					{
262
						SetProperties(0);
263
					}
264
					break;
5606 pavelyakov 265
				}
6403 punk_joker 266
				if (id==20)
267
				{
268
					atr_readonly ^= 1;
269
					DrawPropertiesCheckBoxes();
270
				}
271
				if (id==21)
272
				{
273
					atr_hidden ^= 1;
274
					DrawPropertiesCheckBoxes();
275
				}
276
				if (id==22)
277
				{
278
					atr_system ^= 1;
279
					DrawPropertiesCheckBoxes();
280
				}
5447 punk_joker 281
				break;
282
 
283
		case evMouse:
284
				edit_box_mouse stdcall (#file_name_ed);
285
				edit_box_mouse stdcall (#path_to_file_ed);
286
				break;
287
 
288
		case evKey:
5707 leency 289
				GetKeys();
5702 punk_joker 290
 
5688 punk_joker 291
				if (quest_active)
292
				{
5707 leency 293
					IF (key_scancode==SCAN_CODE_ENTER) SetProperties(2);
294
					IF (key_scancode==SCAN_CODE_ESC) SetProperties(1);
6278 leency 295
					quest_active=false;
5688 punk_joker 296
					break;
297
				}
5707 leency 298
				if (key_scancode==SCAN_CODE_ESC)
5591 pavelyakov 299
				{
300
					cmd_free=3;
301
					ExitProcess();
302
				}
5707 leency 303
				if (key_scancode==SCAN_CODE_ENTER)
5702 punk_joker 304
				{
305
					if (selected_count) || (itdir)
306
					{
6278 leency 307
						ShowConfirmQuestionPopin();
5702 punk_joker 308
					}
309
					else
310
					{
311
						SetProperties(0);
312
					}
313
					break;
314
				}
5447 punk_joker 315
				edit_box_key stdcall(#file_name_ed);
316
				edit_box_key stdcall(#path_to_file_ed);
317
				break;
318
 
319
		case evReDraw:
5688 punk_joker 320
				DrawPropertiesWindow();
321
	}
322
}
5450 leency 323
 
5688 punk_joker 324
void DrawPropertiesWindow()
325
{
6757 leency 326
	dword ext1;
327
	char temp_path[sizeof(file_path)];
6746 leency 328
	DefineAndDrawWindow(Form.left + 150,150,305,360+skin_height,0x34,system.color.work,WINDOW_TITLE_PROPERTIES,0);
6600 punk_joker 329
	if ( !asm test path_to_file_ed.flags, 2)
330
	{
331
		path_to_file_ed.blur_border_color = system.color.work;
332
		path_to_file_ed.color = system.color.work;
333
	}
334
	else
335
	{
336
		path_to_file_ed.blur_border_color = 0x000000;
337
		path_to_file_ed.color = 0xffffff;
338
	}
339
	if ( !asm test path_to_file_ed.flags, 2)
340
	{
341
		file_name_ed.blur_border_color = system.color.work;
342
		file_name_ed.color = system.color.work;
343
	}
344
	else
345
	{
346
		file_name_ed.blur_border_color = 0x000000;
347
		file_name_ed.color = 0xffffff;
348
	}
5688 punk_joker 349
	GetProcessInfo(#settings_form, SelfInfo);
7041 leency 350
 
6678 leency 351
	DrawFlatButton(settings_form.cwidth - 96, settings_form.cheight-34, 10, BTN_CLOSE);
352
	DrawFlatButton(settings_form.cwidth -208, settings_form.cheight-34, 11, BTN_APPLY);
5688 punk_joker 353
 
7041 leency 354
	WriteText(10, 78, 0x90, system.color.work_text, PR_T_DEST);
355
	edit_box_draw stdcall (#path_to_file_ed);
356
 
357
	WriteText(10, 97, 0x90, system.color.work_text, PR_T_SIZE);
358
 
359
	if (selected_count)
6403 punk_joker 360
	{
7086 leency 361
		PropertiesDrawIcon(NULL, "");
7041 leency 362
		sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
363
		WriteText(file_name_ed.left+4, 30, 0x90, system.color.work_text, #folder_info);
364
		sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(size_dir, NULL),size_dir,SET_BYTE_LANG);
365
		WriteText(120, 97, 0x90, system.color.work_text, #element_size_label);
366
	}
367
	else
368
	{
369
		if ( file_info_general.isfolder )
370
				PropertiesDrawIcon(NULL, "");
371
		else {
372
			sprintf(#temp_path,"%s/%s",#path,#file_name2);
373
			ext1 = strrchr(#file_name2,'.');
374
			if (ext1) ext1 += #file_name2;
375
			PropertiesDrawIcon(#temp_path, ext1);
376
		}
377
		WriteText(file_name_ed.left+4, 20, 0x80, system.color.work_text, PR_T_NAME);
378
		edit_box_draw stdcall (#file_name_ed);
5688 punk_joker 379
 
7041 leency 380
		if (!itdir) element_size = file_info_general.sizelo;
381
		else
5688 punk_joker 382
		{
7041 leency 383
			WriteText(10,116, 0x90, system.color.work_text, PR_T_CONTAINS);
5688 punk_joker 384
			sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
7041 leency 385
			WriteText(120, 116, 0x90, system.color.work_text, #folder_info);
386
			element_size = size_dir;
5688 punk_joker 387
		}
7041 leency 388
		WriteTextLines(10,  136, 0x90, system.color.work_text, CREATED_OPENED_MODIFIED, 20);
389
		DrawDate(120,  136, system.color.work, #file_info_general.datecreate);
390
		DrawDate(120, 156, system.color.work, #file_info_general.datelastaccess);
391
		DrawDate(120, 176, system.color.work, #file_info_general.datelastedit);
392
 
393
		sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(element_size, NULL),element_size,SET_BYTE_LANG);
394
		WriteText(120, 99, 0x90, system.color.work_text, #element_size_label);
5447 punk_joker 395
	}
7041 leency 396
	flags_frame.size_x = - flags_frame.start_x * 2 + settings_form.cwidth - 2;
397
	flags_frame.font_color = system.color.work_text;
398
	flags_frame.ext_col = system.color.work_graph;
399
	flags_frame.font_backgr_color = system.color.work;
400
	frame_draw stdcall (#flags_frame);
401
	DrawPropertiesCheckBoxes();
5463 leency 402
}
403
 
7041 leency 404
void PropertiesDrawIcon(dword file_path, extension)
405
{
406
	#define ICON_PADDING 10
407
	DrawBar(20-ICON_PADDING, 30-ICON_PADDING-1, ICON_PADDING*2+16, ICON_PADDING*2+16, system.color.work_light);
408
	DrawIconByExtension(file_path, extension, 20, 30, system.color.work_light);
409
}
410
 
5463 leency 411
void DrawPropertiesCheckBoxes()
412
{
6284 leency 413
	incn y;
414
	y.n = flags_frame.start_y;
415
	CheckBox(24, y.inc(18), 20, PR_T_ONLY_READ, atr_readonly);
416
	CheckBox(24, y.inc(24), 21, PR_T_HIDDEN, atr_hidden);
417
	CheckBox(24, y.inc(24), 22, PR_T_SYSTEM, atr_system);
6600 punk_joker 418
}