Skip to content

Commit

Permalink
Truncate background image name in multibyte-aware way
Browse files Browse the repository at this point in the history
  • Loading branch information
siarzhuk committed Jan 15, 2013
1 parent 2b934bb commit 3c7eaf3
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/preferences/backgrounds/BackgroundImage.cpp
Expand Up @@ -561,16 +561,15 @@ Image::Image(BPath path)
fBitmap(NULL),
fPath(path)
{
const int32 kMaxWidth = 40;
const int32 kMaxNameChars = 40;
fName = path.Leaf();
int extra = fName.Length() - kMaxWidth;
int extra = fName.CountChars() - kMaxNameChars;
if (extra > 0) {
BString extension;
int offset = fName.FindLast('.');
if (offset > 0) {
offset++;
fName.Truncate(offset - extra) << B_UTF8_ELLIPSIS;
fName.Append(path.Leaf() + offset);
}
if (offset > 0)
fName.CopyInto(extension, ++offset, -1);
fName.TruncateChars(kMaxNameChars) << B_UTF8_ELLIPSIS << extension;
}
}

Expand Down

0 comments on commit 3c7eaf3

Please sign in to comment.