From 1519205f24ebe1a45e79e9463aa1c1d2cd8e1f4f Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 8 Mar 2006 12:45:48 +0000 Subject: [PATCH] Automaticall convert message to console charset, use utf8 for GTK2 Gui git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17773 b3059339-0415-0410-9bf9-f77b7e298cf2 --- Gui/mplayer/widgets.c | 1 - cfg-common.h | 4 ++++ configure | 17 +++++++++++++++ mp_msg.c | 49 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) diff --git a/Gui/mplayer/widgets.c b/Gui/mplayer/widgets.c index ac18b2d01a..6fbdeb3a01 100644 --- a/Gui/mplayer/widgets.c +++ b/Gui/mplayer/widgets.c @@ -61,7 +61,6 @@ Pixmap guiIconMask; void gtkInit( void ) { mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[widget] init GTK ...\n" ); - gtk_set_locale(); gtk_init( 0,NULL ); // gdk_set_use_xshm( TRUE ); diff --git a/cfg-common.h b/cfg-common.h index 8f53557541..cec052d040 100644 --- a/cfg-common.h +++ b/cfg-common.h @@ -6,6 +6,9 @@ {"really-quiet", &verbose, CONF_TYPE_FLAG, CONF_GLOBAL, 0, -10, NULL}, {"v", cfg_inc_verbose, CONF_TYPE_FUNC, CONF_GLOBAL|CONF_NOSAVE, 0, 0, NULL}, {"msglevel", msgl_config, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL}, +#ifdef USE_ICONV + {"msgcharset", &mp_msg_charset, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL}, +#endif {"include", cfg_include, CONF_TYPE_FUNC_PARAM, CONF_NOSAVE, 0, 0, NULL}, #ifdef WIN32 {"priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL}, @@ -302,6 +305,7 @@ extern int quiet; extern int verbose; +extern char *mp_msg_charset; // codec/filter opts: (defined at libmpcodecs/vd.c) extern float screen_size_xy; diff --git a/configure b/configure index a28905c493..80b238335f 100755 --- a/configure +++ b/configure @@ -6958,6 +6958,20 @@ else fi # --------------- GUI specific tests end ------------------- +if test "$_charset" = "noconv" ; then + _charset="" +elif test -z "$_charset" ; then + if test "$_gtk1" = yes ; then + _charset=`cat ${_mp_help}.charset` + else + _charset=utf8 + fi +fi +if test "$_charset" ; then + _def_charset="#define MSG_CHARSET \"$_charset\"" +else + _def_charset="#undef MSG_CHARSET" +fi ############################################################################# @@ -7404,6 +7418,9 @@ cat > config.h << EOF /* use GNU internationalization */ $_def_i18n +/* name of messages charset */ +$_def_charset + /* Runtime CPU detection */ $_def_runtime_cpudetection diff --git a/mp_msg.c b/mp_msg.c index 7f522aeb78..8439b141d8 100644 --- a/mp_msg.c +++ b/mp_msg.c @@ -7,6 +7,14 @@ #include "config.h" +#ifdef USE_LANGINFO +#include +#include +#endif +#ifdef USE_ICONV +#include +#endif + #if defined(FOR_MENCODER) || defined(CODECS2HTML) #undef HAVE_NEW_GUI #endif @@ -23,6 +31,11 @@ extern int use_gui; int mp_msg_levels[MSGT_MAX]; // verbose level of this module. inited to -2 int mp_msg_level_all = MSGL_STATUS; int verbose = 0; +#ifdef USE_ICONV +char *mp_msg_charset = NULL; +static char *old_charset = NULL; +static iconv_t msgiconv; +#endif void mp_msg_init(void){ int i; @@ -43,6 +56,16 @@ void mp_msg_init(void){ #endif #endif for(i=0;i