mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 16:01:10 +02:00
filebrowser: improve display of long paths
If a directory is too long to be displayed, the last
part of it is probably more interesting than the first.
A likely overflow is prevented by using asprintf instead
of a static buffer
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1483 e54a6e83-5905-42d5-8d5c-058d10e6a962
Origin commit data
------------------
Branch: ni/coolstream
Commit: 61573462c8
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2011-05-22 (Sun, 22 May 2011)
------------------
This commit was generated by Migit
This commit is contained in:
@@ -1371,16 +1371,37 @@ void CFileBrowser::paintItem(unsigned int pos)
|
||||
|
||||
void CFileBrowser::paintHead()
|
||||
{
|
||||
char l_name[100];
|
||||
char *l_name;
|
||||
int i = 0;
|
||||
int l;
|
||||
frameBuffer->paintBoxRel(x,y, width,theight+0, COL_MENUHEAD_PLUS_0, RADIUS_MID, CORNER_TOP);
|
||||
#ifdef ENABLE_INTERNETRADIO
|
||||
if(m_Mode == ModeSC)
|
||||
snprintf(l_name, sizeof(l_name), "%s %s", g_Locale->getText(LOCALE_AUDIOPLAYER_ADD_SC), FILESYSTEM_ENCODING_TO_UTF8_STRING(name).c_str()); // UTF-8
|
||||
l = asprintf(&l_name, "%s %s", g_Locale->getText(LOCALE_AUDIOPLAYER_ADD_SC), FILESYSTEM_ENCODING_TO_UTF8_STRING(name).c_str());
|
||||
else
|
||||
#endif
|
||||
snprintf(l_name, sizeof(l_name), "%s %s", g_Locale->getText(LOCALE_FILEBROWSER_HEAD), FILESYSTEM_ENCODING_TO_UTF8_STRING(name).c_str()); // UTF-8
|
||||
l = asprintf(&l_name, "%s %s", g_Locale->getText(LOCALE_FILEBROWSER_HEAD), FILESYSTEM_ENCODING_TO_UTF8_STRING(name).c_str());
|
||||
|
||||
g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->RenderString(x+10,y+theight+1, width-11, l_name, COL_MENUHEAD, 0, true); // UTF-8
|
||||
if (l < 1) /* at least 1 for the " " space */
|
||||
{
|
||||
perror("CFileBrowser::paintHead asprintf");
|
||||
return;
|
||||
}
|
||||
|
||||
/* too long? Leave out the "Filebrowser" or "Shoutcast" prefix
|
||||
* the allocated space is sufficient since it is surely shorter than before */
|
||||
if (g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->getRenderWidth(l_name) > width - 11)
|
||||
l = sprintf(l_name, "%s", FILESYSTEM_ENCODING_TO_UTF8_STRING(name).c_str());
|
||||
if (l_name[l - 1] == '/')
|
||||
l_name[--l] = '\0';
|
||||
|
||||
/* still too long? the last part is probably more interesting than the first part... */
|
||||
while ((g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->getRenderWidth(&l_name[i]) > width - 11)
|
||||
&& (i < l))
|
||||
i++;
|
||||
|
||||
g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->RenderString(x+10,y+theight+1, width-11, &l_name[i], COL_MENUHEAD, 0, true);
|
||||
free(l_name);
|
||||
}
|
||||
|
||||
bool chooserDir(char *setting_dir, bool test_dir, const char *action_str, size_t str_leng)
|
||||
|
Reference in New Issue
Block a user