Mercurial > mplayer.hg
annotate Gui/mplayer/gtk/fs.c @ 6765:9c6ed4f15acc
10l fix, by Rmi Guyomarch <rguyom@pobox.com> && Bjrn Sandell
<biorn@dce.chalmers.se>
author | arpi |
---|---|
date | Sun, 21 Jul 2002 22:20:05 +0000 |
parents | a31b9f15cbff |
children | 77980ab4e296 |
rev | line source |
---|---|
2901 | 1 |
2 #include <stdlib.h> | |
3 #include <stdio.h> | |
4 #include <string.h> | |
5 #include <sys/stat.h> | |
6 #include <glob.h> | |
7 #include <unistd.h> | |
8 | |
6625 | 9 #include "../mplayer.h" |
2901 | 10 |
6625 | 11 #include "mplayer/pixmaps/up.xpm" |
12 #include "mplayer/pixmaps/dir.xpm" | |
13 #include "mplayer/pixmaps/file.xpm" | |
2901 | 14 |
15 #include "../../events.h" | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
16 #include "../../interface.h" |
2901 | 17 #include "../../../config.h" |
18 #include "../../../help_mp.h" | |
4846 | 19 #include "../../../libmpdemux/stream.h" |
2901 | 20 |
21 #include "../widgets.h" | |
22 #include "fs.h" | |
23 | |
24 #ifndef __linux__ | |
25 #define get_current_dir_name() getcwd(NULL, PATH_MAX) | |
26 #endif | |
27 | |
28 #ifndef get_current_dir_name | |
29 extern char * get_current_dir_name( void ); | |
30 #endif | |
31 | |
32 gchar * fsSelectedFile = NULL; | |
33 gchar * fsSelectedDirectory = NULL; | |
34 unsigned char * fsThatDir = "."; | |
5786 | 35 gchar fsFilter[64] = "*"; |
2901 | 36 |
37 int fsPressed = 0; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
38 int fsType = 0; |
3054 | 39 |
6146 | 40 int gtkVFileSelect = 0; |
41 | |
5786 | 42 #define fsNumberOfVideoFilterNames 9 |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
43 char * fsVideoFilterNames[fsNumberOfVideoFilterNames+1][2] = |
6089 | 44 { { "MPEG files (*.mpg,*.mpeg)", "*.mpg,*.mpeg" }, |
5786 | 45 { "VOB files (*.vob)", "*.vob" }, |
46 { "AVI files (*.avi)", "*.avi" }, | |
47 { "QT files (*.mov)", "*.mov" }, | |
48 { "ASF files (*.asf)", "*.asf" }, | |
49 { "VIVO files (*.viv)", "*.viv" }, | |
50 { "Windows Media Video (*.wmv)", "*.wmv" }, | |
51 { "Audio files (*.mp2,*.mp3,*.wma)", "*.mp2,*.mp3,*.wma" }, | |
6089 | 52 { "Video files (*.mpg,*.mpeg,*.vob,*.avi,*.mov,*.asf,*.viv,*.wmv)", "*.mpg,*.mpeg,*.vob,*.avi,*.mov,*.asf,*.viv,*.wmv" }, |
5786 | 53 { "All files (*)", "*" } }; |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
54 |
5786 | 55 #define fsNumberOfSubtitleFilterNames 9 |
3499 | 56 char * fsSubtitleFilterNames[fsNumberOfSubtitleFilterNames+1][2] = |
5786 | 57 { { "UTF (*.utf)", "*.utf" }, |
58 { "SUB (*.sub)", "*.sub" }, | |
59 { "SRT (*.srt)", "*.str" }, | |
60 { "SMI (*.smi)", "*.smi" }, | |
61 { "RT (*.rt) ", "*.rt" }, | |
62 { "TXT (*.txt)", "*.txt" }, | |
63 { "SSA (*.ssa)", "*.ssa" }, | |
64 { "AQT (*.aqt)", "*.aqt" }, | |
65 { "Subtitles (*.utf,*.sub,*.srt,*.smi,*.rt,*.txt,*.ssa,*.aqt)", "*.utf,*.sub,*.srt,*.smi,*.rt,*.txt,*.ssa,*.aqt" }, | |
6623 | 66 { "All files ( * )", "*" } }; |
3499 | 67 |
68 #define fsNumberOfOtherFilterNames 0 | |
69 char * fsOtherFilterNames[fsNumberOfOtherFilterNames+1][2] = | |
3587 | 70 { { "All files ( * )", "*" } }; |
6623 | 71 |
72 #define fsNumberOfAudioFilterNames 3 | |
73 char * fsAudioFileNames[fsNumberOfAudioFilterNames+1][2] = | |
74 { { "WAV files (*.wav)", "*.wav" }, | |
75 { "MP3 files (*.mp2, *.mp3)", "*.mp2,*.mp3" }, | |
76 { "Audio files (*.wav,*.mp2,*.mp3)", "*.wav,*.mp2,*.mp3" }, | |
77 { "All files ( * )", "*" } }; | |
2901 | 78 |
79 GtkWidget * fsFileNamesList; | |
80 GtkWidget * fsFNameList; | |
81 GtkWidget * fsFileSelect; | |
82 GdkColormap * fsColorMap; | |
83 GtkWidget * fsOk; | |
84 GtkWidget * fsUp; | |
85 GtkWidget * fsCancel; | |
86 GtkWidget * fsCombo4; | |
3499 | 87 GtkWidget * fsPathCombo; |
2901 | 88 GList * fsList_items = NULL; |
89 GList * fsTopList_items = NULL; | |
3499 | 90 GtkWidget * List; |
91 GtkWidget * fsFilterCombo; | |
2901 | 92 |
3499 | 93 |
94 GtkStyle * style; | |
95 GdkPixmap * dpixmap; | |
96 GdkPixmap * fpixmap; | |
97 GdkBitmap * dmask; | |
98 GdkBitmap * fmask; | |
99 | |
100 void CheckDir( GtkWidget * list,char * directory ) | |
2901 | 101 { |
102 struct stat fs; | |
103 int i,c=2; | |
104 gchar * str[1][2]; | |
3499 | 105 GdkPixmap * pixmap; |
106 GdkBitmap * mask; | |
2901 | 107 glob_t gg; |
108 | |
3499 | 109 if ( !fsFilter[0] ) return; |
110 | |
2901 | 111 gtk_widget_hide( list ); |
3499 | 112 gtk_clist_clear( GTK_CLIST( list ) ); |
2901 | 113 str[0][0]=NULL; |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
114 |
2901 | 115 pixmap=dpixmap; mask=dmask; |
116 str[0][0]=NULL; str[0][1]=(gchar *)malloc( 3 ); | |
3499 | 117 strcpy( str[0][1],"." ); gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_set_pixmap( GTK_CLIST( list ),0,0,pixmap,mask ); |
118 strcpy( str[0][1],".." ); gtk_clist_append( GTK_CLIST( list ),str[0] ); gtk_clist_set_pixmap( GTK_CLIST( list ),1,0,pixmap,mask ); | |
2901 | 119 free( str[0][0] ); |
120 | |
3499 | 121 glob( "*",0,NULL,&gg ); |
2901 | 122 // glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg ); |
123 for( i=0;i<gg.gl_pathc;i++ ) | |
124 { | |
125 stat( gg.gl_pathv[i],&fs ); | |
3499 | 126 if( !S_ISDIR( fs.st_mode ) ) continue; |
127 | |
128 str[0][1]=(gchar *)malloc( strlen( gg.gl_pathv[i] ) + 1 ); | |
129 strcpy( str[0][1],gg.gl_pathv[i] ); | |
130 pixmap=dpixmap; mask=dmask; | |
131 gtk_clist_append( GTK_CLIST( list ),str[0] ); | |
132 gtk_clist_set_pixmap( GTK_CLIST( list ),c++,0,pixmap,mask ); | |
133 free( str[0][1] ); | |
2901 | 134 } |
135 globfree( &gg ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
136 |
5786 | 137 //printf( "fsFiler: '%s'\n",fsFilter ); |
138 if ( strchr( fsFilter,',' ) ) | |
139 { | |
140 char tmp[8]; | |
141 int i,c,glob_param = 0; | |
142 //printf( "sub item detected.\n" ); | |
143 for ( i=0,c=0;i<(int)strlen( fsFilter ) + 1;i++,c++ ) | |
144 { | |
145 tmp[c]=fsFilter[i]; | |
146 if ( ( tmp[c] == ',' )||( tmp[c] == '\0' ) ) | |
147 { | |
148 tmp[c]=0; c=-1; | |
149 // printf( "substr: %s\n",tmp ); | |
150 glob( tmp,glob_param,NULL,&gg ); | |
151 glob_param=GLOB_APPEND; | |
152 } | |
153 } | |
154 } else glob( fsFilter,0,NULL,&gg ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
155 |
3499 | 156 #if 0 |
157 if ( !strcmp( fsFilter,"*" ) ) | |
158 { | |
159 char * f = strdup( fsFilter ); | |
160 int i; | |
161 for( i=0;i<strlen( f );i++ ) | |
162 if ( ( f[i] >= 'A' )&&( f[i] <= 'Z' ) ) f[i]+=32; | |
163 glob( f,GLOB_APPEND,NULL,&gg ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
164 |
3499 | 165 for( i=0;i<strlen( f );i++ ) |
166 if ( ( f[i] >= 'a' )&&( f[i] <= 'z' ) ) f[i]-=32; | |
167 glob( f,GLOB_APPEND,NULL,&gg ); | |
168 free( f ); | |
169 } | |
170 #endif | |
171 | |
2901 | 172 // glob( ".*",GLOB_NOSORT | GLOB_APPEND,NULL,&gg ); |
173 pixmap=fpixmap; mask=fmask; | |
174 for( i=0;i<gg.gl_pathc;i++ ) | |
175 { | |
176 stat( gg.gl_pathv[i],&fs ); | |
177 if( S_ISDIR( fs.st_mode ) ) continue; | |
3499 | 178 |
179 str[0][1]=(gchar *)malloc( strlen( gg.gl_pathv[i] ) + 1 ); | |
180 strcpy( str[0][1],gg.gl_pathv[i] ); | |
2901 | 181 gtk_clist_append( GTK_CLIST( list ),str[0] ); |
3499 | 182 gtk_clist_set_pixmap( GTK_CLIST( list ),c++,0,pixmap,mask ); |
2901 | 183 free( str[0][1] ); |
184 } | |
185 globfree( &gg ); | |
186 | |
187 gtk_clist_set_column_width( GTK_CLIST( list ),0,17 ); | |
188 gtk_clist_select_row( GTK_CLIST( list ),0,1 ); | |
189 gtk_widget_show( list ); | |
190 } | |
191 | |
6044 | 192 static int FirstInit = 1; |
193 | |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6146
diff
changeset
|
194 void ShowFileSelect( int type,int modal ) |
3499 | 195 { |
196 int i; | |
6146 | 197 |
198 if ( gtkVFileSelect ) gtkActive( fsFileSelect ); | |
199 else fsFileSelect=create_FileSelect(); | |
6044 | 200 |
201 if ( FirstInit ) | |
202 { | |
203 fsTopList_items=g_list_append( fsTopList_items,(gchar *)get_current_dir_name() ); | |
204 if ( getenv( "HOME" ) ) fsTopList_items=g_list_append( fsTopList_items,getenv( "HOME" ) ); | |
205 fsTopList_items=g_list_append( fsTopList_items,"/home" ); | |
206 fsTopList_items=g_list_append( fsTopList_items,"/mnt" ); | |
207 fsTopList_items=g_list_append( fsTopList_items,"/" ); | |
208 FirstInit=0; | |
209 } | |
210 gtk_combo_set_popdown_strings( GTK_COMBO( fsCombo4 ),fsTopList_items ); | |
211 | |
3499 | 212 fsType=type; |
213 switch ( type ) | |
214 { | |
215 case fsVideoSelector: | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
216 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FileSelect ); |
3499 | 217 fsList_items=NULL; |
218 for( i=0;i<fsNumberOfVideoFilterNames + 1;i++ ) | |
219 fsList_items=g_list_append( fsList_items,fsVideoFilterNames[i][0] ); | |
220 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
221 g_list_free( fsList_items ); | |
5786 | 222 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsVideoFilterNames[fsNumberOfVideoFilterNames - 1][0] ); |
3499 | 223 break; |
224 case fsSubtitleSelector: | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
225 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_SubtitleSelect ); |
3499 | 226 fsList_items=NULL; |
227 for( i=0;i<fsNumberOfSubtitleFilterNames + 1;i++ ) | |
228 fsList_items=g_list_append( fsList_items,fsSubtitleFilterNames[i][0] ); | |
229 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
230 g_list_free( fsList_items ); | |
5786 | 231 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsSubtitleFilterNames[fsNumberOfSubtitleFilterNames - 1][0] ); |
3499 | 232 break; |
233 case fsOtherSelector: | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
234 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_OtherSelect ); |
3499 | 235 fsList_items=NULL; |
236 for( i=0;i<fsNumberOfSubtitleFilterNames + 1;i++ ) | |
237 fsList_items=g_list_append( fsList_items,fsOtherFilterNames[i][0] ); | |
238 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
239 g_list_free( fsList_items ); | |
240 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsOtherFilterNames[fsNumberOfOtherFilterNames][0] ); | |
241 break; | |
6623 | 242 case fsAudioSelector: |
243 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_AudioFileSelect ); | |
244 fsList_items=NULL; | |
245 for( i=0;i<fsNumberOfAudioFilterNames + 1;i++ ) | |
246 fsList_items=g_list_append( fsList_items,fsAudioFileNames[i][0] ); | |
247 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); | |
248 g_list_free( fsList_items ); | |
249 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsAudioFileNames[fsNumberOfAudioFilterNames - 1][0] ); | |
250 break; | |
3499 | 251 } |
6622
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6146
diff
changeset
|
252 |
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6146
diff
changeset
|
253 gtk_window_set_modal( GTK_WINDOW( fsFileSelect ),modal ); |
da08877b9512
fix window hiding bug with some wms (kde, gnome, icewm, mwm, wmaker)
pontscho
parents:
6146
diff
changeset
|
254 |
6755 | 255 gtk_widget_show( fsFileSelect ); gtkVisible++; |
3499 | 256 } |
257 | |
2901 | 258 void HideFileSelect( void ) |
6146 | 259 { |
6755 | 260 if ( !gtkVFileSelect ) return; |
6146 | 261 gtk_widget_hide( fsFileSelect ); |
262 gtk_widget_destroy( fsFileSelect ); | |
6755 | 263 gtkVFileSelect=0; gtkVisible--; |
6146 | 264 } |
2901 | 265 |
266 void fs_fsFileSelect_destroy( GtkObject * object,gpointer user_data ) | |
267 { HideFileSelect(); } | |
268 | |
3499 | 269 void fs_fsFilterCombo_activate( GtkEditable * editable,gpointer user_data ) |
2901 | 270 { |
3499 | 271 strcpy( fsFilter,gtk_entry_get_text( GTK_ENTRY( user_data ) ) ); |
272 CheckDir( fsFNameList,get_current_dir_name() ); | |
2901 | 273 } |
274 | |
3499 | 275 void fs_fsFilterCombo_changed( GtkEditable * editable,gpointer user_data ) |
2901 | 276 { |
3499 | 277 char * str; |
278 int i; | |
2901 | 279 |
280 str=gtk_entry_get_text( GTK_ENTRY(user_data ) ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
281 |
3499 | 282 switch ( fsType ) |
2901 | 283 { |
3499 | 284 case fsVideoSelector: |
285 for( i=0;i<fsNumberOfVideoFilterNames+1;i++ ) | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
286 if( !strcmp( str,fsVideoFilterNames[i][0] ) ) |
6623 | 287 { strcpy( fsFilter,fsVideoFilterNames[i][1] ); break; } |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
288 break; |
3499 | 289 case fsSubtitleSelector: |
290 for( i=0;i<fsNumberOfSubtitleFilterNames+1;i++ ) | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
291 if( !strcmp( str,fsSubtitleFilterNames[i][0] ) ) |
6623 | 292 { strcpy( fsFilter,fsSubtitleFilterNames[i][1] ); break; } |
3499 | 293 break; |
294 case fsOtherSelector: | |
295 for( i=0;i<fsNumberOfOtherFilterNames+1;i++ ) | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
296 if( !strcmp( str,fsOtherFilterNames[i][0] ) ) |
6623 | 297 { strcpy( fsFilter,fsOtherFilterNames[i][1] ); break; } |
3499 | 298 break; |
6623 | 299 case fsAudioSelector: |
300 for( i=0;i<fsNumberOfAudioFilterNames+1;i++ ) | |
301 if( !strcmp( str,fsAudioFileNames[i][0] ) ) | |
302 { strcpy( fsFilter,fsAudioFileNames[i][1] ); break; } | |
303 break; | |
304 default: return; | |
2901 | 305 } |
6623 | 306 CheckDir( fsFNameList,get_current_dir_name() ); |
2901 | 307 } |
308 | |
3499 | 309 void fs_fsPathCombo_activate( GtkEditable * editable,gpointer user_data ) |
2901 | 310 { |
311 unsigned char * str; | |
312 | |
313 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
3499 | 314 if ( chdir( str ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() ); |
2901 | 315 } |
316 | |
3499 | 317 void fs_fsPathCombo_changed( GtkEditable * editable,gpointer user_data ) |
2901 | 318 { |
319 unsigned char * str; | |
320 | |
321 str=gtk_entry_get_text( GTK_ENTRY( user_data ) ); | |
322 fsPressed=2; | |
3499 | 323 if ( chdir( str ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() ); |
2901 | 324 } |
325 | |
326 void fs_Up_released( GtkButton * button,gpointer user_data ) | |
327 { | |
328 chdir( ".." ); | |
329 fsSelectedFile=fsThatDir; | |
3499 | 330 CheckDir( fsFNameList,get_current_dir_name() ); |
331 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() ); | |
2901 | 332 return; |
333 } | |
334 | |
335 int fsFileExist( unsigned char * fname ) | |
336 { | |
337 FILE * f = fopen( fname,"r" ); | |
338 if ( f == NULL ) return 0; | |
339 fclose( f ); | |
340 return 1; | |
341 } | |
342 | |
343 void fs_Ok_released( GtkButton * button,gpointer user_data ) | |
344 { | |
345 unsigned char * str; | |
346 GList * item; | |
347 int size,j,i = 1; | |
348 struct stat fs; | |
349 | |
350 stat( fsSelectedFile,&fs ); | |
351 if( S_ISDIR(fs.st_mode ) ) | |
352 { | |
353 chdir( fsSelectedFile ); | |
354 fsSelectedFile=fsThatDir; | |
3499 | 355 CheckDir( fsFNameList,get_current_dir_name() ); |
356 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() ); | |
2901 | 357 return; |
358 } | |
359 | |
360 switch( fsPressed ) | |
361 { | |
362 case 1: | |
363 fsSelectedDirectory=(unsigned char *)get_current_dir_name(); | |
364 break; | |
365 case 2: | |
3499 | 366 str=gtk_entry_get_text( GTK_ENTRY( fsPathCombo ) ); |
2901 | 367 fsSelectedFile=str; |
6146 | 368 if ( !fsFileExist( fsSelectedFile ) ) { HideFileSelect(); return; } |
2901 | 369 fsSelectedDirectory=fsSelectedFile; |
370 size=strlen( fsSelectedDirectory ); | |
371 for ( j=0;j<size;j++ ) | |
372 { | |
373 if ( fsSelectedDirectory[ size - j ] == '/' ) | |
374 { | |
375 fsSelectedFile+=size - j + 1; | |
376 fsSelectedDirectory[ size - j ]=0; | |
377 break; | |
378 } | |
379 } | |
380 break; | |
381 } | |
3499 | 382 switch ( fsType ) |
383 { | |
384 case fsVideoSelector: | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
385 guiSetDF( guiIntfStruct.Filename,fsSelectedDirectory,fsSelectedFile ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
386 guiIntfStruct.StreamType=STREAMTYPE_FILE; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
387 guiIntfStruct.FilenameChanged=1; |
6623 | 388 if ( guiIntfStruct.AudioFile ) free( guiIntfStruct.AudioFile ); |
389 guiIntfStruct.AudioFile=NULL; | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
390 break; |
3499 | 391 case fsSubtitleSelector: |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
392 guiSetDF( guiIntfStruct.Subtitlename,fsSelectedDirectory,fsSelectedFile ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
393 guiIntfStruct.SubtitleChanged=1; |
3499 | 394 break; |
395 case fsOtherSelector: | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
396 guiSetDF( guiIntfStruct.Othername,fsSelectedDirectory,fsSelectedFile ); |
3499 | 397 break; |
6623 | 398 case fsAudioSelector: |
399 guiSetDF( guiIntfStruct.AudioFile,fsSelectedDirectory,fsSelectedFile ); | |
400 break; | |
3499 | 401 } |
6146 | 402 |
403 HideFileSelect(); | |
404 | |
2901 | 405 item=fsTopList_items; |
406 while( item ) | |
407 { | |
408 if ( !strcmp( item->data,fsSelectedDirectory ) ) i=0; | |
409 item=item->next; | |
410 } | |
6044 | 411 if ( i ) fsTopList_items=g_list_prepend( fsTopList_items,(gchar *)get_current_dir_name() ); |
6623 | 412 if ( mplMainAutoPlay ) mplEventHandling( evPlay,0 ); |
2901 | 413 } |
414 | |
415 void fs_Cancel_released( GtkButton * button,gpointer user_data ) | |
416 { HideFileSelect(); } | |
417 | |
418 void fs_fsFNameList_select_row( GtkWidget * widget,gint row,gint column,GdkEventButton *bevent,gpointer user_data ) | |
419 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4779
diff
changeset
|
420 gtk_clist_get_text( GTK_CLIST(widget ),row,1,&fsSelectedFile ); |
2901 | 421 fsPressed=1; |
422 if( !bevent ) return; | |
6713 | 423 if( bevent->type == GDK_BUTTON_PRESS ) gtk_button_released( GTK_BUTTON( fsOk ) ); |
2901 | 424 } |
425 | |
426 gboolean on_FileSelect_key_release_event( GtkWidget * widget,GdkEventKey * event,gpointer user_data ) | |
427 { | |
428 switch ( event->keyval ) | |
429 { | |
430 case GDK_Escape: | |
431 gtk_button_released( GTK_BUTTON( fsCancel ) ); | |
432 break; | |
433 case GDK_Return: | |
434 gtk_button_released( GTK_BUTTON( fsOk ) ); | |
435 break; | |
436 case GDK_BackSpace: | |
437 gtk_button_released( GTK_BUTTON( fsUp ) ); | |
438 break; | |
439 } | |
440 return FALSE; | |
441 } | |
442 | |
6146 | 443 void fs_FileSelect_show( GtkWidget * widget,gpointer user_data ) |
444 { gtkVFileSelect=(int)user_data; } | |
445 | |
2901 | 446 GtkWidget * create_FileSelect( void ) |
447 { | |
448 GtkWidget * FSFrame; | |
449 GtkWidget * frame2; | |
450 GtkWidget * frame3; | |
451 GtkWidget * frame4; | |
452 GtkWidget * vbox4; | |
453 GtkWidget * hbox4; | |
454 GtkWidget * vseparator1; | |
455 GtkWidget * hseparator1; | |
456 GtkWidget * hbox6; | |
457 GtkWidget * fsFNameListWindow; | |
458 GtkWidget * label1; | |
459 GtkWidget * hseparator2; | |
460 GtkWidget * hseparator3; | |
461 GtkWidget * hbuttonbox3; | |
462 int i; | |
463 | |
464 GtkWidget * uppixmapwid; | |
465 GdkPixmap * uppixmap; | |
466 GdkBitmap * upmask; | |
467 GtkStyle * upstyle; | |
468 | |
4779 | 469 fsFileSelect=gtk_window_new( GTK_WINDOW_TOPLEVEL ); |
2901 | 470 gtk_widget_set_name( fsFileSelect,"fsFileSelect" ); |
471 gtk_object_set_data( GTK_OBJECT( fsFileSelect ),"fsFileSelect",fsFileSelect ); | |
4779 | 472 gtk_widget_set_usize( fsFileSelect,512,300 ); |
2901 | 473 GTK_WIDGET_SET_FLAGS( fsFileSelect,GTK_CAN_DEFAULT ); |
474 gtk_widget_set_events( fsFileSelect,GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK | GDK_VISIBILITY_NOTIFY_MASK ); | |
475 gtk_window_set_title( GTK_WINDOW( fsFileSelect ),MSGTR_FileSelect ); | |
476 gtk_window_set_position( GTK_WINDOW( fsFileSelect ),GTK_WIN_POS_CENTER ); | |
4779 | 477 gtk_window_set_policy( GTK_WINDOW( fsFileSelect ),TRUE,TRUE,TRUE ); |
6651 | 478 gtk_window_set_wmclass( GTK_WINDOW( fsFileSelect ),MSGTR_FileSelect,"MPlayer" ); |
2901 | 479 fsColorMap=gdk_colormap_get_system(); |
6651 | 480 |
481 gtk_widget_realize( fsFileSelect ); | |
482 gtkAddIcon( fsFileSelect ); | |
2901 | 483 |
3499 | 484 style=gtk_widget_get_style( fsFileSelect ); |
485 dpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&dmask,&style->bg[GTK_STATE_NORMAL],(gchar **)dir_xpm ); | |
486 fpixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&fmask,&style->bg[GTK_STATE_NORMAL],(gchar **)file_xpm ); | |
487 | |
2901 | 488 FSFrame=gtk_frame_new( NULL ); |
489 gtk_widget_set_name( FSFrame,"FSFrame" ); | |
490 gtk_widget_ref( FSFrame ); | |
6044 | 491 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"FSFrame",FSFrame,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 492 gtk_widget_show( FSFrame ); |
493 gtk_container_add( GTK_CONTAINER( fsFileSelect ),FSFrame ); | |
494 gtk_container_set_border_width( GTK_CONTAINER( FSFrame ),1 ); | |
495 gtk_frame_set_shadow_type( GTK_FRAME( FSFrame ),GTK_SHADOW_IN ); | |
496 | |
497 frame2=gtk_frame_new( NULL ); | |
498 gtk_widget_set_name( frame2,"frame2" ); | |
499 gtk_widget_ref( frame2 ); | |
6044 | 500 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"frame2",frame2,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 501 gtk_widget_show( frame2 ); |
502 gtk_container_add( GTK_CONTAINER( FSFrame ),frame2 ); | |
503 gtk_frame_set_shadow_type( GTK_FRAME( frame2 ),GTK_SHADOW_NONE ); | |
504 | |
505 frame3=gtk_frame_new( NULL ); | |
506 gtk_widget_set_name( frame3,"frame3" ); | |
507 gtk_widget_ref( frame3 ); | |
6044 | 508 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"frame3",frame3,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 509 gtk_widget_show( frame3 ); |
510 gtk_container_add( GTK_CONTAINER( frame2 ),frame3 ); | |
511 gtk_frame_set_shadow_type( GTK_FRAME( frame3 ),GTK_SHADOW_ETCHED_OUT ); | |
512 | |
513 frame4=gtk_frame_new( NULL ); | |
514 gtk_widget_set_name( frame4,"frame4" ); | |
515 gtk_widget_ref( frame4 ); | |
6044 | 516 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"frame4",frame4,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 517 gtk_widget_show( frame4 ); |
518 gtk_container_add( GTK_CONTAINER( frame3 ),frame4 ); | |
519 gtk_container_set_border_width( GTK_CONTAINER( frame4 ),1 ); | |
520 gtk_frame_set_shadow_type( GTK_FRAME( frame4 ),GTK_SHADOW_NONE ); | |
521 | |
522 vbox4=gtk_vbox_new( FALSE,0 ); | |
523 gtk_widget_set_name( vbox4,"vbox4" ); | |
524 gtk_widget_ref( vbox4 ); | |
6044 | 525 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"vbox4",vbox4,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 526 gtk_widget_show( vbox4 ); |
527 gtk_container_add( GTK_CONTAINER( frame4 ),vbox4 ); | |
528 | |
529 hbox4=gtk_hbox_new( FALSE,0 ); | |
530 gtk_widget_set_name( hbox4,"hbox4" ); | |
531 gtk_widget_ref( hbox4 ); | |
6044 | 532 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"hbox4",hbox4,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 533 gtk_widget_show( hbox4 ); |
4779 | 534 gtk_box_pack_start( GTK_BOX( vbox4 ),hbox4,FALSE,FALSE,0 ); |
2901 | 535 |
536 fsCombo4=gtk_combo_new(); | |
537 gtk_widget_set_name( fsCombo4,"fsCombo4" ); | |
538 gtk_widget_ref( fsCombo4 ); | |
6044 | 539 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"fsCombo4",fsCombo4,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 540 gtk_widget_show( fsCombo4 ); |
541 gtk_box_pack_start( GTK_BOX( hbox4 ),fsCombo4,TRUE,TRUE,0 ); | |
542 gtk_widget_set_usize( fsCombo4,-2,20 ); | |
543 | |
3499 | 544 fsPathCombo=GTK_COMBO( fsCombo4 )->entry; |
545 gtk_widget_set_name( fsPathCombo,"fsPathCombo" ); | |
546 gtk_widget_ref( fsPathCombo ); | |
6044 | 547 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"fsPathCombo",fsPathCombo,(GtkDestroyNotify)gtk_widget_unref ); |
3499 | 548 gtk_widget_show( fsPathCombo ); |
549 gtk_widget_set_usize( fsPathCombo,-2,20 ); | |
2901 | 550 |
551 vseparator1=gtk_vseparator_new(); | |
552 gtk_widget_set_name( vseparator1,"vseparator1" ); | |
553 gtk_widget_ref( vseparator1 ); | |
6044 | 554 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"vseparator1",vseparator1,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 555 gtk_widget_show( vseparator1 ); |
556 gtk_box_pack_start( GTK_BOX( hbox4 ),vseparator1,FALSE,TRUE,0 ); | |
557 gtk_widget_set_usize( vseparator1,7,20 ); | |
558 | |
559 upstyle=gtk_widget_get_style( fsFileSelect ); | |
560 uppixmap=gdk_pixmap_colormap_create_from_xpm_d( fsFileSelect->window,fsColorMap,&upmask,&upstyle->bg[GTK_STATE_NORMAL],(gchar **)up_xpm ); | |
561 uppixmapwid=gtk_pixmap_new( uppixmap,upmask ); | |
562 gtk_widget_show( uppixmapwid ); | |
563 | |
564 fsUp=gtk_button_new(); | |
565 gtk_container_add( GTK_CONTAINER(fsUp ),uppixmapwid ); | |
566 gtk_widget_show( fsUp ); | |
567 gtk_box_pack_start( GTK_BOX( hbox4 ),fsUp,FALSE,FALSE,0 ); | |
568 gtk_widget_set_usize( fsUp,65,15 ); | |
569 | |
570 hseparator1=gtk_hseparator_new(); | |
571 gtk_widget_set_name( hseparator1,"hseparator1" ); | |
572 gtk_widget_ref( hseparator1 ); | |
6044 | 573 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"hseparator1",hseparator1,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 574 gtk_widget_show( hseparator1 ); |
575 gtk_box_pack_start( GTK_BOX( vbox4 ),hseparator1,FALSE,TRUE,0 ); | |
576 gtk_widget_set_usize( hseparator1,-2,8 ); | |
577 | |
578 hbox6=gtk_hbox_new( FALSE,0 ); | |
579 gtk_widget_set_name( hbox6,"hbox6" ); | |
580 gtk_widget_ref( hbox6 ); | |
6044 | 581 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"hbox6",hbox6,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 582 gtk_widget_show( hbox6 ); |
583 gtk_box_pack_start( GTK_BOX( vbox4 ),hbox6,TRUE,TRUE,0 ); | |
584 | |
585 fsFNameListWindow=gtk_scrolled_window_new( NULL,NULL ); | |
586 gtk_widget_set_name( fsFNameListWindow,"fsFNameListWindow" ); | |
587 gtk_widget_ref( fsFNameListWindow ); | |
6044 | 588 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"fsFNameListWindow",fsFNameListWindow,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 589 gtk_widget_show( fsFNameListWindow ); |
590 gtk_box_pack_start( GTK_BOX( hbox6 ),fsFNameListWindow,TRUE,TRUE,0 ); | |
591 gtk_widget_set_usize( fsFNameListWindow,-2,145 ); | |
592 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( fsFNameListWindow ),GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC ); | |
593 | |
594 fsFNameList=gtk_clist_new( 2 ); | |
595 gtk_widget_set_name( fsFNameList,"fsFNameList" ); | |
596 gtk_widget_ref( fsFNameList ); | |
6044 | 597 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"fsFNameList",fsFNameList,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 598 gtk_container_add( GTK_CONTAINER( fsFNameListWindow ),fsFNameList ); |
599 gtk_clist_set_column_width( GTK_CLIST( fsFNameList ),0,80 ); | |
600 gtk_clist_set_selection_mode( GTK_CLIST( fsFNameList ),GTK_SELECTION_BROWSE ); | |
601 gtk_clist_column_titles_hide( GTK_CLIST( fsFNameList ) ); | |
602 gtk_clist_set_shadow_type( GTK_CLIST( fsFNameList ),GTK_SHADOW_ETCHED_OUT ); | |
3499 | 603 CheckDir( fsFNameList,get_current_dir_name() ); |
2901 | 604 |
605 label1=gtk_label_new( "label1" ); | |
606 gtk_widget_set_name( label1,"label1" ); | |
607 gtk_widget_ref( label1 ); | |
6044 | 608 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"label1",label1,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 609 gtk_widget_show( label1 ); |
610 gtk_clist_set_column_widget( GTK_CLIST( fsFNameList ),0,label1 ); | |
611 | |
612 hseparator2=gtk_hseparator_new(); | |
613 gtk_widget_set_name( hseparator2,"hseparator2" ); | |
614 gtk_widget_ref( hseparator2 ); | |
6044 | 615 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"hseparator2",hseparator2,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 616 gtk_widget_show( hseparator2 ); |
617 gtk_box_pack_start( GTK_BOX( vbox4 ),hseparator2,FALSE,TRUE,0 ); | |
618 gtk_widget_set_usize( hseparator2,-2,9 ); | |
619 | |
620 List=gtk_combo_new(); | |
621 gtk_widget_set_name( List,"List" ); | |
622 gtk_widget_ref( List ); | |
6044 | 623 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"List",List,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 624 gtk_widget_show( List ); |
625 gtk_box_pack_start( GTK_BOX( vbox4 ),List,FALSE,FALSE,0 ); | |
626 gtk_widget_set_usize( List,-2,20 ); | |
627 fsList_items=NULL; | |
3499 | 628 for( i=0;i<fsNumberOfVideoFilterNames + 1;i++ ) |
629 fsList_items=g_list_append( fsList_items,fsVideoFilterNames[i][0] ); | |
2901 | 630 gtk_combo_set_popdown_strings( GTK_COMBO( List ),fsList_items ); |
631 g_list_free( fsList_items ); | |
632 | |
3499 | 633 fsFilterCombo=GTK_COMBO( List )->entry; |
634 gtk_widget_set_name( fsFilterCombo,"fsFilterCombo" ); | |
635 gtk_widget_ref( fsFilterCombo ); | |
6044 | 636 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"fsFilterCombo",fsFilterCombo,(GtkDestroyNotify)gtk_widget_unref ); |
3499 | 637 gtk_widget_show( fsFilterCombo ); |
638 gtk_entry_set_editable (GTK_ENTRY( fsFilterCombo ),FALSE ); | |
5786 | 639 gtk_entry_set_text( GTK_ENTRY( fsFilterCombo ),fsVideoFilterNames[fsNumberOfVideoFilterNames - 1][0] ); |
2901 | 640 |
641 hseparator3=gtk_hseparator_new(); | |
642 gtk_widget_set_name( hseparator3,"hseparator3" ); | |
643 gtk_widget_ref( hseparator3 ); | |
6044 | 644 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"hseparator3",hseparator3,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 645 gtk_widget_show( hseparator3 ); |
646 gtk_box_pack_start( GTK_BOX( vbox4 ),hseparator3,FALSE,TRUE,0 ); | |
647 gtk_widget_set_usize( hseparator3,-2,7 ); | |
648 | |
649 hbuttonbox3=gtk_hbutton_box_new(); | |
650 gtk_widget_set_name( hbuttonbox3,"hbuttonbox3" ); | |
651 gtk_widget_ref( hbuttonbox3 ); | |
6044 | 652 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),"hbuttonbox3",hbuttonbox3,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 653 gtk_widget_show( hbuttonbox3 ); |
654 gtk_box_pack_start( GTK_BOX( vbox4 ),hbuttonbox3,FALSE,TRUE,0 ); | |
655 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox3 ),GTK_BUTTONBOX_END ); | |
656 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox3 ),10 ); | |
657 gtk_button_box_set_child_size( GTK_BUTTON_BOX( hbuttonbox3 ),85,20 ); | |
658 gtk_button_box_set_child_ipadding( GTK_BUTTON_BOX( hbuttonbox3 ),0,0 ); | |
659 | |
660 fsOk=gtk_button_new_with_label( MSGTR_Ok ); | |
661 gtk_widget_set_name( fsOk,MSGTR_Ok ); | |
662 gtk_widget_ref( fsOk ); | |
663 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),MSGTR_Ok,fsOk,( GtkDestroyNotify )gtk_widget_unref ); | |
664 gtk_container_add( GTK_CONTAINER( hbuttonbox3 ),fsOk ); | |
665 gtk_widget_show( fsOk ); | |
666 | |
667 fsCancel=gtk_button_new_with_label( MSGTR_Cancel ); | |
668 gtk_widget_set_name( fsCancel,MSGTR_Cancel ); | |
669 gtk_widget_ref( fsCancel ); | |
670 gtk_object_set_data_full( GTK_OBJECT( fsFileSelect ),MSGTR_Cancel,fsCancel,( GtkDestroyNotify )gtk_widget_unref ); | |
671 gtk_container_add( GTK_CONTAINER( hbuttonbox3 ),fsCancel ); | |
672 gtk_widget_show( fsCancel ); | |
673 | |
6044 | 674 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"destroy",GTK_SIGNAL_FUNC( fs_fsFileSelect_destroy ),NULL ); |
675 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"key_release_event",GTK_SIGNAL_FUNC( on_FileSelect_key_release_event ),NULL ); | |
6146 | 676 |
677 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"show",GTK_SIGNAL_FUNC( fs_FileSelect_show ),1 ); | |
678 gtk_signal_connect( GTK_OBJECT( fsFileSelect ),"hide",GTK_SIGNAL_FUNC( fs_FileSelect_show ),0 ); | |
679 | |
6044 | 680 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsFilterCombo_changed ),fsFilterCombo ); |
681 gtk_signal_connect( GTK_OBJECT( fsFilterCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsFilterCombo_activate ),fsFilterCombo ); | |
682 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"changed",GTK_SIGNAL_FUNC( fs_fsPathCombo_changed ),fsPathCombo ); | |
683 gtk_signal_connect( GTK_OBJECT( fsPathCombo ),"activate",GTK_SIGNAL_FUNC( fs_fsPathCombo_activate ),fsPathCombo ); | |
684 gtk_signal_connect( GTK_OBJECT( fsUp ),"released",GTK_SIGNAL_FUNC( fs_Up_released ),fsFNameList ); | |
685 gtk_signal_connect( GTK_OBJECT( fsOk ),"released",GTK_SIGNAL_FUNC( fs_Ok_released ),fsCombo4 ); | |
686 gtk_signal_connect( GTK_OBJECT( fsCancel ),"released",GTK_SIGNAL_FUNC( fs_Cancel_released ),NULL ); | |
687 gtk_signal_connect( GTK_OBJECT( fsFNameList ),"select_row",(GtkSignalFunc)fs_fsFNameList_select_row,NULL ); | |
2901 | 688 |
689 gtk_widget_grab_focus( fsFNameList ); | |
690 | |
691 return fsFileSelect; | |
692 } | |
693 |