diff gui/ui/render.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 deff81b57903
children 0ba85cad4c7e
line wrap: on
line diff
--- a/gui/ui/render.c	Wed Oct 26 15:12:35 2011 +0000
+++ b/gui/ui/render.c	Wed Oct 26 15:14:06 2011 +0000
@@ -24,11 +24,11 @@
 #include "render.h"
 #include "gui/interface.h"
 #include "gui/skin/font.h"
+#include "gui/util/string.h"
 
 #include "access_mpcontext.h"
 #include "codec-cfg.h"
 #include "config.h"
-#include "help_mp.h"
 #include "libavutil/avstring.h"
 #include "libmpdemux/stheader.h"
 #include "mixer.h"
@@ -40,75 +40,6 @@
 static char *image_buffer;
 static int image_width;
 
-static void 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_VCD
-    case STREAMTYPE_VCD:
-        snprintf(tmp, tmplen, MSGTR_Title, guiInfo.Track - 1);
-        break;
-#endif
-
-#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);
-        }
-    }
-}
-
 static char *Translate(char *str)
 {
     static char trbuf[512];