Subversion Repositories Kolibri OS

Rev

Rev 7244 | Rev 7362 | 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);
5447 punk_joker 178
	}
179
}
180
 
5510 punk_joker 181
void GetSizeMoreFiles(dword way)
182
{
183
	char cur_file[4096];
5957 punk_joker 184
 
5510 punk_joker 185
	for (i=0; i
6646 leency 186
	{
187
		if (getElementSelectedFlag(i) == true)
188
		{
6635 leency 189
			sprintf(#cur_file,"%s/%s",way,file_mas[i]*304+buf+72);
5691 punk_joker 190
			if (TestBit(ESDWORD[file_mas[i]*304+buf+32], 4) )
5510 punk_joker 191
			{
5957 punk_joker 192
				GetSizeDir(#cur_file);
5691 punk_joker 193
				dir_count++;
5510 punk_joker 194
			}
195
			else
196
			{
5957 punk_joker 197
				GetFileInfo(#cur_file, #file_info_dirsize);
198
				size_dir += file_info_dirsize.sizelo;
5691 punk_joker 199
				file_count++;
5510 punk_joker 200
			}
6646 leency 201
		}
5510 punk_joker 202
	}
203
}
204
 
5447 punk_joker 205
void properties_dialog()
206
{
7244 leency 207
	int id;
5447 punk_joker 208
 
5576 pavelyakov 209
	DSBYTE[#folder_info]=0;
5447 punk_joker 210
	file_count = 0;
211
	dir_count = 0;
212
	size_dir = 0;
5510 punk_joker 213
 
5688 punk_joker 214
	if (selected_count)
215
	{
216
		GetSizeMoreFiles(#path);
7244 leency 217
		ch_read_only.checked = 0;
218
		ch_hidden.checked = 0;
219
		ch_system.checked = 0;
5688 punk_joker 220
	}
5510 punk_joker 221
	else
222
	{
223
		GetFileInfo(#file_path, #file_info_general);
224
		strcpy(#file_name2, #file_name);
5591 pavelyakov 225
		file_name_ed.size = strlen(#file_name2);
5957 punk_joker 226
		if(itdir) GetSizeDir(#file_path);
7244 leency 227
		ch_read_only.checked = file_info_general.readonly;
228
		ch_hidden.checked = file_info_general.hidden;
229
		ch_system.checked = file_info_general.system;
5510 punk_joker 230
	}
5447 punk_joker 231
	strcpy(#path_to_file, #path);
232
	path_to_file_ed.size = strlen(#path_to_file);
233
 
7227 leency 234
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
5447 punk_joker 235
	loop() switch(WaitEvent())
236
	{
237
		case evButton:
238
				id=GetButtonID();
7244 leency 239
				ch_read_only.click(id);
240
				ch_hidden.click(id);
241
				ch_system.click(id);
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
				}
5447 punk_joker 266
				break;
267
 
268
		case evMouse:
269
				edit_box_mouse stdcall (#file_name_ed);
270
				edit_box_mouse stdcall (#path_to_file_ed);
271
				break;
272
 
273
		case evKey:
5707 leency 274
				GetKeys();
5702 punk_joker 275
 
5688 punk_joker 276
				if (quest_active)
277
				{
5707 leency 278
					IF (key_scancode==SCAN_CODE_ENTER) SetProperties(2);
279
					IF (key_scancode==SCAN_CODE_ESC) SetProperties(1);
6278 leency 280
					quest_active=false;
5688 punk_joker 281
					break;
282
				}
5707 leency 283
				if (key_scancode==SCAN_CODE_ESC)
5591 pavelyakov 284
				{
285
					cmd_free=3;
286
					ExitProcess();
287
				}
5707 leency 288
				if (key_scancode==SCAN_CODE_ENTER)
5702 punk_joker 289
				{
290
					if (selected_count) || (itdir)
291
					{
6278 leency 292
						ShowConfirmQuestionPopin();
5702 punk_joker 293
					}
294
					else
295
					{
296
						SetProperties(0);
297
					}
298
					break;
299
				}
5447 punk_joker 300
				edit_box_key stdcall(#file_name_ed);
301
				edit_box_key stdcall(#path_to_file_ed);
302
				break;
303
 
304
		case evReDraw:
5688 punk_joker 305
				DrawPropertiesWindow();
306
	}
307
}
5450 leency 308
 
5688 punk_joker 309
void DrawPropertiesWindow()
310
{
6757 leency 311
	dword ext1;
7244 leency 312
	incn y;
6757 leency 313
	char temp_path[sizeof(file_path)];
7227 leency 314
	DefineAndDrawWindow(Form.left + 150,150,315,360+skin_height,0x34,system.color.work,WINDOW_TITLE_PROPERTIES,0);
5688 punk_joker 315
	GetProcessInfo(#settings_form, SelfInfo);
7041 leency 316
 
7278 leency 317
	DrawStandartCaptButton(settings_form.cwidth - 96, settings_form.cheight-34, 10, BTN_CLOSE);
318
	DrawStandartCaptButton(settings_form.cwidth -208, settings_form.cheight-34, 11, BTN_APPLY);
5688 punk_joker 319
 
7041 leency 320
	WriteText(10, 78, 0x90, system.color.work_text, PR_T_DEST);
321
	edit_box_draw stdcall (#path_to_file_ed);
322
 
323
	WriteText(10, 97, 0x90, system.color.work_text, PR_T_SIZE);
324
 
325
	if (selected_count)
6403 punk_joker 326
	{
7086 leency 327
		PropertiesDrawIcon(NULL, "");
7041 leency 328
		sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
329
		WriteText(file_name_ed.left+4, 30, 0x90, system.color.work_text, #folder_info);
330
		sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(size_dir, NULL),size_dir,SET_BYTE_LANG);
331
		WriteText(120, 97, 0x90, system.color.work_text, #element_size_label);
332
	}
333
	else
334
	{
335
		if ( file_info_general.isfolder )
336
				PropertiesDrawIcon(NULL, "");
337
		else {
338
			sprintf(#temp_path,"%s/%s",#path,#file_name2);
339
			ext1 = strrchr(#file_name2,'.');
340
			if (ext1) ext1 += #file_name2;
341
			PropertiesDrawIcon(#temp_path, ext1);
342
		}
7227 leency 343
		WriteText(file_name_ed.left, file_name_ed.top-15, 0x80, system.color.work_text, PR_T_NAME);
344
		DrawEditBox(#file_name_ed);
5688 punk_joker 345
 
7041 leency 346
		if (!itdir) element_size = file_info_general.sizelo;
347
		else
5688 punk_joker 348
		{
7041 leency 349
			WriteText(10,116, 0x90, system.color.work_text, PR_T_CONTAINS);
5688 punk_joker 350
			sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
7041 leency 351
			WriteText(120, 116, 0x90, system.color.work_text, #folder_info);
352
			element_size = size_dir;
5688 punk_joker 353
		}
7041 leency 354
		WriteTextLines(10,  136, 0x90, system.color.work_text, CREATED_OPENED_MODIFIED, 20);
7220 leency 355
		DrawDate(120,  136, system.color.work_text, #file_info_general.datecreate);
356
		DrawDate(120, 156, system.color.work_text, #file_info_general.datelastaccess);
357
		DrawDate(120, 176, system.color.work_text, #file_info_general.datelastedit);
7041 leency 358
 
359
		sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(element_size, NULL),element_size,SET_BYTE_LANG);
360
		WriteText(120, 99, 0x90, system.color.work_text, #element_size_label);
5447 punk_joker 361
	}
7227 leency 362
	DrawFrame(10, 212, -10*2 + settings_form.cwidth - 2, 92, FLAGS);
7244 leency 363
	y.n = 212; //212 => attributes_frame.y
364
	ch_read_only.draw(24, y.inc(18));
365
	ch_hidden.draw(24, y.inc(24));
366
	ch_system.draw(24, y.inc(24));
5463 leency 367
}
368
 
7041 leency 369
void PropertiesDrawIcon(dword file_path, extension)
370
{
7227 leency 371
	#define ICON_PADDING 11
372
	DrawBar(20-ICON_PADDING, 30-ICON_PADDING-1, ICON_PADDING*2+16, ICON_PADDING*2+16, 0xFFFfff);
7041 leency 373
	DrawIconByExtension(file_path, extension, 20, 30, system.color.work_light);
374
}