Subversion Repositories Kolibri OS

Rev

Rev 6284 | Rev 6600 | 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]) {
5691 punk_joker 206
			sprintf(#cur_file,"%s%s",way,file_mas[i]*304+buf+72);
207
			if (TestBit(ESDWORD[file_mas[i]*304+buf+32], 4) )
5510 punk_joker 208
			{
5957 punk_joker 209
				debugln(#cur_file);
210
				GetSizeDir(#cur_file);
5691 punk_joker 211
				dir_count++;
5510 punk_joker 212
			}
213
			else
214
			{
5957 punk_joker 215
				GetFileInfo(#cur_file, #file_info_dirsize);
216
				size_dir += file_info_dirsize.sizelo;
5691 punk_joker 217
				file_count++;
5510 punk_joker 218
			}
219
        }
220
	}
221
}
222
 
5447 punk_joker 223
void properties_dialog()
224
{
225
	byte id;
226
	dword file_name_off;
5510 punk_joker 227
	dword selected_offset2;
5447 punk_joker 228
 
5576 pavelyakov 229
	DSBYTE[#folder_info]=0;
5447 punk_joker 230
	file_count = 0;
231
	dir_count = 0;
232
	size_dir = 0;
5510 punk_joker 233
 
5688 punk_joker 234
	if (selected_count)
235
	{
236
		GetSizeMoreFiles(#path);
5691 punk_joker 237
		debugi(size_dir);
5688 punk_joker 238
		atr_readonly = 0;
239
		atr_hidden = 0;
240
		atr_system = 0;
241
	}
5510 punk_joker 242
	else
243
	{
244
		GetFileInfo(#file_path, #file_info_general);
245
		strcpy(#file_name2, #file_name);
5591 pavelyakov 246
		file_name_ed.size = strlen(#file_name2);
5957 punk_joker 247
		if(itdir) GetSizeDir(#file_path);
5688 punk_joker 248
		atr_readonly = file_info_general.readonly;
249
		atr_hidden = file_info_general.hidden;
250
		atr_system = file_info_general.system;
5510 punk_joker 251
	}
5447 punk_joker 252
	strcpy(#path_to_file, #path);
253
	path_to_file_ed.size = strlen(#path_to_file);
254
 
255
	SetEventMask(0x27);
256
	loop() switch(WaitEvent())
257
	{
258
		case evButton:
259
				id=GetButtonID();
5688 punk_joker 260
				if (quest_active)
261
				{
262
					IF (id==301) SetProperties(2);
263
					IF (id==302) SetProperties(1);
6278 leency 264
					quest_active=false;
5688 punk_joker 265
					break;
266
				}
5591 pavelyakov 267
				if (id==1) || (id==10)
268
				{
269
					cmd_free=3;
270
					ExitProcess();
271
				}
5688 punk_joker 272
				IF (id==11)
5606 pavelyakov 273
				{
5688 punk_joker 274
					if (selected_count) || (itdir)
275
					{
6278 leency 276
						ShowConfirmQuestionPopin();
5688 punk_joker 277
					}
278
					else
279
					{
280
						SetProperties(0);
281
					}
282
					break;
5606 pavelyakov 283
				}
6403 punk_joker 284
				if (id==12)
285
				{
286
					active_tab = TAB_BASIC;
287
					DrawPropertiesWindow();
288
				}
289
				if (id==13)
290
				{
291
					active_tab = TAB_DETAILS;
292
					DrawPropertiesWindow();
293
				}
294
				if (id==20)
295
				{
296
					atr_readonly ^= 1;
297
					DrawPropertiesCheckBoxes();
298
				}
299
				if (id==21)
300
				{
301
					atr_hidden ^= 1;
302
					DrawPropertiesCheckBoxes();
303
				}
304
				if (id==22)
305
				{
306
					atr_system ^= 1;
307
					DrawPropertiesCheckBoxes();
308
				}
5447 punk_joker 309
				break;
310
 
311
		case evMouse:
312
				edit_box_mouse stdcall (#file_name_ed);
313
				edit_box_mouse stdcall (#path_to_file_ed);
314
				break;
315
 
316
		case evKey:
5707 leency 317
				GetKeys();
5702 punk_joker 318
 
5688 punk_joker 319
				if (quest_active)
320
				{
5707 leency 321
					IF (key_scancode==SCAN_CODE_ENTER) SetProperties(2);
322
					IF (key_scancode==SCAN_CODE_ESC) SetProperties(1);
6278 leency 323
					quest_active=false;
5688 punk_joker 324
					break;
325
				}
5707 leency 326
				if (key_scancode==SCAN_CODE_ESC)
5591 pavelyakov 327
				{
328
					cmd_free=3;
329
					ExitProcess();
330
				}
5707 leency 331
				if (key_scancode==SCAN_CODE_ENTER)
5702 punk_joker 332
				{
333
					if (selected_count) || (itdir)
334
					{
6278 leency 335
						ShowConfirmQuestionPopin();
5702 punk_joker 336
					}
337
					else
338
					{
339
						SetProperties(0);
340
					}
341
					break;
342
				}
5707 leency 343
				EAX = key_ascii << 8;
5447 punk_joker 344
				edit_box_key stdcall(#file_name_ed);
345
				edit_box_key stdcall(#path_to_file_ed);
346
				break;
347
 
348
		case evReDraw:
5688 punk_joker 349
				DrawPropertiesWindow();
350
	}
351
}
5450 leency 352
 
5688 punk_joker 353
void DrawPropertiesWindow()
354
{
6403 punk_joker 355
	DefineAndDrawWindow(Form.left + 150,150,305,360+skin_height,0x34,system.color.work,WINDOW_TITLE_PROPERTIES);
5688 punk_joker 356
	GetProcessInfo(#settings_form, SelfInfo);
6403 punk_joker 357
	DrawFlatButton(10, 5, 80, 24, 12, TAB_T_BASIC);
358
	if (exif_load==1) DrawFlatButton(92, 5, 80, 24, 13, TAB_T_DETAILS);
6284 leency 359
	DrawFlatButton(settings_form.cwidth - 93, settings_form.cheight-34, 80, 24, 10, BTN_CLOSE);
360
	DrawFlatButton(settings_form.cwidth -183, settings_form.cheight-34, 80, 24, 11, BTN_APPLY);
5688 punk_joker 361
 
6403 punk_joker 362
	if (active_tab == TAB_BASIC)
363
	{
364
		WriteText(10, 78, 0x90, 0x000000, PR_T_DEST);
365
		edit_box_draw stdcall (#path_to_file_ed);
5688 punk_joker 366
 
6403 punk_joker 367
		WriteText(10, 97, 0x90, 0x000000, PR_T_SIZE);
5688 punk_joker 368
 
6403 punk_joker 369
		if (selected_count)
5688 punk_joker 370
		{
6403 punk_joker 371
			DrawIconByExtension(NULL, 18, 19, system.color.work);
5688 punk_joker 372
			sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
6403 punk_joker 373
			WriteText(50, 49, 0x90, 0x000000, #folder_info);
374
			sprintf(#element_size_label,"%s (%d %s)",ConvertSize(size_dir),size_dir,SET_BYTE_LANG);
375
			WriteText(120, 97, 0x90, 0x000000, #element_size_label);
5688 punk_joker 376
		}
6403 punk_joker 377
		else
378
		{
379
			if ( file_info_general.isfolder )
380
					DrawIconByExtension("", 18, 49, system.color.work);
381
			else
382
					DrawIconByExtension(#file_name2+strrchr(#file_name2,'.'), 18, 49, system.color.work);
383
 
384
			WriteText(50, 40, 0x90, 0x000000, PR_T_NAME);
385
			edit_box_draw stdcall (#file_name_ed);
386
 
387
			if (!itdir) element_size = file_info_general.sizelo;
388
			else
389
			{
390
				WriteText(10,116, 0x90, 0x000000, PR_T_CONTAINS);
391
				sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
392
				WriteText(120, 116, 0x90, 0x000000, #folder_info);
393
				element_size = size_dir;
394
			}
395
			WriteTextLines(10,  136, 0x90, 0x000000, CREATED_OPENED_MODIFIED, 20);
396
			DrawDate(120,  136, 0, #file_info_general.datecreate);
397
			DrawDate(120, 156, 0, #file_info_general.datelastaccess);
398
			DrawDate(120, 176, 0, #file_info_general.datelastedit);
399
 
400
			sprintf(#element_size_label,"%s (%d %s)",ConvertSize(element_size),element_size,SET_BYTE_LANG);
401
			WriteText(120, 99, 0x90, 0x000000, #element_size_label);
402
		}
403
		flags_frame.size_x = - flags_frame.start_x * 2 + settings_form.cwidth - 2;
404
		flags_frame.font_color = system.color.work_text;
405
		flags_frame.ext_col = system.color.work_graph;
406
		flags_frame.font_backgr_color = system.color.work;
407
		frame_draw stdcall (#flags_frame);
408
		DrawPropertiesCheckBoxes();
5447 punk_joker 409
	}
6403 punk_joker 410
	else
411
	{
412
		WriteText(10, 78, 0x90, 0x000000, "EXIF");
413
	}
5463 leency 414
}
415
 
416
void DrawPropertiesCheckBoxes()
417
{
6284 leency 418
	incn y;
419
	y.n = flags_frame.start_y;
420
	CheckBox(24, y.inc(18), 20, PR_T_ONLY_READ, atr_readonly);
421
	CheckBox(24, y.inc(24), 21, PR_T_HIDDEN, atr_hidden);
422
	CheckBox(24, y.inc(24), 22, PR_T_SYSTEM, atr_system);
5447 punk_joker 423
}