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 bindtextdomain("mplayer", PREFIX
"/share/locale");
40 textdomain("mplayer");
42 fprintf(stdout
, "Current domain: %s\n", textdomain(NULL
));
43 fprintf(stdout
, "Current dirname: %s\n\n", bindtextdomain(textdomain(NULL
),NULL
));
46 mp_msg_set_level(MSGL_STATUS
);
49 void mp_msg_set_level(int verbose
){
51 for(i
=0;i
<MSGT_MAX
;i
++){
52 mp_msg_levels
[i
]=verbose
;
56 int mp_msg_test(int mod
, int lev
)
58 return lev
<= mp_msg_levels
[mod
];
61 void mp_msg_c( int x
, const char *format
, ... ){
64 char tmp
[MSGSIZE_MAX
];
66 if((x
&255)>mp_msg_levels
[x
>>8]) return; // do not display
68 vsnprintf(tmp
, MSGSIZE_MAX
, mp_gettext(format
), va
);
70 tmp
[MSGSIZE_MAX
-2] = '\n';
71 tmp
[MSGSIZE_MAX
-1] = 0;
79 gtkMessageBox(GTK_MB_FATAL
|GTK_MB_SIMPLE
, tmp
);
82 gtkMessageBox(GTK_MB_ERROR
|GTK_MB_SIMPLE
, tmp
);
85 // WARNING! Do NOT enable this! There are too many non-critical messages with
86 // MSGL_WARN, for example: broken SPU packets, codec's bit error messages,
87 // etc etc, they should not raise up a new window every time.
89 gtkMessageBox(GTK_MB_WARNING
|GTK_MB_SIMPLE
, tmp
);
97 /* that's only a silly color test */
103 printf("\033[%d;3%dm*** COLOR TEST %d ***\n",(c
>7),c
&7,c
);
107 { unsigned char v_colors
[10]={9,9,11,14,15,7,6,5,5,5};
108 int c
=v_colors
[(x
& 255)];
109 fprintf(((x
& 255) <= MSGL_WARN
)?stderr
:stdout
, "\033[%d;3%dm",(c
>7),c
&7);
112 if ((x
& 255) <= MSGL_WARN
){
113 fprintf(stderr
, "%s", tmp
);fflush(stderr
);
115 printf("%s", tmp
);fflush(stdout
);
120 if((x
&255)>mp_msg_levels
[x
>>8]) return; // do not display
121 va_start(va
, format
);
125 vsnprintf( tmp
,8*80,format
,va
); tmp
[8*80-1]=0;
128 fprintf( stderr
,"%s",tmp
);
130 gtkMessageBox( GTK_MB_FATAL
|GTK_MB_SIMPLE
,tmp
);
133 fprintf( stderr
,"%s",tmp
);
135 gtkMessageBox( GTK_MB_ERROR
|GTK_MB_SIMPLE
,tmp
);
138 fprintf( stderr
, "%s",tmp
);
140 gtkMessageBox( GTK_MB_WARNING
|GTK_MB_SIMPLE
,tmp
);
143 fprintf(stderr
, "%s",tmp
);
148 if((x
&255)<=MSGL_ERR
){
149 // fprintf(stderr,"%%%%%% ");
150 vfprintf(stderr
,format
, va
);
153 // printf("%%%%%% ");
154 vfprintf(stderr
,format
, va
);
163 FILE *mp_msg_file
[MSGT_MAX
]; // print message to this file (can be stdout/err)
164 static FILE* mp_msg_last_file
=NULL
;
166 // how to handle errors->stderr messages->stdout ?
167 void mp_msg( int x
, const char *format
, ... ){
168 if((x
&255)>mp_msg_levels
[x
>>8] || !mp_msg_file
[x
>>8]) return; // do not display
170 va_start(va
, format
);
171 vfprintf(mp_msg_file
[x
>>8],format
, va
);
172 if(mp_msg_last_file
!=mp_msg_file
[x
>>8]){
173 fflush(mp_msg_file
[x
>>8]);
174 mp_msg_last_file
=mp_msg_file
[x
>>8];