Subversion Repositories Kolibri OS

Rev

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