Mercurial > mplayer.hg
diff gui/win32/widgetrender.c @ 34175:a345e7162d0a
Move TranslateFilename() to util/string.c.
Now that the Win32 GUI uses symbolic constants for its messages,
the code of TranslateFilename() both GUIs use is almost identical.
So, share the code.
author | ib |
---|---|
date | Wed, 26 Oct 2011 15:14:06 +0000 |
parents | 95c396eb89ab |
children | 5a45efc630b8 |
line wrap: on
line diff
--- a/gui/win32/widgetrender.c Wed Oct 26 15:12:35 2011 +0000 +++ b/gui/win32/widgetrender.c Wed Oct 26 15:14:06 2011 +0000 @@ -26,12 +26,10 @@ #include <windows.h> #include "gui/util/bitmap.h" +#include "gui/util/string.h" #include "gui/interface.h" #include "gui.h" -#include "help_mp.h" -#include "libavutil/avstring.h" - #define MAX_LABELSIZE 250 static void render(int bitsperpixel, image *dst, image *src, int x, int y, int sx, int sy, int sw, int sh, int transparent) @@ -117,66 +115,6 @@ } } -static char *TranslateFilename (int c, char *tmp, size_t tmplen) -{ - int i; - char *p; - size_t len; - - switch (guiInfo.StreamType) - { - case STREAMTYPE_FILE: - if (guiInfo.Filename && guiInfo.Filename[0]) - { - p = strrchr(guiInfo.Filename, '\\'); - - if (p) av_strlcpy(tmp, p + 1, tmplen); - else av_strlcpy(tmp, guiInfo.Filename, tmplen); - - len = strlen(tmp); - - if (len > 3 && tmp[len - 3] == '.') tmp[len - 3] = 0; - else if (len > 4 && tmp[len - 4] == '.') tmp[len - 4] = 0; - else if (len > 5 && tmp[len - 5] == '.') tmp[len - 5] = 0; - } - else av_strlcpy(tmp, MSGTR_NoFileLoaded, tmplen); - break; - - case STREAMTYPE_STREAM: - av_strlcpy(tmp, guiInfo.Filename, tmplen); - break; - -#ifdef CONFIG_DVDREAD - case STREAMTYPE_DVD: - if (guiInfo.Chapter) snprintf(tmp, tmplen, MSGTR_Chapter, guiInfo.Chapter); - else av_strlcat(tmp, MSGTR_NoChapter, tmplen); - break; -#endif - - default: - av_strlcpy(tmp, MSGTR_NoMediaOpened, tmplen); - break; - } - - if (c) - { - for (i = 0; tmp[i]; i++) - { - int t = 0; - - if (c == 1) - if (tmp[i] >= 'A' && tmp[i] <= 'Z') t = 32; - - if (c == 2) - if (tmp[i] >= 'a' && tmp[i] <= 'z') t = -32; - - tmp[i] = (char) (tmp[i] + t); - } - } - - return tmp; -} - /* replaces the chars with special meaning with the associated data from the player info struct */ static char *generatetextfromlabel(widget *item) {