Subversion Repositories Kolibri OS

Rev

Rev 5957 | Rev 6008 | 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,0x000000,0xffffff,2,4098,#file_name2,#mouse_ddd2, 1000000000000000b,2,2};
  43. edit_box path_to_file_ed = {145,100,46,0xffffff,0x94AECE,0x000000,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, because the static memory -> was a bug !!! But unfortunately pass away to sacrifice speed.
  162.                 GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
  163.                 for (i=0; i<fcount; i++)
  164.                 {
  165.                         filename = i*304+dirbuf+72;
  166.                         sprintf(cur_file,"%s/%s",way,filename);
  167.                        
  168.                         if (TestBit(ESDWORD[filename-40], 4) )
  169.                         {
  170.                                 dir_count++;
  171.                                 GetSizeDir(cur_file);
  172.                         }
  173.                         else
  174.                         {
  175.                                 GetFileInfo(cur_file, #file_info_dirsize);
  176.                                 size_dir += file_info_dirsize.sizelo;
  177.                                 file_count++;
  178.                         }
  179.                 }
  180.                 free(cur_file);
  181.         }
  182. }
  183.  
  184. void GetSizeMoreFiles(dword way)
  185. {
  186.         char cur_file[4096];
  187.         dword selected_offset2;
  188.        
  189.         for (i=0; i<files.count; i++)
  190.     {
  191.         selected_offset2 = file_mas[i]*304 + buf+32 + 7;
  192.         if (ESBYTE[selected_offset2]) {
  193.                         sprintf(#cur_file,"%s%s",way,file_mas[i]*304+buf+72);
  194.                         if (TestBit(ESDWORD[file_mas[i]*304+buf+32], 4) )
  195.                         {
  196.                                 debugln(#cur_file);
  197.                                 GetSizeDir(#cur_file);
  198.                                 dir_count++;
  199.                         }
  200.                         else
  201.                         {
  202.                                 GetFileInfo(#cur_file, #file_info_dirsize);
  203.                                 size_dir += file_info_dirsize.sizelo;
  204.                                 file_count++;
  205.                         }
  206.         }
  207.         }  
  208. }
  209.  
  210. void properties_dialog()
  211. {
  212.         byte id;
  213.         dword file_name_off;
  214.         dword selected_offset2;
  215.        
  216.         DSBYTE[#folder_info]=0;
  217.         file_count = 0;
  218.         dir_count = 0; 
  219.         size_dir = 0;
  220.                        
  221.         if (selected_count)
  222.         {
  223.                 GetSizeMoreFiles(#path);
  224.                 debugi(size_dir);
  225.                 atr_readonly = 0;
  226.                 atr_hidden = 0;
  227.                 atr_system = 0;
  228.         }
  229.         else
  230.         {
  231.                 GetFileInfo(#file_path, #file_info_general);
  232.                 strcpy(#file_name2, #file_name);
  233.                 file_name_ed.size = strlen(#file_name2);  
  234.                 if(itdir) GetSizeDir(#file_path);
  235.                 atr_readonly = file_info_general.readonly;
  236.                 atr_hidden = file_info_general.hidden;
  237.                 atr_system = file_info_general.system;
  238.         }
  239.         strcpy(#path_to_file, #path);
  240.         path_to_file_ed.size = strlen(#path_to_file);
  241.        
  242.         SetEventMask(0x27);
  243.         loop() switch(WaitEvent())
  244.         {
  245.                 case evButton:
  246.                                 id=GetButtonID();
  247.                                 if (quest_active)
  248.                                 {
  249.                                         IF (id==301) SetProperties(2);
  250.                                         IF (id==302) SetProperties(1);
  251.                                         break;
  252.                                 }
  253.                                 if (id==1) || (id==10)
  254.                                 {
  255.                                         cmd_free=3;
  256.                                         ExitProcess();
  257.                                 }
  258.                                 IF (id==11)
  259.                                 {
  260.                                         if (selected_count) || (itdir)
  261.                                         {
  262.                                                 quest_active = 1;
  263.                                                 Quest();
  264.                                         }
  265.                                         else
  266.                                         {
  267.                                                 SetProperties(0);
  268.                                         }
  269.                                         break;
  270.                                 }
  271.                                 if (id==20) atr_readonly ^= 1;
  272.                                 if (id==21) atr_hidden ^= 1;
  273.                                 if (id==22) atr_system ^= 1;
  274.                                 DrawPropertiesCheckBoxes();
  275.                                 break;
  276.                                
  277.                 case evMouse:
  278.                                 edit_box_mouse stdcall (#file_name_ed);
  279.                                 edit_box_mouse stdcall (#path_to_file_ed);
  280.                                 break;
  281.                        
  282.                 case evKey:
  283.                                 GetKeys();
  284.                                
  285.                                 if (quest_active)
  286.                                 {
  287.                                         IF (key_scancode==SCAN_CODE_ENTER) SetProperties(2);
  288.                                         IF (key_scancode==SCAN_CODE_ESC) SetProperties(1);
  289.                                         break;
  290.                                 }
  291.                                 if (key_scancode==SCAN_CODE_ESC)
  292.                                 {
  293.                                         cmd_free=3;
  294.                                         ExitProcess();
  295.                                 }
  296.                                 if (key_scancode==SCAN_CODE_ENTER)
  297.                                 {
  298.                                         if (selected_count) || (itdir)
  299.                                         {
  300.                                                 quest_active = 1;
  301.                                                 Quest();
  302.                                         }
  303.                                         else
  304.                                         {
  305.                                                 SetProperties(0);
  306.                                         }
  307.                                         break;
  308.                                 }
  309.                                 EAX = key_ascii << 8;
  310.                                 edit_box_key stdcall(#file_name_ed);
  311.                                 edit_box_key stdcall(#path_to_file_ed);
  312.                                 break;
  313.                                
  314.                 case evReDraw:
  315.                                 DrawPropertiesWindow();
  316.         }
  317. }
  318.  
  319. void DrawPropertiesWindow()
  320. {
  321.         DefineAndDrawWindow(Form.left + 150,150,270,285+GetSkinHeight(),0x34,0xFFFFFF,WINDOW_TITLE_PROPERTIES);
  322.         GetProcessInfo(#settings_form, SelfInfo);
  323.         DrawFlatButton(settings_form.cwidth - 70 - 13, settings_form.cheight - 34, 70, 22, 10, 0xE4DFE1, BTN_CLOSE);
  324.         DrawFlatButton(settings_form.cwidth - 150 - 13, settings_form.cheight - 34, 70, 22, 11, 0xE4DFE1, BTN_APPLY);
  325.         DrawBar(10, 10, 32, 32, 0xFFFfff);
  326.        
  327.         WriteText(10, 50, 0x80, 0x000000, PR_T_DEST);
  328.         edit_box_draw stdcall (#path_to_file_ed);
  329.  
  330.         WriteText(10, 65, 0x80, 0x000000, PR_T_SIZE);
  331.        
  332.         if (selected_count)
  333.         {
  334.                 Put_icon('', 18, 19, 0xFFFfff, 0);
  335.                 sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
  336.                 WriteText(50, 23, 0x80, 0x000000, #folder_info);
  337.                 sprintf(#element_size_label,"%s (%d %s)",ConvertSize(size_dir),size_dir,SET_BYTE_LANG);
  338.                 WriteText(100, 65, 0x80, 0x000000, #element_size_label);
  339.         }
  340.         else
  341.         {
  342.                 if ( file_info_general.isfolder )
  343.                                 Put_icon("<DIR>", 18, 19, 0xFFFfff, 0);
  344.                 else
  345.                                 Put_icon(#file_name2+strrchr(#file_name2,'.'), 18, 19, 0xFFFfff, 0);
  346.  
  347.                 WriteText(50, 13, 0x80, 0x000000, PR_T_NAME);                          
  348.                 edit_box_draw stdcall (#file_name_ed);
  349.                
  350.                 if (!itdir) element_size = file_info_general.sizelo;
  351.                 else
  352.                 {
  353.                         WriteText(10, 80, 0x80, 0x000000, PR_T_CONTAINS);                              
  354.                         sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
  355.                         WriteText(100, 80, 0x80, 0x000000, #folder_info);
  356.                         element_size = size_dir;
  357.                 }
  358.                 WriteTextLines(10,  95, 0x80, 0x000000, CREATED_OPENED_MODIFIED, 15);
  359.                 DrawDate(100,  95, 0, #file_info_general.datecreate);
  360.         DrawDate(100, 110, 0, #file_info_general.datelastaccess);
  361.         DrawDate(100, 125, 0, #file_info_general.datelastedit);
  362.  
  363.                 sprintf(#element_size_label,"%s (%d %s)",ConvertSize(element_size),element_size,SET_BYTE_LANG);
  364.                 WriteText(100, 65, 0x80, 0x000000, #element_size_label);
  365.         }
  366.         flags_frame.size_x = - flags_frame.start_x * 2 + settings_form.cwidth - 2;
  367.         flags_frame.font_color = system.color.work_text;
  368.         flags_frame.ext_col = system.color.work_graph;
  369.         frame_draw stdcall (#flags_frame);
  370.         DrawPropertiesCheckBoxes();
  371. }
  372.  
  373. void DrawPropertiesCheckBoxes()
  374. {
  375.         CheckBox2(22, flags_frame.start_y + 14, 20, PR_T_ONLY_READ, atr_readonly);
  376.         CheckBox2(22, flags_frame.start_y + 36, 21, PR_T_HIDDEN, atr_hidden);
  377.         CheckBox2(22, flags_frame.start_y + 58, 22, PR_T_SYSTEM, atr_system);
  378. }