Subversion Repositories Kolibri OS

Rev

Rev 7605 | Rev 7878 | 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 "Свойства"
7593 leency 3
	?define T_CLOSE "Закрыть"
4
	?define T_APPLY "Применить"
5688 punk_joker 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"
7593 leency 21
	?define T_CLOSE "Close"
22
	?define T_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
 
7593 leency 39
#define B_SETINGS_APPLY_SUBFOLDER 301
40
#define B_SETINGS_APPLY_NO_SUBFOLDER 302
41
#define B_APPLY 11
42
#define B_CLOSE 12
43
 
7041 leency 44
char path_to_file[4096];
45
char file_name2[4096];
7506 leency 46
edit_box file_name_ed = {230,59,32,0xffffff,0x94AECE,0xFFFfff,0xffffff,0x10000000,sizeof(file_name2)-2,#file_name2,NULL, 0b,2,2};
47
edit_box path_to_file_ed = {160,120,79,0xffffff,0x94AECE,0xFFFfff,0xffffff,2,sizeof(path_to_file)-2,#path_to_file,NULL, 0b,2,2};
5447 punk_joker 48
 
5463 leency 49
BDVK file_info_general;
50
BDVK file_info_dirsize;
5447 punk_joker 51
 
7593 leency 52
bool apply_question_active;
5688 punk_joker 53
 
7369 leency 54
_dir_size more_files_count;
55
 
7244 leency 56
checkbox ch_read_only = { PR_T_ONLY_READ, NULL };
57
checkbox ch_hidden = { PR_T_HIDDEN, NULL };
58
checkbox ch_system = { PR_T_SYSTEM, NULL };
59
 
60
void SetPropertiesFile(dword cur_file, bdvk_pointer)
61
{
62
	GetFileInfo(cur_file, bdvk_pointer);
63
	ESI = bdvk_pointer;
64
	ESI.BDVK.readonly = ch_read_only.checked;
65
	ESI.BDVK.hidden = ch_hidden.checked;
66
	ESI.BDVK.system = ch_system.checked;
67
	SetFileInfo(cur_file, bdvk_pointer);
68
}
69
 
5688 punk_joker 70
void SetPropertiesDir(dword way)
5554 punk_joker 71
{
5688 punk_joker 72
	dword dirbuf, fcount, i, filename;
73
	dword cur_file;
6251 leency 74
	if (dir_exists(way))
5688 punk_joker 75
	{
76
		cur_file = malloc(4096);
77
		GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
78
		for (i=0; i
79
		{
80
			filename = i*304+dirbuf+72;
81
			strcpy(cur_file, way);
82
			chrcat(cur_file, '/');
83
			strcat(cur_file, filename);
84
			if ( TestBit(ESDWORD[filename-40], 4) )
85
			{
86
				SetPropertiesDir(cur_file);
87
			}
7244 leency 88
			SetPropertiesFile(cur_file, #file_info_dirsize);
5688 punk_joker 89
		}
90
		free(cur_file);
91
	}
92
}
93
 
7593 leency 94
#define SET_PROPERTIES_SINGLE_FILE 0
95
#define SET_PROPERTIES_NO_SUBFOLDER 1
96
#define SET_PROPERTIES_ALL_SUBFOLDER 2
97
void SetProperties(int mode)
5688 punk_joker 98
{
7593 leency 99
	char pcur_file[4096];
7422 leency 100
	dword i;
5688 punk_joker 101
 
7593 leency 102
	apply_question_active=false;
103
 
104
	if (SET_PROPERTIES_SINGLE_FILE == mode) {
105
		SetPropertiesFile(#file_path, #file_info_general);
106
	}
107
 
108
	if (SET_PROPERTIES_ALL_SUBFOLDER == mode)
109
	|| (SET_PROPERTIES_NO_SUBFOLDER == mode)
5688 punk_joker 110
	{
111
		if (selected_count)
112
		{
113
			for (i=0; i
114
			{
6646 leency 115
				if (getElementSelectedFlag(i) == true)
5688 punk_joker 116
				{
7593 leency 117
					sprintf(#pcur_file,"%s/%s",#path,file_mas[i]*304+buf+72);
118
					SetPropertiesFile(#pcur_file, #file_info_general);
119
					if (SET_PROPERTIES_ALL_SUBFOLDER == mode) {
120
						if (dir_exists(#pcur_file)) SetPropertiesDir(#pcur_file);
5688 punk_joker 121
					}
122
				}
123
			}
124
		}
125
		else
126
		{
7244 leency 127
			SetPropertiesFile(#file_path, #file_info_general);
7593 leency 128
			if (SET_PROPERTIES_ALL_SUBFOLDER == mode) SetPropertiesDir(#file_path);
5688 punk_joker 129
		}
130
	}
7593 leency 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
{
7593 leency 142
	apply_question_active = 1;
7806 leency 143
	DrawPopup(15,80,250,90,1,sc.work, sc.work_graph);
6280 punk_joker 144
	WriteText(35, 102, 0x90, 0x000000, QUEST_1);
145
	WriteText(65, 117, 0x90, 0x000000, QUEST_2);
7593 leency 146
	DrawStandartCaptButton(62,138,B_SETINGS_APPLY_SUBFOLDER,T_YES);
147
	DrawStandartCaptButton(155,138,B_SETINGS_APPLY_NO_SUBFOLDER,T_NO);
5688 punk_joker 148
}
149
 
5510 punk_joker 150
void GetSizeMoreFiles(dword way)
151
{
152
	char cur_file[4096];
7422 leency 153
	dword i;
5957 punk_joker 154
 
5510 punk_joker 155
	for (i=0; i
6646 leency 156
	{
157
		if (getElementSelectedFlag(i) == true)
158
		{
6635 leency 159
			sprintf(#cur_file,"%s/%s",way,file_mas[i]*304+buf+72);
5691 punk_joker 160
			if (TestBit(ESDWORD[file_mas[i]*304+buf+32], 4) )
5510 punk_joker 161
			{
7369 leency 162
				more_files_count.calculate_loop(#cur_file);
163
				more_files_count.folders++;
5510 punk_joker 164
			}
165
			else
166
			{
5957 punk_joker 167
				GetFileInfo(#cur_file, #file_info_dirsize);
7369 leency 168
				more_files_count.bytes += file_info_dirsize.sizelo;
169
				more_files_count.files++;
5510 punk_joker 170
			}
6646 leency 171
		}
5510 punk_joker 172
	}
173
}
174
 
5447 punk_joker 175
void properties_dialog()
176
{
7244 leency 177
	int id;
5447 punk_joker 178
 
5688 punk_joker 179
	if (selected_count)
180
	{
7369 leency 181
		more_files_count.get(NULL);
5688 punk_joker 182
		GetSizeMoreFiles(#path);
7244 leency 183
		ch_read_only.checked = 0;
184
		ch_hidden.checked = 0;
185
		ch_system.checked = 0;
5688 punk_joker 186
	}
5510 punk_joker 187
	else
188
	{
189
		GetFileInfo(#file_path, #file_info_general);
190
		strcpy(#file_name2, #file_name);
7506 leency 191
		EditBox_UpdateText(#file_name_ed, 0);
7369 leency 192
		if(itdir) dir_size.get(#file_path);
7244 leency 193
		ch_read_only.checked = file_info_general.readonly;
194
		ch_hidden.checked = file_info_general.hidden;
195
		ch_system.checked = file_info_general.system;
5510 punk_joker 196
	}
5447 punk_joker 197
	strcpy(#path_to_file, #path);
198
	path_to_file_ed.size = strlen(#path_to_file);
199
 
7227 leency 200
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
5447 punk_joker 201
	loop() switch(WaitEvent())
202
	{
203
		case evButton:
204
				id=GetButtonID();
7244 leency 205
				ch_read_only.click(id);
206
				ch_hidden.click(id);
207
				ch_system.click(id);
7593 leency 208
				if (apply_question_active)
5688 punk_joker 209
				{
7593 leency 210
					IF (id==B_SETINGS_APPLY_SUBFOLDER)
211
						SetProperties(SET_PROPERTIES_ALL_SUBFOLDER);
212
					IF (id==B_SETINGS_APPLY_NO_SUBFOLDER)
213
						SetProperties(SET_PROPERTIES_NO_SUBFOLDER);
5688 punk_joker 214
					break;
215
				}
7593 leency 216
				if (id==1) || (id==B_CLOSE)
5591 pavelyakov 217
				{
218
					cmd_free=3;
219
					ExitProcess();
220
				}
7593 leency 221
				if (id==B_APPLY) EventApplyProperties();
5447 punk_joker 222
				break;
223
 
224
		case evMouse:
225
				edit_box_mouse stdcall (#file_name_ed);
226
				edit_box_mouse stdcall (#path_to_file_ed);
227
				break;
228
 
229
		case evKey:
5707 leency 230
				GetKeys();
7593 leency 231
 
232
				if (apply_question_active)
5688 punk_joker 233
				{
7593 leency 234
					IF (key_scancode==SCAN_CODE_ENTER)
235
						SetProperties(SET_PROPERTIES_ALL_SUBFOLDER);
236
					IF (key_scancode==SCAN_CODE_ESC)
237
						SetProperties(SET_PROPERTIES_NO_SUBFOLDER);
5688 punk_joker 238
					break;
239
				}
7593 leency 240
 
241
				switch(key_scancode)
5591 pavelyakov 242
				{
7593 leency 243
					case SCAN_CODE_ESC:
244
						cmd_free=3;
245
						ExitProcess();
246
						break;
247
 
248
					case SCAN_CODE_ENTER:
249
						EventApplyProperties();
250
						break;
251
 
252
					default:
7605 leency 253
						if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
254
							EAX = key_editbox;
255
							edit_box_key stdcall(#file_name_ed);
256
							edit_box_key stdcall(#path_to_file_ed);
257
						}
5591 pavelyakov 258
				}
5447 punk_joker 259
				break;
260
 
261
		case evReDraw:
5688 punk_joker 262
				DrawPropertiesWindow();
263
	}
264
}
5450 leency 265
 
5688 punk_joker 266
void DrawPropertiesWindow()
267
{
7593 leency 268
	proc_info pform;
7369 leency 269
	char element_size_label[32];
270
	char folder_info[200];
6757 leency 271
	dword ext1;
7369 leency 272
	dword element_size;
7244 leency 273
	incn y;
6757 leency 274
	char temp_path[sizeof(file_path)];
7806 leency 275
	DefineAndDrawWindow(Form.left + 150,150,315,360+skin_height,0x34,sc.work,WINDOW_TITLE_PROPERTIES,0);
7593 leency 276
	GetProcessInfo(#pform, SelfInfo);
7041 leency 277
 
7593 leency 278
	DrawStandartCaptButton(pform.cwidth - 96, pform.cheight-34, B_CLOSE, T_CLOSE);
279
	DrawStandartCaptButton(pform.cwidth -208, pform.cheight-34, B_APPLY, T_APPLY);
5688 punk_joker 280
 
7806 leency 281
	WriteText(10, 78, 0x90, sc.work_text, PR_T_DEST);
7041 leency 282
	edit_box_draw stdcall (#path_to_file_ed);
283
 
7806 leency 284
	WriteText(10, 97, 0x90, sc.work_text, PR_T_SIZE);
7041 leency 285
 
286
	if (selected_count)
6403 punk_joker 287
	{
7086 leency 288
		PropertiesDrawIcon(NULL, "");
7369 leency 289
		sprintf(#folder_info,"%s%d%s%d",SET_6,more_files_count.files,SET_7,more_files_count.folders);
7806 leency 290
		WriteText(file_name_ed.left+4, 30, 0x90, sc.work_text, #folder_info);
7369 leency 291
		sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(more_files_count.bytes, NULL),more_files_count.bytes,SET_BYTE_LANG);
7806 leency 292
		WriteText(120, 97, 0x90, sc.work_text, #element_size_label);
7041 leency 293
	}
294
	else
295
	{
296
		if ( file_info_general.isfolder )
297
				PropertiesDrawIcon(NULL, "");
298
		else {
299
			sprintf(#temp_path,"%s/%s",#path,#file_name2);
300
			ext1 = strrchr(#file_name2,'.');
301
			if (ext1) ext1 += #file_name2;
302
			PropertiesDrawIcon(#temp_path, ext1);
303
		}
7806 leency 304
		WriteText(file_name_ed.left, file_name_ed.top-15, 0x80, sc.work_text, PR_T_NAME);
7227 leency 305
		DrawEditBox(#file_name_ed);
5688 punk_joker 306
 
7041 leency 307
		if (!itdir) element_size = file_info_general.sizelo;
308
		else
5688 punk_joker 309
		{
7806 leency 310
			WriteText(10,116, 0x90, sc.work_text, PR_T_CONTAINS);
7369 leency 311
			sprintf(#folder_info,"%s%d%s%d",SET_6,dir_size.files,SET_7,dir_size.folders);
7806 leency 312
			WriteText(120, 116, 0x90, sc.work_text, #folder_info);
7369 leency 313
			element_size = dir_size.bytes;
5688 punk_joker 314
		}
7806 leency 315
		WriteTextLines(10,  136, 0x90, sc.work_text, CREATED_OPENED_MODIFIED, 20);
316
		DrawDate(120,  136, sc.work_text, #file_info_general.datecreate);
317
		DrawDate(120, 156, sc.work_text, #file_info_general.datelastaccess);
318
		DrawDate(120, 176, sc.work_text, #file_info_general.datelastedit);
7041 leency 319
 
320
		sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(element_size, NULL),element_size,SET_BYTE_LANG);
7806 leency 321
		WriteText(120, 99, 0x90, sc.work_text, #element_size_label);
5447 punk_joker 322
	}
7593 leency 323
	DrawFrame(10, 212, -10*2 + pform.cwidth - 2, 92, FLAGS);
7244 leency 324
	y.n = 212; //212 => attributes_frame.y
325
	ch_read_only.draw(24, y.inc(18));
326
	ch_hidden.draw(24, y.inc(24));
327
	ch_system.draw(24, y.inc(24));
7593 leency 328
	if (apply_question_active) ShowConfirmQuestionPopin();
5463 leency 329
}
330
 
7041 leency 331
void PropertiesDrawIcon(dword file_path, extension)
332
{
7227 leency 333
	#define ICON_PADDING 11
334
	DrawBar(20-ICON_PADDING, 30-ICON_PADDING-1, ICON_PADDING*2+16, ICON_PADDING*2+16, 0xFFFfff);
7425 leency 335
	DrawIconByExtension(file_path, extension, -icon_size/2+28, -icon_size/2+38, 0xFFFfff);
7041 leency 336
}
7593 leency 337
 
338
void EventApplyProperties()
339
{
340
	if (selected_count) || (itdir) {
341
		ShowConfirmQuestionPopin();
342
	} else {
343
		SetProperties(SET_PROPERTIES_SINGLE_FILE);
344
	}
345
}