Subversion Repositories Kolibri OS

Rev

Rev 5962 | Rev 6050 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #ifdef LANG_RUS
  2.         ?define WINDOW_TITLE_PROPERTIES "‘¢®©á⢠"
  3.         ?define BTN_CLOSE "‡ ªàëâì"
  4.         ?define BTN_APPLY "à¨¬¥­¨âì"
  5.         ?define QUEST_1 "à¨¬¥­¨âì ª® ¢á¥¬ ¢«®¦¥­­ë¬"
  6.         ?define QUEST_2 "ä ©« ¬ ¨ ¯ ¯ª ¬"
  7.         ?define PR_T_NAME "ˆ¬ï:"
  8.         ?define PR_T_DEST " á¯®«®¦¥­¨¥:"
  9.         ?define PR_T_SIZE " §¬¥à:"
  10.         ?define CREATED_OPENED_MODIFIED "‘®§¤ ­:\nŽâªàëâ:\nˆ§¬¥­¥­:"
  11.         ?define SET_6 "” ©«®¢: "
  12.         ?define SET_7 "  ¯®ª: "
  13.         ?define PR_T_CONTAINS "‘®¤¥à¦¨â: "
  14.         ?define FLAGS " €ââਡãâë "
  15.         ?define PR_T_HIDDEN "‘ªàëâë©"
  16.         ?define PR_T_SYSTEM "‘¨á⥬­ë©"
  17.         ?define PR_T_ONLY_READ "’®«ìª® ç⥭¨¥"
  18.         ?define SET_BYTE_LANG "¡ ©â"
  19. #else // Apply to all subfolders
  20.         ?define WINDOW_TITLE_PROPERTIES "Properties"
  21.         ?define BTN_CLOSE "Close"
  22.         ?define BTN_APPLY "Apply"
  23.         ?define QUEST_1 "Apply to all subfolders"
  24.         ?define QUEST_2 "files and Folders"
  25.         ?define PR_T_NAME "Name:"
  26.         ?define PR_T_DEST "Destination:"
  27.         ?define PR_T_SIZE "Size:"
  28.         ?define CREATED_OPENED_MODIFIED "Created:\nOpened:\nModified:"
  29.         ?define SET_6 "Files: "
  30.         ?define SET_7 " Folders: "
  31.         ?define PR_T_CONTAINS "Contains: "
  32.         ?define FLAGS " Attributes "
  33.         ?define PR_T_HIDDEN "Hidden"
  34.         ?define PR_T_SYSTEM "System"
  35.         ?define PR_T_ONLY_READ "Read-only"
  36.         ?define SET_BYTE_LANG "byte"
  37. #endif
  38.  
  39. dword mouse_ddd2;
  40. char path_to_file[4096]="\0";
  41. char file_name2[4096]="\0";
  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};
  44. frame flags_frame = { 0, 280, 10, 83, 151, 0x000111, 0xFFFfff, 1, FLAGS, 0, 0, 6, 0x000111, 0xFFFFFF };
  45.  
  46. int file_count, dir_count, size_dir;
  47. char folder_info[200];
  48. dword element_size;
  49. char element_size_label[32];
  50. BDVK file_info_general;
  51. BDVK file_info_dirsize;
  52.  
  53. proc_info settings_form;
  54. byte quest_active, atr_readonly, atr_hidden, atr_system;
  55.  
  56. void SetPropertiesDir(dword way)
  57. {
  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<fcount; 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<files.count; 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.         }
  129.         else
  130.         {
  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;
  135.                 SetFileInfo(#file_path, #file_info_general);
  136.         }
  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();
  143. }
  144.  
  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.  
  154. void GetSizeDir(dword way)
  155. {
  156.         dword dirbuf, fcount, i, filename;
  157.         dword cur_file;
  158.         if (isdir(way))
  159.         {
  160.                 cur_file = malloc(4096);
  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.
  163.                 GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
  164.                 for (i=0; i<fcount; i++)
  165.                 {
  166.                         filename = i*304+dirbuf+72;
  167.                         sprintf(cur_file,"%s/%s",way,filename);
  168.                        
  169.                         if (TestBit(ESDWORD[filename-40], 4) )
  170.                         {
  171.                                 dir_count++;
  172.                                 GetSizeDir(cur_file);
  173.                         }
  174.                         else
  175.                         {
  176.                                 GetFileInfo(cur_file, #file_info_dirsize);
  177.                                 size_dir += file_info_dirsize.sizelo;
  178.                                 file_count++;
  179.                         }
  180.                 }
  181.                 free(cur_file);
  182.         }
  183. }
  184.  
  185. void GetSizeMoreFiles(dword way)
  186. {
  187.         char cur_file[4096];
  188.         dword selected_offset2;
  189.        
  190.         for (i=0; i<files.count; i++)
  191.     {
  192.         selected_offset2 = file_mas[i]*304 + buf+32 + 7;
  193.         if (ESBYTE[selected_offset2]) {
  194.                         sprintf(#cur_file,"%s%s",way,file_mas[i]*304+buf+72);
  195.                         if (TestBit(ESDWORD[file_mas[i]*304+buf+32], 4) )
  196.                         {
  197.                                 debugln(#cur_file);
  198.                                 GetSizeDir(#cur_file);
  199.                                 dir_count++;
  200.                         }
  201.                         else
  202.                         {
  203.                                 GetFileInfo(#cur_file, #file_info_dirsize);
  204.                                 size_dir += file_info_dirsize.sizelo;
  205.                                 file_count++;
  206.                         }
  207.         }
  208.         }  
  209. }
  210.  
  211. void properties_dialog()
  212. {
  213.         byte id;
  214.         dword file_name_off;
  215.         dword selected_offset2;
  216.        
  217.         DSBYTE[#folder_info]=0;
  218.         file_count = 0;
  219.         dir_count = 0; 
  220.         size_dir = 0;
  221.                        
  222.         if (selected_count)
  223.         {
  224.                 GetSizeMoreFiles(#path);
  225.                 debugi(size_dir);
  226.                 atr_readonly = 0;
  227.                 atr_hidden = 0;
  228.                 atr_system = 0;
  229.         }
  230.         else
  231.         {
  232.                 GetFileInfo(#file_path, #file_info_general);
  233.                 strcpy(#file_name2, #file_name);
  234.                 file_name_ed.size = strlen(#file_name2);  
  235.                 if(itdir) GetSizeDir(#file_path);
  236.                 atr_readonly = file_info_general.readonly;
  237.                 atr_hidden = file_info_general.hidden;
  238.                 atr_system = file_info_general.system;
  239.         }
  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();
  248.                                 if (quest_active)
  249.                                 {
  250.                                         IF (id==301) SetProperties(2);
  251.                                         IF (id==302) SetProperties(1);
  252.                                         break;
  253.                                 }
  254.                                 if (id==1) || (id==10)
  255.                                 {
  256.                                         cmd_free=3;
  257.                                         ExitProcess();
  258.                                 }
  259.                                 IF (id==11)
  260.                                 {
  261.                                         if (selected_count) || (itdir)
  262.                                         {
  263.                                                 quest_active = 1;
  264.                                                 Quest();
  265.                                         }
  266.                                         else
  267.                                         {
  268.                                                 SetProperties(0);
  269.                                         }
  270.                                         break;
  271.                                 }
  272.                                 if (id==20) atr_readonly ^= 1;
  273.                                 if (id==21) atr_hidden ^= 1;
  274.                                 if (id==22) atr_system ^= 1;
  275.                                 DrawPropertiesCheckBoxes();
  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:
  284.                                 GetKeys();
  285.                                
  286.                                 if (quest_active)
  287.                                 {
  288.                                         IF (key_scancode==SCAN_CODE_ENTER) SetProperties(2);
  289.                                         IF (key_scancode==SCAN_CODE_ESC) SetProperties(1);
  290.                                         break;
  291.                                 }
  292.                                 if (key_scancode==SCAN_CODE_ESC)
  293.                                 {
  294.                                         cmd_free=3;
  295.                                         ExitProcess();
  296.                                 }
  297.                                 if (key_scancode==SCAN_CODE_ENTER)
  298.                                 {
  299.                                         if (selected_count) || (itdir)
  300.                                         {
  301.                                                 quest_active = 1;
  302.                                                 Quest();
  303.                                         }
  304.                                         else
  305.                                         {
  306.                                                 SetProperties(0);
  307.                                         }
  308.                                         break;
  309.                                 }
  310.                                 EAX = key_ascii << 8;
  311.                                 edit_box_key stdcall(#file_name_ed);
  312.                                 edit_box_key stdcall(#path_to_file_ed);
  313.                                 break;
  314.                                
  315.                 case evReDraw:
  316.                                 DrawPropertiesWindow();
  317.         }
  318. }
  319.  
  320. void DrawPropertiesWindow()
  321. {
  322.         DefineAndDrawWindow(Form.left + 150,150,270,285+GetSkinHeight(),0x34,system.color.work,WINDOW_TITLE_PROPERTIES);
  323.         GetProcessInfo(#settings_form, SelfInfo);
  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);
  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);
  330.  
  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("<DIR>", 18, 19, 0xFFFfff, 0);
  345.                 else
  346.                                 Put_icon(#file_name2+strrchr(#file_name2,'.'), 18, 19, 0xFFFfff, 0);
  347.  
  348.                 WriteText(50, 13, 0x80, 0x000000, PR_T_NAME);                          
  349.                 edit_box_draw stdcall (#file_name_ed);
  350.                
  351.                 if (!itdir) element_size = file_info_general.sizelo;
  352.                 else
  353.                 {
  354.                         WriteText(10, 80, 0x80, 0x000000, PR_T_CONTAINS);                              
  355.                         sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
  356.                         WriteText(100, 80, 0x80, 0x000000, #folder_info);
  357.                         element_size = size_dir;
  358.                 }
  359.                 WriteTextLines(10,  95, 0x80, 0x000000, CREATED_OPENED_MODIFIED, 15);
  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);
  366.         }
  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();
  372. }
  373.  
  374. void DrawPropertiesCheckBoxes()
  375. {
  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);
  379. }