Subversion Repositories Kolibri OS

Rev

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