1
mirror of https://github.com/mpv-player/mpv synced 2024-11-18 21:16:10 +01:00

add gui error handling jol.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1926 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
pontscho 2001-09-20 10:27:24 +00:00
parent d4e44fe64c
commit 23949ebcfa
5 changed files with 92 additions and 16 deletions

View File

@ -6,7 +6,14 @@ GtkWidget * gtkMessageBoxText;
void on_MessageBox_destroy( GtkObject * object,gpointer user_data )
{
gtk_widget_hide( MessageBox );
/*
switch( (int)user_data )
{
case GTK_MB_ERROR: gtk_widget_hide( ErrorMessageBox ); break;
case GTK_MB_WARNING: gtk_widget_hide( WarningMessageBox ); break;
}
*/
gtk_widget_hide( MessageBox );
gtkVisibleMessageBox=0;
}
@ -100,16 +107,25 @@ GtkWidget * create_MessageBox( int type )
gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 0);
pixmapstyle=gtk_widget_get_style( MessageBox );
pixmapwid=gdk_pixmap_colormap_create_from_xpm_d( MessageBox->window,gdk_colormap_get_system(),&mask,&pixmapstyle->bg[GTK_STATE_NORMAL],(gchar ** )error_xpm );
pixmap1=gtk_pixmap_new( pixmapwid,mask );
gtk_widget_set_name (pixmap1, "pixmap1");
gtk_widget_ref (pixmap1);
gtk_object_set_data_full (GTK_OBJECT (MessageBox), "pixmap1", pixmap1,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (pixmap1);
gtk_box_pack_start (GTK_BOX (hbox1), pixmap1, FALSE, FALSE, 0);
gtk_widget_set_usize (pixmap1, 55, -2);
pixmapwid=gdk_pixmap_colormap_create_from_xpm_d( MessageBox->window,gdk_colormap_get_system(),&mask,&pixmapstyle->bg[GTK_STATE_NORMAL],(gchar ** )warning_xpm );
WarningPixmap=gtk_pixmap_new( pixmapwid,mask );
pixmapwid=gdk_pixmap_colormap_create_from_xpm_d( MessageBox->window,gdk_colormap_get_system(),&mask,&pixmapstyle->bg[GTK_STATE_NORMAL],(gchar ** )error_xpm );
ErrorPixmap=gtk_pixmap_new( pixmapwid,mask );
gtk_widget_set_name (WarningPixmap, "pixmap1");
gtk_widget_ref (WarningPixmap);
gtk_object_set_data_full (GTK_OBJECT (MessageBox), "pixmap1", WarningPixmap,(GtkDestroyNotify)gtk_widget_unref);
gtk_widget_hide (WarningPixmap);
gtk_box_pack_start (GTK_BOX (hbox1), WarningPixmap, FALSE, FALSE, 0);
gtk_widget_set_usize (WarningPixmap, 55, -2);
gtk_widget_set_name (ErrorPixmap, "pixmap1");
gtk_widget_ref (ErrorPixmap);
gtk_object_set_data_full (GTK_OBJECT (MessageBox), "pixmap1", ErrorPixmap,(GtkDestroyNotify)gtk_widget_unref);
gtk_widget_hide (ErrorPixmap);
gtk_box_pack_start (GTK_BOX (hbox1), ErrorPixmap, FALSE, FALSE, 0);
gtk_widget_set_usize (ErrorPixmap, 55, -2);
gtkMessageBoxText = gtk_label_new ( "Text jol. Ha ezt megerted, akkor neked nagyon jo a magyar tudasod, te.");
gtk_widget_set_name (gtkMessageBoxText, "gtkMessageBoxText");

View File

@ -95,7 +95,25 @@ void gtkSigHandler( int s )
break;
case evMessageBox:
gtk_label_set_text( gtkMessageBoxText,(char *)gtkShMem->mb.str );
if ( gtkVisibleMessageBox ) gtk_widget_hide( MessageBox );
if( gtkVisibleMessageBox ) gtk_widget_hide( MessageBox );
switch( gtkShMem->mb.type)
{
case GTK_MB_FATAL:
gtk_window_set_title (GTK_WINDOW (MessageBox), "fatal error ...");
gtk_widget_hide( WarningPixmap );
gtk_widget_show( ErrorPixmap );
break;
case GTK_MB_ERROR:
gtk_window_set_title (GTK_WINDOW (MessageBox), "error ...");
gtk_widget_hide( WarningPixmap );
gtk_widget_show( ErrorPixmap );
break;
case GTK_MB_WARNING:
gtk_window_set_title (GTK_WINDOW (MessageBox), "warning ...");
gtk_widget_show( WarningPixmap );
gtk_widget_hide( ErrorPixmap );
break;
}
gtk_widget_show( MessageBox );
gtkVisibleMessageBox=1;
break;

View File

@ -25,19 +25,21 @@
#include "pixmaps/up.xpm"
#include "pixmaps/dir.xpm"
#include "pixmaps/file.xpm"
#include "pixmaps/logo.xpm"
#include "pixmaps/about.xpm"
#include "pixmaps/stop.xpm"
#include "pixmaps/error.xpm"
#include "pixmaps/warning.xpm"
GtkWidget * SkinBrowser;
GtkWidget * PlayList;
GtkWidget * FileSelect;
GtkWidget * MessageBox;
GtkWidget * AboutBox;
GtkWidget * Options;
GtkWidget * MessageBox;
GtkWidget * WarningPixmap;
GtkWidget * ErrorPixmap;
int gtkVisibleSkinBrowser = 0;
int gtkVisiblePlayList = 0;
int gtkVisibleFileSelect = 0;

View File

@ -59,10 +59,14 @@ extern gtkCommStruct * gtkShMem;
extern GtkWidget * SkinBrowser;
extern GtkWidget * PlayList;
extern GtkWidget * FileSelect;
extern GtkWidget * MessageBox;
extern GtkWidget * AboutBox;
extern GtkWidget * Options;
extern GtkWidget * MessageBox;
extern GtkWidget * WarningPixmap;
extern GtkWidget * ErrorPixmap;
extern GtkWidget * SkinList;
extern GtkWidget * gtkMessageBoxText;
@ -86,4 +90,4 @@ extern void gtkClearList( GtkWidget * list );
extern void gtkSetDefaultToCList( GtkWidget * list,char * item );
extern int gtkFindCList( GtkWidget * list,char * item );
#endif
#endif

View File

@ -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_init(int verbose){
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 @@ void mp_msg_c( int x, const char *format, ... ){
// 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