1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <inttypes.h>
#include "widgets.h"
#include "gtk/menu.h"
#include "play.h"
#include "gtk/fs.h"
#include "../app.h"
#include "../../config.h"
#include "../../help_mp.h"
#include "../../libvo/x11_common.h"
#include "../../libmpdemux/stream.h"
#include "../skin/skin.h"
#include "../wm/ws.h"
#include "../error.h"
#include "./mplayer.h"
#define gtkShow( w ) gtkShMem->vs.window=w; gtkSendMessage( evShowWindow );
pid_t mplMPlayerPID = 0;
pid_t mplParentPID = 0;
pid_t gtkPID = 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( GTK_MB_ERROR,p );
}
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 )&>kFillSkinList( sbMPlayerDirInHome ) )
{
gtkSetDefaultToCList( SkinList,skinName );
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:
ShowFileSelect( fsVideoSelector );
#if 0
if ( gtkVisibleFileSelect ) gtk_widget_hide( FileSelect );
gtk_widget_show( FileSelect );
gtkVisibleFileSelect=1;
gtkShow( evPlay );
#endif
break;
case evFirstLoad:
ShowFileSelect( fsVideoSelector );
#if 0
if ( gtkVisibleFileSelect ) gtk_widget_hide( FileSelect );
gtk_widget_show( FileSelect );
gtkVisibleFileSelect=1;
gtkShow( evFirstLoad );
#endif
break;
case evLoadSubtitle:
ShowFileSelect( fsSubtitleSelector );
// gtkShow( evPlay );
break;
case evMessageBox:
gtk_label_set_text( GTK_LABEL( gtkMessageBoxText ),gtkShMem->mb.str );
if( gtkVisibleMessageBox ) gtk_widget_hide( MessageBox );
switch( gtkShMem->mb.type)
{
case GTK_MB_FATAL:
gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_FatalError );
gtk_widget_hide( WarningPixmap );
gtk_widget_show( ErrorPixmap );
break;
case GTK_MB_ERROR:
gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Error );
gtk_widget_hide( WarningPixmap );
gtk_widget_show( ErrorPixmap );
break;
case GTK_MB_WARNING:
gtk_window_set_title( GTK_WINDOW( MessageBox ),MSGTR_MSGBOX_LABEL_Warning );
gtk_widget_show( WarningPixmap );
gtk_widget_hide( ErrorPixmap );
break;
}
gtk_widget_show( MessageBox );
gtkVisibleMessageBox=1;
break;
case evAbout:
if ( gtkVisibleAboutBox ) gtk_widget_hide( AboutBox );
gtk_widget_show( AboutBox );
gtkVisibleAboutBox=1;
break;
case evExit:
gtk_main_quit();
break;
case evShowPopUpMenu:
gtkShMem->popupmenu=evNone; gtkShMem->popupmenuparam=0;
if ( gtkShMem->visiblepopupmenu ) gtk_widget_hide_on_delete( PopUpMenu );
PopUpMenu=create_PopUpMenu();
gtk_menu_popup( GTK_MENU( PopUpMenu ),NULL,NULL,NULL,NULL,0,0 );
gtkShMem->visiblepopupmenu=1;
break;
case evHidePopUpMenu:
if ( gtkShMem->visiblepopupmenu ) gtk_widget_hide_on_delete( PopUpMenu );
gtkShMem->visiblepopupmenu=0;
break;
}
gtkShMem->message=0;
}
void mplMainSigHandler( int s )
{
if ( s != SIGTYPE ) return;
// #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
switch ( gtkShMem->message )
{
case evGtkIsOk:
#ifdef DEBUG
dbprintf( 5,"[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: mplShMem->SkinChange=1; break;
case evFileLoaded:
printf("*** gtkShMem->fs.dir == '%s' \n",gtkShMem->fs.dir);
printf("*** gtkShMem->fs.filename == '%s' \n",gtkShMem->fs.filename);
strcpy( mplShMem->Filename,gtkShMem->fs.dir );
strcat( mplShMem->Filename,"/" );
strcat( mplShMem->Filename,gtkShMem->fs.filename );
printf( "%%%%%%%% Playing file: %s\n",mplShMem->Filename );
mplShMem->FilenameChanged=1;
mplShMem->StreamType=STREAMTYPE_FILE;
if ( mplMainAutoPlay ) mplGeneralTimer=1;
break;
case evSubtitleLoaded:
printf("*** gtkShMem->fs.subtitlename == '%s' \n",gtkShMem->fs.subtitlename );
strcpy( mplShMem->Subtitlename,gtkShMem->fs.subtitlename );
mplShMem->SubtitleChanged=1;
break;
case evShowPopUpMenu:
fprintf( stderr,"[psignal] PopUpMenu: %d param: %d\n",gtkShMem->popupmenu,gtkShMem->popupmenuparam );
mplMiddleMenu=1; mplGeneralTimer=1;
break;
case evMessageBox:
if ( mplCriticalError )
{ gtkSendMessage( evExit ); exit( 1 ); }
mplCriticalError=0;
break;
}
// switch( mplShMem->message )
// {
// }
gtkShMem->message=0;
// mplShMem->message=0;
}
void gtkSendMessage( int msg )
{
if ( !gtkIsOk ) return;
gtkShMem->message=msg;
kill( gtkPID,SIGTYPE );
}
|