Mercurial > mplayer.hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
34174:a93891202051 | 34175:a345e7162d0a |
---|---|
24 #include <stdio.h> | 24 #include <stdio.h> |
25 #include <ctype.h> | 25 #include <ctype.h> |
26 #include <windows.h> | 26 #include <windows.h> |
27 | 27 |
28 #include "gui/util/bitmap.h" | 28 #include "gui/util/bitmap.h" |
29 #include "gui/util/string.h" | |
29 #include "gui/interface.h" | 30 #include "gui/interface.h" |
30 #include "gui.h" | 31 #include "gui.h" |
31 | |
32 #include "help_mp.h" | |
33 #include "libavutil/avstring.h" | |
34 | 32 |
35 #define MAX_LABELSIZE 250 | 33 #define MAX_LABELSIZE 250 |
36 | 34 |
37 static void render(int bitsperpixel, image *dst, image *src, int x, int y, int sx, int sy, int sw, int sh, int transparent) | 35 static void render(int bitsperpixel, image *dst, image *src, int x, int y, int sx, int sy, int sw, int sh, int transparent) |
38 { | 36 { |
113 while((offset = strpos(dest, what)) != -1) | 111 while((offset = strpos(dest, what)) != -1) |
114 { | 112 { |
115 memmove(dest + offset + strlen(tmp), dest + offset + strlen(what), strlen(dest + offset + strlen(what)) + 1); | 113 memmove(dest + offset + strlen(tmp), dest + offset + strlen(what), strlen(dest + offset + strlen(what)) + 1); |
116 memcpy(dest + offset, tmp, strlen(tmp)); | 114 memcpy(dest + offset, tmp, strlen(tmp)); |
117 } | 115 } |
118 } | |
119 | |
120 static char *TranslateFilename (int c, char *tmp, size_t tmplen) | |
121 { | |
122 int i; | |
123 char *p; | |
124 size_t len; | |
125 | |
126 switch (guiInfo.StreamType) | |
127 { | |
128 case STREAMTYPE_FILE: | |
129 if (guiInfo.Filename && guiInfo.Filename[0]) | |
130 { | |
131 p = strrchr(guiInfo.Filename, '\\'); | |
132 | |
133 if (p) av_strlcpy(tmp, p + 1, tmplen); | |
134 else av_strlcpy(tmp, guiInfo.Filename, tmplen); | |
135 | |
136 len = strlen(tmp); | |
137 | |
138 if (len > 3 && tmp[len - 3] == '.') tmp[len - 3] = 0; | |
139 else if (len > 4 && tmp[len - 4] == '.') tmp[len - 4] = 0; | |
140 else if (len > 5 && tmp[len - 5] == '.') tmp[len - 5] = 0; | |
141 } | |
142 else av_strlcpy(tmp, MSGTR_NoFileLoaded, tmplen); | |
143 break; | |
144 | |
145 case STREAMTYPE_STREAM: | |
146 av_strlcpy(tmp, guiInfo.Filename, tmplen); | |
147 break; | |
148 | |
149 #ifdef CONFIG_DVDREAD | |
150 case STREAMTYPE_DVD: | |
151 if (guiInfo.Chapter) snprintf(tmp, tmplen, MSGTR_Chapter, guiInfo.Chapter); | |
152 else av_strlcat(tmp, MSGTR_NoChapter, tmplen); | |
153 break; | |
154 #endif | |
155 | |
156 default: | |
157 av_strlcpy(tmp, MSGTR_NoMediaOpened, tmplen); | |
158 break; | |
159 } | |
160 | |
161 if (c) | |
162 { | |
163 for (i = 0; tmp[i]; i++) | |
164 { | |
165 int t = 0; | |
166 | |
167 if (c == 1) | |
168 if (tmp[i] >= 'A' && tmp[i] <= 'Z') t = 32; | |
169 | |
170 if (c == 2) | |
171 if (tmp[i] >= 'a' && tmp[i] <= 'z') t = -32; | |
172 | |
173 tmp[i] = (char) (tmp[i] + t); | |
174 } | |
175 } | |
176 | |
177 return tmp; | |
178 } | 116 } |
179 | 117 |
180 /* replaces the chars with special meaning with the associated data from the player info struct */ | 118 /* replaces the chars with special meaning with the associated data from the player info struct */ |
181 static char *generatetextfromlabel(widget *item) | 119 static char *generatetextfromlabel(widget *item) |
182 { | 120 { |