Subversion Repositories Kolibri OS

Rev

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