Subversion Repositories Kolibri OS

Rev

Rev 6995 | Rev 7086 | 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,55,35,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. frame flags_frame = { 0, NULL, 10, 92, 212, 0x000111, 0xFFFfff, 1, FLAGS, 0, 1, 12, 0x000111, 0xFFFFFF };
  45.  
  46. int file_count, dir_count, size_dir;
  47. char folder_info[200];
  48. dword element_size;
  49. char element_size_label[32];
  50. BDVK file_info_general;
  51. BDVK file_info_dirsize;
  52.  
  53. proc_info settings_form;
  54. bool quest_active, atr_readonly, atr_hidden, atr_system;
  55.  
  56. void SetPropertiesDir(dword way)
  57. {
  58.         dword dirbuf, fcount, i, filename;
  59.         dword cur_file;
  60.         if (dir_exists(way))
  61.         {
  62.                 cur_file = malloc(4096);
  63.                 GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
  64.                 for (i=0; i<fcount; i++)
  65.                 {
  66.                         filename = i*304+dirbuf+72;
  67.                         strcpy(cur_file, way);
  68.                         chrcat(cur_file, '/');
  69.                         strcat(cur_file, filename);
  70.                         if ( TestBit(ESDWORD[filename-40], 4) )
  71.                         {
  72.                                 SetPropertiesDir(cur_file);
  73.                         }
  74.                         GetFileInfo(cur_file, #file_info_dirsize);
  75.                         file_info_dirsize.readonly = atr_readonly;
  76.                         file_info_dirsize.hidden = atr_hidden;
  77.                         file_info_dirsize.system = atr_system;
  78.                         SetFileInfo(cur_file, #file_info_dirsize);
  79.                 }
  80.                 free(cur_file);
  81.         }
  82. }
  83.  
  84. void SetProperties(byte prop)
  85. {
  86.         dword cur_file;
  87.  
  88.         if (prop==1) || (prop==2)
  89.         {
  90.                 if (selected_count)
  91.                 {
  92.                         cur_file = malloc(4096);
  93.                         for (i=0; i<files.count; i++)
  94.                         {
  95.                                 if (getElementSelectedFlag(i) == true)
  96.                                 {
  97.                                         strcpy(cur_file, #path);
  98.                                         strcat(cur_file, file_mas[i]*304+buf+72);
  99.                                         GetFileInfo(cur_file, #file_info_general);
  100.                                         file_info_general.readonly = atr_readonly;
  101.                                         file_info_general.hidden = atr_hidden;
  102.                                         file_info_general.system = atr_system;
  103.                                         SetFileInfo(cur_file, #file_info_general);
  104.                                         if (prop==2)
  105.                                         {
  106.                                                 if (dir_exists(cur_file))
  107.                                                 {
  108.                                                         SetPropertiesDir(cur_file);
  109.                                                 }
  110.                                         }
  111.                                 }
  112.                         }
  113.                         free(cur_file);
  114.                 }
  115.                 else
  116.                 {
  117.                         GetFileInfo(#file_path, #file_info_general);
  118.                         file_info_general.readonly = atr_readonly;
  119.                         file_info_general.hidden = atr_hidden;
  120.                         file_info_general.system = atr_system;
  121.                         SetFileInfo(#file_path, #file_info_general);
  122.                         if (prop==2) SetPropertiesDir(#file_path);
  123.                 }
  124.                 quest_active = 0;
  125.                 DrawPropertiesWindow();
  126.         }
  127.         else
  128.         {
  129.                 GetFileInfo(#file_path, #file_info_general);
  130.                 file_info_general.readonly = atr_readonly;
  131.                 file_info_general.hidden = atr_hidden;
  132.                 file_info_general.system = atr_system;
  133.                 SetFileInfo(#file_path, #file_info_general);
  134.         }
  135.         cmd_free=3;
  136.         _not_draw = true;
  137.         Open_Dir(#path,WITH_REDRAW);
  138.         _not_draw = false;
  139.         EventRedrawWindow(Form.left,Form.top);
  140.         ExitProcess();
  141. }
  142.  
  143. void ShowConfirmQuestionPopin()
  144. {
  145.         quest_active = 1;
  146.         DrawPopup(15,80,250,90,1,system.color.work, system.color.work_graph);
  147.         WriteText(35, 102, 0x90, 0x000000, QUEST_1);
  148.         WriteText(65, 117, 0x90, 0x000000, QUEST_2);
  149.         DrawFlatButton(62,138,301,T_YES);
  150.         DrawFlatButton(155,138,302,T_NO);
  151. }
  152.  
  153. void GetSizeDir(dword way)
  154. {
  155.         dword dirbuf, fcount, i, filename;
  156.         dword cur_file;
  157.         if (dir_exists(way))
  158.         {
  159.                 cur_file = malloc(4096);
  160.                 // In the process of recursive descent, memory must be allocated dynamically,
  161.                 // because the static memory -> was a bug !!! But unfortunately pass away to sacrifice speed.
  162.                 GetDir(#dirbuf, #fcount, way, DIRS_ONLYREAL);
  163.                 for (i=0; i<fcount; i++)
  164.                 {
  165.                         filename = i*304+dirbuf+72;
  166.                         sprintf(cur_file,"%s/%s",way,filename);
  167.                        
  168.                         if (TestBit(ESDWORD[filename-40], 4) )
  169.                         {
  170.                                 dir_count++;
  171.                                 GetSizeDir(cur_file);
  172.                         }
  173.                         else
  174.                         {
  175.                                 GetFileInfo(cur_file, #file_info_dirsize);
  176.                                 size_dir += file_info_dirsize.sizelo;
  177.                                 file_count++;
  178.                         }
  179.                 }
  180.                 free(cur_file);
  181.         }
  182. }
  183.  
  184. void GetSizeMoreFiles(dword way)
  185. {
  186.         char cur_file[4096];
  187.        
  188.         for (i=0; i<files.count; i++)
  189.         {
  190.                 if (getElementSelectedFlag(i) == true)
  191.                 {
  192.                         sprintf(#cur_file,"%s/%s",way,file_mas[i]*304+buf+72);
  193.                         if (TestBit(ESDWORD[file_mas[i]*304+buf+32], 4) )
  194.                         {
  195.                                 GetSizeDir(#cur_file);
  196.                                 dir_count++;
  197.                         }
  198.                         else
  199.                         {
  200.                                 GetFileInfo(#cur_file, #file_info_dirsize);
  201.                                 size_dir += file_info_dirsize.sizelo;
  202.                                 file_count++;
  203.                         }
  204.                 }
  205.         }  
  206. }
  207.  
  208. void properties_dialog()
  209. {
  210.         byte id;
  211.        
  212.         DSBYTE[#folder_info]=0;
  213.         file_count = 0;
  214.         dir_count = 0; 
  215.         size_dir = 0;
  216.                        
  217.         if (selected_count)
  218.         {
  219.                 GetSizeMoreFiles(#path);
  220.                 atr_readonly = 0;
  221.                 atr_hidden = 0;
  222.                 atr_system = 0;
  223.         }
  224.         else
  225.         {
  226.                 GetFileInfo(#file_path, #file_info_general);
  227.                 strcpy(#file_name2, #file_name);
  228.                 file_name_ed.size = strlen(#file_name2);  
  229.                 if(itdir) GetSizeDir(#file_path);
  230.                 atr_readonly = file_info_general.readonly;
  231.                 atr_hidden = file_info_general.hidden;
  232.                 atr_system = file_info_general.system;
  233.         }
  234.         strcpy(#path_to_file, #path);
  235.         path_to_file_ed.size = strlen(#path_to_file);
  236.        
  237.         SetEventMask(0x27);
  238.         loop() switch(WaitEvent())
  239.         {
  240.                 case evButton:
  241.                                 id=GetButtonID();
  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.                                 if (id==20)
  267.                                 {
  268.                                         atr_readonly ^= 1;
  269.                                         DrawPropertiesCheckBoxes();
  270.                                 }
  271.                                 if (id==21)
  272.                                 {
  273.                                         atr_hidden ^= 1;
  274.                                         DrawPropertiesCheckBoxes();
  275.                                 }
  276.                                 if (id==22)
  277.                                 {
  278.                                         atr_system ^= 1;
  279.                                         DrawPropertiesCheckBoxes();
  280.                                 }
  281.                                 break;
  282.                                
  283.                 case evMouse:
  284.                                 edit_box_mouse stdcall (#file_name_ed);
  285.                                 edit_box_mouse stdcall (#path_to_file_ed);
  286.                                 break;
  287.                        
  288.                 case evKey:
  289.                                 GetKeys();
  290.                                
  291.                                 if (quest_active)
  292.                                 {
  293.                                         IF (key_scancode==SCAN_CODE_ENTER) SetProperties(2);
  294.                                         IF (key_scancode==SCAN_CODE_ESC) SetProperties(1);
  295.                                         quest_active=false;
  296.                                         break;
  297.                                 }
  298.                                 if (key_scancode==SCAN_CODE_ESC)
  299.                                 {
  300.                                         cmd_free=3;
  301.                                         ExitProcess();
  302.                                 }
  303.                                 if (key_scancode==SCAN_CODE_ENTER)
  304.                                 {
  305.                                         if (selected_count) || (itdir)
  306.                                         {
  307.                                                 ShowConfirmQuestionPopin();
  308.                                         }
  309.                                         else
  310.                                         {
  311.                                                 SetProperties(0);
  312.                                         }
  313.                                         break;
  314.                                 }
  315.                                 edit_box_key stdcall(#file_name_ed);
  316.                                 edit_box_key stdcall(#path_to_file_ed);
  317.                                 break;
  318.                                
  319.                 case evReDraw:
  320.                                 DrawPropertiesWindow();
  321.         }
  322. }
  323.  
  324. void DrawPropertiesWindow()
  325. {
  326.         dword ext1;
  327.         char temp_path[sizeof(file_path)];
  328.         DefineAndDrawWindow(Form.left + 150,150,305,360+skin_height,0x34,system.color.work,WINDOW_TITLE_PROPERTIES,0);
  329.         if ( !asm test path_to_file_ed.flags, 2)
  330.         {
  331.                 path_to_file_ed.blur_border_color = system.color.work;
  332.                 path_to_file_ed.color = system.color.work;
  333.         }
  334.         else
  335.         {
  336.                 path_to_file_ed.blur_border_color = 0x000000;
  337.                 path_to_file_ed.color = 0xffffff;
  338.         }
  339.         if ( !asm test path_to_file_ed.flags, 2)
  340.         {
  341.                 file_name_ed.blur_border_color = system.color.work;
  342.                 file_name_ed.color = system.color.work;
  343.         }
  344.         else
  345.         {
  346.                 file_name_ed.blur_border_color = 0x000000;
  347.                 file_name_ed.color = 0xffffff;
  348.         }
  349.         GetProcessInfo(#settings_form, SelfInfo);
  350.  
  351.         DrawFlatButton(settings_form.cwidth - 96, settings_form.cheight-34, 10, BTN_CLOSE);
  352.         DrawFlatButton(settings_form.cwidth -208, settings_form.cheight-34, 11, BTN_APPLY);
  353.        
  354.         WriteText(10, 78, 0x90, system.color.work_text, PR_T_DEST);
  355.         edit_box_draw stdcall (#path_to_file_ed);
  356.  
  357.         WriteText(10, 97, 0x90, system.color.work_text, PR_T_SIZE);
  358.        
  359.         if (selected_count)
  360.         {
  361.                 PropertiesDrawIcon(NULL, NULL);
  362.                 sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
  363.                 WriteText(file_name_ed.left+4, 30, 0x90, system.color.work_text, #folder_info);
  364.                 sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(size_dir, NULL),size_dir,SET_BYTE_LANG);
  365.                 WriteText(120, 97, 0x90, system.color.work_text, #element_size_label);
  366.         }
  367.         else
  368.         {
  369.                 if ( file_info_general.isfolder )
  370.                                 PropertiesDrawIcon(NULL, "<DIR>");
  371.                 else {
  372.                         sprintf(#temp_path,"%s/%s",#path,#file_name2);
  373.                         ext1 = strrchr(#file_name2,'.');
  374.                         if (ext1) ext1 += #file_name2;
  375.                         PropertiesDrawIcon(#temp_path, ext1);
  376.                 }
  377.                 WriteText(file_name_ed.left+4, 20, 0x80, system.color.work_text, PR_T_NAME);                          
  378.                 edit_box_draw stdcall (#file_name_ed);
  379.                
  380.                 if (!itdir) element_size = file_info_general.sizelo;
  381.                 else
  382.                 {
  383.                         WriteText(10,116, 0x90, system.color.work_text, PR_T_CONTAINS);                              
  384.                         sprintf(#folder_info,"%s%d%s%d",SET_6,file_count,SET_7,dir_count);
  385.                         WriteText(120, 116, 0x90, system.color.work_text, #folder_info);
  386.                         element_size = size_dir;
  387.                 }
  388.                 WriteTextLines(10,  136, 0x90, system.color.work_text, CREATED_OPENED_MODIFIED, 20);
  389.                 DrawDate(120,  136, system.color.work, #file_info_general.datecreate);
  390.                 DrawDate(120, 156, system.color.work, #file_info_general.datelastaccess);
  391.                 DrawDate(120, 176, system.color.work, #file_info_general.datelastedit);
  392.  
  393.                 sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(element_size, NULL),element_size,SET_BYTE_LANG);
  394.                 WriteText(120, 99, 0x90, system.color.work_text, #element_size_label);
  395.         }
  396.         flags_frame.size_x = - flags_frame.start_x * 2 + settings_form.cwidth - 2;
  397.         flags_frame.font_color = system.color.work_text;
  398.         flags_frame.ext_col = system.color.work_graph;
  399.         flags_frame.font_backgr_color = system.color.work;
  400.         frame_draw stdcall (#flags_frame);
  401.         DrawPropertiesCheckBoxes();
  402. }
  403.  
  404. void PropertiesDrawIcon(dword file_path, extension)
  405. {
  406.         #define ICON_PADDING 10
  407.         DrawBar(20-ICON_PADDING, 30-ICON_PADDING-1, ICON_PADDING*2+16, ICON_PADDING*2+16, system.color.work_light);
  408.         DrawIconByExtension(file_path, extension, 20, 30, system.color.work_light);
  409. }
  410.  
  411. void DrawPropertiesCheckBoxes()
  412. {
  413.         incn y;
  414.         y.n = flags_frame.start_y;
  415.         CheckBox(24, y.inc(18), 20, PR_T_ONLY_READ, atr_readonly);
  416.         CheckBox(24, y.inc(24), 21, PR_T_HIDDEN, atr_hidden);
  417.         CheckBox(24, y.inc(24), 22, PR_T_SYSTEM, atr_system);
  418. }
  419.