Subversion Repositories Kolibri OS

Rev

Rev 9693 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. char path_to_file[PATHLEN];
  3. char file_name2[PATHLEN];
  4. edit_box file_name_ed = {230,59,32,0xffffff,0x94AECE,0xFFFfff,0xffffff,0x10000000,sizeof(file_name2)-2,#file_name2,NULL, 0b,2,2};
  5. edit_box path_to_file_ed = {160,120,79,0xffffff,0x94AECE,0xFFFfff,0xffffff,2,sizeof(path_to_file)-2,#path_to_file,NULL, 0b,2,2};
  6.  
  7. BDVK file_info_general;
  8. BDVK file_info_dirsize;
  9.  
  10. bool apply_question_active;
  11.  
  12. DIR_SIZE more_files_count;
  13. DIR_SIZE dir_size;
  14.  
  15. checkbox ch_read_only = { PR_T_ONLY_READ, NULL };
  16. checkbox ch_hidden = { PR_T_HIDDEN, NULL };
  17. checkbox ch_system = { PR_T_SYSTEM, NULL };
  18.  
  19. void SetPropertiesFile(dword cur_file, bdvk_pointer)
  20. {
  21.         GetFileInfo(cur_file, bdvk_pointer);
  22.         ESI = bdvk_pointer;
  23.         ESI.BDVK.readonly = ch_read_only.checked;
  24.         ESI.BDVK.hidden = ch_hidden.checked;
  25.         ESI.BDVK.system = ch_system.checked;
  26.         SetFileInfo(cur_file, bdvk_pointer);
  27. }
  28.  
  29. void SetPropertiesDir(dword way)
  30. {
  31.         dword dirbuf, fcount, i, filename;
  32.         dword cur_file;
  33.         if (dir_exists(way))
  34.         {
  35.                 cur_file = malloc(PATHLEN);
  36.                 GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
  37.                 for (i=0; i<fcount; i++)
  38.                 {
  39.                         filename = i*304+dirbuf+72;
  40.                         sprintf(cur_file, "%s/%s", way, filename);
  41.                         if ( ESDWORD[filename-40] & ATR_FOLDER )
  42.                         {
  43.                                 SetPropertiesDir(cur_file);
  44.                         }
  45.                         SetPropertiesFile(cur_file, #file_info_dirsize);
  46.                 }
  47.                 free(cur_file);
  48.         }
  49. }
  50.  
  51. #define SET_PROPERTIES_SINGLE_FILE 0
  52. #define SET_PROPERTIES_NO_SUBFOLDER 1
  53. #define SET_PROPERTIES_ALL_SUBFOLDER 2
  54. void SetProperties(int mode)
  55. {
  56.         char pcur_file[4096];
  57.         dword i;
  58.  
  59.         apply_question_active = false;
  60.  
  61.         if (SET_PROPERTIES_SINGLE_FILE == mode) {
  62.                 SetPropertiesFile(#file_path, #file_info_general);
  63.         }
  64.  
  65.         if (SET_PROPERTIES_ALL_SUBFOLDER == mode)
  66.         || (SET_PROPERTIES_NO_SUBFOLDER == mode)
  67.         {
  68.                 if (getSelectedCount())
  69.                 {
  70.                         for (i=0; i<files.count; i++)
  71.                         {
  72.                                 if (getElementSelectedFlag(i) == true)
  73.                                 {
  74.                                         sprintf(#pcur_file,"%s/%s",path,items.get(i)*304+buf+72);
  75.                                         SetPropertiesFile(#pcur_file, #file_info_general);
  76.                                         if (SET_PROPERTIES_ALL_SUBFOLDER == mode) {
  77.                                                 if (dir_exists(#pcur_file)) SetPropertiesDir(#pcur_file);
  78.                                         }
  79.                                 }
  80.                         }
  81.                 }
  82.                 else
  83.                 {
  84.                         SetPropertiesFile(#file_path, #file_info_general);
  85.                         if (SET_PROPERTIES_ALL_SUBFOLDER == mode) SetPropertiesDir(#file_path);
  86.                 }
  87.         }
  88.  
  89.         cmd_free=3;
  90.         OpenDir(ONLY_OPEN);
  91.         ExitProcess();
  92. }
  93.  
  94. void ShowConfirmQuestionPopin()
  95. {
  96.         apply_question_active = true;
  97.         DrawPopup(15,80,250,90,1,sc.work, sc.line);
  98.         WriteText(35, 102, 0x90, 0x000000, QUEST_1);
  99.         WriteText(65, 117, 0x90, 0x000000, QUEST_2);
  100.         DrawStandartCaptButton(62,138,B_SETINGS_APPLY_SUBFOLDER,T_YES);
  101.         DrawStandartCaptButton(155,138,B_SETINGS_APPLY_NO_SUBFOLDER,T_NO);
  102. }
  103.  
  104. void GetSizeMoreFiles(dword way)
  105. {
  106.         char cur_file[4096];
  107.         dword i;
  108.        
  109.         for (i=0; i<files.count; i++)
  110.         {
  111.                 if (getElementSelectedFlag(i) == true)
  112.                 {
  113.                         sprintf(#cur_file,"%s/%s",way,items.get(i)*304+buf+72);
  114.                         if (ESDWORD[items.get(i)*304+buf+32] & ATR_FOLDER )
  115.                         {
  116.                                 more_files_count.calculate_loop(#cur_file);
  117.                                 more_files_count.folders++;
  118.                         }
  119.                         else
  120.                         {
  121.                                 GetFileInfo(#cur_file, #file_info_dirsize);
  122.                                 more_files_count.sizelo += file_info_dirsize.sizelo;
  123.                                 more_files_count.sizehi += file_info_dirsize.sizehi;
  124.                                 more_files_count.files++;
  125.                         }
  126.                 }
  127.         }  
  128. }
  129.  
  130. void properties_dialog()
  131. {
  132.         int id;
  133.        
  134.         if (getSelectedCount())
  135.         {
  136.                 more_files_count.get(NULL);
  137.                 GetSizeMoreFiles(path);
  138.                 ch_read_only.checked = 0;
  139.                 ch_hidden.checked = 0;
  140.                 ch_system.checked = 0;
  141.         }
  142.         else
  143.         {
  144.                 GetFileInfo(#file_path, #file_info_general);
  145.                 edit_box_set_text stdcall (#file_name_ed, #file_name);
  146.                 if(itdir) dir_size.get(#file_path);
  147.                 ch_read_only.checked = file_info_general.readonly;
  148.                 ch_hidden.checked = file_info_general.hidden;
  149.                 ch_system.checked = file_info_general.system;
  150.         }
  151.         edit_box_set_text stdcall (#path_to_file_ed, path);
  152.        
  153.         SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
  154.         loop() switch(WaitEvent())
  155.         {
  156.                 case evButton:
  157.                                 id=GetButtonID();
  158.                                 ch_read_only.click(id);
  159.                                 ch_hidden.click(id);
  160.                                 ch_system.click(id);
  161.                                 if (apply_question_active)
  162.                                 {
  163.                                         IF (id==B_SETINGS_APPLY_SUBFOLDER)
  164.                                                 SetProperties(SET_PROPERTIES_ALL_SUBFOLDER);
  165.                                         IF (id==B_SETINGS_APPLY_NO_SUBFOLDER)
  166.                                                 SetProperties(SET_PROPERTIES_NO_SUBFOLDER);
  167.                                         break;
  168.                                 }
  169.                                 if (id==1) || (id==B_CLOSE)
  170.                                 {
  171.                                         cmd_free=3;
  172.                                         ExitProcess();
  173.                                 }
  174.                                 if (id==B_APPLY) goto _APPLY_PROPERTIES;
  175.                                 break;
  176.                                
  177.                 case evMouse:
  178.                                 edit_box_mouse stdcall (#file_name_ed);
  179.                                 edit_box_mouse stdcall (#path_to_file_ed);
  180.                                 break;
  181.                        
  182.                 case evKey:
  183.                                 GetKeys();
  184.  
  185.                                 if (apply_question_active)
  186.                                 {
  187.                                         IF (key_scancode==SCAN_CODE_ENTER)
  188.                                                 SetProperties(SET_PROPERTIES_ALL_SUBFOLDER);
  189.                                         IF (key_scancode==SCAN_CODE_ESC)
  190.                                                 SetProperties(SET_PROPERTIES_NO_SUBFOLDER);
  191.                                         break;
  192.                                 }
  193.  
  194.                                 switch(key_scancode)
  195.                                 {
  196.                                         case SCAN_CODE_ESC:
  197.                                                 cmd_free=3;
  198.                                                 ExitProcess();
  199.                                                 break;
  200.  
  201.                                         case SCAN_CODE_ENTER:
  202.                                                 _APPLY_PROPERTIES:
  203.                                                 if (getSelectedCount()) || (itdir) {
  204.                                                         ShowConfirmQuestionPopin();
  205.                                                 } else {
  206.                                                         SetProperties(SET_PROPERTIES_SINGLE_FILE);
  207.                                                 }
  208.                                                 break;
  209.  
  210.                                         case SCAN_CODE_KEY_A:
  211.                                         case SCAN_CODE_KEY_C:
  212.                                                 if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
  213.                                                         edit_box_key_c stdcall(#file_name_ed,key_editbox);
  214.                                                         edit_box_key_c stdcall(#path_to_file_ed,key_editbox);
  215.                                                 }
  216.                                 }
  217.                                 break;
  218.                                
  219.                 case evReDraw:
  220.                                 DrawPropertiesWindow();
  221.         }
  222. }
  223.  
  224. void DrawPropertiesWindow()
  225. {
  226.         proc_info pform;
  227.         dword ext1;
  228.         incn y;
  229.         char temp_path[PATHLEN];
  230.         bool show_date = false;
  231.  
  232.         dword p_t_formated_size;
  233.         dword p_q_size_bytes;
  234.         dword t_contains_files_and_folders[200];
  235.  
  236.         if (chrnum(path, '/')>1) || (streq(path, "/kolibrios")) || (streq(path, "/sys")) show_date = true;
  237.         if (getSelectedCount()) show_date = false;
  238.  
  239.         DefineAndDrawWindow(Form.left + 150,150,315,show_date*60+342+skin_h,0x34,sc.work,WINDOW_TITLE_PROPERTIES,0);
  240.         GetProcessInfo(#pform, SelfInfo);
  241.  
  242.         DrawStandartCaptButton(pform.cwidth - 96, pform.cheight-34, B_CLOSE, T_CLOSE);
  243.         DrawStandartCaptButton(pform.cwidth -208, pform.cheight-34, B_APPLY, T_APPLY);
  244.        
  245.         if (getSelectedCount())
  246.         {
  247.                 PropertiesDrawIcon(NULL, "<lot>");
  248.                 WriteText(file_name_ed.left+4, 30, 0x90, sc.work_text, T_BULK_SELECTION);
  249.                 p_t_formated_size = ConvertSize64(more_files_count.sizelo, more_files_count.sizehi);
  250.                 p_q_size_bytes = #more_files_count.sizelo;
  251.                 sprintf(#t_contains_files_and_folders,T_FILES_FOLDERS,more_files_count.files,more_files_count.folders);
  252.         } else {
  253.                 WriteText(file_name_ed.left, file_name_ed.top-15, 0x80, sc.work_text, T_NAME);
  254.                 DrawEditBox(#file_name_ed);
  255.                 if (itdir) {
  256.                         PropertiesDrawIcon(NULL, "<DIR>");
  257.                         p_t_formated_size = ConvertSize64(dir_size.sizelo, dir_size.sizehi);
  258.                         p_q_size_bytes = #dir_size.sizelo;
  259.                         sprintf(#t_contains_files_and_folders,T_FILES_FOLDERS,dir_size.files,dir_size.folders);
  260.                 } else {
  261.                         sprintf(#temp_path,"%s/%s",path,#file_name2);
  262.                         if (ext1 = strrchr(#file_name2,'.')) ext1 += #file_name2;
  263.                         PropertiesDrawIcon(#temp_path, ext1);
  264.                         p_t_formated_size = ConvertSize64(file_info_general.sizelo, file_info_general.sizehi);
  265.                         p_q_size_bytes = #file_info_general.sizelo;
  266.                         sprintf(#t_contains_files_and_folders,T_DATA);
  267.                 }      
  268.         }
  269.         WriteTextLines(10, y.set(78), 0x90, sc.work_text, T_PATH_SIZE, 20);
  270.         edit_box_draw stdcall (#path_to_file_ed);
  271.  
  272.         WriteText(120, y.inc(20), 0x90, sc.work_text, p_t_formated_size);
  273.         WriteNumber(120, y.inc(20), 0x90, sc.work_text, 0xc0140001, p_q_size_bytes);
  274.         WriteText(120, y.inc(20), 0x90, sc.work_text, #t_contains_files_and_folders);
  275.  
  276.         if (show_date) {
  277.                 WriteTextLines(10, y.inc(32), 0x90, sc.work_text, CREATED_OPENED_MODIFIED, 20);
  278.                 DrawDateTime(120, y.n, sc.work_text, #file_info_general.datecreate, #file_info_general.timecreate);
  279.                 DrawDateTime(120, y.inc(20), sc.work_text, #file_info_general.datelastaccess, #file_info_general.timelastaccess);
  280.                 DrawDateTime(120, y.inc(20), sc.work_text, #file_info_general.datelastedit, #file_info_general.timelastedit);                  
  281.         }
  282.  
  283.         DrawFrame(10, y.set(pform.cheight - 143), -10*2 + pform.cwidth - 2, 92, FLAGS);
  284.         ch_read_only.draw(24, y.inc(18));
  285.         ch_hidden.draw(24, y.inc(24));
  286.         ch_system.draw(24, y.inc(24));
  287.         if (apply_question_active) ShowConfirmQuestionPopin();
  288. }
  289.  
  290. void PropertiesDrawIcon(dword file_path, extension)
  291. {
  292.         int icon_n = ini_icons.get(file_path, extension, 32);
  293.         draw_icon_32(12, 22, sc.work, icon_n);
  294. }
  295.