Subversion Repositories Kolibri OS

Rev

Rev 9580 | Rev 9602 | Go to most recent revision | 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.work_graph);
  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.bytes += file_info_dirsize.sizelo;
  123.                                 more_files_count.files++;
  124.                         }
  125.                 }
  126.         }  
  127. }
  128.  
  129. void properties_dialog()
  130. {
  131.         int id;
  132.        
  133.         if (getSelectedCount())
  134.         {
  135.                 more_files_count.get(NULL);
  136.                 GetSizeMoreFiles(path);
  137.                 ch_read_only.checked = 0;
  138.                 ch_hidden.checked = 0;
  139.                 ch_system.checked = 0;
  140.         }
  141.         else
  142.         {
  143.                 GetFileInfo(#file_path, #file_info_general);
  144.                 edit_box_set_text stdcall (#file_name_ed, #file_name);
  145.                 if(itdir) dir_size.get(#file_path);
  146.                 ch_read_only.checked = file_info_general.readonly;
  147.                 ch_hidden.checked = file_info_general.hidden;
  148.                 ch_system.checked = file_info_general.system;
  149.         }
  150.         edit_box_set_text stdcall (#path_to_file_ed, path);
  151.        
  152.         SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
  153.         loop() switch(WaitEvent())
  154.         {
  155.                 case evButton:
  156.                                 id=GetButtonID();
  157.                                 ch_read_only.click(id);
  158.                                 ch_hidden.click(id);
  159.                                 ch_system.click(id);
  160.                                 if (apply_question_active)
  161.                                 {
  162.                                         IF (id==B_SETINGS_APPLY_SUBFOLDER)
  163.                                                 SetProperties(SET_PROPERTIES_ALL_SUBFOLDER);
  164.                                         IF (id==B_SETINGS_APPLY_NO_SUBFOLDER)
  165.                                                 SetProperties(SET_PROPERTIES_NO_SUBFOLDER);
  166.                                         break;
  167.                                 }
  168.                                 if (id==1) || (id==B_CLOSE)
  169.                                 {
  170.                                         cmd_free=3;
  171.                                         ExitProcess();
  172.                                 }
  173.                                 if (id==B_APPLY) EventApplyProperties();
  174.                                 break;
  175.                                
  176.                 case evMouse:
  177.                                 edit_box_mouse stdcall (#file_name_ed);
  178.                                 edit_box_mouse stdcall (#path_to_file_ed);
  179.                                 break;
  180.                        
  181.                 case evKey:
  182.                                 GetKeys();
  183.  
  184.                                 if (apply_question_active)
  185.                                 {
  186.                                         IF (key_scancode==SCAN_CODE_ENTER)
  187.                                                 SetProperties(SET_PROPERTIES_ALL_SUBFOLDER);
  188.                                         IF (key_scancode==SCAN_CODE_ESC)
  189.                                                 SetProperties(SET_PROPERTIES_NO_SUBFOLDER);
  190.                                         break;
  191.                                 }
  192.  
  193.                                 switch(key_scancode)
  194.                                 {
  195.                                         case SCAN_CODE_ESC:
  196.                                                 cmd_free=3;
  197.                                                 ExitProcess();
  198.                                                 break;
  199.  
  200.                                         case SCAN_CODE_ENTER:
  201.                                                 EventApplyProperties();
  202.                                                 break;
  203.  
  204.                                         case SCAN_CODE_KEY_A:
  205.                                         case SCAN_CODE_KEY_C:
  206.                                                 if (key_modifier & KEY_LCTRL) || (key_modifier & KEY_RCTRL) {
  207.                                                         EAX = key_editbox;
  208.                                                         edit_box_key stdcall(#file_name_ed);
  209.                                                         edit_box_key stdcall(#path_to_file_ed);
  210.                                                 }
  211.                                 }
  212.                                 break;
  213.                                
  214.                 case evReDraw:
  215.                                 DrawPropertiesWindow();
  216.         }
  217. }
  218.  
  219. void DrawPropertiesWindow()
  220. {
  221.         proc_info pform;
  222.         char element_size_label[32];
  223.         char folder_info[200];
  224.         dword ext1;
  225.         dword element_size;
  226.         incn y;
  227.         char temp_path[PATHLEN];
  228.         bool show_date = false;
  229.  
  230.         if (chrnum(path, '/')>1) || (streq(path, "/kolibrios")) || (streq(path, "/sys")) show_date = true;
  231.         if (getSelectedCount()) show_date = false;
  232.  
  233.         DefineAndDrawWindow(Form.left + 150,150,315,show_date*60+300+skin_h,0x34,sc.work,WINDOW_TITLE_PROPERTIES,0);
  234.         GetProcessInfo(#pform, SelfInfo);
  235.  
  236.         DrawStandartCaptButton(pform.cwidth - 96, pform.cheight-34, B_CLOSE, T_CLOSE);
  237.         DrawStandartCaptButton(pform.cwidth -208, pform.cheight-34, B_APPLY, T_APPLY);
  238.        
  239.         WriteText(10, 78, 0x90, sc.work_text, PR_T_DEST);
  240.         edit_box_draw stdcall (#path_to_file_ed);
  241.        
  242.         if (getSelectedCount())
  243.         {
  244.                 PropertiesDrawIcon(NULL, "<lot>");
  245.                 sprintf(#folder_info,T_FILES_FOLDERS,more_files_count.files,more_files_count.folders);
  246.                 WriteText(file_name_ed.left+4, 30, 0x90, sc.work_text, #folder_info);
  247.                 sprintf(#element_size_label,T_PROP_SIZE,ConvertSize64(more_files_count.bytes, NULL),more_files_count.bytes);
  248.                 WriteText(10, 97, 0x90, sc.work_text, #element_size_label);
  249.         }
  250.         else
  251.         {
  252.                 if ( file_info_general.isfolder )
  253.                                 PropertiesDrawIcon(NULL, "<DIR>");
  254.                 else {
  255.                         sprintf(#temp_path,"%s/%s",path,#file_name2);
  256.                         ext1 = strrchr(#file_name2,'.');
  257.                         if (ext1) ext1 += #file_name2;
  258.                         PropertiesDrawIcon(#temp_path, ext1);
  259.                 }
  260.                 WriteText(file_name_ed.left, file_name_ed.top-15, 0x80, sc.work_text, PR_T_NAME);
  261.                 DrawEditBox(#file_name_ed);
  262.                
  263.                 if (!itdir) {
  264.                         element_size = file_info_general.sizelo;
  265.                 } else {
  266.                         sprintf(#folder_info,T_FILES_FOLDERS,dir_size.files,dir_size.folders);
  267.                         WriteText(10,  117, 0x90, sc.work_text, PR_T_CONTAINS);                              
  268.                         WriteText(120, 117, 0x90, sc.work_text, #folder_info);
  269.                         element_size = dir_size.bytes;
  270.                 }
  271.                 sprintf(#element_size_label,T_PROP_SIZE,ConvertSize64(element_size, NULL),element_size);
  272.                 WriteText(10, 99, 0x90, sc.work_text, #element_size_label);
  273.         }
  274.  
  275.         if (show_date) {
  276.                 WriteTextLines(10,  136, 0x90, sc.work_text, CREATED_OPENED_MODIFIED, 20);
  277.                 DrawDate(120, 136, sc.work_text, #file_info_general.datecreate);
  278.                 DrawDate(120, 156, sc.work_text, #file_info_general.datelastaccess);
  279.                 DrawDate(120, 176, sc.work_text, #file_info_general.datelastedit);                     
  280.         }
  281.  
  282.         DrawFrame(10, y.set(pform.cheight - 143), -10*2 + pform.cwidth - 2, 92, FLAGS);
  283.         ch_read_only.draw(24, y.inc(18));
  284.         ch_hidden.draw(24, y.inc(24));
  285.         ch_system.draw(24, y.inc(24));
  286.         if (apply_question_active) ShowConfirmQuestionPopin();
  287. }
  288.  
  289. void PropertiesDrawIcon(dword file_path, extension)
  290. {
  291.         int icon_n = ini_icons.get(file_path, extension, 32);
  292.         draw_icon_32(12, 22, sc.work, icon_n);
  293. }
  294.  
  295. void EventApplyProperties()
  296. {
  297.         if (getSelectedCount()) || (itdir) {
  298.                 ShowConfirmQuestionPopin();
  299.         } else {
  300.                 SetProperties(SET_PROPERTIES_SINGLE_FILE);
  301.         }
  302. }