Mercurial > mplayer.hg
annotate mp_msg.c @ 6616:0b5a789d7fab
using the new rgb2rgb converters (the LQ ones are only used if -sws 0 or -sws 4)
author | michael |
---|---|
date | Sun, 30 Jun 2002 20:34:54 +0000 |
parents | 786ab42c10be |
children | 2e5c07262861 |
rev | line source |
---|---|
1562 | 1 |
2 #include <stdio.h> | |
3 #include <stdlib.h> | |
4 #include <stdarg.h> | |
5 | |
1925 | 6 #include "config.h" |
7 | |
8 #ifdef HAVE_NEW_GUI | |
9 #include "Gui/mplayer/widgets.h" | |
10 extern void gtkMessageBox( int type,char * str ); | |
11 extern int use_gui; | |
12 #endif | |
1562 | 13 #include "mp_msg.h" |
14 | |
6306
786ab42c10be
Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents:
6048
diff
changeset
|
15 /* maximum message length of mp_msg */ |
786ab42c10be
Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents:
6048
diff
changeset
|
16 #define MSGSIZE_MAX 3072 |
786ab42c10be
Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents:
6048
diff
changeset
|
17 |
1562 | 18 static int mp_msg_levels[MSGT_MAX]; // verbose level of this module |
19 | |
20 #if 1 | |
21 | |
5220
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
22 void mp_msg_init(){ |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
23 #ifdef USE_I18N |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
24 fprintf(stdout, "Using GNU internationalization\n"); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
25 fprintf(stdout, "Original domain: %s\n", textdomain(NULL)); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
26 fprintf(stdout, "Original dirname: %s\n", bindtextdomain(textdomain(NULL),NULL)); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
27 setlocale(LC_ALL, ""); /* set from the environment variables */ |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
28 bindtextdomain("mplayer", PREFIX"/share/locale"); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
29 textdomain("mplayer"); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
30 fprintf(stdout, "Current domain: %s\n", textdomain(NULL)); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
31 fprintf(stdout, "Current dirname: %s\n", bindtextdomain(textdomain(NULL),NULL)); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
32 #endif |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
33 mp_msg_set_level(MSGL_STATUS); |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
34 } |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
35 |
4afbe13150e6
splitted mp_msg_init and mp_msg_set_level and added i18n support to init
alex
parents:
5102
diff
changeset
|
36 void mp_msg_set_level(int verbose){ |
1562 | 37 int i; |
38 for(i=0;i<MSGT_MAX;i++){ | |
39 mp_msg_levels[i]=verbose; | |
40 } | |
41 } | |
42 | |
43 void mp_msg_c( int x, const char *format, ... ){ | |
5102 | 44 #if 1 |
45 va_list va; | |
6306
786ab42c10be
Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents:
6048
diff
changeset
|
46 char tmp[MSGSIZE_MAX]; |
5102 | 47 |
48 if((x&255)>mp_msg_levels[x>>8]) return; // do not display | |
5286
30caf02c0eae
10l - va_start needs teh pointer to stack - not the translated message
arpi
parents:
5220
diff
changeset
|
49 va_start(va, format); |
6306
786ab42c10be
Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents:
6048
diff
changeset
|
50 vsnprintf(tmp, MSGSIZE_MAX, mp_gettext(format), va); |
786ab42c10be
Extend maximum mp_msg message size, some translations need it or help message will be cutted.
atmos4
parents:
6048
diff
changeset
|
51 tmp[MSGSIZE_MAX-1] = 0; |
5102 | 52 |
6048
4301077b29d0
HAVE_MENCODER->FOR_MENCODER (forgot to commit some weeks ago...)
arpi
parents:
5919
diff
changeset
|
53 #if defined(HAVE_NEW_GUI) && !defined(FOR_MENCODER) |
5102 | 54 if(use_gui) |
55 { | |
56 switch(x & 255) | |
57 { | |
58 case MSGL_FATAL: | |
59 gtkMessageBox(GTK_MB_FATAL|GTK_MB_SIMPLE, tmp); | |
60 break; | |
61 case MSGL_ERR: | |
62 gtkMessageBox(GTK_MB_ERROR|GTK_MB_SIMPLE, tmp); | |
63 break; | |
5919 | 64 // case MSGL_WARN: |
65 // gtkMessageBox(GTK_MB_WARNING|GTK_MB_SIMPLE, tmp); | |
66 // break; | |
5102 | 67 } |
68 } | |
69 #endif | |
70 | |
71 fprintf(stderr, "%s", tmp); | |
72 if ((x & 255) <= MSGL_ERR) | |
73 fflush(stderr); | |
74 else | |
75 fflush(stdout); | |
76 | |
77 va_end(va); | |
78 #else | |
1562 | 79 va_list va; |
80 if((x&255)>mp_msg_levels[x>>8]) return; // do not display | |
81 va_start(va, format); | |
6048
4301077b29d0
HAVE_MENCODER->FOR_MENCODER (forgot to commit some weeks ago...)
arpi
parents:
5919
diff
changeset
|
82 #if defined( HAVE_NEW_GUI ) && !defined( FOR_MENCODER ) |
1971 | 83 if(use_gui){ |
3293 | 84 char tmp[16*80]; |
1971 | 85 vsnprintf( tmp,8*80,format,va ); tmp[8*80-1]=0; |
86 switch( x&255 ) { | |
1925 | 87 case MSGL_FATAL: |
88 fprintf( stderr,"%s",tmp ); | |
3780 | 89 fflush(stderr); |
1971 | 90 gtkMessageBox( GTK_MB_FATAL|GTK_MB_SIMPLE,tmp ); |
1925 | 91 break; |
92 case MSGL_ERR: | |
93 fprintf( stderr,"%s",tmp ); | |
3780 | 94 fflush(stderr); |
1971 | 95 gtkMessageBox( GTK_MB_ERROR|GTK_MB_SIMPLE,tmp ); |
1925 | 96 break; |
97 case MSGL_WARN: | |
4888
cb2adf32c356
Use stdout as default mencoder's output if no filename specified
nick
parents:
4176
diff
changeset
|
98 fprintf( stderr, "%s",tmp ); |
3780 | 99 fflush(stdout); |
1971 | 100 gtkMessageBox( GTK_MB_WARNING|GTK_MB_SIMPLE,tmp ); |
1925 | 101 break; |
102 default: | |
4888
cb2adf32c356
Use stdout as default mencoder's output if no filename specified
nick
parents:
4176
diff
changeset
|
103 fprintf(stderr, "%s",tmp ); |
3780 | 104 fflush(stdout); |
1971 | 105 } |
106 } else | |
107 #endif | |
108 if((x&255)<=MSGL_ERR){ | |
109 // fprintf(stderr,"%%%%%% "); | |
110 vfprintf(stderr,format, va); | |
3780 | 111 fflush(stderr); |
1971 | 112 } else { |
113 // printf("%%%%%% "); | |
4888
cb2adf32c356
Use stdout as default mencoder's output if no filename specified
nick
parents:
4176
diff
changeset
|
114 vfprintf(stderr,format, va); |
3780 | 115 fflush(stdout); |
1971 | 116 } |
117 va_end(va); | |
5102 | 118 #endif |
1562 | 119 } |
120 | |
121 #else | |
122 | |
123 FILE *mp_msg_file[MSGT_MAX]; // print message to this file (can be stdout/err) | |
124 static FILE* mp_msg_last_file=NULL; | |
125 | |
126 // how to handle errors->stderr messages->stdout ? | |
127 void mp_msg( int x, const char *format, ... ){ | |
128 if((x&255)>mp_msg_levels[x>>8] || !mp_msg_file[x>>8]) return; // do not display | |
129 va_list va; | |
130 va_start(va, format); | |
131 vfprintf(mp_msg_file[x>>8],format, va); | |
132 if(mp_msg_last_file!=mp_msg_file[x>>8]){ | |
133 fflush(mp_msg_file[x>>8]); | |
134 mp_msg_last_file=mp_msg_file[x>>8]; | |
135 } | |
136 va_end(va); | |
137 } | |
138 | |
139 #endif |