2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "widgets.h"
|
|
|
|
#include "play.h"
|
|
|
|
|
|
|
|
#include "../app.h"
|
|
|
|
|
|
|
|
#include "../skin/skin.h"
|
|
|
|
#include "../wm/ws.h"
|
|
|
|
#include "../error.h"
|
|
|
|
|
|
|
|
#include "../../config.h"
|
2001-08-27 23:56:44 +00:00
|
|
|
#include "../../libvo/x11_common.h"
|
2001-10-24 10:58:18 +00:00
|
|
|
#include "../../libmpdemux/stream.h"
|
2001-08-27 23:56:44 +00:00
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
#include "./mplayer.h"
|
|
|
|
|
|
|
|
#define gtkShow( w ) gtkShMem->vs.window=w; gtkSendMessage( evShowWindow );
|
|
|
|
|
|
|
|
pid_t mplMPlayerPID = 0;
|
|
|
|
pid_t mplParentPID = 0;
|
|
|
|
|
2001-08-29 13:44:12 +00:00
|
|
|
pid_t gtkPID = 0;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
int mplCriticalError = 0;
|
|
|
|
int gtkIsOk = 0;
|
|
|
|
|
|
|
|
void mplErrorHandler( int critical,const char * format, ... )
|
|
|
|
{
|
|
|
|
char * p;
|
|
|
|
va_list ap;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
if ( (p=(char *)malloc( 512 ) ) == NULL ) return;
|
|
|
|
va_start( ap,format );
|
|
|
|
n=vsnprintf( p,512,format,ap );
|
|
|
|
va_end( ap );
|
|
|
|
mplCriticalError=critical;
|
2001-09-17 21:16:00 +00:00
|
|
|
gtkMessageBox( GTK_MB_ERROR,p );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void gtkSigHandler( int s )
|
|
|
|
{
|
|
|
|
if ( s != SIGTYPE ) return;
|
|
|
|
#ifdef DEBUG
|
|
|
|
dbprintf( 5,"[psignal] gtk sig handler msg: %d\n",gtkShMem->message );
|
|
|
|
#endif
|
|
|
|
switch ( gtkShMem->message )
|
|
|
|
{
|
|
|
|
case evHideWindow:
|
|
|
|
switch ( gtkShMem->vs.window )
|
|
|
|
{
|
|
|
|
case evPlayList: gtk_widget_hide( PlayList ); gtkVisiblePlayList=0; break;
|
|
|
|
case evSkinBrowser: gtk_widget_hide( SkinBrowser ); gtkVisibleSkinBrowser=0; break;
|
|
|
|
case evLoad: gtk_widget_hide( FileSelect ); gtkVisibleFileSelect=0; break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case evSkinBrowser:
|
|
|
|
if ( gtkVisibleSkinBrowser ) gtk_widget_hide( SkinBrowser );
|
|
|
|
gtkClearList( SkinList );
|
2001-09-17 21:16:00 +00:00
|
|
|
if ( gtkFillSkinList( sbMPlayerPrefixDir )&>kFillSkinList( sbMPlayerDirInHome ) )
|
2001-08-25 21:04:29 +00:00
|
|
|
{
|
2001-09-07 21:04:14 +00:00
|
|
|
gtkSetDefaultToCList( SkinList,skinName );
|
2001-08-25 21:04:29 +00:00
|
|
|
gtk_widget_show( SkinBrowser );
|
|
|
|
gtkVisibleSkinBrowser=1;
|
|
|
|
gtkShow( evSkinBrowser );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case evPreferences:
|
|
|
|
if ( gtkVisibleOptions ) gtk_widget_hide( Options );
|
|
|
|
gtk_widget_show( Options );
|
|
|
|
gtkVisibleOptions=1;
|
|
|
|
break;
|
|
|
|
case evPlayList:
|
|
|
|
if ( gtkVisiblePlayList ) gtk_widget_hide( PlayList );
|
|
|
|
gtk_widget_show( PlayList );
|
|
|
|
gtkVisiblePlayList=1;
|
|
|
|
gtkShow( evPlayList );
|
|
|
|
break;
|
|
|
|
case evLoad:
|
|
|
|
if ( gtkVisibleFileSelect ) gtk_widget_hide( FileSelect );
|
|
|
|
gtk_widget_show( FileSelect );
|
|
|
|
gtkVisibleFileSelect=1;
|
|
|
|
gtkShow( evPlay );
|
|
|
|
break;
|
2001-08-29 13:44:12 +00:00
|
|
|
case evFirstLoad:
|
|
|
|
if ( gtkVisibleFileSelect ) gtk_widget_hide( FileSelect );
|
|
|
|
gtk_widget_show( FileSelect );
|
|
|
|
gtkVisibleFileSelect=1;
|
|
|
|
gtkShow( evFirstLoad );
|
|
|
|
break;
|
2001-08-25 21:04:29 +00:00
|
|
|
case evMessageBox:
|
|
|
|
gtk_label_set_text( gtkMessageBoxText,(char *)gtkShMem->mb.str );
|
2001-09-20 10:27:24 +00:00
|
|
|
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;
|
|
|
|
}
|
2001-08-25 21:04:29 +00:00
|
|
|
gtk_widget_show( MessageBox );
|
|
|
|
gtkVisibleMessageBox=1;
|
|
|
|
break;
|
|
|
|
case evAbout:
|
|
|
|
if ( gtkVisibleAboutBox ) gtk_widget_hide( AboutBox );
|
|
|
|
gtk_widget_show( AboutBox );
|
|
|
|
gtkVisibleAboutBox=1;
|
|
|
|
break;
|
|
|
|
case evExit:
|
2001-08-26 00:28:56 +00:00
|
|
|
gtk_main_quit();
|
2001-08-25 21:04:29 +00:00
|
|
|
break;
|
2001-11-14 16:04:25 +00:00
|
|
|
case evShowPopUpMenu:
|
|
|
|
// if ( gtkVisiblePopUpMenu ) gtk_widget_hide( PopUpMenu );
|
|
|
|
// gtk_widget_show( PopUpMenu );
|
|
|
|
gtk_menu_popup( GTK_MENU( PopUpMenu ),NULL,NULL,NULL,NULL,0,0 );
|
|
|
|
gtkVisiblePopUpMenu=1;
|
|
|
|
break;
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
gtkShMem->message=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mplMainSigHandler( int s )
|
|
|
|
{
|
2001-08-29 13:44:12 +00:00
|
|
|
if ( s != SIGTYPE ) return;
|
|
|
|
|
2001-08-31 13:05:37 +00:00
|
|
|
// #ifdef DEBUG
|
2001-08-31 14:16:28 +00:00
|
|
|
// if ( gtkShMem->message ) dbprintf( 5,"[psignal] main sig handler gtk msg: %d\n",gtkShMem->message );
|
2001-08-29 13:44:12 +00:00
|
|
|
// if ( mplShMem->message ) dbprintf( 5,"[psignal] main sig handler mpl msg: %d\n",mplShMem->message );
|
2001-08-31 13:05:37 +00:00
|
|
|
// #endif
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
switch ( gtkShMem->message )
|
|
|
|
{
|
|
|
|
case evGtkIsOk:
|
|
|
|
#ifdef DEBUG
|
2001-08-29 13:44:12 +00:00
|
|
|
dbprintf( 5,"[psignal] gtk is ok.\n" );
|
2001-08-25 21:04:29 +00:00
|
|
|
#endif
|
|
|
|
gtkIsOk=True;
|
|
|
|
break;
|
|
|
|
case evShowWindow:
|
|
|
|
switch ( gtkShMem->vs.window )
|
|
|
|
{
|
|
|
|
case evPlayList: gtkVisiblePlayList=1; break;
|
|
|
|
case evLoad: gtkVisibleFileSelect=1; break;
|
|
|
|
case evSkinBrowser: gtkVisibleSkinBrowser=1; break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case evHideWindow:
|
|
|
|
switch ( gtkShMem->vs.window )
|
|
|
|
{
|
|
|
|
case evPlayList:
|
|
|
|
btnModify( evPlayList,btnReleased ); gtkVisiblePlayList=0;
|
|
|
|
mplMainRender=1; wsPostRedisplay( &appMPlayer.mainWindow );
|
|
|
|
break;
|
|
|
|
case evSkinBrowser: gtkVisibleSkinBrowser=0; break;
|
|
|
|
case evLoad: gtkVisibleFileSelect=0; break;
|
|
|
|
}
|
|
|
|
break;
|
2001-08-31 14:16:28 +00:00
|
|
|
case evSkinBrowser: mplShMem->SkinChange=1; break;
|
2001-08-25 21:04:29 +00:00
|
|
|
case evFileLoaded:
|
2001-09-13 19:50:06 +00:00
|
|
|
printf("*** gtkShMem->fs.dir == '%s' \n",gtkShMem->fs.dir);
|
|
|
|
printf("*** gtkShMem->fs.filename == '%s' \n",gtkShMem->fs.filename);
|
2001-08-31 22:07:53 +00:00
|
|
|
strcpy( mplShMem->Filename,gtkShMem->fs.dir );
|
|
|
|
strcat( mplShMem->Filename,"/" );
|
|
|
|
strcat( mplShMem->Filename,gtkShMem->fs.filename );
|
|
|
|
printf( "%%%%%%%% Playing file: %s\n",mplShMem->Filename );
|
2001-08-31 21:23:55 +00:00
|
|
|
mplShMem->FilenameChanged=1;
|
2001-10-24 10:58:18 +00:00
|
|
|
mplShMem->StreamType=STREAMTYPE_FILE;
|
2001-08-25 21:04:29 +00:00
|
|
|
if ( mplMainAutoPlay ) mplGeneralTimer=1;
|
|
|
|
break;
|
|
|
|
case evMessageBox:
|
|
|
|
if ( mplCriticalError )
|
|
|
|
{ gtkSendMessage( evExit ); exit( 1 ); }
|
|
|
|
mplCriticalError=0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// switch( mplShMem->message )
|
|
|
|
// {
|
|
|
|
// }
|
|
|
|
gtkShMem->message=0;
|
2001-08-29 13:44:12 +00:00
|
|
|
// mplShMem->message=0;
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void gtkSendMessage( int msg )
|
|
|
|
{
|
|
|
|
if ( !gtkIsOk ) return;
|
|
|
|
gtkShMem->message=msg;
|
2001-08-29 13:44:12 +00:00
|
|
|
kill( gtkPID,SIGTYPE );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|