Mercurial > mplayer.hg
annotate mp_msg.c @ 4176:116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
| author | pontscho |
|---|---|
| date | Tue, 15 Jan 2002 17:03:19 +0000 |
| parents | 9eb4aa623ab6 |
| children | cb2adf32c356 |
| 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 | |
| 13 | |
| 1562 | 14 #include "mp_msg.h" |
| 15 | |
| 16 static int mp_msg_levels[MSGT_MAX]; // verbose level of this module | |
| 17 | |
| 18 #if 1 | |
| 19 | |
| 20 void mp_msg_init(int verbose){ | |
| 21 int i; | |
| 22 for(i=0;i<MSGT_MAX;i++){ | |
| 23 mp_msg_levels[i]=verbose; | |
| 24 } | |
| 25 } | |
| 26 | |
| 27 void mp_msg_c( int x, const char *format, ... ){ | |
| 28 va_list va; | |
| 29 if((x&255)>mp_msg_levels[x>>8]) return; // do not display | |
| 30 va_start(va, format); | |
|
4176
116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents:
3780
diff
changeset
|
31 #if defined( HAVE_NEW_GUI ) && !defined( HAVE_MENCODER ) |
| 1971 | 32 if(use_gui){ |
| 3293 | 33 char tmp[16*80]; |
| 1971 | 34 vsnprintf( tmp,8*80,format,va ); tmp[8*80-1]=0; |
| 35 switch( x&255 ) { | |
| 1925 | 36 case MSGL_FATAL: |
| 37 fprintf( stderr,"%s",tmp ); | |
| 3780 | 38 fflush(stderr); |
| 1971 | 39 gtkMessageBox( GTK_MB_FATAL|GTK_MB_SIMPLE,tmp ); |
| 1925 | 40 break; |
| 41 case MSGL_ERR: | |
| 42 fprintf( stderr,"%s",tmp ); | |
| 3780 | 43 fflush(stderr); |
| 1971 | 44 gtkMessageBox( GTK_MB_ERROR|GTK_MB_SIMPLE,tmp ); |
| 1925 | 45 break; |
| 46 case MSGL_WARN: | |
| 47 printf( "%s",tmp ); | |
| 3780 | 48 fflush(stdout); |
| 1971 | 49 gtkMessageBox( GTK_MB_WARNING|GTK_MB_SIMPLE,tmp ); |
| 1925 | 50 break; |
| 51 default: | |
| 52 printf( "%s",tmp ); | |
| 3780 | 53 fflush(stdout); |
| 1971 | 54 } |
| 55 } else | |
| 56 #endif | |
| 57 if((x&255)<=MSGL_ERR){ | |
| 58 // fprintf(stderr,"%%%%%% "); | |
| 59 vfprintf(stderr,format, va); | |
| 3780 | 60 fflush(stderr); |
| 1971 | 61 } else { |
| 62 // printf("%%%%%% "); | |
| 63 vprintf(format, va); | |
| 3780 | 64 fflush(stdout); |
| 1971 | 65 } |
| 66 va_end(va); | |
| 1562 | 67 } |
| 68 | |
| 69 #else | |
| 70 | |
| 71 FILE *mp_msg_file[MSGT_MAX]; // print message to this file (can be stdout/err) | |
| 72 static FILE* mp_msg_last_file=NULL; | |
| 73 | |
| 74 // how to handle errors->stderr messages->stdout ? | |
| 75 void mp_msg( int x, const char *format, ... ){ | |
| 76 if((x&255)>mp_msg_levels[x>>8] || !mp_msg_file[x>>8]) return; // do not display | |
| 77 va_list va; | |
| 78 va_start(va, format); | |
| 79 vfprintf(mp_msg_file[x>>8],format, va); | |
| 80 if(mp_msg_last_file!=mp_msg_file[x>>8]){ | |
| 81 fflush(mp_msg_file[x>>8]); | |
| 82 mp_msg_last_file=mp_msg_file[x>>8]; | |
| 83 } | |
| 84 va_end(va); | |
| 85 } | |
| 86 | |
| 87 #endif |
