[MPlayer-cvslog] r34223 - trunk/gui/win32/widgetrender.c
ib
subversion at mplayerhq.hu
Thu Oct 20 15:09:08 CEST 2011
Author: ib
Date: Thu Oct 20 15:09:08 2011
New Revision: 34223
Log:
Add TranslateFilename() to the Win32 GUI.
What the filename related dynamic labels show so far differs from
the X11/GTK GUI. With no filename available, the even say "(null)".
Improve this by adding TranslateFilename().
TranslateFilename() is basically the same function as used for the
X11/GTK GUI.
Modified:
trunk/gui/win32/widgetrender.c
Modified: trunk/gui/win32/widgetrender.c
==============================================================================
--- trunk/gui/win32/widgetrender.c Thu Oct 20 14:53:27 2011 (r34222)
+++ trunk/gui/win32/widgetrender.c Thu Oct 20 15:09:08 2011 (r34223)
@@ -29,6 +29,8 @@
#include "gui/interface.h"
#include "gui.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)
@@ -114,6 +116,66 @@ static void stringreplace(char *dest, co
}
}
+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, "No file loaded.", tmplen);
+ break;
+
+ case STREAMTYPE_STREAM:
+ av_strlcpy(tmp, guiInfo.Filename, tmplen);
+ break;
+
+#ifdef CONFIG_DVDREAD
+ case STREAMTYPE_DVD:
+ if (guiInfo.Chapter) snprintf(tmp, tmplen, "Chapter %d", guiInfo.Chapter);
+ else av_strlcat(tmp, "No chapter", tmplen);
+ break;
+#endif
+
+ default:
+ av_strlcpy(tmp, "No media opened.", 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)
{
@@ -143,7 +205,7 @@ static char *generatetextfromlabel(widge
stringreplace(text, "$b", "%3.2f", guiInfo.Balance);
stringreplace(text, "$B", "%3.1f", guiInfo.Balance);
stringreplace(text, "$t", "%.2i", guiInfo.Track);
- stringreplace(text, "$o", "%s", guiInfo.Filename);
+ stringreplace(text, "$o", "%s", TranslateFilename(0, tmp, sizeof(tmp)));
stringreplace(text, "$x", "%i", guiInfo.VideoWidth);
stringreplace(text, "$y", "%i", guiInfo.VideoHeight);
stringreplace(text, "$C", "%s", guiInfo.sh_video ? codecname : "");
@@ -168,16 +230,8 @@ static char *generatetextfromlabel(widge
#endif
else stringreplace(text, "$T", "u");
- if(guiInfo.Filename)
- {
- for (i=0; i<strlen(guiInfo.Filename); i++)
- tmp[i] = tolower(guiInfo.Filename[i]);
- stringreplace(text, "$f", tmp);
-
- for (i=0; i<strlen(guiInfo.Filename); i++)
- tmp[i] = toupper(guiInfo.Filename[i]);
- stringreplace(text, "$F", tmp);
- }
+ stringreplace(text, "$f", TranslateFilename(1, tmp, sizeof(tmp)));
+ stringreplace(text, "$F", TranslateFilename(2, tmp, sizeof(tmp)));
return text;
}
More information about the MPlayer-cvslog
mailing list