Subversion Repositories Kolibri OS

Rev

Rev 7278 | Rev 7369 | 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];
7227 leency 42
edit_box file_name_ed = {230,59,32,0xffffff,0x94AECE,0xFFFfff,0xffffff,0x10000000,sizeof(file_name2),#file_name2,#mouse_2, 1000000000000000b,2,2};
7041 leency 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};
5447 punk_joker 44
 
45
int file_count, dir_count, size_dir;
46
char folder_info[200];
5688 punk_joker 47
dword element_size;
48
char element_size_label[32];
5463 leency 49
BDVK file_info_general;
50
BDVK file_info_dirsize;
5447 punk_joker 51
 
5688 punk_joker 52
proc_info settings_form;
7244 leency 53
bool quest_active;
5688 punk_joker 54
 
7244 leency 55
checkbox ch_read_only = { PR_T_ONLY_READ, NULL };
56
checkbox ch_hidden = { PR_T_HIDDEN, NULL };
57
checkbox ch_system = { PR_T_SYSTEM, NULL };
58
 
59
void SetPropertiesFile(dword cur_file, bdvk_pointer)
60
{
61
	GetFileInfo(cur_file, bdvk_pointer);
62
	ESI = bdvk_pointer;
63
	ESI.BDVK.readonly = ch_read_only.checked;
64
	ESI.BDVK.hidden = ch_hidden.checked;
65
	ESI.BDVK.system = ch_system.checked;
66
	SetFileInfo(cur_file, bdvk_pointer);
67
}
68
 
5688 punk_joker 69
void SetPropertiesDir(dword way)
5554 punk_joker 70
{
5688 punk_joker 71
	dword dirbuf, fcount, i, filename;
72
	dword cur_file;
6251 leency 73
	if (dir_exists(way))
5688 punk_joker 74
	{
75
		cur_file = malloc(4096);
76
		GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
77
		for (i=0; i
78
		{
79
			filename = i*304+dirbuf+72;
80
			strcpy(cur_file, way);
81
			chrcat(cur_file, '/');
82
			strcat(cur_file, filename);
83
			if ( TestBit(ESDWORD[filename-40], 4) )
84
			{
85
				SetPropertiesDir(cur_file);
86
			}
7244 leency 87
			SetPropertiesFile(cur_file, #file_info_dirsize);
5688 punk_joker 88
		}
89
		free(cur_file);
90
	}
91
}
92
 
93
void SetProperties(byte prop)
94
{
95
	dword cur_file;
96
 
97
	if (prop==1) || (prop==2)
98
	{
99
		if (selected_count)
100
		{
101
			cur_file = malloc(4096);
102
			for (i=0; i
103
			{
6646 leency 104
				if (getElementSelectedFlag(i) == true)
5688 punk_joker 105
				{
106
					strcpy(cur_file, #path);
107
					strcat(cur_file, file_mas[i]*304+buf+72);
7244 leency 108
					SetPropertiesDir(cur_file);
5688 punk_joker 109
					if (prop==2)
110
					{
6251 leency 111
						if (dir_exists(cur_file))
5688 punk_joker 112
						{
113
							SetPropertiesDir(cur_file);
114
						}
115
					}
116
				}
117
			}
118
			free(cur_file);
119
		}
120
		else
121
		{
7244 leency 122
			SetPropertiesFile(#file_path, #file_info_general);
5688 punk_joker 123
			if (prop==2) SetPropertiesDir(#file_path);
124
		}
125
		quest_active = 0;
126
		DrawPropertiesWindow();
127
	}
5554 punk_joker 128
	else
129
	{
7244 leency 130
		SetPropertiesFile(#file_path, #file_info_general);
5554 punk_joker 131
	}
5688 punk_joker 132
	cmd_free=3;
133
	_not_draw = true;
6646 leency 134
	Open_Dir(#path,WITH_REDRAW);
135
	_not_draw = false;
136
	EventRedrawWindow(Form.left,Form.top);
5688 punk_joker 137
	ExitProcess();
5554 punk_joker 138
}
5487 leency 139
 
6278 leency 140
void ShowConfirmQuestionPopin()
5688 punk_joker 141
{
6278 leency 142
	quest_active = 1;
6280 punk_joker 143
	DrawPopup(15,80,250,90,1,system.color.work, system.color.work_graph);
144
	WriteText(35, 102, 0x90, 0x000000, QUEST_1);
145
	WriteText(65, 117, 0x90, 0x000000, QUEST_2);
7278 leency 146
	DrawStandartCaptButton(62,138,301,T_YES);
147
	DrawStandartCaptButton(155,138,302,T_NO);
5688 punk_joker 148
}
149
 
5447 punk_joker 150
void GetSizeDir(dword way)
151
{
152
	dword dirbuf, fcount, i, filename;
5591 pavelyakov 153
	dword cur_file;
6251 leency 154
	if (dir_exists(way))
5447 punk_joker 155
	{
5591 pavelyakov 156
		cur_file = malloc(4096);
6008 leency 157
		// In the process of recursive descent, memory must be allocated dynamically,
158
		// because the static memory -> was a bug !!! But unfortunately pass away to sacrifice speed.
5447 punk_joker 159
		GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
160
		for (i=0; i
161
		{
162
			filename = i*304+dirbuf+72;
5591 pavelyakov 163
			sprintf(cur_file,"%s/%s",way,filename);
164
 
165
			if (TestBit(ESDWORD[filename-40], 4) )
5447 punk_joker 166
			{
167
				dir_count++;
5591 pavelyakov 168
				GetSizeDir(cur_file);
5447 punk_joker 169
			}
170
			else
171
			{
5591 pavelyakov 172
				GetFileInfo(cur_file, #file_info_dirsize);
173
				size_dir += file_info_dirsize.sizelo;
5447 punk_joker 174
				file_count++;
175
			}
176
		}
5591 pavelyakov 177
		free(cur_file);
7362 leency 178
		free(dirbuf);
5447 punk_joker 179
	}
180
}
181
 
5510 punk_joker 182
void GetSizeMoreFiles(dword way)
183
{
184
	char cur_file[4096];
5957 punk_joker 185
 
5510 punk_joker 186
	for (i=0; i
6646 leency 187
	{
188
		if (getElementSelectedFlag(i) == true)
189
		{
6635 leency 190
			sprintf(#cur_file,"%s/%s",way,file_mas[i]*304+buf+72);
5691 punk_joker 191
			if (TestBit(ESDWORD[file_mas[i]*304+buf+32], 4) )
5510 punk_joker 192
			{
5957 punk_joker 193
				GetSizeDir(#cur_file);
5691 punk_joker 194
				dir_count++;
5510 punk_joker 195
			}
196
			else
197
			{
5957 punk_joker 198
				GetFileInfo(#cur_file, #file_info_dirsize);
199
				size_dir += file_info_dirsize.sizelo;
5691 punk_joker 200
				file_count++;
5510 punk_joker 201
			}
6646 leency 202
		}
5510 punk_joker 203
	}
204
}
205
 
5447 punk_joker 206
void properties_dialog()
207
{
7244 leency 208
	int id;
5447 punk_joker 209
 
5576 pavelyakov 210
	DSBYTE[#folder_info]=0;
5447 punk_joker 211
	file_count = 0;
212
	dir_count = 0;
213
	size_dir = 0;
5510 punk_joker 214
 
5688 punk_joker 215
	if (selected_count)
216
	{
217
		GetSizeMoreFiles(#path);
7244 leency 218
		ch_read_only.checked = 0;
219
		ch_hidden.checked = 0;
220
		ch_system.checked = 0;
5688 punk_joker 221
	}
5510 punk_joker 222
	else
223
	{
224
		GetFileInfo(#file_path, #file_info_general);
225
		strcpy(#file_name2, #file_name);
5591 pavelyakov 226
		file_name_ed.size = strlen(#file_name2);
5957 punk_joker 227
		if(itdir) GetSizeDir(#file_path);
7244 leency 228
		ch_read_only.checked = file_info_general.readonly;
229
		ch_hidden.checked = file_info_general.hidden;
230
		ch_system.checked = file_info_general.system;
5510 punk_joker 231
	}
5447 punk_joker 232
	strcpy(#path_to_file, #path);
233
	path_to_file_ed.size = strlen(#path_to_file);
234
 
7227 leency 235
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
5447 punk_joker 236
	loop() switch(WaitEvent())
237
	{
238
		case evButton:
239
				id=GetButtonID();
7244 leency 240
				ch_read_only.click(id);
241
				ch_hidden.click(id);
242
				ch_system.click(id);
5688 punk_joker 243
				if (quest_active)
244
				{
245
					IF (id==301) SetProperties(2);
246
					IF (id==302) SetProperties(1);
6278 leency 247
					quest_active=false;
5688 punk_joker 248
					break;
249
				}
5591 pavelyakov 250
				if (id==1) || (id==10)
251
				{
252
					cmd_free=3;
253
					ExitProcess();
254
				}
5688 punk_joker 255
				IF (id==11)
5606 pavelyakov 256
				{
5688 punk_joker 257
					if (selected_count) || (itdir)
258
					{
6278 leency 259
						ShowConfirmQuestionPopin();
5688 punk_joker 260
					}
261
					else
262
					{
263
						SetProperties(0);
264
					}
265
					break;
5606 pavelyakov 266
				}
5447 punk_joker 267
				break;
268
 
269
		case evMouse:
270
				edit_box_mouse stdcall (#file_name_ed);
271
				edit_box_mouse stdcall (#path_to_file_ed);
272
				break;
273
 
274
		case evKey:
5707 leency 275
				GetKeys();
5702 punk_joker 276
 
5688 punk_joker 277
				if (quest_active)
278
				{
5707 leency 279
					IF (key_scancode==SCAN_CODE_ENTER) SetProperties(2);
280
					IF (key_scancode==SCAN_CODE_ESC) SetProperties(1);
6278 leency 281
					quest_active=false;
5688 punk_joker 282
					break;
283
				}
5707 leency 284
				if (key_scancode==SCAN_CODE_ESC)
5591 pavelyakov 285
				{
286
					cmd_free=3;
287
					ExitProcess();
288
				}
5707 leency 289
				if (key_scancode==SCAN_CODE_ENTER)
5702 punk_joker 290
				{
291
					if (selected_count) || (itdir)
292
					{
6278 leency 293
						ShowConfirmQuestionPopin();
5702 punk_joker 294
					}
295
					else
296
					{
297
						SetProperties(0);
298
					}
299
					break;
300
				}
5447 punk_joker 301
				edit_box_key stdcall(#file_name_ed);
302
				edit_box_key stdcall(#path_to_file_ed);
303
				break;
304
 
305
		case evReDraw:
5688 punk_joker 306
				DrawPropertiesWindow();
307
	}
308
}
5450 leency 309
 
5688 punk_joker 310
void DrawPropertiesWindow()
311
{
6757 leency 312
	dword ext1;
7244 leency 313
	incn y;
6757 leency 314
	char temp_path[sizeof(file_path)];
7227 leency 315
	DefineAndDrawWindow(Form.left + 150,150,315,360+skin_height,0x34,system.color.work,WINDOW_TITLE_PROPERTIES,0);
5688 punk_joker 316
	GetProcessInfo(#settings_form, SelfInfo);
7041 leency 317
 
7278 leency 318
	DrawStandartCaptButton(settings_form.cwidth - 96, settings_form.cheight-34, 10, BTN_CLOSE);
319
	DrawStandartCaptButton(settings_form.cwidth -208, settings_form.cheight-34, 11, BTN_APPLY);
5688 punk_joker 320
 
7041 leency 321
	WriteText(10, 78, 0x90, system.color.work_text, PR_T_DEST);
322
	edit_box_draw stdcall (#path_to_file_ed);
323
 
324
	WriteText(10, 97, 0x90, system.color.work_text, PR_T_SIZE);
325
 
326
	if (selected_count)
6403 punk_joker 327
	{
7086 leency 328
		PropertiesDrawIcon(NULL, "");
7041 leency 329
		sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
330
		WriteText(file_name_ed.left+4, 30, 0x90, system.color.work_text, #folder_info);
331
		sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(size_dir, NULL),size_dir,SET_BYTE_LANG);
332
		WriteText(120, 97, 0x90, system.color.work_text, #element_size_label);
333
	}
334
	else
335
	{
336
		if ( file_info_general.isfolder )
337
				PropertiesDrawIcon(NULL, "");
338
		else {
339
			sprintf(#temp_path,"%s/%s",#path,#file_name2);
340
			ext1 = strrchr(#file_name2,'.');
341
			if (ext1) ext1 += #file_name2;
342
			PropertiesDrawIcon(#temp_path, ext1);
343
		}
7227 leency 344
		WriteText(file_name_ed.left, file_name_ed.top-15, 0x80, system.color.work_text, PR_T_NAME);
345
		DrawEditBox(#file_name_ed);
5688 punk_joker 346
 
7041 leency 347
		if (!itdir) element_size = file_info_general.sizelo;
348
		else
5688 punk_joker 349
		{
7041 leency 350
			WriteText(10,116, 0x90, system.color.work_text, PR_T_CONTAINS);
5688 punk_joker 351
			sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
7041 leency 352
			WriteText(120, 116, 0x90, system.color.work_text, #folder_info);
353
			element_size = size_dir;
5688 punk_joker 354
		}
7041 leency 355
		WriteTextLines(10,  136, 0x90, system.color.work_text, CREATED_OPENED_MODIFIED, 20);
7220 leency 356
		DrawDate(120,  136, system.color.work_text, #file_info_general.datecreate);
357
		DrawDate(120, 156, system.color.work_text, #file_info_general.datelastaccess);
358
		DrawDate(120, 176, system.color.work_text, #file_info_general.datelastedit);
7041 leency 359
 
360
		sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(element_size, NULL),element_size,SET_BYTE_LANG);
361
		WriteText(120, 99, 0x90, system.color.work_text, #element_size_label);
5447 punk_joker 362
	}
7227 leency 363
	DrawFrame(10, 212, -10*2 + settings_form.cwidth - 2, 92, FLAGS);
7244 leency 364
	y.n = 212; //212 => attributes_frame.y
365
	ch_read_only.draw(24, y.inc(18));
366
	ch_hidden.draw(24, y.inc(24));
367
	ch_system.draw(24, y.inc(24));
5463 leency 368
}
369
 
7041 leency 370
void PropertiesDrawIcon(dword file_path, extension)
371
{
7227 leency 372
	#define ICON_PADDING 11
373
	DrawBar(20-ICON_PADDING, 30-ICON_PADDING-1, ICON_PADDING*2+16, ICON_PADDING*2+16, 0xFFFfff);
7041 leency 374
	DrawIconByExtension(file_path, extension, 20, 30, system.color.work_light);
375
}