Mercurial > audlegacy-plugins
comparison src/modplug/gui/main.cxx @ 1601:be8babbd772c
Convert strings to UTF-8 using str_to_utf8(). This solution is not
"Correct(tm)", but since the encoding used in module files cannot be known,
it's the best bet.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 05 Sep 2007 11:54:05 +0300 |
parents | f026de9d341c |
children | f6f5603a0954 |
comparison
equal
deleted
inserted
replaced
1600:49fe2225d236 | 1601:be8babbd772c |
---|---|
7 # include <config.h> | 7 # include <config.h> |
8 #endif | 8 #endif |
9 | 9 |
10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
11 #include <libintl.h> | 11 #include <libintl.h> |
12 extern "C" { | |
12 #include "audacious/util.h" | 13 #include "audacious/util.h" |
14 #include "audacious/strings.h" | |
15 } | |
13 | 16 |
14 #include "interface.h" | 17 #include "interface.h" |
15 #include "support.h" | 18 #include "support.h" |
16 #include "main.h" | 19 #include "main.h" |
17 | 20 |
150 if(!InfoWin) | 153 if(!InfoWin) |
151 InfoWin = create_Info(); | 154 InfoWin = create_Info(); |
152 | 155 |
153 uint32 lSongTime, lNumSamples, lNumInstruments, i; | 156 uint32 lSongTime, lNumSamples, lNumInstruments, i; |
154 string lInfo; | 157 string lInfo; |
155 char lBuffer[33]; | 158 gchar lBuffer[33]; |
156 stringstream lStrStream(ios::out); //C++ replacement for sprintf() | 159 stringstream lStrStream(ios::out); //C++ replacement for sprintf() |
157 | 160 |
158 CSoundFile* lSoundFile; | 161 CSoundFile* lSoundFile; |
159 | 162 |
160 Archive* lArchive; | 163 Archive* lArchive; |
161 string lShortFN; | 164 string lShortFN; |
162 uint32 lPos; | 165 uint32 lPos; |
166 gchar *tmps; | |
163 | 167 |
164 lPos = aFilename.find_last_of('/') + 1; | 168 lPos = aFilename.find_last_of('/') + 1; |
165 lShortFN = aFilename.substr(lPos); | 169 lShortFN = aFilename.substr(lPos); |
166 | 170 |
167 //open and mmap the file | 171 //open and mmap the file |
175 lSoundFile = new CSoundFile; | 179 lSoundFile = new CSoundFile; |
176 lSoundFile->Create((uchar*)lArchive->Map(), lArchive->Size()); | 180 lSoundFile->Create((uchar*)lArchive->Map(), lArchive->Size()); |
177 | 181 |
178 lInfo = lShortFN; | 182 lInfo = lShortFN; |
179 lInfo += '\n'; | 183 lInfo += '\n'; |
180 lInfo += lSoundFile->GetTitle(); | 184 tmps = str_to_utf8(lSoundFile->GetTitle()); |
185 lInfo += tmps; | |
186 g_free(tmps); | |
181 lInfo += '\n'; | 187 lInfo += '\n'; |
182 | 188 |
183 switch(lSoundFile->GetType()) | 189 switch(lSoundFile->GetType()) |
184 { | 190 { |
185 case MOD_TYPE_MOD: | 191 case MOD_TYPE_MOD: |
273 | 279 |
274 lInfo = ""; | 280 lInfo = ""; |
275 for(i = 0; i < lNumSamples; i++) | 281 for(i = 0; i < lNumSamples; i++) |
276 { | 282 { |
277 lSoundFile->GetSampleName(i, lBuffer); | 283 lSoundFile->GetSampleName(i, lBuffer); |
278 lInfo += lBuffer; | 284 tmps = str_to_utf8(lBuffer); |
285 lInfo += tmps; | |
286 g_free(tmps); | |
279 lInfo += '\n'; | 287 lInfo += '\n'; |
280 } | 288 } |
281 gtk_label_set_text((GtkLabel*)lookup_widget(InfoWin, "info_samples"), lInfo.c_str()); | 289 gtk_label_set_text((GtkLabel*)lookup_widget(InfoWin, "info_samples"), lInfo.c_str()); |
282 | 290 |
283 lInfo = ""; | 291 lInfo = ""; |
284 for(i = 0; i < lNumInstruments; i++) | 292 for(i = 0; i < lNumInstruments; i++) |
285 { | 293 { |
286 lSoundFile->GetInstrumentName(i, lBuffer); | 294 lSoundFile->GetInstrumentName(i, lBuffer); |
287 lInfo += lBuffer; | 295 tmps = str_to_utf8(lBuffer); |
296 lInfo += tmps; | |
297 g_free(tmps); | |
288 lInfo += '\n'; | 298 lInfo += '\n'; |
289 } | 299 } |
290 gtk_label_set_text((GtkLabel*)lookup_widget(InfoWin, "info_instruments"), lInfo.c_str()); | 300 gtk_label_set_text((GtkLabel*)lookup_widget(InfoWin, "info_instruments"), lInfo.c_str()); |
291 | 301 |
292 char message[MAX_MESSAGE_LENGTH]; | 302 char message[MAX_MESSAGE_LENGTH]; |
294 | 304 |
295 //textbox = (GtkLabel*)lookup_widget(InfoWin, "info_message"); | 305 //textbox = (GtkLabel*)lookup_widget(InfoWin, "info_message"); |
296 //gtk_text_backward_delete(textbox, length); | 306 //gtk_text_backward_delete(textbox, length); |
297 length = lSoundFile->GetSongComments(message, MAX_MESSAGE_LENGTH, 80); | 307 length = lSoundFile->GetSongComments(message, MAX_MESSAGE_LENGTH, 80); |
298 if (length != 0) { | 308 if (length != 0) { |
299 gtk_label_set_text((GtkLabel*)lookup_widget(InfoWin, "info_message"), message); | 309 tmps = str_to_utf8(message); |
310 gtk_label_set_text((GtkLabel*)lookup_widget(InfoWin, "info_message"), tmps); | |
311 g_free(tmps); | |
300 } | 312 } |
301 | 313 |
302 //unload the file | 314 //unload the file |
303 lSoundFile->Destroy(); | 315 lSoundFile->Destroy(); |
304 delete lSoundFile; | 316 delete lSoundFile; |