Subversion Repositories Kolibri OS

Rev

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