Subversion Repositories Kolibri OS

Rev

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