Subversion Repositories Kolibri OS

Rev

Rev 7220 | Rev 7244 | 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_2;
  40. char path_to_file[4096];
  41. char file_name2[4096];
  42. edit_box file_name_ed = {230,59,32,0xffffff,0x94AECE,0xFFFfff,0xffffff,0x10000000,sizeof(file_name2),#file_name2,#mouse_2, 1000000000000000b,2,2};
  43. edit_box path_to_file_ed = {160,120,79,0xffffff,0x94AECE,0xFFFfff,0xffffff,2,sizeof(path_to_file),#path_to_file,#mouse_2, 1000000000000000b,2,2};
  44.  
  45. int file_count, dir_count, size_dir;
  46. char folder_info[200];
  47. dword element_size;
  48. char element_size_label[32];
  49. BDVK file_info_general;
  50. BDVK file_info_dirsize;
  51.  
  52. proc_info settings_form;
  53. bool quest_active, atr_readonly, atr_hidden, atr_system;
  54.  
  55. void SetPropertiesDir(dword way)
  56. {
  57.         dword dirbuf, fcount, i, filename;
  58.         dword cur_file;
  59.         if (dir_exists(way))
  60.         {
  61.                 cur_file = malloc(4096);
  62.                 GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
  63.                 for (i=0; i<fcount; i++)
  64.                 {
  65.                         filename = i*304+dirbuf+72;
  66.                         strcpy(cur_file, way);
  67.                         chrcat(cur_file, '/');
  68.                         strcat(cur_file, filename);
  69.                         if ( TestBit(ESDWORD[filename-40], 4) )
  70.                         {
  71.                                 SetPropertiesDir(cur_file);
  72.                         }
  73.                         GetFileInfo(cur_file, #file_info_dirsize);
  74.                         file_info_dirsize.readonly = atr_readonly;
  75.                         file_info_dirsize.hidden = atr_hidden;
  76.                         file_info_dirsize.system = atr_system;
  77.                         SetFileInfo(cur_file, #file_info_dirsize);
  78.                 }
  79.                 free(cur_file);
  80.         }
  81. }
  82.  
  83. void SetProperties(byte prop)
  84. {
  85.         dword cur_file;
  86.  
  87.         if (prop==1) || (prop==2)
  88.         {
  89.                 if (selected_count)
  90.                 {
  91.                         cur_file = malloc(4096);
  92.                         for (i=0; i<files.count; i++)
  93.                         {
  94.                                 if (getElementSelectedFlag(i) == true)
  95.                                 {
  96.                                         strcpy(cur_file, #path);
  97.                                         strcat(cur_file, file_mas[i]*304+buf+72);
  98.                                         GetFileInfo(cur_file, #file_info_general);
  99.                                         file_info_general.readonly = atr_readonly;
  100.                                         file_info_general.hidden = atr_hidden;
  101.                                         file_info_general.system = atr_system;
  102.                                         SetFileInfo(cur_file, #file_info_general);
  103.                                         if (prop==2)
  104.                                         {
  105.                                                 if (dir_exists(cur_file))
  106.                                                 {
  107.                                                         SetPropertiesDir(cur_file);
  108.                                                 }
  109.                                         }
  110.                                 }
  111.                         }
  112.                         free(cur_file);
  113.                 }
  114.                 else
  115.                 {
  116.                         GetFileInfo(#file_path, #file_info_general);
  117.                         file_info_general.readonly = atr_readonly;
  118.                         file_info_general.hidden = atr_hidden;
  119.                         file_info_general.system = atr_system;
  120.                         SetFileInfo(#file_path, #file_info_general);
  121.                         if (prop==2) SetPropertiesDir(#file_path);
  122.                 }
  123.                 quest_active = 0;
  124.                 DrawPropertiesWindow();
  125.         }
  126.         else
  127.         {
  128.                 GetFileInfo(#file_path, #file_info_general);
  129.                 file_info_general.readonly = atr_readonly;
  130.                 file_info_general.hidden = atr_hidden;
  131.                 file_info_general.system = atr_system;
  132.                 SetFileInfo(#file_path, #file_info_general);
  133.         }
  134.         cmd_free=3;
  135.         _not_draw = true;
  136.         Open_Dir(#path,WITH_REDRAW);
  137.         _not_draw = false;
  138.         EventRedrawWindow(Form.left,Form.top);
  139.         ExitProcess();
  140. }
  141.  
  142. void ShowConfirmQuestionPopin()
  143. {
  144.         quest_active = 1;
  145.         DrawPopup(15,80,250,90,1,system.color.work, system.color.work_graph);
  146.         WriteText(35, 102, 0x90, 0x000000, QUEST_1);
  147.         WriteText(65, 117, 0x90, 0x000000, QUEST_2);
  148.         DrawFlatButton(62,138,301,T_YES);
  149.         DrawFlatButton(155,138,302,T_NO);
  150. }
  151.  
  152. void GetSizeDir(dword way)
  153. {
  154.         dword dirbuf, fcount, i, filename;
  155.         dword cur_file;
  156.         if (dir_exists(way))
  157.         {
  158.                 cur_file = malloc(4096);
  159.                 // In the process of recursive descent, memory must be allocated dynamically,
  160.                 // because the static memory -> was a bug !!! But unfortunately pass away to sacrifice speed.
  161.                 GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
  162.                 for (i=0; i<fcount; i++)
  163.                 {
  164.                         filename = i*304+dirbuf+72;
  165.                         sprintf(cur_file,"%s/%s",way,filename);
  166.                        
  167.                         if (TestBit(ESDWORD[filename-40], 4) )
  168.                         {
  169.                                 dir_count++;
  170.                                 GetSizeDir(cur_file);
  171.                         }
  172.                         else
  173.                         {
  174.                                 GetFileInfo(cur_file, #file_info_dirsize);
  175.                                 size_dir += file_info_dirsize.sizelo;
  176.                                 file_count++;
  177.                         }
  178.                 }
  179.                 free(cur_file);
  180.         }
  181. }
  182.  
  183. void GetSizeMoreFiles(dword way)
  184. {
  185.         char cur_file[4096];
  186.        
  187.         for (i=0; i<files.count; i++)
  188.         {
  189.                 if (getElementSelectedFlag(i) == true)
  190.                 {
  191.                         sprintf(#cur_file,"%s/%s",way,file_mas[i]*304+buf+72);
  192.                         if (TestBit(ESDWORD[file_mas[i]*304+buf+32], 4) )
  193.                         {
  194.                                 GetSizeDir(#cur_file);
  195.                                 dir_count++;
  196.                         }
  197.                         else
  198.                         {
  199.                                 GetFileInfo(#cur_file, #file_info_dirsize);
  200.                                 size_dir += file_info_dirsize.sizelo;
  201.                                 file_count++;
  202.                         }
  203.                 }
  204.         }  
  205. }
  206.  
  207. void properties_dialog()
  208. {
  209.         byte id;
  210.        
  211.         DSBYTE[#folder_info]=0;
  212.         file_count = 0;
  213.         dir_count = 0; 
  214.         size_dir = 0;
  215.                        
  216.         if (selected_count)
  217.         {
  218.                 GetSizeMoreFiles(#path);
  219.                 atr_readonly = 0;
  220.                 atr_hidden = 0;
  221.                 atr_system = 0;
  222.         }
  223.         else
  224.         {
  225.                 GetFileInfo(#file_path, #file_info_general);
  226.                 strcpy(#file_name2, #file_name);
  227.                 file_name_ed.size = strlen(#file_name2);  
  228.                 if(itdir) GetSizeDir(#file_path);
  229.                 atr_readonly = file_info_general.readonly;
  230.                 atr_hidden = file_info_general.hidden;
  231.                 atr_system = file_info_general.system;
  232.         }
  233.         strcpy(#path_to_file, #path);
  234.         path_to_file_ed.size = strlen(#path_to_file);
  235.        
  236.         SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
  237.         loop() switch(WaitEvent())
  238.         {
  239.                 case evButton:
  240.                                 id=GetButtonID();
  241.                                 if (quest_active)
  242.                                 {
  243.                                         IF (id==301) SetProperties(2);
  244.                                         IF (id==302) SetProperties(1);
  245.                                         quest_active=false;
  246.                                         break;
  247.                                 }
  248.                                 if (id==1) || (id==10)
  249.                                 {
  250.                                         cmd_free=3;
  251.                                         ExitProcess();
  252.                                 }
  253.                                 IF (id==11)
  254.                                 {
  255.                                         if (selected_count) || (itdir)
  256.                                         {
  257.                                                 ShowConfirmQuestionPopin();
  258.                                         }
  259.                                         else
  260.                                         {
  261.                                                 SetProperties(0);
  262.                                         }
  263.                                         break;
  264.                                 }
  265.                                 if (id==20)
  266.                                 {
  267.                                         atr_readonly ^= 1;
  268.                                         DrawPropertiesCheckBoxes();
  269.                                 }
  270.                                 if (id==21)
  271.                                 {
  272.                                         atr_hidden ^= 1;
  273.                                         DrawPropertiesCheckBoxes();
  274.                                 }
  275.                                 if (id==22)
  276.                                 {
  277.                                         atr_system ^= 1;
  278.                                         DrawPropertiesCheckBoxes();
  279.                                 }
  280.                                 break;
  281.                                
  282.                 case evMouse:
  283.                                 edit_box_mouse stdcall (#file_name_ed);
  284.                                 edit_box_mouse stdcall (#path_to_file_ed);
  285.                                 break;
  286.                        
  287.                 case evKey:
  288.                                 GetKeys();
  289.                                
  290.                                 if (quest_active)
  291.                                 {
  292.                                         IF (key_scancode==SCAN_CODE_ENTER) SetProperties(2);
  293.                                         IF (key_scancode==SCAN_CODE_ESC) SetProperties(1);
  294.                                         quest_active=false;
  295.                                         break;
  296.                                 }
  297.                                 if (key_scancode==SCAN_CODE_ESC)
  298.                                 {
  299.                                         cmd_free=3;
  300.                                         ExitProcess();
  301.                                 }
  302.                                 if (key_scancode==SCAN_CODE_ENTER)
  303.                                 {
  304.                                         if (selected_count) || (itdir)
  305.                                         {
  306.                                                 ShowConfirmQuestionPopin();
  307.                                         }
  308.                                         else
  309.                                         {
  310.                                                 SetProperties(0);
  311.                                         }
  312.                                         break;
  313.                                 }
  314.                                 edit_box_key stdcall(#file_name_ed);
  315.                                 edit_box_key stdcall(#path_to_file_ed);
  316.                                 break;
  317.                                
  318.                 case evReDraw:
  319.                                 DrawPropertiesWindow();
  320.         }
  321. }
  322.  
  323. void DrawPropertiesWindow()
  324. {
  325.         dword ext1;
  326.         char temp_path[sizeof(file_path)];
  327.         DefineAndDrawWindow(Form.left + 150,150,315,360+skin_height,0x34,system.color.work,WINDOW_TITLE_PROPERTIES,0);
  328.         GetProcessInfo(#settings_form, SelfInfo);
  329.  
  330.         DrawFlatButton(settings_form.cwidth - 96, settings_form.cheight-34, 10, BTN_CLOSE);
  331.         DrawFlatButton(settings_form.cwidth -208, settings_form.cheight-34, 11, BTN_APPLY);
  332.        
  333.         WriteText(10, 78, 0x90, system.color.work_text, PR_T_DEST);
  334.         edit_box_draw stdcall (#path_to_file_ed);
  335.  
  336.         WriteText(10, 97, 0x90, system.color.work_text, PR_T_SIZE);
  337.        
  338.         if (selected_count)
  339.         {
  340.                 PropertiesDrawIcon(NULL, "<lot>");
  341.                 sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
  342.                 WriteText(file_name_ed.left+4, 30, 0x90, system.color.work_text, #folder_info);
  343.                 sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(size_dir, NULL),size_dir,SET_BYTE_LANG);
  344.                 WriteText(120, 97, 0x90, system.color.work_text, #element_size_label);
  345.         }
  346.         else
  347.         {
  348.                 if ( file_info_general.isfolder )
  349.                                 PropertiesDrawIcon(NULL, "<DIR>");
  350.                 else {
  351.                         sprintf(#temp_path,"%s/%s",#path,#file_name2);
  352.                         ext1 = strrchr(#file_name2,'.');
  353.                         if (ext1) ext1 += #file_name2;
  354.                         PropertiesDrawIcon(#temp_path, ext1);
  355.                 }
  356.                 WriteText(file_name_ed.left, file_name_ed.top-15, 0x80, system.color.work_text, PR_T_NAME);
  357.                 DrawEditBox(#file_name_ed);
  358.                
  359.                 if (!itdir) element_size = file_info_general.sizelo;
  360.                 else
  361.                 {
  362.                         WriteText(10,116, 0x90, system.color.work_text, PR_T_CONTAINS);                              
  363.                         sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
  364.                         WriteText(120, 116, 0x90, system.color.work_text, #folder_info);
  365.                         element_size = size_dir;
  366.                 }
  367.                 WriteTextLines(10,  136, 0x90, system.color.work_text, CREATED_OPENED_MODIFIED, 20);
  368.                 DrawDate(120,  136, system.color.work_text, #file_info_general.datecreate);
  369.                 DrawDate(120, 156, system.color.work_text, #file_info_general.datelastaccess);
  370.                 DrawDate(120, 176, system.color.work_text, #file_info_general.datelastedit);
  371.  
  372.                 sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(element_size, NULL),element_size,SET_BYTE_LANG);
  373.                 WriteText(120, 99, 0x90, system.color.work_text, #element_size_label);
  374.         }
  375.         DrawFrame(10, 212, -10*2 + settings_form.cwidth - 2, 92, FLAGS);
  376.         DrawPropertiesCheckBoxes();
  377. }
  378.  
  379. void PropertiesDrawIcon(dword file_path, extension)
  380. {
  381.         #define ICON_PADDING 11
  382.         DrawBar(20-ICON_PADDING, 30-ICON_PADDING-1, ICON_PADDING*2+16, ICON_PADDING*2+16, 0xFFFfff);
  383.         DrawIconByExtension(file_path, extension, 20, 30, system.color.work_light);
  384. }
  385.  
  386. void DrawPropertiesCheckBoxes()
  387. {
  388.         incn y;
  389.         y.n = 212; //212 => attributes_frame.y
  390.         CheckBox(24, y.inc(18), 20, PR_T_ONLY_READ, atr_readonly);
  391.         CheckBox(24, y.inc(24), 21, PR_T_HIDDEN, atr_hidden);
  392.         CheckBox(24, y.inc(24), 22, PR_T_SYSTEM, atr_system);
  393. }
  394.