[Mplayer-cvslog] CVS: main/Gui/mplayer Makefile,NONE,1.1 menu.h,NONE,1.1 mixer.c,NONE,1.1 mixer.h,NONE,1.1 mplayer.c,NONE,1.1 mplayer.h,NONE,1.1 mw.h,NONE,1.1 play.c,NONE,1.1 play.h,NONE,1.1 psignal.c,NONE,1.1 psignal.h,NONE,1.1 sw.h,NONE,1.1 widgets.c,NONE,1.1 widgets.h,NONE,1.1

Arpi of Ize arpi at mplayer.dev.hu
Sat Aug 25 23:04:31 CEST 2001


Update of /cvsroot/mplayer/main/Gui/mplayer
In directory mplayer:/var/tmp.root/cvs-serv13203/mplayer

Added Files:
	Makefile menu.h mixer.c mixer.h mplayer.c mplayer.h mw.h 
	play.c play.h psignal.c psignal.h sw.h widgets.c widgets.h 
Log Message:
GUI version n-1

--- NEW FILE ---

include ../../config.mak
include ../config.mak

include ../bitmap/bitmap.mak
include ../gui.mak

LIB = mplayer

INCDIR  = -I. -I../event -I../wm -I../skin $(GTKINC)

OPTIMIZE =  $(OPTFLAGS) -fomit-frame-pointer \
	    -fexpensive-optimizations -malign-double -fschedule-insns2 -mwide-multiply -Wall

CFLAGS = $(OPTIMIZE) $(INCDIR) $(DEBUG)

.SUFFIXES: .c .o

.c.o:
	$(CC) -c $(CFLAGS) -o $@ $<

### TARGETS ###

default:	.depend	$(MPLAYEROBJS)

all:	default

clean:
	rm -rf $(MPLAYEROBJS) *.o *~ *.bak .depend

distclean: clean

dep:    depend

depend: .depend

.depend: Makefile ../config.mak ../config.h ../gui.mak ../bitmap/bitmap.mak
	$(CC) -MM $(CFLAGS) $(MPLAYERSRCS) 1>.depend

#
# include dependency files if they exist
#
ifneq ($(wildcard .depend),)
include .depend
endif

--- NEW FILE ---

unsigned char * mplMenuDrawBuffer = NULL;
int             mplMenuRender = 1;
int             mplMenuItem = -1;
int             mplOldMenuItem = -1;
int             mplMenuX,mplMenuY;

void mplHideMenu( int mx,int my );

void mplMenuDraw( wsParamDisplay )
{
 unsigned long * buf = NULL;
 unsigned long * drw = NULL;
 unsigned long   x,y,tmp;

 if ( !appMPlayer.menuBase.Bitmap.Image ) return;
 if ( !appMPlayer.menuWindow.Visible ) return;

 if ( mplMenuRender || mplMenuItem != mplOldMenuItem )
  {
   memcpy( mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.Image,appMPlayer.menuBase.Bitmap.ImageSize );
// ---
   if ( mplMenuItem != -1 )
    {
     buf=(unsigned long *)mplMenuDrawBuffer;
     drw=(unsigned long *)appMPlayer.menuSelected.Bitmap.Image;
     for ( y=appMPlayer.MenuItems[ mplMenuItem ].y; y < appMPlayer.MenuItems[ mplMenuItem ].y + appMPlayer.MenuItems[ mplMenuItem ].height; y++ )
       for ( x=appMPlayer.MenuItems[ mplMenuItem ].x; x < appMPlayer.MenuItems[ mplMenuItem ].x + appMPlayer.MenuItems[ mplMenuItem ].width; x++ )
         {
          tmp=drw[ y * appMPlayer.menuSelected.width + x ];
          if ( tmp != 0x00ff00ff ) buf[ y * appMPlayer.menuBase.width + x ]=tmp;
         }
    }
   mplOldMenuItem=mplMenuItem;
// ---
   wsConvert( &appMPlayer.menuWindow,mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.ImageSize );
//   wsConvert( &appMPlayer.menuWindow,mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.Height * appMPlayer.menuBase.Bitmap.Width );
   mplMenuRender=0;
  }
 wsPutImage( &appMPlayer.menuWindow );
}

void mplMenuMouseHandle( int X,int Y,int RX,int RY )
{
 int x,y,i;

 if ( !appMPlayer.menuBase.Bitmap.Image ) return;

 mplMenuItem=-1;
 x=RX - appMPlayer.menuWindow.X;
 y=RY - appMPlayer.menuWindow.Y;
 if ( ( x < 0 ) || ( y < 0  ) || ( x > appMPlayer.menuBase.width ) || ( y > appMPlayer.menuBase.height ) )
  {
   wsPostRedisplay( &appMPlayer.menuWindow );
   return;
  }

 for( i=0;i<appMPlayer.NumberOfMenuItems+1;i++ )
  {
   if ( wgIsRect( x,y,
         appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,
         appMPlayer.MenuItems[i].x+appMPlayer.MenuItems[i].width,appMPlayer.MenuItems[i].y+appMPlayer.MenuItems[i].height ) ) mplMenuItem=i;
  }
 wsPostRedisplay( &appMPlayer.menuWindow );
}

void mplShowMenu( int mx,int my )
{
 int x,y;

 if ( !appMPlayer.menuBase.Bitmap.Image ) return;

 x=mx;
 if ( x + appMPlayer.menuWindow.Width > wsMaxX ) x=wsMaxX - appMPlayer.menuWindow.Width - 1;
 y=my;
 if ( y + appMPlayer.menuWindow.Height > wsMaxY ) y=wsMaxY - appMPlayer.menuWindow.Height - 1;

 mplMenuX=x; mplMenuY=y;

 mplMenuItem = 0;

 wsMoveWindow( &appMPlayer.menuWindow,x,y );
 wsVisibleWindow( &appMPlayer.menuWindow,wsShowWindow );
 wsMoveTopWindow( &appMPlayer.menuWindow );
}

void mplHideMenu( int mx,int my )
{
 int x,y,i=mplMenuItem;

 if ( !appMPlayer.menuBase.Bitmap.Image ) return;

 x=mx-mplMenuX;
 y=my-mplMenuY;

 wsVisibleWindow( &appMPlayer.menuWindow,wsHideWindow );

 if ( ( x < 0 ) || ( y < 0 ) ) return;

 if ( wgIsRect( x,y,
        appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,
        appMPlayer.MenuItems[i].x+appMPlayer.MenuItems[i].width,
        appMPlayer.MenuItems[i].y+appMPlayer.MenuItems[i].height ) )
   {
    mplMsgHandle( appMPlayer.MenuItems[i].msg,0 );
   }
}

void mplMenuInit( void )
{

 if ( !appMPlayer.menuBase.Bitmap.Image ) return;

 appMPlayer.menuBase.x=0;
 appMPlayer.menuBase.y=0;

 if ( ( mplMenuDrawBuffer = calloc( 1,appMPlayer.menuBase.Bitmap.ImageSize ) ) == NULL )
  {
   #ifdef DEBUG
    dbprintf( 1,langNEMFMR );
   #endif
   gtkMessageBox( langNEMFMR );
   return;
  }

 wsCreateWindow( &appMPlayer.menuWindow,
 appMPlayer.menuBase.x,appMPlayer.menuBase.y,appMPlayer.menuBase.width,appMPlayer.menuBase.height,
 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsHideFrame|wsMaxSize|wsMinSize|wsHideWindow,"MPlayer menu" );

 #ifdef DEBUG
  dbprintf( 1,"[menu.h] menu: 0x%x\n",(int)appMPlayer.menuWindow.WindowID );
 #endif

 appMPlayer.menuWindow.ReDraw=mplMenuDraw;
// appMPlayer.menuWindow.MouseHandler=mplMenuMouseHandle;
// appMPlayer.menuWindow.KeyHandler=mplMainKeyHandle;

 wsPostRedisplay( &appMPlayer.menuWindow );
}

--- NEW FILE ---

#include "play.h"

float mixerGetVolume( void )
{
// ---
// ---
 return mplShMem->Volume;
}

void mixerSetVolume( float v )
{ // 0.0 ... 100.0
// ---
printf("%%%%%% mixerSetVolume(%5.3f)  \n",v);
// ---
 mplShMem->Volume=v;
}

void mixerIncVolume( void )
{
 mixerSetVolume(  mixerGetVolume() + 1.0f );
}

void mixerDecVolume( void )
{
 mixerSetVolume(  mixerGetVolume() - 1.0f );
}

void mixerMute( void )
{
}

void mixerSetBalance( float b )
{
// ---
// ---
printf("%%%%%% mixerSetBalance(%5.3f)  \n",b);
 mplShMem->Balance=b;
}

--- NEW FILE ---

#ifndef _MIXER_H
#define _MIXER_H

extern float mixerGetVolume( void );
extern void  mixerSetVolume( float v );
extern void  mixerIncVolume( void );
extern void  mixerDecVolume( void );
extern void  mixerMute( void );
extern void  mixerSetBalance( float b );

#endif

--- NEW FILE ---

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "./mplayer.h"
#include "../events.h"
#include "../app.h"
#include "../skin/skin.h"
#include "../skin/font.h"
#include "../wm/ws.h"
#include "../wm/wskeys.h"
#include "../wm/widget.h"
#include "../bitmap/bitmap.h"
#include "../timer.h"
#include "../language.h"
#include "../error.h"

#include "../../config.h"

#define mplMouseTimerConst  100
#define mplRedrawTimerConst 50

int mplMouseTimer  = mplMouseTimerConst;
int mplRedrawTimer = mplRedrawTimerConst;
int mplGeneralTimer = -1;
int mplTimer = 0;

int mplSkinChanged = 0;

void mplMsgHandle( int msg,float param );

#include "widgets.h"
#include "play.h"
#include "menu.h"
#include "mw.h"
#include "sw.h"
#include "widget.h"

void mplTimerHandler( int signum )
{
 mplTimer++;
 mplMouseTimer--;
 mplRedrawTimer--;
 mplGeneralTimer--;
 if ( mplMouseTimer == 0 ) mplMsgHandle( evHideMouseCursor,0 );
 if ( mplRedrawTimer == 0 ) mplMsgHandle( evRedraw,0 );
 if ( mplGeneralTimer == 0 ) mplMsgHandle( evGeneralTimer,0 );
}

void mplInit( int argc,char* argv[], char *envp[] )
{
// parse_cfgfiles( argc,argv,envp );
 gtkInit( argc,argv,envp );
 mplMPlayerInit( argc,argv,envp );

 message=mplErrorHandler;

 wsXInit();

 if ( ( mplDrawBuffer = (unsigned char *)calloc( 1,appMPlayer.main.Bitmap.ImageSize ) ) == NULL )
  {
   fprintf( stderr,langNEMDB );
   exit( 0 );
  }

 wsCreateWindow( &appMPlayer.subWindow,
  appMPlayer.sub.x,appMPlayer.sub.y,appMPlayer.sub.width,appMPlayer.sub.height,
  wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsShowFrame|wsShowWindow,"ViDEO" );

 wsCreateWindow( &appMPlayer.mainWindow,
  appMPlayer.main.x,appMPlayer.main.y,appMPlayer.main.width,appMPlayer.main.height,
  wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsHideFrame|wsMaxSize|wsMinSize|wsShowWindow,"MPlayer" );

 wsSetShape( &appMPlayer.mainWindow,appMPlayer.main.Mask.Image );

 mplMenuInit();

 #ifdef DEBUG
  dbprintf( 1,"[main] Depth on screen: %d\n",wsDepthOnScreen );
  dbprintf( 1,"[main] parent: 0x%x\n",(int)appMPlayer.mainWindow.WindowID );
  dbprintf( 1,"[main] sub: 0x%x\n",(int)appMPlayer.subWindow.WindowID );
 #endif

 appMPlayer.mainWindow.ReDraw=mplMainDraw;
 appMPlayer.mainWindow.MouseHandler=mplMainMouseHandle;
 appMPlayer.mainWindow.KeyHandler=mplMainKeyHandle;

 appMPlayer.subWindow.ReDraw=mplSubDraw;
 appMPlayer.subWindow.MouseHandler=mplSubMouseHandle;
 appMPlayer.subWindow.KeyHandler=mplMainKeyHandle;
 appMPlayer.subWindow.ReSize=mplResize;

 wsPostRedisplay( &appMPlayer.mainWindow );
 wsPostRedisplay( &appMPlayer.subWindow );

 btnModify( evSetVolume,mplShMem->Volume );
 btnModify( evSetBalance,mplShMem->Balance );
 btnModify( evSetMoviePosition,mplShMem->Position );

 timerSetHandler( mplTimerHandler );
 timerInit();

 wsMainLoop();

 dbprintf( 1,"[mplayer] exit.\n" );

 mplStop();
 timerDone();
 gtkDone();
 wsXDone();
}

--- NEW FILE ---

#ifndef __MYMPLAYERHANDLER
#define __MYMPLAYERHANDLER

extern int             mplSubRender;
extern int             mplMainRender;
extern int             mplGeneralTimer;
extern int             mplSkinChanged;

extern unsigned char * mplDrawBuffer;
extern unsigned char * mplMenuDrawBuffer;
extern int             mainVisible;

extern int             mplMainAutoPlay;

extern void mplInit( int argc,char* argv[], char *envp[] );
extern void mplMsgHandle( int msg,float param );

#endif

--- NEW FILE ---

// main window

#include "mixer.h"

unsigned char * mplDrawBuffer = NULL;
int             mplMainRender = 1;
int             mplMainAutoPlay = 0;

int             mainVisible = 1;

int             boxMoved = 0;
int             msButton = 0;
int             sx = 0,sy = 0;
int             i,pot = 0;

char * Translate( char * str )
{
 static char   trbuf[512];
        char   tmp[128];
        int    i,c;
        int    t,h,m,s;
 memset( trbuf,0,512 );
 memset( tmp,0,128 );
 for ( c=0,i=0;i < strlen( str );i++ )
  {
   if ( str[i] != '$' ) { trbuf[c++]=str[i]; trbuf[c]=0; }
    else
    {
     switch ( str[++i] )
      {
       case 't':
            if ( mplShMem->Track < 10 ) strcat( trbuf,"0" );
            sprintf( tmp,"%d",mplShMem->Track ); strcat( trbuf,tmp );
            break;
       case 'f':
            if ( strlen( gtkShMem->fs.filename ) )
             {
              int i;
              strcpy( tmp,gtkShMem->fs.filename );
              for ( i=0;i < strlen( tmp );i++ )
               {
                t=0;
                if ( ( tmp[i] >= 'A' )&&( tmp[i] <= 'Z' ) ) t=32;
                tmp[i]=(char)( tmp[i] + t );
               }
              if ( tmp[strlen( tmp ) - 4] == '.' ) tmp[strlen( tmp ) - 4]=0;
              if ( tmp[strlen( tmp ) - 5] == '.' ) tmp[strlen( tmp ) - 5]=0;
             } else strcpy( tmp,"no file loaded" );
            strcat( trbuf,tmp );
            break;
       case 'F':
            if ( strlen( gtkShMem->fs.filename ) )
             {
              int i;
              strcpy( tmp,gtkShMem->fs.filename );
              for ( i=0;i < strlen( tmp );i++ )
               {
                char t = 0;
                if ( ( tmp[i] >= 'a' )&&( tmp[i] <= 'z' ) ) t=32;
                tmp[i]=tmp[i] - t;
               }
              if ( tmp[strlen( tmp ) - 4] == '.' ) tmp[strlen( tmp ) - 4]=0;
              if ( tmp[strlen( tmp ) - 5] == '.' ) tmp[strlen( tmp ) - 5]=0;
             } else strcpy( tmp,"NO FILE LOADED" );
            strcat( trbuf,tmp );
            break;
       case 'o':
            if ( strlen( gtkShMem->fs.filename ) )
             {
              strcat( trbuf,gtkShMem->fs.filename );
              if ( trbuf[strlen( trbuf ) - 4] == '.' ) trbuf[strlen( trbuf ) - 4]=0;
              if ( trbuf[strlen( trbuf ) - 5] == '.' ) trbuf[strlen( trbuf ) - 5]=0;
             } else strcat( trbuf,"no file loaded" );
            break;
       case '6': t=mplShMem->LengthInSec; goto calclengthhhmmss;
       case '1': t=mplShMem->TimeSec;
calclengthhhmmss:
            s=t%60; t=( t - s ) / 60; m=t%60; h=t/60;
            sprintf( tmp,"%02d:%02d:%02d",h,m,s ); strcat( trbuf,tmp );
            break;
       case '7': t=mplShMem->LengthInSec; goto calclengthmmmmss;
       case '2': t=mplShMem->TimeSec;
calclengthmmmmss:
            s=t%60; m=( ( t - s ) / 60 ) % 60;
            sprintf( tmp,"%04d:%02d",m,s ); strcat( trbuf,tmp );
            break;
       case '3':
            sprintf( tmp,"%02d",( mplShMem->TimeSec - ( mplShMem->TimeSec % 60 ) ) / 3600 ); strcat( trbuf,tmp );
            break;
       case '4':
            sprintf( tmp,"%02d",( ( mplShMem->TimeSec - ( mplShMem->TimeSec % 60 ) ) / 60 ) % 60 ); strcat( trbuf,tmp );
            break;
       case '5':
            sprintf( tmp,"%02d",mplShMem->TimeSec % 60 ); strcat( trbuf,tmp );
            break;
       case 'v':
            sprintf( tmp,"%3.2f%%",mplShMem->Volume ); strcat( trbuf,tmp );
            break;
       case 'V':
            sprintf( tmp,"%3.1f",mplShMem->Volume ); strcat( trbuf,tmp );
            break;
       case 'b':
            sprintf( tmp,"%3.2f%%",mplShMem->Balance ); strcat( trbuf,tmp );
            break;
       case 'B':
            sprintf( tmp,"%3.1f",mplShMem->Balance ); strcat( trbuf,tmp );
            break;
       case 's':
            if ( mplShMem->Playing == 0 ) strcat( trbuf,"s" );
            break;
       case 'l':
            if ( mplShMem->Playing == 1 ) strcat( trbuf,"p" );
            break;
       case 'e':
            if ( mplShMem->Playing == 2 ) strcat( trbuf,"e" );
            break;
       case '$':
            strcat( trbuf,"$" );
            break;
       default: continue;
      }
     c=strlen( trbuf );
    }
  }
 return trbuf;
}

void PutImage( txSample * bf,int x,int y,int max,int ofs )
{
 int i=0,ix,iy;
 unsigned long * buf = NULL;
 unsigned long * drw = NULL;
 unsigned long   tmp;

 if ( ( !bf )||( bf->Image == NULL ) ) return;

 i=( bf->Width * ( bf->Height / max ) ) * ofs;
 buf=(unsigned long *)mplDrawBuffer;
 drw=(unsigned long *)bf->Image;

 for ( iy=y;iy < y+bf->Height / max;iy++ )
  for ( ix=x;ix < x+bf->Width;ix++ )
   {
    tmp=drw[i++];
    if ( tmp != 0x00ff00ff )
     buf[ iy*appMPlayer.main.Bitmap.Width+ix ]=tmp;
   }
}

void mplMainDraw( wsParamDisplay )
{
 wItem    * item;
 txSample * image = NULL;
 int        i;
 char     * tmp;

 if ( appMPlayer.mainWindow.Visible == wsWindowNotVisible ||
      !mainVisible ||
      !appMPlayer.mainWindow.Mapped ) return;

 if ( mplMainRender )
  {
   memcpy( mplDrawBuffer,appMPlayer.main.Bitmap.Image,appMPlayer.main.Bitmap.ImageSize );
   for( i=0;i < appMPlayer.NumberOfItems + 1;i++ )
    {
     item=&appMPlayer.Items[i];
     switch( item->type )
      {
       case itButton:
            PutImage( &item->Bitmap,item->x,item->y,3,item->pressed );
            break;
       case itHPotmeter:
            PutImage( &item->Bitmap,item->x,item->y,item->phases,item->phases * ( item->value / 100.0f ) );
            PutImage( &item->Mask,item->x + (int)( ( item->width - item->psx ) * item->value / 100.0f ),item->y,3,item->pressed );
            break;
       case itPotmeter:
            PutImage( &item->Bitmap,item->x,item->y,item->phases,
             item->phases * ( item->value / 100.0f ) );
            break;
       case itSLabel:
            image=fntRender( item->fontid,0,item->width,"%s",item->label );
            goto drawrenderedtext;
       case itDLabel:
            image=fntRender( item->fontid,( mplTimer / 10 )%item->width,item->width,"%s",Translate( item->label ) );
drawrenderedtext:
            PutImage( image,item->x,item->y,1,0 );
            if ( image )
             {
              if ( image->Image ) free( image->Image );
              free( image );
             }
            break;
      }
    }
   wsConvert( &appMPlayer.mainWindow,mplDrawBuffer,appMPlayer.main.Bitmap.ImageSize );
   mplMainRender=0;
  }
 wsPutImage( &appMPlayer.mainWindow );
}

void mplMsgHandle( int msg,float param )
{
 int j;

 switch( msg )
  {
// --- user events
   case evExit:
        wsDoExit();
        break;
   case evIconify:
        wsIconify( appMPlayer.mainWindow );
        break;
   case evFullScreen:
        for ( j=0;j<appMPlayer.NumberOfItems + 1;j++ )
         {
          if ( appMPlayer.Items[j].msg == evFullScreen )
           {
            appMPlayer.Items[j].tmp=!appMPlayer.Items[j].tmp;
            appMPlayer.Items[j].pressed=appMPlayer.Items[j].tmp;
           }
         }
        mplMainRender=1;
        mplFullScreen();
        break;

   case evPlaySwitchToPause:
        if ( Filename )
         {
          btnModify( evPlaySwitchToPause,btnDisabled );
          btnModify( evPauseSwitchToPlay,btnReleased );
         }
        if ( mplShMem->Playing == 1 ) goto NoPause;
   case evPlay:
        mplMainRender=1;
        mplPlay();
        break;

   case evPauseSwitchToPlay:
        btnModify( evPlaySwitchToPause,btnReleased );
        btnModify( evPauseSwitchToPlay,btnDisabled );
   case evPause:
NoPause:
        mplMainRender=1;
        mplPause();
        break;

   case evStop:
        btnModify( evPlaySwitchToPause,btnReleased );
        btnModify( evPauseSwitchToPlay,btnDisabled );
        mplMainRender=1;
        mplStop();
        break;

   case evLoadPlay:
        mplMainAutoPlay=1;
   case evLoad:
        mplMainRender=1;
        gtkSendMessage( evLoad );
        break;
   case evPrev:
        mplMainRender=1;
        #ifdef DEBUG
         dbprintf( 1,"[mw.h] previous stream ...\n" );
        #endif
        break;
   case evNext:
        mplMainRender=1;
        #ifdef DEBUG
         dbprintf( 1,"[mw.h] next stream ...\n" );
        #endif
        break;

   case evPlayList:
        mplMainRender=1;
        if ( gtkVisiblePlayList )
         {
          btnModify( evPlayList,btnReleased );
          gtkShMem->vs.window=evPlayList;
          gtkSendMessage( evHideWindow );
          gtkVisiblePlayList=0;
         }
         else
          {
           gtkSendMessage( evPlayList );
           btnModify( evPlayList,btnPressed );
           gtkVisiblePlayList=1;
          }
        break;

   case evSkinBrowser: gtkSendMessage( evSkinBrowser ); break;
   case evAbout:       gtkSendMessage( evAbout ); break;
   case evPreferences: gtkSendMessage( evPreferences ); break;

   case evForward1min:      mplRelSeek( 60 );  break;
   case evBackward1min:     mplRelSeek( -60 ); break;
   case evForward10sec:     mplRelSeek( 10 );  break;
   case evBackward10sec:    mplRelSeek( -10 ); break;
   case evSetMoviePosition: mplAbsSeek( param ); break;

   case evIncVolume:  mixerIncVolume(); break;
   case evDecVolume:  mixerDecVolume(); break;
   case evSetVolume:  mixerSetVolume( param ); break;
   case evSetBalance: mixerSetBalance( param ); break;
   case evMute:       mixerMute();       break;

   case evIncAudioBufDelay: mplIncAudioBufDelay(); break;
   case evDecAudioBufDelay: mplDecAudioBufDelay(); break;

   case evNormalSize: if ( mplShMem->Playing ) wsResizeWindow( &appMPlayer.subWindow,mplwidth,mplheight ); break;
   case evDoubleSize: if ( mplShMem->Playing ) wsResizeWindow( &appMPlayer.subWindow,mplwidth * 2,mplheight * 2 ); break;

// --- timer events
   case evHideMouseCursor:
        wsVisibleMouse( &appMPlayer.subWindow,wsHideMouseCursor );
        break;
   case evRedraw:
        mplMainRender=1;
        wsPostRedisplay( &appMPlayer.mainWindow );
        if ( !mplShMem->Playing ) wsPostRedisplay( &appMPlayer.subWindow );
        XFlush( wsDisplay );
        mplRedrawTimer=mplRedrawTimerConst;
        break;
   case evGeneralTimer:
        if ( mplMainAutoPlay )
         {
          mplMainRender=1;
          mplMainAutoPlay=0;
          mplPlay();
         }
        break;
// --- system events
   case evNone:
        dbprintf( 1,"[mw] event none received.\n" );
        break;
   default:
        dbprintf( 1,"[mw] unknown event received ( %d,%.2f ).\n",msg,param );
        break;
  }
}

void mplMainMouseHandle( int Button,int X,int Y,int RX,int RY )
{
 static int     itemtype = 0;
 static int     SelectedButton = -1;
        wItem * item = NULL;
        float   value = 0.0f;
 wsVisibleMouse( &appMPlayer.subWindow,wsShowMouseCursor );
 switch ( Button )
  {
   case wsPRMouseButton:
          mplShowMenu( RX,RY );
          msButton=wsPRMouseButton;
          break;
   case wsRRMouseButton:
          mplHideMenu( RX,RY );
          msButton=0;
          break;
   case wsPLMouseButton:
          sx=X; sy=Y;
          boxMoved=1;
          msButton=wsPLMouseButton;
          for ( i=0;i < appMPlayer.NumberOfItems + 1;i++ )
           {
            item=&appMPlayer.Items[i];
            if ( item->pressed != btnDisabled )
             {
              switch( item->type )
               {
                case itButton:
                     if ( wgIsRect( X,Y,
                          item->x,item->y,
                          item->x+item->width,item->y+item->height ) )
                      {
                       item->pressed=btnPressed;
                       mplMainRender=1;
                       SelectedButton=i;
                       msButton=0;
                       boxMoved=0;
                      }
                     if ( ( SelectedButton > -1 ) &&
                        ( ( ( appMPlayer.Items[SelectedButton].msg == evPlaySwitchToPause && item->msg == evPauseSwitchToPlay ) ) ||
                          ( ( appMPlayer.Items[SelectedButton].msg == evPauseSwitchToPlay && item->msg == evPlaySwitchToPause ) ) ) )
                      {
                       appMPlayer.Items[SelectedButton].pressed=btnDisabled;
                       SelectedButton=i;
                       appMPlayer.Items[SelectedButton].pressed=btnPressed;
                      }
                     itemtype=itButton;
                     break;
                case itPotmeter:
                     if ( wgIsRect( X,Y,
                          item->x,item->y,
                          item->x+item->width,item->y+item->height ) )
                      {
                       item->pressed=btnPressed;
                       mplMainRender=1;
                       SelectedButton=i;
                       boxMoved=0;
                       msButton=itPotmeter;
                       itemtype=itPotmeter;
                      }
                      break;
                case itHPotmeter:
                     if ( wgIsRect( X,Y,
                          item->x,item->y,
                          item->x+item->width,item->y+item->height ) )
                      {
                       item->pressed=btnPressed;
                       mplMainRender=1;
                       SelectedButton=i;
                       boxMoved=0;
                       msButton=itHPotmeter;
                       itemtype=itHPotmeter;
                      }
                     break;
               }
             }
           }
          break;
   case wsMoveMouse:
          item=&appMPlayer.Items[SelectedButton];
          switch ( msButton )
           {
            case wsPLMouseButton:
                 wsMoveWindow( &appMPlayer.mainWindow,RX - abs( sx ),RY - abs( sy ) );
                 mplMainRender=0;
                 break;
            case wsPRMouseButton:
                 mplMenuMouseHandle( X,Y,RX,RY );
                 break;
            case itPotmeter:
                 value=(float)( X - item->x ) / item->width * 100.0f;
                 goto potihandled;
            case itHPotmeter:
                 value=(float)( X - item->x ) / item->width * 100.0f;
potihandled:
                 btnModify( item->msg,value );
                 if ( ( item->msg == evSetVolume )||( item->msg == evSetBalance ) ) mplMsgHandle( item->msg,item->value );
                 mplMainRender=1; wsPostRedisplay( &appMPlayer.mainWindow );
                 break;
           }
          break;
   case wsRLMouseButton:
          msButton=0;
          boxMoved=0;
          item=&appMPlayer.Items[SelectedButton];
          item->pressed=btnReleased;
          switch( itemtype )
           {
            case itButton:
                 if ( wgIsRect( X,Y,
                        item->x,item->y,
                        item->x+item->width,item->y+item->height ) ) value=0;
                  break;
            case itPotmeter:
            case itHPotmeter:
                 btnModify( item->msg,(float)( X - item->x ) / item->width * 100.0f );
                 value=item->value;
                 break;
           }
          if ( SelectedButton != -1 ) mplMsgHandle( item->msg,value );
          SelectedButton=-1;
          mplMainRender=1;
          itemtype=0;
          break;
   case wsPMMouseButton: break;
   case wsRMMouseButton: break;
  }
 if ( Button != wsMoveMouse ) wsPostRedisplay( &appMPlayer.mainWindow );
}

int keyPressed = 0;

void mplMainKeyHandle( int State,int Type,int Key )
{
 int msg = evNone;
 switch ( Key )
  {
   case '.':
   case '>':         msg=evNext; break;
   case ',':
   case '<':         msg=evPrev; break;

   case wsx:
   case wsX:
   case wsEscape:    msg=evExit; break;

   case wsUp:        msg=evForward1min; break;
   case wsDown:      msg=evBackward1min; break;
   case wsRight:     msg=evForward10sec; break;
   case wsLeft:      msg=evBackward10sec; break;

   case wsGrayMul:   msg=evIncVolume; break;
   case wsGrayDiv:   msg=evDecVolume; break;

   case wsGrayPlus:  msg=evIncAudioBufDelay; break;
   case wsGrayMinus: msg=evDecAudioBufDelay; break;

   case wsEnter:     msg=evPlay; break;
   case wsSpace:     msg=evPause; break;
   case wsa:
   case wsA:         msg=evAbout; break;
   case wsb:
   case wsB:         msg=evSkinBrowser; break;
   case wse:
   case wsE:         msg=evEqualeaser; break;
   case wsf:
   case wsF:         msg=evFullScreen; break;
   case wsl:
   case wsL:         msg=evLoad; break;
   case wsm:
   case wsM:         msg=evMute; break;
   case wss:
   case wsS:         msg=evStop; break;
   case wsp:
   case wsP:         msg=evPlayList; break;
  }
 if ( ( msg != evNone )&&( Type == wsKeyPressed ) )
  {
   mplMsgHandle( msg,0 );
   mplMainRender=1;
   wsPostRedisplay( &appMPlayer.mainWindow );
  }
}

--- NEW FILE ---

#include <stdlib.h>
#include <stdio.h>

#include <unistd.h>
#include <signal.h>

int    mplParent = 1;

int    mplx,mply,mplwidth,mplheight;

#include "../app.h"

#include "../wm/ws.h"
#include "../wm/wskeys.h"
#include "../wm/widget.h"

#include "../../config.h"

#include "widgets.h"
#include "./mplayer.h"
#include "psignal.h"
#include "play.h"

mplCommStruct * mplShMem;
char          * Filename = NULL;

void mplPlayerThread( void )
{
// mplayer( 0,NULL,NULL );
}

void mplFullScreen( void )
{
 if ( appMPlayer.subWindow.isFullScreen )
  {
   if ( mplShMem->Playing )
    {
     appMPlayer.subWindow.OldX=mplx;
     appMPlayer.subWindow.OldY=mply;
     appMPlayer.subWindow.OldWidth=mplwidth;
     appMPlayer.subWindow.OldHeight=mplheight;
    }
    else
     {
      appMPlayer.subWindow.OldWidth=appMPlayer.sub.width;
      appMPlayer.subWindow.OldHeight=appMPlayer.sub.height;
      appMPlayer.subWindow.OldX=( wsMaxX - appMPlayer.sub.width ) / 2;
      appMPlayer.subWindow.OldY=( wsMaxY - appMPlayer.sub.height ) / 2;
     }
  }
 wsFullScreen( &appMPlayer.subWindow );
 wsMoveTopWindow( &appMPlayer.subWindow );
}

extern int mplSubRender;

void mplStop()
{
 if ( !mplShMem->Playing ) return;
// ---
printf("%%%%%% STOP  \n");
// ---
 mplShMem->Playing=0;
}

void mplPlay( void )
{
 if ( !Filename ) return;
 if ( mplShMem->Playing ) mplStop();
// ---
printf("%%%%%% PLAY  \n");
// ---
 mplShMem->Playing=1;
}

void mplPause( void )
{
 if ( mplShMem->Playing != 1 ) return;
// ---
printf("%%%%%% PAUSE  \n");
// ---
 mplShMem->Playing=2;
}

void mplResize( unsigned int X,unsigned int Y,unsigned int width,unsigned int height )
{
}

void mplMPlayerInit( int argc,char* argv[], char *envp[] )
{
 mplShMem=shmem_alloc( ShMemSize );
 signal( SIGTYPE,mplMainSigHandler );
 signal( SIGCHLD,SIG_IGN );

 mplShMem->Playing=0;
 mplShMem->Volume=0.0f;
 mplShMem->Position=0.0f;
 mplShMem->Balance=50.0f;
 mplShMem->Track=0;
 mplShMem->AudioType=0;
 mplShMem->StreamType=0;
 mplShMem->TimeSec=0;
 mplShMem->LengthInSec=0;

// ---
// ---
}

float mplGetPosition( void )
{ // return 0.0 ... 100.0
 return mplShMem->Position;
}

void mplRelSeek( float s )
{ // -+s
// ---
printf("%%%%%% RelSEEK=%5.3f  \n",s);
// ---
 mplShMem->Position=mplGetPosition() + s;
}

void mplAbsSeek( float s )
{ // 0.0 ... 100.0
// ---
printf("%%%%%% AbsSEEK=%5.3f  \n",s);
// ---
 mplShMem->Position=s;
 mplShMem->TimeSec=s;
}

void mplIncAudioBufDelay( void )
{
}

void mplDecAudioBufDelay( void )
{
}

--- NEW FILE ---

#ifndef __GUI_PLAY_H
#define __GUI_PLAY_H

#include "./psignal.h"

typedef struct
{
 int x;
 int y;
 int width;
 int height;
} mplResizeStruct;

typedef struct
{
 int  signal;
 char module[512];
} mplUnknowErrorStruct;

typedef struct
{
 int  seek;
 int  format;
 int  width;
 int  height;
 char codecdll[128];
} mplVideoStruct;

typedef struct
{
 int message;
   mplResizeStruct      resize;
   mplVideoStruct       videodata;
   mplUnknowErrorStruct error;

   int    Playing;
   float  Volume;
   float  Position;
   float  Balance;
   int    Track;
   int    AudioType;
   int    StreamType;
   int    TimeSec;
   int    LengthInSec;
} mplCommStruct;

extern mplCommStruct * mplShMem;
extern char * Filename;

extern int   mplParent;

extern int   mplx;
extern int   mply;
extern int   mplwidth;
extern int   mplheight;

extern mplCommStruct * mplShMem;

extern void mplMPlayerInit( int argc,char* argv[], char *envp[] );

extern void mplStop();
extern void mplFullScreen( void );
extern void mplPlay( void );
extern void mplPause( void );
extern void mplResize( unsigned int X,unsigned int Y,unsigned int width,unsigned int height );

extern void mplIncAudioBufDelay( void );
extern void mplDecAudioBufDelay( void );

extern void  mplRelSeek( float s );
extern void  mplAbsSeek( float s );
extern float mplGetPosition( void );

extern void mplPlayFork( void );
extern void mplSigHandler( int s );
extern void mplSendMessage( int msg );
extern void mplPlayerThread( void );

#endif
--- NEW FILE ---

#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 "../config.h"
#include "../error.h"
#include "../language.h"

#include "../../config.h"

#include "./mplayer.h"

#define gtkShow( w ) gtkShMem->vs.window=w; gtkSendMessage( evShowWindow );

pid_t mplMPlayerPID = 0;
pid_t mplParentPID = 0;

pid_t gtkChildPID = 0;
pid_t gtkParentPID = 0;

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;
 gtkMessageBox( p );
// message( False,p );
}

void mplPlayerSigHandler( int s )
{
 #ifdef DEBUG
  dbprintf( 5,"[psignal] mpl sig handler msg: %d\n",mplShMem->message );
 #endif
 if ( s != SIGTYPE ) return;
 switch ( mplShMem->message )
  {
   case mplQuit:
//        exit_player( "Quit" );
        break;
   case mplPauseEvent:
//        if ( osd_function != OSD_PAUSE ) osd_function=OSD_PAUSE;
//          else osd_function=OSD_PLAY;
        break;
   case mplResizeEvent:
//        vo_resize=1;
//        vo_expose=1;
//        dbprintf( 2,"[psignal] resize.\n" );
//        if (video_out != NULL ) video_out->check_events();
        break;
   case mplExposeEvent:
//        vo_expose=1;
//        if (video_out != NULL ) video_out->check_events();
        break;
   case mplSeekEvent:
//        rel_seek_secs+=mplShMem->videodata.seek;
//        if ( rel_seek_secs > 0 ) osd_function=OSD_FFW;
//          else osd_function=OSD_REW;
        break;
   case mplIncAudioBufferDelay:
//        audio_delay+=0.1;  // increase audio buffer delay
//        a_frame-=0.1;
        break;
   case mplDecAudioBufferDelay:
//        audio_delay-=0.1;  // increase audio buffer delay
//        a_frame+=0.1;
        break;
  }
 mplShMem->message=0;
}

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 );
        if ( !gtkFillSkinList( sbMPlayerPrefixDir ) ) break;
        if ( gtkFillSkinList( sbMPlayerDirInHome ) )
         {
          gtkSetDefaultToCList( SkinList,cfgSkin );
          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;
   case evMessageBox:
        gtk_label_set_text( gtkMessageBoxText,(char *)gtkShMem->mb.str );
        gtk_widget_set_usize( MessageBox,gtkShMem->mb.sx,gtkShMem->mb.sy );
        gtk_widget_set_usize( gtkMessageBoxText,gtkShMem->mb.tsx,gtkShMem->mb.tsy );
        if ( gtkVisibleMessageBox ) gtk_widget_hide( MessageBox );
        gtk_widget_show( MessageBox );
        gtkVisibleMessageBox=1;
        break;
   case evAbout:
        if ( gtkVisibleAboutBox ) gtk_widget_hide( AboutBox );
        gtk_widget_show( AboutBox );
        gtkVisibleAboutBox=1;
        break;
   case evExit:
        gtkExit();
        break;
  }
 gtkShMem->message=0;
}

listItems tmpList;

void mplMainSigHandler( int s )
{
 #ifdef DEBUG
  if ( gtkShMem->message ) dbprintf( 5,"[psignal] main sig handler gtk msg: %d\n",gtkShMem->message );
  if ( mplShMem->message ) dbprintf( 5,"[psignal] main sig handler mpl msg: %d\n",mplShMem->message );
 #endif

 if ( s != SIGTYPE ) return;

 switch ( gtkShMem->message )
  {
   case evGtkIsOk:
        #ifdef DEBUG
         dbprintf( 1,"[psignal] gtk is ok.\n" );
        #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;
   case evSkinBrowser:
        if ( strcmp( cfgSkin,gtkShMem->sb.name ) )
         {
          int ret;
          #ifdef DEBUG
           dbprintf( 1,"[psignal] skin: %s\n",gtkShMem->sb.name );
          #endif

          mainVisible=0;

          appInitStruct( &tmpList );
          skinAppMPlayer=&tmpList;
          ret=skinRead( gtkShMem->sb.name );

          appInitStruct( &tmpList );
          skinAppMPlayer=&appMPlayer;
          appInitStruct( &appMPlayer );
          if ( !ret ) strcpy( cfgSkin,gtkShMem->sb.name );
          skinRead( cfgSkin );

          if ( ret )
           {
            mainVisible=1;
            break;
           }

//          appCopy( &appMPlayer,&tmpList );
//          appInitStruct( &tmpList );
//          skinAppMPlayer=&appMPlayer;
//          strcpy( cfgSkin,gtkShMem->sb.name );

          if ( mplDrawBuffer ) free( mplDrawBuffer );
          if ( ( mplDrawBuffer = (unsigned char *)calloc( 1,appMPlayer.main.Bitmap.ImageSize ) ) == NULL )
           { message( False,langNEMDB ); break; }
          wsResizeWindow( &appMPlayer.mainWindow,appMPlayer.main.width,appMPlayer.main.height );
          wsMoveWindow( &appMPlayer.mainWindow,appMPlayer.main.x,appMPlayer.main.y );
          wsResizeImage( &appMPlayer.mainWindow );
          wsSetShape( &appMPlayer.mainWindow,appMPlayer.main.Mask.Image );
          mainVisible=1; mplMainRender=1; wsPostRedisplay( &appMPlayer.mainWindow );
          btnModify( evSetVolume,mplShMem->Volume );
          btnModify( evSetBalance,mplShMem->Balance );
          btnModify( evSetMoviePosition,mplShMem->Position );

          if ( appMPlayer.menuBase.Bitmap.Image )
           {
            if ( mplMenuDrawBuffer ) free( mplMenuDrawBuffer );
            if ( ( mplMenuDrawBuffer = (unsigned char *)calloc( 1,appMPlayer.menuBase.Bitmap.ImageSize ) ) == NULL )
             { message( False,langNEMDB ); break; }
            wsResizeWindow( &appMPlayer.menuWindow,appMPlayer.menuBase.width,appMPlayer.menuBase.height );
            wsResizeImage( &appMPlayer.menuWindow );
           }

          mplSkinChanged=1;
          if ( !mplShMem->Playing )
           {
            mplSkinChanged=0;
            if ( appMPlayer.subWindow.isFullScreen ) wsFullScreen( &appMPlayer.subWindow );
            wsResizeWindow( &appMPlayer.subWindow,appMPlayer.sub.width,appMPlayer.sub.height );
            wsMoveWindow( &appMPlayer.subWindow,appMPlayer.sub.x,appMPlayer.sub.y );
            if ( appMPlayer.sub.Bitmap.Image ) wsResizeImage( &appMPlayer.subWindow );
            mplSubRender=1; wsPostRedisplay( &appMPlayer.subWindow );
           }
         }
        break;
   case evFileLoaded:
        if ( Filename ) free( Filename );
        Filename=(char *)malloc( strlen( gtkShMem->fs.dir ) + strlen( gtkShMem->fs.filename ) + 2 );
        strcpy( Filename,gtkShMem->fs.dir ); strcat( Filename,"/" ); strcat( Filename,gtkShMem->fs.filename );
        if ( mplMainAutoPlay ) mplGeneralTimer=1;
        break;
   case evMessageBox:
        if ( mplCriticalError )
         { gtkSendMessage( evExit ); exit( 1 ); }
        mplCriticalError=0;
        break;
  }

// switch( mplShMem->message )
//  {
//  }
 gtkShMem->message=0;
 mplShMem->message=0;
}

void mplSendMessage( int msg )
{
 if ( !mplShMem->Playing ) return;
 mplShMem->message=msg;
 kill( mplMPlayerPID,SIGTYPE ); usleep( 10 );
 kill( mplMPlayerPID,SIGTYPE ); usleep( 10 );
 kill( mplMPlayerPID,SIGTYPE );
}

void gtkSendMessage( int msg )
{
 if ( !gtkIsOk ) return;
 gtkShMem->message=msg;
 kill( gtkChildPID,SIGTYPE );
}

--- NEW FILE ---

#ifndef __GUI_SIGNAL
#define __GUI_SIGNAL

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>

#define mplNoneEvent                             0
#define mplResizeEvent                           1
#define mplQuit                                  2
#define mplPauseEvent                            3
#define mplEndOfFile                             4
#define mplExposeEvent                           5
#define mplSetVideoData                          6
#define mplAudioError                            7
#define mplUnknowError                           8
#define mplSeekEvent                             9
#define mplUnknowFileType                        10
#define mplCodecConfNotFound                     11
#define mplErrorDVDKeyProcess                    12
#define mplErrorDVDAuth                          13
#define mplErrorAVINI                            14
#define mplAVIErrorMissingVideoStream            15
#define mplASFErrorMissingVideoStream            16
#define mplMPEGErrorSeqHeaderSearch              17
#define mplErrorShMemAlloc                       18
#define mplMPEGErrorCannotReadSeqHeader          19
#define mplMPEGErrorBadSeqHeader                 20
#define mplMPEGErrorCannotReadSeqHeaderExt       21
#define mplMPEGErrorBadSeqHeaderExt              22
#define mplCantFindCodecForVideoFormat           23
#define mplIncompatibleVideoOutDevice            24
#define mplCompileWithoutDSSupport               25
#define mplDSCodecNotFound                       26
#define mplCantInitVideoDriver                   27
#define mplIncAudioBufferDelay                   28
#define mplDecAudioBufferDelay                   29

#define SIGTYPE _NSIG - 1

extern int gtkIsOk;

extern pid_t mplMPlayerPID;
extern pid_t mplParentPID;

extern pid_t gtkChildPID;
extern pid_t gtkParentPID;

extern void gtkSigHandler( int s );
extern void mplPlayerSigHandler( int s );
extern void mplMainSigHandler( int s );

extern void mplSendMessage( int msg );
extern void gtkSendMessage( int msg );

extern void mplErrorHandler( int critical,const char * format, ... );

#endif
--- NEW FILE ---

// sub window

int             mplSubRender = 1;
int             mplSubMoved = 0;

void mplSubDraw( wsParamDisplay )
{
 if ( !appMPlayer.subWindow.Visible || mplShMem->Playing )
  {
   mplSendMessage( mplExposeEvent );
   return;
  }

 if ( mplSubRender )
  {
   wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.subR,appMPlayer.subG,appMPlayer.subB );
   wsClearWindow( appMPlayer.subWindow );
   if ( appMPlayer.sub.Bitmap.Image ) wsConvert( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Image,appMPlayer.sub.Bitmap.ImageSize );
   mplSubRender=0;
  }
 if ( appMPlayer.sub.Bitmap.Image ) wsPutImage( &appMPlayer.subWindow );
 XFlush( wsDisplay );
 XSync( wsDisplay,False );
}

void mplSubMouseHandle( int Button,int X,int Y,int RX,int RY )
{
 mplMouseTimer=mplMouseTimerConst;
 wsVisibleMouse( &appMPlayer.subWindow,wsShowMouseCursor );

 switch( Button )
  {
   case wsPRMouseButton:
          mplShowMenu( RX,RY );
          msButton=wsPRMouseButton;
          break;
   case wsRRMouseButton:
          mplHideMenu( RX,RY );
          msButton=0;
          break;
   case wsPLMouseButton:
          sx=X; sy=Y;
          msButton=wsPLMouseButton;
          mplSubMoved=0;
          break;
   case wsMoveMouse:
          switch ( msButton )
           {
            case wsPLMouseButton:
                   mplSubMoved=1;
                   wsMoveWindow( &appMPlayer.subWindow,RX - sx,RY - sy );
                   break;
            case wsPRMouseButton:
                   mplMenuMouseHandle( X,Y,RX,RY );
                   mplMouseTimer=mplMouseTimerConst;
                   break;
           }
          break;
   case wsRLMouseButton:
          if ( !mplSubMoved ) wsMoveTopWindow( &appMPlayer.mainWindow );
          msButton=0;
          mplSubMoved=0;
          break;
  }
}

//void mplSubResizeHandle( unsigned int X,unsigned int Y,unsigned int width,unsigned int height )
//{ mplResize( X,Y,width,height ); }
--- NEW FILE ---

#include <stdlib.h>
#include <stdio.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>

#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>

#include "widgets.h"

#include "./mplayer.h"
#include "psignal.h"
#include "../events.h"

#include "../../config.h"
#include "../error.h"

#include "pixmaps/up.xpm"
#include "pixmaps/dir.xpm"
#include "pixmaps/file.xpm"
#include "pixmaps/logo.xpm"

GtkWidget     * SkinBrowser;
GtkWidget     * PlayList;
GtkWidget     * FileSelect;
GtkWidget     * MessageBox;
GtkWidget     * AboutBox;
GtkWidget     * Options;

int             gtkVisibleSkinBrowser = 0;
int             gtkVisiblePlayList = 0;
int             gtkVisibleFileSelect = 0;
int             gtkVisibleMessageBox = 0;
int             gtkVisibleAboutBox = 0;
int             gtkVisibleOptions = 0;

gtkCommStruct * gtkShMem;

#include "gtk/sb.h"
#include "gtk/pl.h"
#include "gtk/fs.h"
#include "gtk/mb.h"
#include "gtk/about.h"
#include "gtk/opts.h"

void widgetsCreate( void )
{
 AboutBox=create_About();
 SkinBrowser=create_SkinBrowser();
 PlayList=create_PlayList();
 FileSelect=create_FileSelect();
 MessageBox=create_MessageBox();
 Options=create_Options();
}

int             gtkParent = 1;

// --- forked function

static void gtkThreadProc( int argc,char * argv[] )
{
 gtk_set_locale();
 gtk_init( &argc,&argv );
 gdk_set_use_xshm( TRUE );

 widgetsCreate();

 gtkParentPID=getpid();
 gtkChildPID=getppid();
 gtkParent=0;

 signal( SIGTYPE,gtkSigHandler );

 gtkIsOk=True;
 gtkSendMessage( evGtkIsOk );

 gtk_main();
 dbprintf( 6,"[gtk] exit.\n" );
 exit( 0 );
}

// --- init & close gtk

void gtkInit( int argc,char* argv[], char *envp[] )
{
 gtkParentPID=getpid();
 gtkShMem=shmem_alloc( ShMemSize );
 if ( ( gtkChildPID = fork() ) == 0 ) gtkThreadProc( argc,argv );
}

void gtkDone( void )
{
 kill( gtkChildPID,SIGKILL );
 usleep( 1000 );
}

void gtkMessageBox( gchar * str )
{
 gtkShMem->mb.sx=420; gtkShMem->mb.sy=128;
 gtkShMem->mb.tsx=384; gtkShMem->mb.tsy=77;
 if ( strlen( str ) > 200 )
  {
   gtkShMem->mb.sx=512;
   gtkShMem->mb.sy=128;
   gtkShMem->mb.tsx=476;
   gtkShMem->mb.tsy=77;
  }
 strcpy( gtkShMem->mb.str,str );
 gtkSendMessage( evMessageBox );
}

void gtkClearList( GtkWidget * list )
{ gtk_clist_clear( GTK_CLIST( list ) ); }

int gtkFindCList( GtkWidget * list,char * item )
{
 gint    j,t;
 gchar * tmpstr;
 for( t=0,j=0;j<GTK_CLIST( list )->rows;j++ )
  {
   gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr );
   if ( !strcmp( tmpstr,item ) ) return j;
  }
 return -1;
}

void gtkSetDefaultToCList( GtkWidget * list,char * item )
{
 gint    i;
 if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 );
}

void gtkExit( void )
{ gtk_main_quit(); }

--- NEW FILE ---

#ifndef __MY_WIDGET
#define __MY_WIDGET

#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>

#include "../shmem.h"

typedef struct
{
 char dir[ 1024 ];
 char filename[ 1024 ];
} gtkFileSelectorStruct;

typedef struct
{
 int  sx;
 int  sy;
 int  tsx;
 int  tsy;
 char str[512];
} gtkMessageBoxStruct;

typedef struct
{
 char name[128];
} gtkSkinStruct;

typedef struct
{
 int window;
} gtkVisibleStruct;

typedef struct
{
 int i;
} gtkOptionsStruct;

typedef struct
{
 int                   message;
 gtkFileSelectorStruct fs;
 gtkMessageBoxStruct   mb;
 gtkSkinStruct         sb;
 gtkVisibleStruct      vs;
 gtkOptionsStruct      op;
} gtkCommStruct;

#define ShMemSize sizeof( gtkCommStruct )

extern gtkCommStruct * gtkShMem;

extern GtkWidget     * SkinBrowser;
extern GtkWidget     * PlayList;
extern GtkWidget     * FileSelect;
extern GtkWidget     * MessageBox;
extern GtkWidget     * AboutBox;
extern GtkWidget     * Options;

extern GtkWidget     * SkinList;
extern GtkWidget     * gtkMessageBoxText;

extern int             gtkVisibleSkinBrowser;
extern int             gtkVisiblePlayList;
extern int             gtkVisibleFileSelect;
extern int             gtkVisibleMessageBox;
extern int             gtkVisibleAboutBox;
extern int             gtkVisibleOptions;

extern char          * sbMPlayerDirInHome;
extern char          * sbMPlayerPrefixDir;

extern void widgetsCreate( void );

extern void gtkInit( int argc,char* argv[], char *envp[] );
extern void gtkDone( void );
extern void gtkMessageBox( gchar * str );
extern int  gtkFillSkinList( gchar * dir );
extern void gtkClearList( GtkWidget * list );
extern void gtkSetDefaultToCList( GtkWidget * list,char * item );
extern int  gtkFindCList( GtkWidget * list,char * item );
extern void gtkExit( void );

#endif



More information about the MPlayer-cvslog mailing list