Subversion Repositories Kolibri OS

Rev

Rev 7244 | Rev 7362 | 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.         }
  179. }
  180.  
  181. void GetSizeMoreFiles(dword way)
  182. {
  183.         char cur_file[4096];
  184.        
  185.         for (i=0; i<files.count; i++)
  186.         {
  187.                 if (getElementSelectedFlag(i) == true)
  188.                 {
  189.                         sprintf(#cur_file,"%s/%s",way,file_mas[i]*304+buf+72);
  190.                         if (TestBit(ESDWORD[file_mas[i]*304+buf+32], 4) )
  191.                         {
  192.                                 GetSizeDir(#cur_file);
  193.                                 dir_count++;
  194.                         }
  195.                         else
  196.                         {
  197.                                 GetFileInfo(#cur_file, #file_info_dirsize);
  198.                                 size_dir += file_info_dirsize.sizelo;
  199.                                 file_count++;
  200.                         }
  201.                 }
  202.         }  
  203. }
  204.  
  205. void properties_dialog()
  206. {
  207.         int id;
  208.        
  209.         DSBYTE[#folder_info]=0;
  210.         file_count = 0;
  211.         dir_count = 0; 
  212.         size_dir = 0;
  213.                        
  214.         if (selected_count)
  215.         {
  216.                 GetSizeMoreFiles(#path);
  217.                 ch_read_only.checked = 0;
  218.                 ch_hidden.checked = 0;
  219.                 ch_system.checked = 0;
  220.         }
  221.         else
  222.         {
  223.                 GetFileInfo(#file_path, #file_info_general);
  224.                 strcpy(#file_name2, #file_name);
  225.                 file_name_ed.size = strlen(#file_name2);  
  226.                 if(itdir) GetSizeDir(#file_path);
  227.                 ch_read_only.checked = file_info_general.readonly;
  228.                 ch_hidden.checked = file_info_general.hidden;
  229.                 ch_system.checked = file_info_general.system;
  230.         }
  231.         strcpy(#path_to_file, #path);
  232.         path_to_file_ed.size = strlen(#path_to_file);
  233.        
  234.         SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
  235.         loop() switch(WaitEvent())
  236.         {
  237.                 case evButton:
  238.                                 id=GetButtonID();
  239.                                 ch_read_only.click(id);
  240.                                 ch_hidden.click(id);
  241.                                 ch_system.click(id);
  242.                                 if (quest_active)
  243.                                 {
  244.                                         IF (id==301) SetProperties(2);
  245.                                         IF (id==302) SetProperties(1);
  246.                                         quest_active=false;
  247.                                         break;
  248.                                 }
  249.                                 if (id==1) || (id==10)
  250.                                 {
  251.                                         cmd_free=3;
  252.                                         ExitProcess();
  253.                                 }
  254.                                 IF (id==11)
  255.                                 {
  256.                                         if (selected_count) || (itdir)
  257.                                         {
  258.                                                 ShowConfirmQuestionPopin();
  259.                                         }
  260.                                         else
  261.                                         {
  262.                                                 SetProperties(0);
  263.                                         }
  264.                                         break;
  265.                                 }
  266.                                 break;
  267.                                
  268.                 case evMouse:
  269.                                 edit_box_mouse stdcall (#file_name_ed);
  270.                                 edit_box_mouse stdcall (#path_to_file_ed);
  271.                                 break;
  272.                        
  273.                 case evKey:
  274.                                 GetKeys();
  275.                                
  276.                                 if (quest_active)
  277.                                 {
  278.                                         IF (key_scancode==SCAN_CODE_ENTER) SetProperties(2);
  279.                                         IF (key_scancode==SCAN_CODE_ESC) SetProperties(1);
  280.                                         quest_active=false;
  281.                                         break;
  282.                                 }
  283.                                 if (key_scancode==SCAN_CODE_ESC)
  284.                                 {
  285.                                         cmd_free=3;
  286.                                         ExitProcess();
  287.                                 }
  288.                                 if (key_scancode==SCAN_CODE_ENTER)
  289.                                 {
  290.                                         if (selected_count) || (itdir)
  291.                                         {
  292.                                                 ShowConfirmQuestionPopin();
  293.                                         }
  294.                                         else
  295.                                         {
  296.                                                 SetProperties(0);
  297.                                         }
  298.                                         break;
  299.                                 }
  300.                                 edit_box_key stdcall(#file_name_ed);
  301.                                 edit_box_key stdcall(#path_to_file_ed);
  302.                                 break;
  303.                                
  304.                 case evReDraw:
  305.                                 DrawPropertiesWindow();
  306.         }
  307. }
  308.  
  309. void DrawPropertiesWindow()
  310. {
  311.         dword ext1;
  312.         incn y;
  313.         char temp_path[sizeof(file_path)];
  314.         DefineAndDrawWindow(Form.left + 150,150,315,360+skin_height,0x34,system.color.work,WINDOW_TITLE_PROPERTIES,0);
  315.         GetProcessInfo(#settings_form, SelfInfo);
  316.  
  317.         DrawStandartCaptButton(settings_form.cwidth - 96, settings_form.cheight-34, 10, BTN_CLOSE);
  318.         DrawStandartCaptButton(settings_form.cwidth -208, settings_form.cheight-34, 11, BTN_APPLY);
  319.        
  320.         WriteText(10, 78, 0x90, system.color.work_text, PR_T_DEST);
  321.         edit_box_draw stdcall (#path_to_file_ed);
  322.  
  323.         WriteText(10, 97, 0x90, system.color.work_text, PR_T_SIZE);
  324.        
  325.         if (selected_count)
  326.         {
  327.                 PropertiesDrawIcon(NULL, "<lot>");
  328.                 sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
  329.                 WriteText(file_name_ed.left+4, 30, 0x90, system.color.work_text, #folder_info);
  330.                 sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(size_dir, NULL),size_dir,SET_BYTE_LANG);
  331.                 WriteText(120, 97, 0x90, system.color.work_text, #element_size_label);
  332.         }
  333.         else
  334.         {
  335.                 if ( file_info_general.isfolder )
  336.                                 PropertiesDrawIcon(NULL, "<DIR>");
  337.                 else {
  338.                         sprintf(#temp_path,"%s/%s",#path,#file_name2);
  339.                         ext1 = strrchr(#file_name2,'.');
  340.                         if (ext1) ext1 += #file_name2;
  341.                         PropertiesDrawIcon(#temp_path, ext1);
  342.                 }
  343.                 WriteText(file_name_ed.left, file_name_ed.top-15, 0x80, system.color.work_text, PR_T_NAME);
  344.                 DrawEditBox(#file_name_ed);
  345.                
  346.                 if (!itdir) element_size = file_info_general.sizelo;
  347.                 else
  348.                 {
  349.                         WriteText(10,116, 0x90, system.color.work_text, PR_T_CONTAINS);                              
  350.                         sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
  351.                         WriteText(120, 116, 0x90, system.color.work_text, #folder_info);
  352.                         element_size = size_dir;
  353.                 }
  354.                 WriteTextLines(10,  136, 0x90, system.color.work_text, CREATED_OPENED_MODIFIED, 20);
  355.                 DrawDate(120,  136, system.color.work_text, #file_info_general.datecreate);
  356.                 DrawDate(120, 156, system.color.work_text, #file_info_general.datelastaccess);
  357.                 DrawDate(120, 176, system.color.work_text, #file_info_general.datelastedit);
  358.  
  359.                 sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(element_size, NULL),element_size,SET_BYTE_LANG);
  360.                 WriteText(120, 99, 0x90, system.color.work_text, #element_size_label);
  361.         }
  362.         DrawFrame(10, 212, -10*2 + settings_form.cwidth - 2, 92, FLAGS);
  363.         y.n = 212; //212 => attributes_frame.y
  364.         ch_read_only.draw(24, y.inc(18));
  365.         ch_hidden.draw(24, y.inc(24));
  366.         ch_system.draw(24, y.inc(24));
  367. }
  368.  
  369. void PropertiesDrawIcon(dword file_path, extension)
  370. {
  371.         #define ICON_PADDING 11
  372.         DrawBar(20-ICON_PADDING, 30-ICON_PADDING-1, ICON_PADDING*2+16, ICON_PADDING*2+16, 0xFFFfff);
  373.         DrawIconByExtension(file_path, extension, 20, 30, system.color.work_light);
  374. }
  375.