Subversion Repositories Kolibri OS

Rev

Rev 9602 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. bool KolibriosMounted()
  2. {
  3.         static bool kolibrios_mounted;
  4.         if (kolibrios_mounted) return true;
  5.         kolibrios_mounted = real_dir_exists("/kolibrios");
  6.         return kolibrios_mounted;
  7. }
  8.  
  9. struct _SystemDiscs
  10. {
  11.         collection list;
  12.         int dev_num;
  13.         void Get();
  14.         void Draw();
  15.         void DrawSelect();
  16.         void DrawOptions();
  17. } SystemDiscs=0;
  18.  
  19. void _SystemDiscs::Get()
  20. {
  21.         char dev_name[10], sys_discs[10];
  22.         int i1, j1, dev_disc_num, real_dev_num;
  23.         dword devbuf, diskbuf;
  24.  
  25.         list.drop();
  26.         devbuf = malloc(10000);
  27.         ReadDir(19, devbuf, "/");
  28.         dev_num = real_dev_num = EBX;
  29.  
  30.         list.add("/sys");
  31.         dev_num++;
  32.  
  33.         if (KolibriosMounted()) {
  34.                 //need to check that /sys != /kolibrios
  35.                 list.add("/kolibrios");
  36.                 dev_num++;
  37.         }
  38.  
  39.         for (i1=0; i1<real_dev_num; i1++)
  40.         {
  41.                 sprintf(#dev_name,"/%s",i1*304+ devbuf+72);
  42.                 GetDir(#diskbuf, #dev_disc_num, #dev_name, DIRS_NOROOT);
  43.                 if (!EAX) for (j1=0; j1<dev_disc_num; j1++;)
  44.                 {
  45.                         sprintf(#sys_discs,"%s/%s",#dev_name,j1*304+ diskbuf+72);
  46.                         if (sys_discs[1]=='r') {
  47.                                 dev_num--;
  48.                                 continue;
  49.                         }
  50.                         if (sys_discs[1]=='c') || (sys_discs[1]=='f') || (dir_exists(#sys_discs)) {
  51.                                 list.add(#sys_discs);
  52.                         }
  53.                 }
  54.         }
  55.         free(devbuf);
  56.         free(diskbuf);
  57. }
  58.  
  59. void GetDiskIconAndName(dword dev_name, icon, disc_name)
  60. {
  61.         int i;
  62.         dword volume_label;
  63.         for (i=0; devinfo[i]!=0; i+=3) {
  64.                 if (!strncmp(dev_name+1, devinfo[i], 2)) {
  65.                         ESBYTE[icon] = devinfo[i+1];
  66.                         if (ESBYTE[icon]==4)
  67.                         {
  68.                                 //show label only for hard disk drives
  69.                                 volume_label = GetVolumeLabel(dev_name);
  70.                                 if (ESBYTE[volume_label]) {
  71.                                         strncpy(disc_name, volume_label, 15);
  72.                                         chrcat(disc_name, ' ');
  73.                                         return;                                
  74.                                 }
  75.                         }
  76.                         strcpy(disc_name, devinfo[i+2]);
  77.                         return;
  78.                 }
  79.         }
  80.         ESBYTE[icon]=4;
  81.         strcpy(disc_name, T_UNC);
  82. }
  83.  
  84. void _SystemDiscs::Draw()
  85. {    
  86.         char dev_name[15], disc_name[100], i, dev_icon;
  87.         bool is_active=0;
  88.         int draw_y, draw_x;
  89.        
  90.         if (efm) {
  91.                 DrawSelect(2, KFM_DEV_DROPDOWN_1, location[0]);
  92.                 DrawSelect(Form.cwidth/2, KFM_DEV_DROPDOWN_2, location[sizeof(dword)]);
  93.                 files.y = 40 + 17;
  94.         } else {
  95.                 Tip(56, T_DEVICES, 55, "=");
  96.                 for (i=0; i<30; i++) DeleteButton(100+i);
  97.  
  98.                 draw_y = 74;
  99.                 draw_x = 17;
  100.                 for (i=0;i<list.count;i++) {
  101.                         strcpy(#dev_name, list.get(i));
  102.                         GetDiskIconAndName(#dev_name, #dev_icon, #disc_name);
  103.                         if (strstr(path, #dev_name)==path) is_active=true; else is_active=false;
  104.  
  105.                         DrawBar(draw_x,draw_y,6,DEV_H+1,0xFFFFFF);
  106.                         DrawBar(draw_x+6+18,draw_y,160-6-18,DEV_H+1,0xFFFFFF);
  107.                         DefineHiddenButton(draw_x,draw_y,159,16,100+i);
  108.                         if (show_dev_name.checked)
  109.                         {
  110.                                 strcat(#disc_name, #dev_name);
  111.                                 if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#disc_name);
  112.                                 WriteText(draw_x+29,draw_y+5,0x80,0,#disc_name);
  113.                                 //if (is_active) kfont.bold = true;
  114.                                 //kfont.WriteIntoWindow(draw_x + 29, draw_y+2, 0xFFFfff, 0x000000, kfont.size.pt, #disc_name);
  115.                                 //kfont.bold = false;
  116.                         } else {
  117.                                 if (is_active) WriteText(draw_x+30,draw_y+5,0x80,0x555555,#dev_name);
  118.                                 WriteText(draw_x+29,draw_y+5,0x80,0,#dev_name);
  119.                         }
  120.                         PutImage(draw_x+6,draw_y, 18,17, is_active*7+dev_icon*17*18*3+#devices);
  121.                         draw_y += DEV_H;                       
  122.                 }
  123.                 DrawBar(draw_x+6, draw_y, 18, 1, 0xFFFfff);
  124.                 ActionsDraw(list.count*DEV_H+108);
  125.                 DrawLeftPanelBg(list.count*DEV_H);
  126.         }
  127. }
  128.  
  129. void _SystemDiscs::DrawSelect(int draw_x, btid, dword _path)
  130. {
  131.         char dev_name[15], disc_name[100], i, dev_icon;
  132.  
  133.         if (ESBYTE[_path+1]=='\0') {
  134.                 strcpy(#dev_name, "/root");
  135.                 dev_icon = 0;
  136.         } else if (chrnum(_path, '/')==1) {
  137.                 strcpy(#dev_name, _path);
  138.                 GetDiskIconAndName(#dev_name, #dev_icon, #disc_name);
  139.         } else for (i=0;i<list.count;i++) {
  140.                 strcpy(#dev_name, list.get(i));
  141.                 GetDiskIconAndName(#dev_name, #dev_icon, #disc_name);
  142.                 if (strstr(_path, #dev_name)-_path==0) break;
  143.         }
  144.         DrawRectangle(draw_x-1, SELECTY-1, DDW+2-KFM2_DEVH, KFM2_DEVH+1, sc.line);
  145.         DrawBar(draw_x, SELECTY, DDW+1-KFM2_DEVH, KFM2_DEVH, 0xFFFFFF);
  146.         PutImage(draw_x + 5, SELECTY+2, 18,17, dev_icon*17*18*3+#devices);
  147.         kfont.WriteIntoWindow(draw_x + 24, math.max(KFM2_DEVH-kfont.height/2+SELECTY,0), 0xFFFfff, 0x000000, kfont.size.pt, #dev_name+1);
  148.         DefineHiddenButton(draw_x, SELECTY, DDW-1, KFM2_DEVH-1, btid);
  149.         DrawFlatButtonSmall(draw_x+DDW-KFM2_DEVH+1, SELECTY-1, KFM2_DEVH-1, KFM2_DEVH+1, NULL, "\x19");
  150. }
  151.  
  152. void _SystemDiscs::DrawOptions(int draw_x)
  153. {
  154.         int optionsy = SELECTY+KFM2_DEVH+1;
  155.         char dev_name[15], disc_name[100], volume_label[64], label_file_name[100];
  156.         char i, dev_icon, is_active=0;
  157.                
  158.         SystemDiscs.Get();
  159.  
  160.         DrawPopup(draw_x, optionsy, DDW, list.count*KFM2_DEVH, 1, -1, sc.line);
  161.  
  162.         for (i=0;i<list.count;i++) {
  163.                 strcpy(#dev_name, list.get(i));
  164.                 GetDiskIconAndName(#dev_name, #dev_icon, #disc_name);
  165.                 if (strstr(path, #dev_name)!=0) is_active=true; else is_active=false;
  166.  
  167.                 DrawBar(draw_x, optionsy, DDW, KFM2_DEVH, 0xFFFFFF);
  168.                 DefineButton(draw_x, optionsy, DDW, KFM2_DEVH-1, 100+i+BT_HIDE,0xFFFFFF);
  169.                 PutImage(draw_x + 5, optionsy+2, 18,17, is_active*7+dev_icon*17*18*3+#devices);
  170.                 if (is_active) kfont.bold = true;
  171.                 //strncpy(#volume_label, GetVolumeLabel(#dev_name), sizeof(volume_label));
  172.                 strcpy(#label_file_name, #dev_name);
  173.                 //if (dev_name[1]!='k') && (dev_name[2]!='y') {
  174.                 //      if (volume_label) sprintf(#label_file_name, "%s [%s]", #dev_name, #volume_label);
  175.                 //}
  176.                 kfont.WriteIntoWindow(draw_x + 24, optionsy+2, 0xFFFfff, 0x000000, kfont.size.pt, #label_file_name+1);
  177.                 kfont.bold = false;
  178.                 optionsy += KFM2_DEVH;
  179.         }
  180. }
  181.  
  182.  
  183.