Subversion Repositories Kolibri OS

Rev

Rev 7972 | Rev 8944 | 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
 
7878 leency 54
DIR_SIZE more_files_count;
55
DIR_SIZE dir_size;
7369 leency 56
 
7244 leency 57
checkbox ch_read_only = { PR_T_ONLY_READ, NULL };
58
checkbox ch_hidden = { PR_T_HIDDEN, NULL };
59
checkbox ch_system = { PR_T_SYSTEM, NULL };
60
 
61
void SetPropertiesFile(dword cur_file, bdvk_pointer)
62
{
63
	GetFileInfo(cur_file, bdvk_pointer);
64
	ESI = bdvk_pointer;
65
	ESI.BDVK.readonly = ch_read_only.checked;
66
	ESI.BDVK.hidden = ch_hidden.checked;
67
	ESI.BDVK.system = ch_system.checked;
68
	SetFileInfo(cur_file, bdvk_pointer);
69
}
70
 
5688 punk_joker 71
void SetPropertiesDir(dword way)
5554 punk_joker 72
{
5688 punk_joker 73
	dword dirbuf, fcount, i, filename;
74
	dword cur_file;
6251 leency 75
	if (dir_exists(way))
5688 punk_joker 76
	{
77
		cur_file = malloc(4096);
78
		GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
79
		for (i=0; i
80
		{
81
			filename = i*304+dirbuf+72;
82
			strcpy(cur_file, way);
83
			chrcat(cur_file, '/');
84
			strcat(cur_file, filename);
85
			if ( TestBit(ESDWORD[filename-40], 4) )
86
			{
87
				SetPropertiesDir(cur_file);
88
			}
7244 leency 89
			SetPropertiesFile(cur_file, #file_info_dirsize);
5688 punk_joker 90
		}
91
		free(cur_file);
92
	}
93
}
94
 
7593 leency 95
#define SET_PROPERTIES_SINGLE_FILE 0
96
#define SET_PROPERTIES_NO_SUBFOLDER 1
97
#define SET_PROPERTIES_ALL_SUBFOLDER 2
98
void SetProperties(int mode)
5688 punk_joker 99
{
7593 leency 100
	char pcur_file[4096];
7422 leency 101
	dword i;
5688 punk_joker 102
 
7593 leency 103
	apply_question_active=false;
104
 
105
	if (SET_PROPERTIES_SINGLE_FILE == mode) {
106
		SetPropertiesFile(#file_path, #file_info_general);
107
	}
108
 
109
	if (SET_PROPERTIES_ALL_SUBFOLDER == mode)
110
	|| (SET_PROPERTIES_NO_SUBFOLDER == mode)
5688 punk_joker 111
	{
112
		if (selected_count)
113
		{
114
			for (i=0; i
115
			{
6646 leency 116
				if (getElementSelectedFlag(i) == true)
5688 punk_joker 117
				{
7972 leency 118
					sprintf(#pcur_file,"%s/%s",#path,items.get(i)*304+buf+72);
7593 leency 119
					SetPropertiesFile(#pcur_file, #file_info_general);
120
					if (SET_PROPERTIES_ALL_SUBFOLDER == mode) {
121
						if (dir_exists(#pcur_file)) SetPropertiesDir(#pcur_file);
5688 punk_joker 122
					}
123
				}
124
			}
125
		}
126
		else
127
		{
7244 leency 128
			SetPropertiesFile(#file_path, #file_info_general);
7593 leency 129
			if (SET_PROPERTIES_ALL_SUBFOLDER == mode) SetPropertiesDir(#file_path);
5688 punk_joker 130
		}
131
	}
7593 leency 132
 
5688 punk_joker 133
	cmd_free=3;
134
	_not_draw = true;
6646 leency 135
	Open_Dir(#path,WITH_REDRAW);
136
	_not_draw = false;
137
	EventRedrawWindow(Form.left,Form.top);
5688 punk_joker 138
	ExitProcess();
5554 punk_joker 139
}
5487 leency 140
 
6278 leency 141
void ShowConfirmQuestionPopin()
5688 punk_joker 142
{
7593 leency 143
	apply_question_active = 1;
7806 leency 144
	DrawPopup(15,80,250,90,1,sc.work, sc.work_graph);
6280 punk_joker 145
	WriteText(35, 102, 0x90, 0x000000, QUEST_1);
146
	WriteText(65, 117, 0x90, 0x000000, QUEST_2);
7593 leency 147
	DrawStandartCaptButton(62,138,B_SETINGS_APPLY_SUBFOLDER,T_YES);
148
	DrawStandartCaptButton(155,138,B_SETINGS_APPLY_NO_SUBFOLDER,T_NO);
5688 punk_joker 149
}
150
 
5510 punk_joker 151
void GetSizeMoreFiles(dword way)
152
{
153
	char cur_file[4096];
7422 leency 154
	dword i;
5957 punk_joker 155
 
5510 punk_joker 156
	for (i=0; i
6646 leency 157
	{
158
		if (getElementSelectedFlag(i) == true)
159
		{
7972 leency 160
			sprintf(#cur_file,"%s/%s",way,items.get(i)*304+buf+72);
161
			if (TestBit(ESDWORD[items.get(i)*304+buf+32], 4) )
5510 punk_joker 162
			{
7369 leency 163
				more_files_count.calculate_loop(#cur_file);
164
				more_files_count.folders++;
5510 punk_joker 165
			}
166
			else
167
			{
5957 punk_joker 168
				GetFileInfo(#cur_file, #file_info_dirsize);
7369 leency 169
				more_files_count.bytes += file_info_dirsize.sizelo;
170
				more_files_count.files++;
5510 punk_joker 171
			}
6646 leency 172
		}
5510 punk_joker 173
	}
174
}
175
 
5447 punk_joker 176
void properties_dialog()
177
{
7244 leency 178
	int id;
5447 punk_joker 179
 
5688 punk_joker 180
	if (selected_count)
181
	{
7369 leency 182
		more_files_count.get(NULL);
5688 punk_joker 183
		GetSizeMoreFiles(#path);
7244 leency 184
		ch_read_only.checked = 0;
185
		ch_hidden.checked = 0;
186
		ch_system.checked = 0;
5688 punk_joker 187
	}
5510 punk_joker 188
	else
189
	{
190
		GetFileInfo(#file_path, #file_info_general);
8336 leency 191
		edit_box_set_text stdcall (#file_name_ed, #file_name);
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
	}
8336 leency 197
	edit_box_set_text stdcall (#path_to_file_ed, #path);
5447 punk_joker 198
 
7227 leency 199
	SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
5447 punk_joker 200
	loop() switch(WaitEvent())
201
	{
202
		case evButton:
203
				id=GetButtonID();
7244 leency 204
				ch_read_only.click(id);
205
				ch_hidden.click(id);
206
				ch_system.click(id);
7593 leency 207
				if (apply_question_active)
5688 punk_joker 208
				{
7593 leency 209
					IF (id==B_SETINGS_APPLY_SUBFOLDER)
210
						SetProperties(SET_PROPERTIES_ALL_SUBFOLDER);
211
					IF (id==B_SETINGS_APPLY_NO_SUBFOLDER)
212
						SetProperties(SET_PROPERTIES_NO_SUBFOLDER);
5688 punk_joker 213
					break;
214
				}
7593 leency 215
				if (id==1) || (id==B_CLOSE)
5591 pavelyakov 216
				{
217
					cmd_free=3;
218
					ExitProcess();
219
				}
7593 leency 220
				if (id==B_APPLY) EventApplyProperties();
5447 punk_joker 221
				break;
222
 
223
		case evMouse:
224
				edit_box_mouse stdcall (#file_name_ed);
225
				edit_box_mouse stdcall (#path_to_file_ed);
226
				break;
227
 
228
		case evKey:
5707 leency 229
				GetKeys();
7593 leency 230
 
231
				if (apply_question_active)
5688 punk_joker 232
				{
7593 leency 233
					IF (key_scancode==SCAN_CODE_ENTER)
234
						SetProperties(SET_PROPERTIES_ALL_SUBFOLDER);
235
					IF (key_scancode==SCAN_CODE_ESC)
236
						SetProperties(SET_PROPERTIES_NO_SUBFOLDER);
5688 punk_joker 237
					break;
238
				}
7593 leency 239
 
240
				switch(key_scancode)
5591 pavelyakov 241
				{
7593 leency 242
					case SCAN_CODE_ESC:
243
						cmd_free=3;
244
						ExitProcess();
245
						break;
246
 
247
					case SCAN_CODE_ENTER:
248
						EventApplyProperties();
249
						break;
250
 
7914 leency 251
					case SCAN_CODE_KEY_A:
252
					case SCAN_CODE_KEY_C:
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
}