forked from KolibriOS/kolibrios
444 lines
12 KiB
C
444 lines
12 KiB
C
#ifdef LANG_RUS
|
||
?define WINDOW_TITLE_PROPERTIES "‘¢®©á⢠"
|
||
?define BTN_CLOSE "‡ ªàëâì"
|
||
?define BTN_APPLY "<EFBFBD>ਬ¥¨âì"
|
||
?define QUEST_1 "<EFBFBD>ਬ¥¨âì ª® ¢á¥¬ ¢«®¦¥ë¬"
|
||
?define QUEST_2 "ä ©« ¬ ¨ ¯ ¯ª ¬?"
|
||
?define PR_T_NAME "ˆ¬ï:"
|
||
?define PR_T_DEST "<EFBFBD> ᯮ«®¦¥¨¥:"
|
||
?define PR_T_SIZE "<EFBFBD> §¬¥à:"
|
||
?define CREATED_OPENED_MODIFIED "‘®§¤ :\nŽâªàëâ:\nˆ§¬¥¥:"
|
||
?define SET_6 "” ©«®¢: "
|
||
?define SET_7 " <20> ¯®ª: "
|
||
?define PR_T_CONTAINS "‘®¤¥à¦¨â: "
|
||
?define FLAGS " €ââਡãâë "
|
||
?define PR_T_HIDDEN "‘ªàëâë©"
|
||
?define PR_T_SYSTEM "‘¨á⥬ë©"
|
||
?define PR_T_ONLY_READ "’®«ìª® ç⥨¥"
|
||
?define SET_BYTE_LANG "¡ ©â"
|
||
?define TAB_T_BASIC "Ž¡é¨¥"
|
||
?define TAB_T_DETAILS "<EFBFBD>®¤à®¡¥¥"
|
||
#else // Apply to all subfolders
|
||
?define WINDOW_TITLE_PROPERTIES "Properties"
|
||
?define BTN_CLOSE "Close"
|
||
?define BTN_APPLY "Apply"
|
||
?define QUEST_1 "Apply to all subfolders"
|
||
?define QUEST_2 "files and Folders?"
|
||
?define PR_T_NAME "Name:"
|
||
?define PR_T_DEST "Destination:"
|
||
?define PR_T_SIZE "Size:"
|
||
?define CREATED_OPENED_MODIFIED "Created:\nOpened:\nModified:"
|
||
?define SET_6 "Files: "
|
||
?define SET_7 " Folders: "
|
||
?define PR_T_CONTAINS "Contains: "
|
||
?define FLAGS " Attributes "
|
||
?define PR_T_HIDDEN "Hidden"
|
||
?define PR_T_SYSTEM "System"
|
||
?define PR_T_ONLY_READ "Read-only"
|
||
?define SET_BYTE_LANG "byte"
|
||
?define TAB_T_BASIC "Basic"
|
||
?define TAB_T_DETAILS "Details"
|
||
#endif
|
||
|
||
dword mouse_ddd2;
|
||
char path_to_file[4096]="\0";
|
||
char file_name2[4096]="\0";
|
||
edit_box file_name_ed = {230,50,57,0xffffff,0x94AECE,0xFFFfff,0xffffff,2,4098,#file_name2,#mouse_ddd2, 1000000000000000b,2,2};
|
||
edit_box path_to_file_ed = {160,120,79,0xffffff,0x94AECE,0xFFFfff,0xffffff,2,4098,#path_to_file,#mouse_ddd2, 1000000000000000b,2,2};
|
||
frame flags_frame = { 0, NULL, 10, 92, 212, 0x000111, 0xFFFfff, 1, FLAGS, 0, 1, 12, 0x000111, 0xFFFFFF };
|
||
|
||
//NewElement options
|
||
enum {
|
||
TAB_BASIC,
|
||
TAB_DETAILS,
|
||
};
|
||
|
||
byte active_tab;
|
||
int file_count, dir_count, size_dir;
|
||
char folder_info[200];
|
||
dword element_size;
|
||
char element_size_label[32];
|
||
BDVK file_info_general;
|
||
BDVK file_info_dirsize;
|
||
|
||
proc_info settings_form;
|
||
bool quest_active, atr_readonly, atr_hidden, atr_system;
|
||
|
||
void SetPropertiesDir(dword way)
|
||
{
|
||
dword dirbuf, fcount, i, filename;
|
||
dword cur_file;
|
||
if (dir_exists(way))
|
||
{
|
||
cur_file = malloc(4096);
|
||
GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
|
||
for (i=0; i<fcount; i++)
|
||
{
|
||
filename = i*304+dirbuf+72;
|
||
strcpy(cur_file, way);
|
||
chrcat(cur_file, '/');
|
||
strcat(cur_file, filename);
|
||
if ( TestBit(ESDWORD[filename-40], 4) )
|
||
{
|
||
SetPropertiesDir(cur_file);
|
||
}
|
||
GetFileInfo(cur_file, #file_info_dirsize);
|
||
file_info_dirsize.readonly = atr_readonly;
|
||
file_info_dirsize.hidden = atr_hidden;
|
||
file_info_dirsize.system = atr_system;
|
||
SetFileInfo(cur_file, #file_info_dirsize);
|
||
}
|
||
free(cur_file);
|
||
}
|
||
}
|
||
|
||
void SetProperties(byte prop)
|
||
{
|
||
dword cur_file;
|
||
dword selected_offset2;
|
||
|
||
if (prop==1) || (prop==2)
|
||
{
|
||
if (selected_count)
|
||
{
|
||
cur_file = malloc(4096);
|
||
for (i=0; i<files.count; i++)
|
||
{
|
||
selected_offset2 = file_mas[i]*304 + buf+32 + 7;
|
||
if (ESBYTE[selected_offset2])
|
||
{
|
||
strcpy(cur_file, #path);
|
||
strcat(cur_file, file_mas[i]*304+buf+72);
|
||
GetFileInfo(cur_file, #file_info_general);
|
||
file_info_general.readonly = atr_readonly;
|
||
file_info_general.hidden = atr_hidden;
|
||
file_info_general.system = atr_system;
|
||
SetFileInfo(cur_file, #file_info_general);
|
||
if (prop==2)
|
||
{
|
||
if (dir_exists(cur_file))
|
||
{
|
||
SetPropertiesDir(cur_file);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
free(cur_file);
|
||
}
|
||
else
|
||
{
|
||
GetFileInfo(#file_path, #file_info_general);
|
||
file_info_general.readonly = atr_readonly;
|
||
file_info_general.hidden = atr_hidden;
|
||
file_info_general.system = atr_system;
|
||
SetFileInfo(#file_path, #file_info_general);
|
||
if (prop==2) SetPropertiesDir(#file_path);
|
||
}
|
||
quest_active = 0;
|
||
DrawPropertiesWindow();
|
||
}
|
||
else
|
||
{
|
||
GetFileInfo(#file_path, #file_info_general);
|
||
file_info_general.readonly = atr_readonly;
|
||
file_info_general.hidden = atr_hidden;
|
||
file_info_general.system = atr_system;
|
||
SetFileInfo(#file_path, #file_info_general);
|
||
}
|
||
cmd_free=3;
|
||
_not_draw = true;
|
||
Open_Dir(#path,WITH_REDRAW);
|
||
_not_draw = false;
|
||
EventRedrawWindow(Form.left,Form.top);
|
||
ExitProcess();
|
||
}
|
||
|
||
void ShowConfirmQuestionPopin()
|
||
{
|
||
quest_active = 1;
|
||
DrawPopup(15,80,250,90,1,system.color.work, system.color.work_graph);
|
||
WriteText(35, 102, 0x90, 0x000000, QUEST_1);
|
||
WriteText(65, 117, 0x90, 0x000000, QUEST_2);
|
||
DrawFlatButton(62,138,70,20,301,T_YES);
|
||
DrawFlatButton(155,138,70,20,302,T_NO);
|
||
}
|
||
|
||
void GetSizeDir(dword way)
|
||
{
|
||
dword dirbuf, fcount, i, filename;
|
||
dword cur_file;
|
||
if (dir_exists(way))
|
||
{
|
||
cur_file = malloc(4096);
|
||
// In the process of recursive descent, memory must be allocated dynamically,
|
||
// because the static memory -> was a bug !!! But unfortunately pass away to sacrifice speed.
|
||
GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
|
||
for (i=0; i<fcount; i++)
|
||
{
|
||
filename = i*304+dirbuf+72;
|
||
sprintf(cur_file,"%s/%s",way,filename);
|
||
|
||
if (TestBit(ESDWORD[filename-40], 4) )
|
||
{
|
||
dir_count++;
|
||
GetSizeDir(cur_file);
|
||
}
|
||
else
|
||
{
|
||
GetFileInfo(cur_file, #file_info_dirsize);
|
||
size_dir += file_info_dirsize.sizelo;
|
||
file_count++;
|
||
}
|
||
}
|
||
free(cur_file);
|
||
}
|
||
}
|
||
|
||
void GetSizeMoreFiles(dword way)
|
||
{
|
||
char cur_file[4096];
|
||
dword selected_offset2;
|
||
|
||
for (i=0; i<files.count; i++)
|
||
{
|
||
selected_offset2 = file_mas[i]*304 + buf+32 + 7;
|
||
if (ESBYTE[selected_offset2]) {
|
||
sprintf(#cur_file,"%s%s",way,file_mas[i]*304+buf+72);
|
||
if (TestBit(ESDWORD[file_mas[i]*304+buf+32], 4) )
|
||
{
|
||
debugln(#cur_file);
|
||
GetSizeDir(#cur_file);
|
||
dir_count++;
|
||
}
|
||
else
|
||
{
|
||
GetFileInfo(#cur_file, #file_info_dirsize);
|
||
size_dir += file_info_dirsize.sizelo;
|
||
file_count++;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
void properties_dialog()
|
||
{
|
||
byte id;
|
||
dword file_name_off;
|
||
dword selected_offset2;
|
||
|
||
DSBYTE[#folder_info]=0;
|
||
file_count = 0;
|
||
dir_count = 0;
|
||
size_dir = 0;
|
||
|
||
if (selected_count)
|
||
{
|
||
GetSizeMoreFiles(#path);
|
||
debugi(size_dir);
|
||
atr_readonly = 0;
|
||
atr_hidden = 0;
|
||
atr_system = 0;
|
||
}
|
||
else
|
||
{
|
||
GetFileInfo(#file_path, #file_info_general);
|
||
strcpy(#file_name2, #file_name);
|
||
file_name_ed.size = strlen(#file_name2);
|
||
if(itdir) GetSizeDir(#file_path);
|
||
atr_readonly = file_info_general.readonly;
|
||
atr_hidden = file_info_general.hidden;
|
||
atr_system = file_info_general.system;
|
||
}
|
||
strcpy(#path_to_file, #path);
|
||
path_to_file_ed.size = strlen(#path_to_file);
|
||
|
||
SetEventMask(0x27);
|
||
loop() switch(WaitEvent())
|
||
{
|
||
case evButton:
|
||
id=GetButtonID();
|
||
if (quest_active)
|
||
{
|
||
IF (id==301) SetProperties(2);
|
||
IF (id==302) SetProperties(1);
|
||
quest_active=false;
|
||
break;
|
||
}
|
||
if (id==1) || (id==10)
|
||
{
|
||
cmd_free=3;
|
||
ExitProcess();
|
||
}
|
||
IF (id==11)
|
||
{
|
||
if (selected_count) || (itdir)
|
||
{
|
||
ShowConfirmQuestionPopin();
|
||
}
|
||
else
|
||
{
|
||
SetProperties(0);
|
||
}
|
||
break;
|
||
}
|
||
if (id==12)
|
||
{
|
||
active_tab = TAB_BASIC;
|
||
DrawPropertiesWindow();
|
||
}
|
||
if (id==13)
|
||
{
|
||
active_tab = TAB_DETAILS;
|
||
DrawPropertiesWindow();
|
||
}
|
||
if (id==20)
|
||
{
|
||
atr_readonly ^= 1;
|
||
DrawPropertiesCheckBoxes();
|
||
}
|
||
if (id==21)
|
||
{
|
||
atr_hidden ^= 1;
|
||
DrawPropertiesCheckBoxes();
|
||
}
|
||
if (id==22)
|
||
{
|
||
atr_system ^= 1;
|
||
DrawPropertiesCheckBoxes();
|
||
}
|
||
break;
|
||
|
||
case evMouse:
|
||
edit_box_mouse stdcall (#file_name_ed);
|
||
edit_box_mouse stdcall (#path_to_file_ed);
|
||
break;
|
||
|
||
case evKey:
|
||
GetKeys();
|
||
|
||
if (quest_active)
|
||
{
|
||
IF (key_scancode==SCAN_CODE_ENTER) SetProperties(2);
|
||
IF (key_scancode==SCAN_CODE_ESC) SetProperties(1);
|
||
quest_active=false;
|
||
break;
|
||
}
|
||
if (key_scancode==SCAN_CODE_ESC)
|
||
{
|
||
cmd_free=3;
|
||
ExitProcess();
|
||
}
|
||
if (key_scancode==SCAN_CODE_ENTER)
|
||
{
|
||
if (selected_count) || (itdir)
|
||
{
|
||
ShowConfirmQuestionPopin();
|
||
}
|
||
else
|
||
{
|
||
SetProperties(0);
|
||
}
|
||
break;
|
||
}
|
||
EAX = key_ascii << 8;
|
||
edit_box_key stdcall(#file_name_ed);
|
||
edit_box_key stdcall(#path_to_file_ed);
|
||
break;
|
||
|
||
case evReDraw:
|
||
DrawPropertiesWindow();
|
||
}
|
||
}
|
||
|
||
void DrawPropertiesWindow()
|
||
{
|
||
DefineAndDrawWindow(Form.left + 150,150,305,360+skin_height,0x34,system.color.work,WINDOW_TITLE_PROPERTIES);
|
||
if ( !asm test path_to_file_ed.flags, 2)
|
||
{
|
||
path_to_file_ed.blur_border_color = system.color.work;
|
||
path_to_file_ed.color = system.color.work;
|
||
}
|
||
else
|
||
{
|
||
path_to_file_ed.blur_border_color = 0x000000;
|
||
path_to_file_ed.color = 0xffffff;
|
||
}
|
||
if ( !asm test path_to_file_ed.flags, 2)
|
||
{
|
||
file_name_ed.blur_border_color = system.color.work;
|
||
file_name_ed.color = system.color.work;
|
||
}
|
||
else
|
||
{
|
||
file_name_ed.blur_border_color = 0x000000;
|
||
file_name_ed.color = 0xffffff;
|
||
}
|
||
GetProcessInfo(#settings_form, SelfInfo);
|
||
DrawFlatButton(10, 5, 80, 24, 12, TAB_T_BASIC);
|
||
if (exif_load==1) DrawFlatButton(92, 5, 80, 24, 13, TAB_T_DETAILS);
|
||
DrawFlatButton(settings_form.cwidth - 93, settings_form.cheight-34, 80, 24, 10, BTN_CLOSE);
|
||
DrawFlatButton(settings_form.cwidth -183, settings_form.cheight-34, 80, 24, 11, BTN_APPLY);
|
||
|
||
if (active_tab == TAB_BASIC)
|
||
{
|
||
WriteText(10, 78, 0x90, 0x000000, PR_T_DEST);
|
||
edit_box_draw stdcall (#path_to_file_ed);
|
||
|
||
WriteText(10, 97, 0x90, 0x000000, PR_T_SIZE);
|
||
|
||
if (selected_count)
|
||
{
|
||
DrawIconByExtension(NULL, 18, 19, system.color.work);
|
||
sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
|
||
WriteText(50, 49, 0x90, 0x000000, #folder_info);
|
||
sprintf(#element_size_label,"%s (%d %s)",ConvertSize(size_dir),size_dir,SET_BYTE_LANG);
|
||
WriteText(120, 97, 0x90, 0x000000, #element_size_label);
|
||
}
|
||
else
|
||
{
|
||
if ( file_info_general.isfolder )
|
||
DrawIconByExtension("<DIR>", 18, 49, system.color.work);
|
||
else
|
||
DrawIconByExtension(#file_name2+strrchr(#file_name2,'.'), 18, 49, system.color.work);
|
||
|
||
WriteText(50, 40, 0x90, 0x000000, PR_T_NAME);
|
||
edit_box_draw stdcall (#file_name_ed);
|
||
|
||
if (!itdir) element_size = file_info_general.sizelo;
|
||
else
|
||
{
|
||
WriteText(10,116, 0x90, 0x000000, PR_T_CONTAINS);
|
||
sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
|
||
WriteText(120, 116, 0x90, 0x000000, #folder_info);
|
||
element_size = size_dir;
|
||
}
|
||
WriteTextLines(10, 136, 0x90, 0x000000, CREATED_OPENED_MODIFIED, 20);
|
||
DrawDate(120, 136, 0, #file_info_general.datecreate);
|
||
DrawDate(120, 156, 0, #file_info_general.datelastaccess);
|
||
DrawDate(120, 176, 0, #file_info_general.datelastedit);
|
||
|
||
sprintf(#element_size_label,"%s (%d %s)",ConvertSize(element_size),element_size,SET_BYTE_LANG);
|
||
WriteText(120, 99, 0x90, 0x000000, #element_size_label);
|
||
}
|
||
flags_frame.size_x = - flags_frame.start_x * 2 + settings_form.cwidth - 2;
|
||
flags_frame.font_color = system.color.work_text;
|
||
flags_frame.ext_col = system.color.work_graph;
|
||
flags_frame.font_backgr_color = system.color.work;
|
||
frame_draw stdcall (#flags_frame);
|
||
DrawPropertiesCheckBoxes();
|
||
}
|
||
else
|
||
{
|
||
WriteText(10, 78, 0x90, 0x000000, "EXIF");
|
||
}
|
||
}
|
||
|
||
void DrawPropertiesCheckBoxes()
|
||
{
|
||
incn y;
|
||
y.n = flags_frame.start_y;
|
||
CheckBox(24, y.inc(18), 20, PR_T_ONLY_READ, atr_readonly);
|
||
CheckBox(24, y.inc(24), 21, PR_T_HIDDEN, atr_hidden);
|
||
CheckBox(24, y.inc(24), 22, PR_T_SYSTEM, atr_system);
|
||
}
|