Mercurial > mplayer.hg
annotate Gui/mplayer/psignal.c @ 3343:58ab1490a0be
dunnowhat Q/A de biztos jo
author | gabucino |
---|---|
date | Wed, 05 Dec 2001 23:07:05 +0000 |
parents | 9507f90d8254 |
children | 93351eec9f1f |
rev | line source |
---|---|
1693 | 1 |
2 #include <stdlib.h> | |
3 #include <stdio.h> | |
4 #include <string.h> | |
5 #include <signal.h> | |
6 #include <unistd.h> | |
7 | |
8 #include "widgets.h" | |
9 #include "play.h" | |
10 | |
11 #include "../app.h" | |
12 | |
13 #include "../skin/skin.h" | |
14 #include "../wm/ws.h" | |
15 #include "../error.h" | |
16 | |
17 #include "../../config.h" | |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1700
diff
changeset
|
18 #include "../../libvo/x11_common.h" |
2447 | 19 #include "../../libmpdemux/stream.h" |
1723
5e4214a7540e
GUI stuff. now seeking works, and xmga renders to video window
arpi
parents:
1700
diff
changeset
|
20 |
1693 | 21 #include "./mplayer.h" |
22 | |
23 #define gtkShow( w ) gtkShMem->vs.window=w; gtkSendMessage( evShowWindow ); | |
24 | |
25 pid_t mplMPlayerPID = 0; | |
26 pid_t mplParentPID = 0; | |
27 | |
1741 | 28 pid_t gtkPID = 0; |
1693 | 29 |
30 int mplCriticalError = 0; | |
31 int gtkIsOk = 0; | |
32 | |
33 void mplErrorHandler( int critical,const char * format, ... ) | |
34 { | |
35 char * p; | |
36 va_list ap; | |
37 int n; | |
38 | |
39 if ( (p=(char *)malloc( 512 ) ) == NULL ) return; | |
40 va_start( ap,format ); | |
41 n=vsnprintf( p,512,format,ap ); | |
42 va_end( ap ); | |
43 mplCriticalError=critical; | |
1907 | 44 gtkMessageBox( GTK_MB_ERROR,p ); |
1693 | 45 } |
46 | |
47 void gtkSigHandler( int s ) | |
48 { | |
49 if ( s != SIGTYPE ) return; | |
50 #ifdef DEBUG | |
51 dbprintf( 5,"[psignal] gtk sig handler msg: %d\n",gtkShMem->message ); | |
52 #endif | |
53 switch ( gtkShMem->message ) | |
54 { | |
55 case evHideWindow: | |
56 switch ( gtkShMem->vs.window ) | |
57 { | |
58 case evPlayList: gtk_widget_hide( PlayList ); gtkVisiblePlayList=0; break; | |
59 case evSkinBrowser: gtk_widget_hide( SkinBrowser ); gtkVisibleSkinBrowser=0; break; | |
60 case evLoad: gtk_widget_hide( FileSelect ); gtkVisibleFileSelect=0; break; | |
61 } | |
62 break; | |
63 case evSkinBrowser: | |
64 if ( gtkVisibleSkinBrowser ) gtk_widget_hide( SkinBrowser ); | |
65 gtkClearList( SkinList ); | |
1907 | 66 if ( gtkFillSkinList( sbMPlayerPrefixDir )&>kFillSkinList( sbMPlayerDirInHome ) ) |
1693 | 67 { |
1866
32b1bb50a0e8
some bug fix, and add decoration item to skin conffile. faszom(C)
pontscho
parents:
1858
diff
changeset
|
68 gtkSetDefaultToCList( SkinList,skinName ); |
1693 | 69 gtk_widget_show( SkinBrowser ); |
70 gtkVisibleSkinBrowser=1; | |
71 gtkShow( evSkinBrowser ); | |
72 } | |
73 break; | |
74 case evPreferences: | |
75 if ( gtkVisibleOptions ) gtk_widget_hide( Options ); | |
76 gtk_widget_show( Options ); | |
77 gtkVisibleOptions=1; | |
78 break; | |
79 case evPlayList: | |
80 if ( gtkVisiblePlayList ) gtk_widget_hide( PlayList ); | |
81 gtk_widget_show( PlayList ); | |
82 gtkVisiblePlayList=1; | |
83 gtkShow( evPlayList ); | |
84 break; | |
85 case evLoad: | |
86 if ( gtkVisibleFileSelect ) gtk_widget_hide( FileSelect ); | |
87 gtk_widget_show( FileSelect ); | |
88 gtkVisibleFileSelect=1; | |
89 gtkShow( evPlay ); | |
90 break; | |
1741 | 91 case evFirstLoad: |
92 if ( gtkVisibleFileSelect ) gtk_widget_hide( FileSelect ); | |
93 gtk_widget_show( FileSelect ); | |
94 gtkVisibleFileSelect=1; | |
95 gtkShow( evFirstLoad ); | |
96 break; | |
1693 | 97 case evMessageBox: |
98 gtk_label_set_text( gtkMessageBoxText,(char *)gtkShMem->mb.str ); | |
1925 | 99 if( gtkVisibleMessageBox ) gtk_widget_hide( MessageBox ); |
100 switch( gtkShMem->mb.type) | |
101 { | |
102 case GTK_MB_FATAL: | |
103 gtk_window_set_title (GTK_WINDOW (MessageBox), "fatal error ..."); | |
104 gtk_widget_hide( WarningPixmap ); | |
105 gtk_widget_show( ErrorPixmap ); | |
106 break; | |
107 case GTK_MB_ERROR: | |
108 gtk_window_set_title (GTK_WINDOW (MessageBox), "error ..."); | |
109 gtk_widget_hide( WarningPixmap ); | |
110 gtk_widget_show( ErrorPixmap ); | |
111 break; | |
112 case GTK_MB_WARNING: | |
113 gtk_window_set_title (GTK_WINDOW (MessageBox), "warning ..."); | |
114 gtk_widget_show( WarningPixmap ); | |
115 gtk_widget_hide( ErrorPixmap ); | |
116 break; | |
117 } | |
1693 | 118 gtk_widget_show( MessageBox ); |
119 gtkVisibleMessageBox=1; | |
120 break; | |
121 case evAbout: | |
122 if ( gtkVisibleAboutBox ) gtk_widget_hide( AboutBox ); | |
123 gtk_widget_show( AboutBox ); | |
124 gtkVisibleAboutBox=1; | |
125 break; | |
126 case evExit: | |
1700 | 127 gtk_main_quit(); |
1693 | 128 break; |
2901 | 129 case evShowPopUpMenu: |
3054 | 130 gtkShMem->popupmenu=evNone; gtkShMem->popupmenuparam=0; |
2980 | 131 if ( gtkShMem->visiblepopupmenu ) gtk_widget_hide_on_delete( PopUpMenu ); |
132 PopUpMenu=create_PopUpMenu(); | |
2901 | 133 gtk_menu_popup( GTK_MENU( PopUpMenu ),NULL,NULL,NULL,NULL,0,0 ); |
2980 | 134 gtkShMem->visiblepopupmenu=1; |
135 break; | |
136 case evHidePopUpMenu: | |
137 if ( gtkShMem->visiblepopupmenu ) gtk_widget_hide_on_delete( PopUpMenu ); | |
138 gtkShMem->visiblepopupmenu=0; | |
2901 | 139 break; |
1693 | 140 } |
141 gtkShMem->message=0; | |
142 } | |
143 | |
144 void mplMainSigHandler( int s ) | |
145 { | |
1741 | 146 if ( s != SIGTYPE ) return; |
147 | |
1801 | 148 // #ifdef DEBUG |
1802 | 149 // if ( gtkShMem->message ) dbprintf( 5,"[psignal] main sig handler gtk msg: %d\n",gtkShMem->message ); |
1741 | 150 // if ( mplShMem->message ) dbprintf( 5,"[psignal] main sig handler mpl msg: %d\n",mplShMem->message ); |
1801 | 151 // #endif |
1693 | 152 |
153 switch ( gtkShMem->message ) | |
154 { | |
155 case evGtkIsOk: | |
156 #ifdef DEBUG | |
1741 | 157 dbprintf( 5,"[psignal] gtk is ok.\n" ); |
1693 | 158 #endif |
159 gtkIsOk=True; | |
160 break; | |
161 case evShowWindow: | |
162 switch ( gtkShMem->vs.window ) | |
163 { | |
164 case evPlayList: gtkVisiblePlayList=1; break; | |
165 case evLoad: gtkVisibleFileSelect=1; break; | |
166 case evSkinBrowser: gtkVisibleSkinBrowser=1; break; | |
167 } | |
168 break; | |
169 case evHideWindow: | |
170 switch ( gtkShMem->vs.window ) | |
171 { | |
172 case evPlayList: | |
173 btnModify( evPlayList,btnReleased ); gtkVisiblePlayList=0; | |
174 mplMainRender=1; wsPostRedisplay( &appMPlayer.mainWindow ); | |
175 break; | |
176 case evSkinBrowser: gtkVisibleSkinBrowser=0; break; | |
177 case evLoad: gtkVisibleFileSelect=0; break; | |
178 } | |
179 break; | |
1802 | 180 case evSkinBrowser: mplShMem->SkinChange=1; break; |
1693 | 181 case evFileLoaded: |
1891 | 182 printf("*** gtkShMem->fs.dir == '%s' \n",gtkShMem->fs.dir); |
183 printf("*** gtkShMem->fs.filename == '%s' \n",gtkShMem->fs.filename); | |
1815 | 184 strcpy( mplShMem->Filename,gtkShMem->fs.dir ); |
185 strcat( mplShMem->Filename,"/" ); | |
186 strcat( mplShMem->Filename,gtkShMem->fs.filename ); | |
187 printf( "%%%%%%%% Playing file: %s\n",mplShMem->Filename ); | |
1813 | 188 mplShMem->FilenameChanged=1; |
2447 | 189 mplShMem->StreamType=STREAMTYPE_FILE; |
1693 | 190 if ( mplMainAutoPlay ) mplGeneralTimer=1; |
191 break; | |
2940 | 192 case evShowPopUpMenu: |
3054 | 193 fprintf( stderr,"[psignal] PopUpMenu: %d param: %d\n",gtkShMem->popupmenu,gtkShMem->popupmenuparam ); |
2940 | 194 mplMiddleMenu=1; mplGeneralTimer=1; |
195 break; | |
1693 | 196 case evMessageBox: |
197 if ( mplCriticalError ) | |
198 { gtkSendMessage( evExit ); exit( 1 ); } | |
199 mplCriticalError=0; | |
200 break; | |
201 } | |
202 | |
203 // switch( mplShMem->message ) | |
204 // { | |
205 // } | |
206 gtkShMem->message=0; | |
1741 | 207 // mplShMem->message=0; |
1693 | 208 } |
209 | |
210 void gtkSendMessage( int msg ) | |
211 { | |
212 if ( !gtkIsOk ) return; | |
213 gtkShMem->message=msg; | |
1741 | 214 kill( gtkPID,SIGTYPE ); |
1693 | 215 } |