Subversion Repositories Kolibri OS

Rev

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