Subversion Repositories Kolibri OS

Rev

Rev 9356 | Rev 9525 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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