Subversion Repositories Kolibri OS

Rev

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