void PanelView::ReadDisks(void) //////////////////////////////////////////////////////////////////////// { char drivename[256]; char drivepath[256]; // SetMousePointer(CR_HOURGLASS); MAINWINDOW->SetMousePointer(GenesisWindow::CR_HOURGLASS); CustomListItem *item; item = new CustomListItem("..",m_Path.String(),FT_DISKBACK, 0); item->AddIcon(m_ParentIcon); m_CustomListView->AddItem(item); item->SetHeight(15.0f); // Collect available volumes... BVolumeRoster *vr = new BVolumeRoster(); if (vr) { BVolume v; while (vr->GetNextVolume(&v)==B_NO_ERROR) { if (v.GetName(drivename)==B_NO_ERROR) { if (strlen(drivename)>0) { BDirectory dir; BEntry entry; BPath path; v.GetRootDirectory(&dir); dir.GetEntry(&entry); entry.GetPath(&path); sprintf(drivepath,"%s",path.Path()); item = new CustomListItem(drivename,drivepath,FT_DISKITEM,v.FreeBytes(),v.Capacity(),v.Device()); m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(&v)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } } } delete vr; } m_CustomListView->DoSortList(); m_CustomListView->Select(0,false); // SetMousePointer(CR_DEFAULT); MAINWINDOW->SetMousePointer(GenesisWindow::CR_DEFAULT); }
CustomListItem *PanelView::AddDirectoryEntry(BEntry *entry, bool sorted) //////////////////////////////////////////////////////////////////////// { CustomListItem *item; char name[B_FILE_NAME_LENGTH]; entry->GetName(name); if (entry->IsDirectory()) { item = new CustomListItem(name,m_Path.String(),FT_DIRECTORY, 0, this); if (sorted) m_CustomListView->AddSortedItem(item); else m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(entry)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } else if (entry->IsSymLink()) { BEntry symlinkentry; entry_ref ref; struct stat statbuf; entry->GetRef(&ref); if (symlinkentry.SetTo(&ref, true)==B_OK) { if (symlinkentry.IsDirectory()) { item = new CustomListItem(name,m_Path.String(),FT_SYMLINKDIR, 0, this); if (sorted) m_CustomListView->AddSortedItem(item); else m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(&symlinkentry)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } else { symlinkentry.GetStat(&statbuf); item = new CustomListItem(name,m_Path.String(),FT_SYMLINKFILE,statbuf.st_size, this); if (sorted) m_CustomListView->AddSortedItem(item); else m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(&symlinkentry)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } } else { // Broken link... item = new CustomListItem(name, m_Path.String(), FT_SYMLINKBROKEN, 0 , this); if (sorted) m_CustomListView->AddSortedItem(item); else m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(entry)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } } else { struct stat statbuf; entry->GetStat(&statbuf); item = new CustomListItem(name,m_Path.String(),FT_FILE,statbuf.st_size, this); if (sorted) m_CustomListView->AddSortedItem(item); else m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { if (!item->GetIcon(entry)) item->AddIcon(m_UnknownIcon); item->SetHeight(15.0f); } } return item; }
void PanelView::ReadDirectory(const char *itemname) //////////////////////////////////////////////////////////////////////// { BDirectory *dir; CustomListItem *item; stop_watching(this); // SetMousePointer(CR_HOURGLASS); MAINWINDOW->SetMousePointer(GenesisWindow::CR_HOURGLASS); // If we are not in the root directory, simply start the dir with a '..' entry... if (strcmp(m_Path.String(),"/")!=0) { item = new CustomListItem("..", m_Path.String(), FT_PARENT, 0); m_CustomListView->AddItem(item); if (m_Setting_ShowIcons) { item->AddIcon(m_ParentIcon); item->SetHeight(15.0f); } } dir = new BDirectory(m_Path.String()); if (dir) { BEntry entry; if (dir->GetEntry(&entry)==B_OK) { while (dir->GetNextEntry(&entry)==B_OK) { AddDirectoryEntry(&entry); } } delete dir; } m_CustomListView->DoSortList(); // Always select the first item in the list or the child where we came from... if (itemname) { CustomListItem *item; int n = m_CustomListView->CountItems(); for (int i=0;i<n;i++) { item = (CustomListItem *)m_CustomListView->ItemAt(i); if (strcasecmp(itemname,item->m_FileName.String())==0) { m_CustomListView->Select(i,false); m_CustomListView->ScrollToSelection(); break; } } // When the given file disappeared, we have to select the first entry... if (m_CustomListView->CountSelectedEntries(CT_WITHPARENT)==0) m_CustomListView->Select(0,false); } else m_CustomListView->Select(0,false); m_CurrentTotalSize = m_CustomListView->GetCurrentTotalSize(); // Probably we have to update the path of the command line... Parent()->Looper()->PostMessage(new BMessage(MSG_UPDATECOMMANDLINE_PATH)); // To update command line... EnableMonitoring(); // SetMousePointer(CR_DEFAULT); MAINWINDOW->SetMousePointer(GenesisWindow::CR_DEFAULT); }