void update_property_dialog(Icon *i) { Fl_String val; Fl_Config i_config(i->get_cfg()->filename()); i_config.set_section("Desktop Entry"); val = get_localized_name(i_config); if(!val.empty()) { pr_name->label(val); } if(!i_config.read("Exec", val, 0)) { pr_exec->label(val); } Fl_FileAttr *attr = fl_file_attr(i->get_cfg()->filename()); if(attr) { char size[32]; snprintf(size, 32, _("%d bytes, %s"), (int) attr->size, attr->time); pr_size->label(size); delete attr; } pr_icon->image(i->icon_im); }
void Fl_File_Dialog::read_dir(const char *_path) { image_cache.clear(); update_preview(0); static char read_path[4096]; if(_path && *_path) { normalize_path(_path, read_path); //strncpy(read_path, _path, 4096); } else read_path[0] = '\0'; #ifndef _WIN32 if(!*read_path) { _path = "/"; } if(!strcmp(read_path, "My Home")) { char *home = fl_get_homedir(); strncpy(read_path, home, 4096); delete []home; _path = read_path; } parse_dirs(_path); #else parse_dirs(_path); bool get_drives = false; bool read_net = false; LPNETRESOURCE netres=0; if(!*read_path || !strcmp(read_path, "My Computer")) { get_drives = true; _path=0; } else if(!strcmp(read_path, "My Network")) { read_net = true; _path=0; } else if(read_path[0]=='\\' && read_path[1]=='\\') { char *p = strchr((char *)(read_path+2), '\\'); if(!p) { //Network path, w/o share name. Try to read all shares NETRESOURCE net; memset(&net, 0, sizeof(net)); net.lpRemoteName = strdup(read_path); netres = &net; read_net = true; } } #endif fullpath(_path); if(!fullpath_) up_->deactivate(); else up_->activate(); if(mode_!=Fl_File_Dialog::DIRECTORY || (mode_==Fl_File_Dialog::DIRECTORY && !fullpath_)) ok_->deactivate(); location_->value(""); listview_->yposition(0); listview_->column_width(0, -1); listview_->clear(); listview_->begin(); #ifdef _WIN32 if(get_drives) { listview_->column_name(1, "Type"); listview_->column_name(2, "Used Space"); listview_->column_name(3, "Free Space"); DWORD drvs = GetLogicalDrives(); char drive[4]; Fl_FileItem *it; for(int i = 'A'; i <= 'Z'; i++, drvs >>= 1) { if(drvs & 1) { sprintf(drive, "%c:", i); it = new Fl_FileItem(drive, fl_file_attr(drive)); it->image(0, hd_pix); } } } else if(read_net) {
// 'Fl_FileBrowser::load()' - Load a directory into the browser. int // O - Number of files loaded Fl_File_Browser::load(const Fl_String &dir) // I - Directory to load { Fl_String old_dir(directory()); m_dir_ds.directory(dir); clear(); clear_columns(); sort_col(1); m_up_item = 0; if(dir.empty()) { header()->add_column("", 20); // No directory specified: // - For UNIX list all mount points. // - For Win32 list all valid drive letters. //icon = Fl_FileIcon::find("any", Fl_FileIcon::DEVICE); //if (icon == (Fl_FileIcon *)0) // icon = Fl_FileIcon::find("any", Fl_FileIcon::DIR); begin(); char filename[FL_PATH_MAX]; #ifdef _WIN32 header()->add_column(_("File"), 100); header()->add_column(_("Type"), 100); header()->add_column(_("Capacity"), 100); header()->add_column(_("Free Space"), 100); // Drive available bits DWORD drives = GetLogicalDrives(); for(int i = 'A'; i <= 'Z'; i ++, drives >>= 1) { if (drives & 1) { Fl_ListView_Item *item = new Fl_ListView_Item(); item->image(&hd_pix); snprintf(filename, sizeof(filename)-1, "%c:\\", i); item->label(1, filename); Fl_File_Attr *attr = fl_file_attr(filename); if(attr->flags & Fl_File_Attr::DEVICE) { uint type = GetDriveTypeA(filename); const char *typestr=_(types[0]); if (type==DRIVE_CDROM) { typestr=_(types[4]); item->image(&cd_pix); } else if (type==DRIVE_REMOVABLE) { typestr=_(types[5]); item->image(&floppy_pix); } else if (type==DRIVE_FIXED) typestr=_(types[6]); else if (type==DRIVE_REMOTE) typestr=_(types[7]); else if (type==DRIVE_RAMDISK) typestr=_(types[8]); item->label(2, typestr); uint s = 0; Fl_String suffix; if((s = get_dev_size(attr->capacity, suffix))>0) { item->label(3, Fl_String(s)+" "+suffix); } if((s = get_dev_size(attr->free, suffix))>0) { item->label(4, Fl_String(s)+" "+suffix); } /* //TOO SLOW!!! char drivename[255]; if(GetVolumeInformation( filename, drivename, sizeof(drivename)-1, NULL, NULL, NULL, NULL, 0)) { if(drivename[0]) snprintf(fname, sizeof(fname)-1, "%s (%s)", filename, drivename); } */ } } } #else header()->add_column(_("File"), 100); header()->add_column(_("Device"), 100); header()->add_column(_("Type"), 100); FILE *mtab = 0; // /etc/mtab or /etc/mnttab file char line[1024]; // Input line char dev[256]; // Device name char fstype[256]; // Filesystem type // Open the file that contains a list of mounted filesystems... # if defined(__hpux) || defined(__sun) // Fairly standard mtab = fl_fopen("/etc/mnttab", "r"); # elif defined(__sgi) || defined(linux) // More standard mtab = fl_fopen("/etc/mtab", "r"); # endif // Otherwise fallback to full list if(mtab == NULL) mtab = fl_fopen("/etc/fstab", "r"); if(mtab == NULL) mtab = fl_fopen("/etc/vfstab", "r"); if (mtab != NULL) { while (fgets(line, sizeof(line), mtab) != NULL) { if (line[0] == '#' || line[0] == '\n') continue; if (sscanf(line, "%255s%4095s%255s", dev, filename, fstype) != 3) continue; if(!strcasecmp(dev, "none")) continue; Fl_ListView_Item *item = new Fl_ListView_Item(); item->image(&hd_pix); item->label(1, filename); item->label(2, dev); item->label(3, fstype); } fclose(mtab); } #endif // _WIN32 end(); resizable_col(0, false); return children(); } else {