diff mp_msg.c @ 1925:633a7f0d72a4

add gui error handling jol.
author pontscho
date Thu, 20 Sep 2001 10:27:24 +0000
parents 913c1ee56b4f
children b024d0c98457
line wrap: on
line diff
--- a/mp_msg.c	Thu Sep 20 10:26:22 2001 +0000
+++ b/mp_msg.c	Thu Sep 20 10:27:24 2001 +0000
@@ -3,6 +3,14 @@
 #include <stdlib.h>
 #include <stdarg.h>
 
+#include "config.h"
+
+#ifdef HAVE_NEW_GUI
+#include "Gui/mplayer/widgets.h"
+extern void gtkMessageBox( int type,char * str );
+extern int use_gui;
+#endif
+
 #include "mp_msg.h"
 
 static int mp_msg_levels[MSGT_MAX]; // verbose level of this module
@@ -18,8 +26,11 @@
 
 void mp_msg_c( int x, const char *format, ... ){
     va_list va;
+    char tmp[128];
     if((x&255)>mp_msg_levels[x>>8]) return; // do not display
     va_start(va, format);
+    vsnprintf( tmp,128,format,va );
+/*    
     if((x&255)<=MSGL_ERR){
 //	fprintf(stderr,"%%%%%% ");
 	vfprintf(stderr,format, va);
@@ -27,7 +38,32 @@
 //	printf("%%%%%% ");
 	vprintf(format, va);
     }
+*/    
     va_end(va);
+    switch( x&255 )
+     {
+       case MSGL_FATAL: 
+              fprintf( stderr,"%s",tmp );
+              #ifdef HAVE_NEW_GUI
+               if ( use_gui ) gtkMessageBox( GTK_MB_FATAL|GTK_MB_SIMPLE,tmp );
+              #endif
+       	   break;
+       case MSGL_ERR:
+              fprintf( stderr,"%s",tmp );
+              #ifdef HAVE_NEW_GUI 
+               if ( use_gui ) gtkMessageBox( GTK_MB_ERROR|GTK_MB_SIMPLE,tmp );
+              #endif
+       	   break;
+       case MSGL_WARN:
+              printf( "%s",tmp );
+              #ifdef HAVE_NEW_GUI 
+               if ( use_gui ) gtkMessageBox( GTK_MB_WARNING|GTK_MB_SIMPLE,tmp );
+              #endif
+       	   break;
+       default:
+              printf( "%s",tmp );
+       	   break;
+     }
 }
 
 #else