2 //#define MSG_USE_COLORS
10 #if defined(FOR_MENCODER) || defined(CODECS2HTML)
11 #undef ENABLE_GUI_CODE
12 #elif defined(HAVE_NEW_GUI)
13 #define ENABLE_GUI_CODE HAVE_NEW_GUI
15 #undef ENABLE_GUI_CODE
19 #include "Gui/mplayer/widgets.h"
20 extern void gtkMessageBox( int type
,char * str
);
25 /* maximum message length of mp_msg */
26 #define MSGSIZE_MAX 3072
28 static int mp_msg_levels
[MSGT_MAX
]; // verbose level of this module
35 fprintf(stdout
, "Using GNU internationalization\n");
36 fprintf(stdout
, "Original domain: %s\n", textdomain(NULL
));
37 fprintf(stdout
, "Original dirname: %s\n", bindtextdomain(textdomain(NULL
),NULL
));
39 setlocale(LC_ALL
, ""); /* set from the environment variables */
40 bindtextdomain("mplayer", PREFIX
"/share/locale");
41 textdomain("mplayer");
43 fprintf(stdout
, "Current domain: %s\n", textdomain(NULL
));
44 fprintf(stdout
, "Current dirname: %s\n\n", bindtextdomain(textdomain(NULL
),NULL
));
47 mp_msg_set_level(MSGL_STATUS
);
50 void mp_msg_set_level(int verbose
){
52 for(i
=0;i
<MSGT_MAX
;i
++){
53 mp_msg_levels
[i
]=verbose
;
57 int mp_msg_test(int mod
, int lev
)
59 return lev
<= mp_msg_levels
[mod
];
62 void mp_msg_c( int x
, const char *format
, ... ){
65 char tmp
[MSGSIZE_MAX
];
67 if((x
&255)>mp_msg_levels
[x
>>8]) return; // do not display
69 vsnprintf(tmp
, MSGSIZE_MAX
, mp_gettext(format
), va
);
71 tmp
[MSGSIZE_MAX
-2] = '\n';
72 tmp
[MSGSIZE_MAX
-1] = 0;
80 gtkMessageBox(GTK_MB_FATAL
|GTK_MB_SIMPLE
, tmp
);
83 gtkMessageBox(GTK_MB_ERROR
|GTK_MB_SIMPLE
, tmp
);
86 // WARNING! Do NOT enable this! There are too many non-critical messages with
87 // MSGL_WARN, for example: broken SPU packets, codec's bit error messages,
88 // etc etc, they should not raise up a new window every time.
90 gtkMessageBox(GTK_MB_WARNING
|GTK_MB_SIMPLE
, tmp
);
98 /* that's only a silly color test */
104 printf("\033[%d;3%dm*** COLOR TEST %d ***\n",(c
>7),c
&7,c
);
108 { unsigned char v_colors
[10]={9,9,11,14,15,7,6,5,5,5};
109 int c
=v_colors
[(x
& 255)];
110 fprintf(((x
& 255) <= MSGL_WARN
)?stderr
:stdout
, "\033[%d;3%dm",(c
>7),c
&7);
113 if ((x
& 255) <= MSGL_WARN
){
114 fprintf(stderr
, "%s", tmp
);fflush(stderr
);
116 printf("%s", tmp
);fflush(stdout
);
121 if((x
&255)>mp_msg_levels
[x
>>8]) return; // do not display
122 va_start(va
, format
);
126 vsnprintf( tmp
,8*80,format
,va
); tmp
[8*80-1]=0;
129 fprintf( stderr
,"%s",tmp
);
131 gtkMessageBox( GTK_MB_FATAL
|GTK_MB_SIMPLE
,tmp
);
134 fprintf( stderr
,"%s",tmp
);
136 gtkMessageBox( GTK_MB_ERROR
|GTK_MB_SIMPLE
,tmp
);
139 fprintf( stderr
, "%s",tmp
);
141 gtkMessageBox( GTK_MB_WARNING
|GTK_MB_SIMPLE
,tmp
);
144 fprintf(stderr
, "%s",tmp
);
149 if((x
&255)<=MSGL_ERR
){
150 // fprintf(stderr,"%%%%%% ");
151 vfprintf(stderr
,format
, va
);
154 // printf("%%%%%% ");
155 vfprintf(stderr
,format
, va
);
164 FILE *mp_msg_file
[MSGT_MAX
]; // print message to this file (can be stdout/err)
165 static FILE* mp_msg_last_file
=NULL
;
167 // how to handle errors->stderr messages->stdout ?
168 void mp_msg( int x
, const char *format
, ... ){
169 if((x
&255)>mp_msg_levels
[x
>>8] || !mp_msg_file
[x
>>8]) return; // do not display
171 va_start(va
, format
);
172 vfprintf(mp_msg_file
[x
>>8],format
, va
);
173 if(mp_msg_last_file
!=mp_msg_file
[x
>>8]){
174 fflush(mp_msg_file
[x
>>8]);
175 mp_msg_last_file
=mp_msg_file
[x
>>8];