Subversion Repositories Kolibri OS

Rev

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