Subversion Repositories Kolibri OS

Rev

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