Subversion Repositories Kolibri OS

Rev

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