String RenderTheme::fileListNameForWidth(const FileList* fileList, const Font& font, int width, bool multipleFilesAllowed) const { if (width <= 0) return String(); String string; if (fileList->isEmpty()) string = fileListDefaultLabel(multipleFilesAllowed); else if (fileList->length() == 1) string = fileList->item(0)->name(); else return StringTruncator::rightTruncate(multipleFileUploadText(fileList->length()), width, font, StringTruncator::EnableRoundingHacks); return StringTruncator::centerTruncate(string, width, font, StringTruncator::EnableRoundingHacks); }
String RenderTheme::fileListNameForWidth(const Vector<String>& filenames, const Font& font, int width) { if (width <= 0) return String(); String string; if (filenames.isEmpty()) string = fileButtonNoFileSelectedLabel(); else if (filenames.size() == 1) string = pathGetFileName(filenames[0]); else return StringTruncator::rightTruncate(multipleFileUploadText(filenames.size()), width, font, StringTruncator::EnableRoundingHacks); return StringTruncator::centerTruncate(string, width, font, StringTruncator::EnableRoundingHacks); }
String FileChooser::basenameForWidth(const Font& font, int width) const { if (width <= 0) return String(); String string; if (m_filenames.isEmpty()) string = fileButtonNoFileSelectedLabel(); else if (m_filenames.size() == 1) string = pathGetDisplayFileName(m_filenames[0]); else return StringTruncator::rightTruncate(multipleFileUploadText(m_filenames.size()), width, font, false); return StringTruncator::centerTruncate(string, static_cast<float>(width), font, false); }
String FileChooser::basenameForWidth(const Font& font, int width) const { if (width <= 0) return String(); String string = fileButtonNoFileSelectedLabel(); if (m_filenames.size() == 1) { CString systemFilename = fileSystemRepresentation(m_filenames[0]); gchar* systemBasename = g_path_get_basename(systemFilename.data()); stringByAdoptingFileSystemRepresentation(systemBasename, string); } else if (m_filenames.size() > 1) return StringTruncator::rightTruncate(multipleFileUploadText(m_filenames.size()), width, font, false); return StringTruncator::centerTruncate(string, width, font, false); }
String RenderThemeGtk::fileListNameForWidth(const FileList* fileList, const Font& font, int width, bool multipleFilesAllowed) const { if (width <= 0) return String(); if (fileList->length() > 1) return StringTruncator::rightTruncate(multipleFileUploadText(fileList->length()), width, font, StringTruncator::EnableRoundingHacks); String string; if (fileList->length()) string = pathGetFileName(fileList->item(0)->path()); else if (multipleFilesAllowed) string = fileButtonNoFilesSelectedLabel(); else string = fileButtonNoFileSelectedLabel(); return StringTruncator::centerTruncate(string, width, font, StringTruncator::EnableRoundingHacks); }