Subversion Repositories Kolibri OS

Rev

Rev 8956 | Rev 9535 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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